/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * l2_rw is based on vnet classifier and provides a way
 * to modify packets matching a given table.
 *
 * Tables must be created using vnet's classify features.
 * Entries contained within these tables must have their
 * opaque index set to the rewrite entry created with l2_rw_mod_entry.
 */

#ifndef L2_RW_H_
#define L2_RW_H_

#include <vnet/l2/l2_input.h>

typedef CLIB_PACKED(struct _l2_rw_entry {
  u16 skip_n_vectors;
  u16 rewrite_n_vectors;
  u64 hit_count;
  u32x4 *mask;
  u32x4 *value;
}) l2_rw_entry_t;

/* l2_rw configuration for one interface */
typedef CLIB_PACKED(struct _l2_rw_config {
  u32 table_index; /* Which classify table to use */
  u32 miss_index;  /* Rewrite entry to use if table does not match */
}) l2_rw_config_t;

typedef struct
{
  /* Next feature node indexes */
  u32 feat_next_node_index[32];

  /* A pool of entries */
  l2_rw_entry_t *entries;

  /* Config vector indexed by sw_if_index */
  l2_rw_config_t *configs;
  uword *configs_bitmap;
} l2_rw_main_t;

extern l2_rw_main_t l2_rw_main;

/*
 * Specifies which classify table and miss_index should be used
 * with the given interface.
 * Use special values ~0 in order to un-set table_index
 * or miss_index.
 * l2_rw feature is automatically enabled for the interface
 * when table_index or miss_index is not ~0.
 * returns 0 on success and something else on error.
 */
int l2_rw_interface_set_table (u32 sw_if_index,
			       u32 table_index, u32 miss_index);

/*
 * Creates, modifies or delete a rewrite entry.
 * If *index != ~0, modifies an existing entry (or simply
 * deletes it if is_del is set).
 * If *index == ~0, creates a new entry and the created
 * entry index is stored in *index (Does nothing if is_del
 * is set).
 * returns 0 on success and something else on error.
 */
int l2_rw_mod_entry (u32 * index,
		     u8 * mask, u8 * value, u32 len, u32 skip, u8 is_del);

extern vlib_node_registration_t l2_rw_node;

#endif /* L2_FW_H_ */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
