From: Denis Pryazhennikov <denis.pryazhenni...@arknetworks.am> A "table" is structure used for lookups, consisting of a set of entries which can be matched against an N-bit "request", to return either a "hit" with an M-bit "response", or a "miss" if there is no match. There are a number of HW tables of various types that could be used in MAE.
In some types of table the entry may also be associated with an N-bit "mask", allowing some bits of the request to be treated as don't-care, and an integer "priority" to determine which entry is used if more than one matches. BCAM tables don't support "mask" and "priority", so the corresponding fields must be zeroed. Signed-off-by: Denis Pryazhennikov <denis.pryazhenni...@arknetworks.am> Reviewed-by: Ivan Malov <ivan.ma...@arknetworks.am> Reviewed-by: Andy Moreton <amore...@xilinx.com> --- drivers/net/sfc/sfc_tbls.h | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 drivers/net/sfc/sfc_tbls.h diff --git a/drivers/net/sfc/sfc_tbls.h b/drivers/net/sfc/sfc_tbls.h new file mode 100644 index 0000000000..302f67224c --- /dev/null +++ b/drivers/net/sfc/sfc_tbls.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + */ + +#ifndef _SFC_TBLS_H +#define _SFC_TBLS_H + +#include "efx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Table types: + * CAM - Content addressable memory + * BCAM - Binary CAM + * TCAM - Ternary CAM + * STCAM - Semi-ternary CAM + * + * Short description: + * TCAM: Each entry has a key, mask, response and priority. An entry matches + * when (key & mask) == (request & mask). In the case of multiple + * matches, the entry with the highest priority wins; Each entry may + * have its own mask, but TCAM table definitions may place constraints + * on the possible masks allowed for each of the individual fields. + * STCAM: A limited form of TCAM in which only a limited number of masks and + * associated priorities), up to some maximum fixed by the definition + * of the table, may be in use at any one time. + * BCAM: Each entry has only a key and response, with the whole request + * matched against the key (like a typical hash table or "map"). + * Direct (sometimes "DCAM", although it's not really content-addressable): + * Essentially just an array, where the key bits are used simply as an + * index. + */ + +/* Priority is used only for TCAM or STCAM, use 0 in case of BCAM */ +#define SFC_TBLS_BCAM_PRIORITY 0 + +/* Mask ID is used only for STCAM with ALLOC_MASKS flag, use 0 for BCAM */ +#define SFC_TBLS_BCAM_MASK_ID 0 + +/* Mask is used only for STCAM */ +#define SFC_TBLS_BCAM_MASK_WIDTH 0 + +static inline int +sfc_tbls_bcam_entry_insert(efx_nic_t *enp, efx_table_id_t table_id, uint16_t key_width, + uint16_t resp_width, uint8_t *data, unsigned int data_size) +{ + return efx_table_entry_insert(enp, table_id, SFC_TBLS_BCAM_PRIORITY, + SFC_TBLS_BCAM_MASK_ID, key_width, + SFC_TBLS_BCAM_MASK_WIDTH, resp_width, + data, data_size); +} + +static inline int +sfc_tbls_bcam_entry_delete(efx_nic_t *enp, efx_table_id_t table_id, uint16_t key_width, + uint8_t *data, unsigned int data_size) +{ + return efx_table_entry_delete(enp, table_id, SFC_TBLS_BCAM_MASK_ID, + key_width, SFC_TBLS_BCAM_MASK_WIDTH, + data, data_size); +} + +#ifdef __cplusplus +} +#endif +#endif /* _SFC_TBLS_H */ -- 2.30.2