Re: [dpdk-dev] [RFC PATCH] ethdev: add support for testpmd-compliant flow rule dumping
Hi Ivan, First nice idea and thanks for the picking up the ball. Before a detail review, The main thing I'm concerned about is that this print will be partially supported, I know that you covered this issue by printing unknown for unsupported item/actions, but this will mean that it is enough that one item/action is not supported and already the flow can't be used in testpmd. To get full support it means that the developer needs to add such print with each new item/action. I agree it is possible, but it has high overhead for each feature. Maybe we should somehow create a macros for the prints or other easier to support ways. For example, just printing the ipv4 has 7 function calls inside of it each one with error checking, and I'm not counting the dedicated functions. Best, Ori > -Original Message- > From: Ivan Malov > Sent: Thursday, May 27, 2021 11:25 AM > To: dev@dpdk.org > Cc: NBU-Contact-Thomas Monjalon ; Ferruh Yigit > ; Andrew Rybchenko > ; Ori Kam ; Ray > Kinsella ; Neil Horman > Subject: [RFC PATCH] ethdev: add support for testpmd-compliant flow rule > dumping > > DPDK applications (for example, OvS) or tests which use RTE flow API need to > log created or rejected flow rules to help to recognise what goes right or > wrong. From this standpoint, testpmd-compliant format is nice for the > purpose because it allows to copy-paste the flow rules and debug using > testpmd. > > Recognisable pattern items: > VOID, VF, PF, PHY_PORT, PORT_ID, ETH, VLAN, IPV4, IPV6, UDP, TCP, VXLAN, > NVGRE, GENEVE, MARK, PPPOES, PPPOED. > > Recognisable actions: > VOID, JUMP, MARK, FLAG, QUEUE, DROP, COUNT, RSS, PF, VF, PHY_PORT, > PORT_ID, OF_POP_VLAN, OF_PUSH_VLAN, OF_SET_VLAN_VID, > OF_SET_VLAN_PCP, VXLAN_ENCAP, VXLAN_DECAP. > > Recognisable RSS types (action RSS): > IPV4, FRAG_IPV4, NONFRAG_IPV4_TCP, NONFRAG_IPV4_UDP, > NONFRAG_IPV4_OTHER, IPV6, FRAG_IPV6, NONFRAG_IPV6_TCP, > NONFRAG_IPV6_UDP, NONFRAG_IPV6_OTHER, IPV6_EX, IPV6_TCP_EX, > IPV6_UDP_EX, L3_SRC_ONLY, L3_DST_ONLY, L4_SRC_ONLY, L4_DST_ONLY. > > Unrecognised parts of the flow specification are represented by tokens > "{unknown}" and "{unknown bits}". Interested parties are welcome to > extend this tool to recognise more items and actions. > > Signed-off-by: Ivan Malov > --- > lib/ethdev/meson.build|1 + > lib/ethdev/rte_flow.h | 33 + > lib/ethdev/rte_flow_snprint.c | 1681 > + > lib/ethdev/version.map|3 + > 4 files changed, 1718 insertions(+) > create mode 100644 lib/ethdev/rte_flow_snprint.c > > diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index > 0205c853df..97bba4fa1b 100644 > --- a/lib/ethdev/meson.build > +++ b/lib/ethdev/meson.build > @@ -8,6 +8,7 @@ sources = files( > 'rte_class_eth.c', > 'rte_ethdev.c', > 'rte_flow.c', > + 'rte_flow_snprint.c', > 'rte_mtr.c', > 'rte_tm.c', > ) > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index > 961a5884fe..cd5e9ef631 100644 > --- a/lib/ethdev/rte_flow.h > +++ b/lib/ethdev/rte_flow.h > @@ -4288,6 +4288,39 @@ rte_flow_tunnel_item_release(uint16_t port_id, >struct rte_flow_item *items, >uint32_t num_of_items, >struct rte_flow_error *error); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Dump testpmd-compliant textual representation of the flow rule. > + * Invoke this with zero-size buffer to learn the string size and > + * invoke this for the second time to actually dump the flow rule. > + * The buffer size on the second invocation = the string size + 1. > + * > + * @param[out] buf > + * Buffer to save the dump in, or NULL > + * @param buf_size > + * Buffer size, or 0 > + * @param[out] nb_chars_total > + * Resulting string size (excluding the terminating null byte) > + * @param[in] attr > + * Flow rule attributes. > + * @param[in] pattern > + * Pattern specification (list terminated by the END pattern item). > + * @param[in] actions > + * Associated actions (list terminated by the END action). > + * > + * @return > + * 0 on success, a negative errno value otherwise > + */ > +__rte_experimental > +int > +rte_flow_snprint(char *buf, size_t buf_size, size_t *nb_chars_total, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[]); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/ethdev/rte_flow_snprint.c b/lib/ethdev/rte_flow_snprint.c > new file mode 100644 index 00..513886528b > --- /dev/null > +++ b/lib/ethdev/rte_flow_snprint.c > @@ -0,0 +1,1681 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * > + * Copyright(c) 2021 Xilinx, Inc. > + */ > + > +#include > +#include > +#include > + > +#include > +#include "rte_ethdev.h" > +#include "rte_flow.h" > + > +stati
[dpdk-dev] [PATCH 00/58] enhancements to host based flow table management
This patchset adds flow table management support for Thor network adapter and introduces enhancements to the existing flow table management functionality. Farah Smith (11): net/bnxt: add base TRUFLOW support for Thor net/bnxt: update TRUFLOW resources net/bnxt: add action SRAM Translation net/bnxt: add 64B SRAM record management with RM net/bnxt: modify TRUFLOW HWRM messages net/bnxt: shared TCAM region support net/bnxt: cleanup session open/close messages net/bnxt: add WC TCAM hi/lo move support net/bnxt: add API to get shared table increments net/bnxt: cleanup of WC TCAM shared unbind net/bnxt: add API to clear hi/lo WC region Jay Ding (9): net/bnxt: check resource reservation in TRUFLOW net/bnxt: add L2 Context TCAM get support net/bnxt: add Thor WC TCAM support net/bnxt: change RM database type net/bnxt: add shared session support net/bnxt: update shared session functionality net/bnxt: modify resource reservation strategy net/bnxt: modify host session failure cleanup net/bnxt: add support for WC TCAM shared session Jeffrey Huang (1): net/bnxt: add CFA folder to HCAPI directory Kishore Padmanabha (23): net/bnxt: add support for generic table processing net/bnxt: add support for mapper flow database opcodes net/bnxt: modify TCAM opcode processing net/bnxt: modify table processing net/bnxt: modify ULP priority opcode processing net/bnxt: add support for conflict resolution net/bnxt: add support for conditional goto processing net/bnxt: set shared handle for generic table net/bnxt: modify ULP template net/bnxt: add conditional opcode and L4 port fields net/bnxt: refactor TF ULP net/bnxt: add partial header field processing net/bnxt: add support for wild card pattern match net/bnxt: enable extended exact match support net/bnxt: refactor ULP mapper and parser net/bnxt: add support for generic hash table net/bnxt: add support for Thor platform net/bnxt: refactor flow parser in ULP net/bnxt: add field opcodes in ULP net/bnxt: add support for application ID in ULP matcher net/bnxt: add support for shared sessions in ULP net/bnxt: add support for icmp6 ULP parsing net/bnxt: add support for ULP context list for timers Mike Baucom (5): net/bnxt: add conditional execution and rejection net/bnxt: add shared session support to ULP net/bnxt: process resource lists before session open net/bnxt: add HA support in ULP net/bnxt: add Thor template support Peter Spreadborough (4): net/bnxt: add mailbox selection via dev op net/bnxt: add support for EM with FKB net/bnxt: add hashing changes for Thor net/bnxt: add dpool allocator for EM allocation Shahaji Bhosle (1): net/bnxt: cleanup ULP parser and mapper Venkat Duvvuru (4): net/bnxt: check FW capability to support TRUFLOW net/bnxt: modify VXLAN decap for multichannel mode net/bnxt: add support for GRE flows net/bnxt: reorganize ULP template directory structure doc/guides/nics/bnxt.rst | 3 +- drivers/net/bnxt/bnxt.h |19 +- drivers/net/bnxt/bnxt_ethdev.c| 162 +- drivers/net/bnxt/bnxt_hwrm.c | 7 +- drivers/net/bnxt/bnxt_util.h | 3 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h| 126 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c |83 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h | 381 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c | 292 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h | 185 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c| 122 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h| 142 + drivers/net/bnxt/hcapi/cfa/meson.build|12 + drivers/net/bnxt/hcapi/cfa_p40_hw.h | 781 - drivers/net/bnxt/hcapi/cfa_p40_tbl.h | 303 - drivers/net/bnxt/hcapi/hcapi_cfa.h| 295 - drivers/net/bnxt/hcapi/hcapi_cfa_defs.h | 672 - drivers/net/bnxt/hcapi/hcapi_cfa_p4.c | 399 - drivers/net/bnxt/hcapi/hcapi_cfa_p4.h | 467 - drivers/net/bnxt/hsi_struct_def_dpdk.h| 281 +- drivers/net/bnxt/meson.build |65 +- drivers/net/bnxt/tf_core/bitalloc.c |10 +- drivers/net/bnxt/tf_core/bitalloc.h | 5 +- drivers/net/bnxt/tf_core/cfa_resource_types.h | 3 +- drivers/net/bnxt/tf_core/dpool.c | 373 + drivers/net/bnxt/tf_core/dpool.h | 309 + drivers/net/bnxt/tf_core/hwrm_tf.h| 195 - drivers/net/bnxt/tf_core/lookup3.h| 2 +- drivers/net/bnxt/tf_core/meson.build |36 + drivers/net/bnxt/tf_core/tf_core.c| 326 +- drivers/net/bnxt/tf_core/tf_core.h| 563 +- drivers/net/bnxt/tf_core/tf_device.c | 530 +- drivers/net/bnxt/tf_core/tf_device.h | 276 +- drivers/net/bnxt/tf_core/tf_device_p4.c | 164 +- drivers/net/bnxt/tf_core/tf_device_p4.h | 203 +- drivers/net/bnxt/t
[dpdk-dev] [PATCH 01/58] net/bnxt: add CFA folder to HCAPI directory
From: Jeffrey Huang Before introducing more HCAPI components to DPDK, the CFA code needs to be organized into a dedicated folder so it is separated from other new HCAPI components Signed-off-by: Jeffrey Huang Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa.h | 14 - .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_defs.h | 8 +- .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.c | 0 .../net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.h | 2 - drivers/net/bnxt/hcapi/cfa/meson.build| 10 + drivers/net/bnxt/hcapi/cfa_p40_hw.h | 781 -- drivers/net/bnxt/hcapi/cfa_p40_tbl.h | 303 --- drivers/net/bnxt/meson.build | 65 +- drivers/net/bnxt/tf_core/meson.build | 33 + drivers/net/bnxt/tf_core/tf_core.h| 2 +- drivers/net/bnxt/tf_core/tf_em.h | 2 +- drivers/net/bnxt/tf_ulp/meson.build | 28 + 12 files changed, 89 insertions(+), 1159 deletions(-) rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa.h (96%) rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_defs.h (98%) rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.c (100%) rename drivers/net/bnxt/hcapi/{ => cfa}/hcapi_cfa_p4.h (99%) create mode 100644 drivers/net/bnxt/hcapi/cfa/meson.build delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_hw.h delete mode 100644 drivers/net/bnxt/hcapi/cfa_p40_tbl.h create mode 100644 drivers/net/bnxt/tf_core/meson.build create mode 100644 drivers/net/bnxt/tf_ulp/meson.build diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h similarity index 96% rename from drivers/net/bnxt/hcapi/hcapi_cfa.h rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h index c58092e72d..b8c85a0fca 100644 --- a/drivers/net/bnxt/hcapi/hcapi_cfa.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h @@ -14,20 +14,6 @@ #include "hcapi_cfa_defs.h" -#if CHIP_CFG == SR_A -#define SUPPORT_CFA_HW_P45 1 -#undef SUPPORT_CFA_HW_P4 -#define SUPPORT_CFA_HW_P4 0 -#elif CHIP_CFG == CMB_A -#define SUPPORT_CFA_HW_P4 1 -#else -#error "Chip not supported" -#endif - -#if SUPPORT_CFA_HW_P4 && SUPPORT_CFA_HW_P58 && SUPPORT_CFA_HW_P59 -#define SUPPORT_CFA_HW_ALL 1 -#endif - /** * Index used for the sram_entries field */ diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_defs.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h similarity index 98% rename from drivers/net/bnxt/hcapi/hcapi_cfa_defs.h rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h index b3d6892b0b..08f098ec86 100644 --- a/drivers/net/bnxt/hcapi/hcapi_cfa_defs.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h @@ -17,11 +17,6 @@ #include #include -#define SUPPORT_CFA_HW_ALL 0 -#define SUPPORT_CFA_HW_P4 1 -#define SUPPORT_CFA_HW_P58 0 -#define SUPPORT_CFA_HW_P59 0 - #define CFA_BITS_PER_BYTE (8) #define __CFA_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define CFA_ALIGN(x, a) __CFA_ALIGN_MASK(x, (a) - 1) @@ -49,8 +44,7 @@ enum hcapi_cfa_ver { HCAPI_CFA_P40 = 0, /**< CFA phase 4.0 */ HCAPI_CFA_P45 = 1, /**< CFA phase 4.5 */ HCAPI_CFA_P58 = 2, /**< CFA phase 5.8 */ - HCAPI_CFA_P59 = 3, /**< CFA phase 5.9 */ - HCAPI_CFA_PMAX = 4 + HCAPI_CFA_PMAX = 3 }; /** diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.c b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c similarity index 100% rename from drivers/net/bnxt/hcapi/hcapi_cfa_p4.c rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c diff --git a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h similarity index 99% rename from drivers/net/bnxt/hcapi/hcapi_cfa_p4.h rename to drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h index 305c83bc9f..74a5483c0b 100644 --- a/drivers/net/bnxt/hcapi/hcapi_cfa_p4.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h @@ -6,8 +6,6 @@ #ifndef _HCAPI_CFA_P4_H_ #define _HCAPI_CFA_P4_H_ -#include "cfa_p40_hw.h" - /** CFA phase 4 fix formatted table(layout) ID definition * */ diff --git a/drivers/net/bnxt/hcapi/cfa/meson.build b/drivers/net/bnxt/hcapi/cfa/meson.build new file mode 100644 index 00..8b70d273f4 --- /dev/null +++ b/drivers/net/bnxt/hcapi/cfa/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation +# Copyright(c) 2021 Broadcom + +#Include the folder for headers +includes += include_directories('.') + +#Add the source files +sources += files( +'hcapi_cfa_p4.c') diff --git a/drivers/net/bnxt/hcapi/cfa_p40_hw.h b/drivers/net/bnxt/hcapi/cfa_p40_hw.h deleted file mode 100644 index 5e32529886..00 --- a/drivers/net/bnxt/hcapi/cfa_p40_hw.h +++ /dev/null @@ -1,781 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. - */ -/* - * Name: cfa_p40_hw.h - * - * Description: header for SWE based on Truflow - * - * Date: taken from 12/16/19 17:18:12 - * - * Note: This file was first generat
[dpdk-dev] [PATCH 02/58] net/bnxt: add base TRUFLOW support for Thor
From: Farah Smith Add infrastructure code to support TRUFLOW on Thor NICs. Also update meson.build Signed-off-by: Farah Smith Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/cfa_resource_types.h | 1 - drivers/net/bnxt/tf_core/meson.build | 1 + drivers/net/bnxt/tf_core/tf_core.c| 1 + drivers/net/bnxt/tf_core/tf_device.c | 207 + drivers/net/bnxt/tf_core/tf_device.h | 24 ++ drivers/net/bnxt/tf_core/tf_device_p4.c | 111 ++- drivers/net/bnxt/tf_core/tf_device_p4.h | 3 +- drivers/net/bnxt/tf_core/tf_device_p58.c | 284 ++ drivers/net/bnxt/tf_core/tf_device_p58.h | 79 + drivers/net/bnxt/tf_core/tf_em_common.c | 4 +- drivers/net/bnxt/tf_core/tf_msg.c | 33 -- drivers/net/bnxt/tf_core/tf_rm.c | 8 +- drivers/net/bnxt/tf_core/tf_shadow_tcam.c | 4 +- 13 files changed, 711 insertions(+), 49 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.c create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.h diff --git a/drivers/net/bnxt/tf_core/cfa_resource_types.h b/drivers/net/bnxt/tf_core/cfa_resource_types.h index f55a98a388..b63b87bcf3 100644 --- a/drivers/net/bnxt/tf_core/cfa_resource_types.h +++ b/drivers/net/bnxt/tf_core/cfa_resource_types.h @@ -254,5 +254,4 @@ #define CFA_RESOURCE_TYPE_P4_TBL_SCOPE 0x22UL #define CFA_RESOURCE_TYPE_P4_LAST CFA_RESOURCE_TYPE_P4_TBL_SCOPE - #endif /* _CFA_RESOURCE_TYPES_H_ */ diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build index b23e0fbe70..d7e8f664fd 100644 --- a/drivers/net/bnxt/tf_core/meson.build +++ b/drivers/net/bnxt/tf_core/meson.build @@ -20,6 +20,7 @@ sources += files( 'tf_session.c', 'tf_device.c', 'tf_device_p4.c', +'tf_device_p58.c', 'tf_identifier.c', 'tf_shadow_tbl.c', 'tf_shadow_tcam.c', diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index feec3cf459..b1ce4e721c 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -35,6 +35,7 @@ tf_open_session(struct tf *tfp, * firmware open session succeeds. */ if (parms->device_type != TF_DEVICE_TYPE_WH && + parms->device_type != TF_DEVICE_TYPE_THOR && parms->device_type != TF_DEVICE_TYPE_SR) { TFP_DRV_LOG(ERR, "Unsupported device type %d\n", diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index f68eb723fe..9c63f6d5d4 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -5,6 +5,7 @@ #include "tf_device.h" #include "tf_device_p4.h" +#include "tf_device_p58.h" #include "tfp.h" #include "tf_em.h" @@ -12,6 +13,7 @@ struct tf; /* Forward declarations */ static int tf_dev_unbind_p4(struct tf *tfp); +static int tf_dev_unbind_p58(struct tf *tfp); /** * Device specific bind function, WH+ @@ -234,6 +236,203 @@ tf_dev_unbind_p4(struct tf *tfp) return rc; } +/** + * Device specific bind function, THOR + * + * [in] tfp + * Pointer to TF handle + * + * [in] shadow_copy + * Flag controlling shadow copy DB creation + * + * [in] resources + * Pointer to resource allocation information + * + * [out] dev_handle + * Device handle + * + * Returns + * - (0) if successful. + * - (-EINVAL) on parameter or internal failure. + */ +static int +tf_dev_bind_p58(struct tf *tfp, + bool shadow_copy, + struct tf_session_resources *resources, + struct tf_dev_info *dev_handle) +{ + int rc; + int frc; + struct tf_ident_cfg_parms ident_cfg; + struct tf_tbl_cfg_parms tbl_cfg; + struct tf_tcam_cfg_parms tcam_cfg; + struct tf_em_cfg_parms em_cfg; + struct tf_if_tbl_cfg_parms if_tbl_cfg; + struct tf_global_cfg_cfg_parms global_cfg; + + /* Initial function initialization */ + dev_handle->ops = &tf_dev_ops_p58_init; + + /* Initialize the modules */ + + ident_cfg.num_elements = TF_IDENT_TYPE_MAX; + ident_cfg.cfg = tf_ident_p58; + ident_cfg.shadow_copy = shadow_copy; + ident_cfg.resources = resources; + rc = tf_ident_bind(tfp, &ident_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Identifier initialization failure\n"); + goto fail; + } + + tbl_cfg.num_elements = TF_TBL_TYPE_MAX; + tbl_cfg.cfg = tf_tbl_p58; + tbl_cfg.shadow_copy = shadow_copy; + tbl_cfg.resources = resources; + rc = tf_tbl_bind(tfp, &tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Table initialization failure\n"); + goto fail
[dpdk-dev] [PATCH 04/58] net/bnxt: check resource reservation in TRUFLOW
From: Jay Ding - Allow tf_open to continue if no resource is allocated for some table type. - Close the session if binding fails for any table. - Close the session if no resource is allocated for all tables. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Peter Spreadborough --- drivers/net/bnxt/tf_core/tf_device.c | 284 +++--- drivers/net/bnxt/tf_core/tf_session.c | 2 +- 2 files changed, 207 insertions(+), 79 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 5116601a69..d4c93439ec 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -15,6 +15,44 @@ struct tf; static int tf_dev_unbind_p4(struct tf *tfp); static int tf_dev_unbind_p58(struct tf *tfp); +/** + * Resource Reservation Check function + * + * [in] tfp + * Pointer to TF handle + * + * [in] cfg + * Pointer to rm element config + * + * [in] reservations + * Pointer to resource reservation array + * + * Returns + * - (n) number of tables that have non-zero reservation count. + */ +static int +tf_dev_reservation_check(struct tf *tfp __rte_unused, +uint16_t count, +struct tf_rm_element_cfg *cfg, +uint16_t *reservations) +{ + uint16_t cnt = 0; + uint16_t *rm_num; + int i, j; + + for (i = 0; i < TF_DIR_MAX; i++) { + rm_num = (uint16_t *)reservations + i * count; + for (j = 0; j < count; j++) { + if ((cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI || +cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) && +rm_num[j] > 0) + cnt++; + } + } + + return cnt; +} + /** * Device specific bind function, WH+ * @@ -42,6 +80,8 @@ tf_dev_bind_p4(struct tf *tfp, { int rc; int frc; + int rsv_cnt; + bool no_rsv_flag = true; struct tf_ident_cfg_parms ident_cfg; struct tf_tbl_cfg_parms tbl_cfg; struct tf_tcam_cfg_parms tcam_cfg; @@ -54,69 +94,117 @@ tf_dev_bind_p4(struct tf *tfp, /* Initialize the modules */ - ident_cfg.num_elements = TF_IDENT_TYPE_MAX; - ident_cfg.cfg = tf_ident_p4; - ident_cfg.shadow_copy = shadow_copy; - ident_cfg.resources = resources; - rc = tf_ident_bind(tfp, &ident_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "Identifier initialization failure\n"); - goto fail; + rsv_cnt = tf_dev_reservation_check(tfp, + TF_IDENT_TYPE_MAX, + tf_ident_p4, + (uint16_t *)resources->ident_cnt); + if (rsv_cnt) { + ident_cfg.num_elements = TF_IDENT_TYPE_MAX; + ident_cfg.cfg = tf_ident_p4; + ident_cfg.shadow_copy = shadow_copy; + ident_cfg.resources = resources; + rc = tf_ident_bind(tfp, &ident_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Identifier initialization failure\n"); + goto fail; + } + + no_rsv_flag = false; } - tbl_cfg.num_elements = TF_TBL_TYPE_MAX; - tbl_cfg.cfg = tf_tbl_p4; - tbl_cfg.shadow_copy = shadow_copy; - tbl_cfg.resources = resources; - rc = tf_tbl_bind(tfp, &tbl_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "Table initialization failure\n"); - goto fail; + rsv_cnt = tf_dev_reservation_check(tfp, + TF_TBL_TYPE_MAX, + tf_tbl_p4, + (uint16_t *)resources->tbl_cnt); + if (rsv_cnt) { + tbl_cfg.num_elements = TF_TBL_TYPE_MAX; + tbl_cfg.cfg = tf_tbl_p4; + tbl_cfg.shadow_copy = shadow_copy; + tbl_cfg.resources = resources; + rc = tf_tbl_bind(tfp, &tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Table initialization failure\n"); + goto fail; + } + + no_rsv_flag = false; } - tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX; - tcam_cfg.cfg = tf_tcam_p4; - tcam_cfg.shadow_copy = shadow_copy; - tcam_cfg.resources = resources; - rc = tf_tcam_bind(tfp, &tcam_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "TCAM initialization failure\n"); - goto fail; + rsv_cnt = tf_dev_reservation_check(tfp, + TF_TCAM_TBL_TYPE_MAX, +
[dpdk-dev] [PATCH 03/58] net/bnxt: add mailbox selection via dev op
From: Peter Spreadborough Add get mailbox dev op so that mailbox offset is based on device rather than hard coded. Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_device.c | 21 ++ drivers/net/bnxt/tf_core/tf_device.h | 12 + drivers/net/bnxt/tf_core/tf_device_p4.c | 8 + drivers/net/bnxt/tf_core/tf_device_p58.c | 7 + drivers/net/bnxt/tf_core/tf_msg.c| 410 +-- drivers/net/bnxt/tf_core/tf_msg.h| 12 +- drivers/net/bnxt/tf_core/tf_rm.c | 2 + drivers/net/bnxt/tf_core/tf_session.c| 22 +- drivers/net/bnxt/tf_core/tf_tcam.c | 4 +- 9 files changed, 463 insertions(+), 35 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 9c63f6d5d4..5116601a69 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -461,6 +461,27 @@ tf_dev_bind(struct tf *tfp __rte_unused, } } +int +tf_dev_bind_ops(enum tf_device_type type, + struct tf_dev_info *dev_handle) +{ + switch (type) { + case TF_DEVICE_TYPE_WH: + case TF_DEVICE_TYPE_SR: + dev_handle->ops = &tf_dev_ops_p4; + break; + case TF_DEVICE_TYPE_THOR: + dev_handle->ops = &tf_dev_ops_p58; + break; + default: + TFP_DRV_LOG(ERR, + "No such device\n"); + return -ENODEV; + } + + return 0; +} + int tf_dev_unbind(struct tf *tfp, struct tf_dev_info *dev_handle) diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index d5ef72309f..cbacc09ea5 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -108,6 +108,10 @@ int tf_dev_bind(struct tf *tfp, int tf_dev_unbind(struct tf *tfp, struct tf_dev_info *dev_handle); +int +tf_dev_bind_ops(enum tf_device_type type, + struct tf_dev_info *dev_handle); + /** * Truflow device specific function hooks structure * @@ -724,6 +728,14 @@ struct tf_dev_ops { */ int (*tf_dev_get_global_cfg)(struct tf *tfp, struct tf_global_cfg_parms *parms); + + /** +* Get mailbox +* +*returns: +* mailbox +*/ + int (*tf_dev_get_mailbox)(void); }; /** diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 257a0fb2d0..6b28f6ce59 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -13,6 +13,7 @@ #include "tf_em.h" #include "tf_if_tbl.h" #include "tfp.h" +#include "tf_msg_common.h" #define TF_DEV_P4_PARIF_MAX 16 #define TF_DEV_P4_PF_MASK 0xfUL @@ -241,6 +242,11 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused, return 0; } +static int tf_dev_p4_get_mailbox(void) +{ + return TF_KONG_MB; +} + /** * Truflow P4 device specific functions @@ -278,6 +284,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_get_if_tbl = NULL, .tf_dev_set_global_cfg = NULL, .tf_dev_get_global_cfg = NULL, + .tf_dev_get_mailbox = tf_dev_p4_get_mailbox, }; /** @@ -316,4 +323,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, .tf_dev_get_global_cfg = tf_global_cfg_get, + .tf_dev_get_mailbox = tf_dev_p4_get_mailbox, }; diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index fb5ad29a5c..b4530f8762 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -13,6 +13,7 @@ #include "tf_em.h" #include "tf_if_tbl.h" #include "tfp.h" +#include "tf_msg_common.h" #define TF_DEV_P58_PARIF_MAX 16 #define TF_DEV_P58_PF_MASK 0xfUL @@ -206,6 +207,10 @@ tf_dev_p58_map_parif(struct tf *tfp __rte_unused, return 0; } +static int tf_dev_p58_get_mailbox(void) +{ + return TF_CHIMP_MB; +} /** * Truflow P58 device specific functions @@ -243,6 +248,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = { .tf_dev_get_if_tbl = NULL, .tf_dev_set_global_cfg = NULL, .tf_dev_get_global_cfg = NULL, + .tf_dev_get_mailbox = tf_dev_p58_get_mailbox, }; /** @@ -281,4 +287,5 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, .tf_dev_get_global_cfg = tf_global_cfg_get, + .tf_dev_get_mailbox = tf_dev_p58_get_mailbox, }; diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index f20a5113bf..1007211363 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@
[dpdk-dev] [PATCH 05/58] net/bnxt: update TRUFLOW resources
From: Farah Smith - Remove unused tables from tf_tbl_type - Encode flow type into flow handle (internal or external) - Clean up Whitney resource tables - Clean up Truflow CLI open tables and update Thor resources - Add Thor SRAM and external pool types to core API - Remove unneeded Stingray table reference Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Jay Ding Reviewed-by: Peter Spreadborough --- drivers/net/bnxt/tf_core/tf_core.c| 9 +- drivers/net/bnxt/tf_core/tf_core.h| 83 + drivers/net/bnxt/tf_core/tf_device.c | 5 +- drivers/net/bnxt/tf_core/tf_device_p4.c | 105 --- drivers/net/bnxt/tf_core/tf_device_p4.h | 175 ++ drivers/net/bnxt/tf_core/tf_device_p45.h | 105 --- drivers/net/bnxt/tf_core/tf_device_p58.c | 61 +++--- drivers/net/bnxt/tf_core/tf_device_p58.h | 6 + drivers/net/bnxt/tf_core/tf_em_common.c | 2 +- drivers/net/bnxt/tf_core/tf_em_internal.c | 2 +- drivers/net/bnxt/tf_core/tf_ext_flow_handle.h | 15 +- drivers/net/bnxt/tf_core/tf_msg.c | 3 +- drivers/net/bnxt/tf_core/tf_rm.c | 14 +- drivers/net/bnxt/tf_core/tf_shadow_tbl.c | 2 - drivers/net/bnxt/tf_core/tf_util.c| 8 +- 15 files changed, 246 insertions(+), 349 deletions(-) delete mode 100644 drivers/net/bnxt/tf_core/tf_device_p45.h diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index b1ce4e721c..ebe0fc34aa 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -19,6 +19,7 @@ #include "rand.h" #include "tf_common.h" #include "hwrm_tf.h" +#include "tf_ext_flow_handle.h" int tf_open_session(struct tf *tfp, @@ -251,6 +252,7 @@ int tf_delete_em_entry(struct tf *tfp, struct tf_session *tfs; struct tf_dev_info *dev; int rc; + unsigned int flag = 0; TF_CHECK_PARMS2(tfp, parms); @@ -274,12 +276,11 @@ int tf_delete_em_entry(struct tf *tfp, return rc; } - if (parms->mem == TF_MEM_EXTERNAL) - rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms); - else if (parms->mem == TF_MEM_INTERNAL) + TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag); + if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL)) rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms); else - return -EINVAL; + rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms); if (rc) { TFP_DRV_LOG(ERR, diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 5e458c58fb..4fe0590569 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -158,34 +158,40 @@ enum tf_device_type { */ enum tf_identifier_type { /** +* WH/SR/TH/SR2 * The L2 Context is returned from the L2 Ctxt TCAM lookup * and can be used in WC TCAM or EM keys to virtualize further * lookups. */ TF_IDENT_TYPE_L2_CTXT_HIGH, /** +* WH/SR/TH/SR2 * The L2 Context is returned from the L2 Ctxt TCAM lookup * and can be used in WC TCAM or EM keys to virtualize further * lookups. */ TF_IDENT_TYPE_L2_CTXT_LOW, /** +* WH/SR/TH/SR2 * The WC profile func is returned from the L2 Ctxt TCAM lookup * to enable virtualization of the profile TCAM. */ TF_IDENT_TYPE_PROF_FUNC, /** +* WH/SR/TH/SR2 * The WC profile ID is included in the WC lookup key * to enable virtualization of the WC TCAM hardware. */ TF_IDENT_TYPE_WC_PROF, /** +* WH/SR/TH/SR2 * The EM profile ID is included in the EM lookup key * to enable virtualization of the EM hardware. (not required for SR2 * as it has table scope) */ TF_IDENT_TYPE_EM_PROF, /** +* TH/SR2 * The L2 func is included in the ILT result and from recycling to * enable virtualization of further lookups. */ @@ -203,59 +209,63 @@ enum tf_identifier_type { enum tf_tbl_type { /* Internal */ - /** Wh+/SR Action Record */ + /** Wh+/SR/TH Action Record */ TF_TBL_TYPE_FULL_ACT_RECORD, - /** Wh+/SR/Th Multicast Groups */ + /** TH Compact Action Record */ + TF_TBL_TYPE_COMPACT_ACT_RECORD, + /** (Future) Multicast Groups */ TF_TBL_TYPE_MCAST_GROUPS, - /** Wh+/SR Action Encap 8 Bytes */ + /** Wh+/SR/TH Action Encap 8 Bytes */ TF_TBL_TYPE_ACT_ENCAP_8B, - /** Wh+/SR Action Encap 16 Bytes */ + /** Wh+/SR/TH Action Encap 16 Bytes */ TF_TBL_TYPE_ACT_ENCAP_16B, - /** Action Encap 32 Bytes */ + /** WH+/SR/TH Action En
[dpdk-dev] [PATCH 06/58] net/bnxt: add support for EM with FKB
From: Peter Spreadborough Main TF changes to support EM insert with FKB. Flexible Key builder is required to create Wild Card and Exact Match keys for TCAM lookups. Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/meson.build | 1 + drivers/net/bnxt/tf_core/tf_device_p58.c | 14 +- drivers/net/bnxt/tf_core/tf_em.h | 32 + .../net/bnxt/tf_core/tf_em_hash_internal.c| 123 ++ drivers/net/bnxt/tf_core/tf_em_internal.c | 3 +- drivers/net/bnxt/tf_core/tf_msg.c | 96 ++ drivers/net/bnxt/tf_core/tf_msg.h | 35 + 7 files changed, 295 insertions(+), 9 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/tf_em_hash_internal.c diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build index d7e8f664fd..373ee0413b 100644 --- a/drivers/net/bnxt/tf_core/meson.build +++ b/drivers/net/bnxt/tf_core/meson.build @@ -30,5 +30,6 @@ sources += files( 'll.c', 'tf_global_cfg.c', 'tf_em_host.c', +'tf_em_hash_internal.c', 'tf_shadow_identifier.c', 'tf_hash.c') diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index 7dd806000c..6cef1d5ba5 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -256,14 +256,14 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_alloc_search_tcam = tf_tcam_alloc_search, .tf_dev_set_tcam = tf_tcam_set, .tf_dev_get_tcam = NULL, - .tf_dev_insert_int_em_entry = tf_em_insert_int_entry, - .tf_dev_delete_int_em_entry = tf_em_delete_int_entry, - .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry, - .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry, - .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc, - .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope, + .tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry, + .tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry, + .tf_dev_insert_ext_em_entry = NULL, + .tf_dev_delete_ext_em_entry = NULL, + .tf_dev_alloc_tbl_scope = NULL, + .tf_dev_map_tbl_scope = NULL, .tf_dev_map_parif = tf_dev_p58_map_parif, - .tf_dev_free_tbl_scope = tf_em_ext_common_free, + .tf_dev_free_tbl_scope = NULL, .tf_dev_set_if_tbl = tf_if_tbl_set, .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index b5c3acb09a..5a67ca3509 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -197,6 +197,38 @@ int tf_em_insert_int_entry(struct tf *tfp, int tf_em_delete_int_entry(struct tf *tfp, struct tf_delete_em_entry_parms *parms); +/** + * Insert record in to internal EM table + * + * [in] tfp + * Pointer to TruFlow handle + * + * [in] parms + * Pointer to input parameters + * + * Returns: + * 0 - Success + * -EINVAL - Parameter error + */ +int tf_em_hash_insert_int_entry(struct tf *tfp, + struct tf_insert_em_entry_parms *parms); + +/** + * Delete record from internal EM table + * + * [in] tfp + * Pointer to TruFlow handle + * + * [in] parms + * Pointer to input parameters + * + * Returns: + * 0 - Success + * -EINVAL - Parameter error + */ +int tf_em_hash_delete_int_entry(struct tf *tfp, + struct tf_delete_em_entry_parms *parms); + /** * Insert record in to external EEM table * diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c new file mode 100644 index 00..09183b42f0 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2021 Broadcom + * All rights reserved. + */ + +#include +#include +#include +#include + +#include "tf_core.h" +#include "tf_util.h" +#include "tf_common.h" +#include "tf_em.h" +#include "tf_msg.h" +#include "tfp.h" +#include "tf_ext_flow_handle.h" + +#include "bnxt.h" + +/** + * EM Pool + */ +extern struct stack em_pool[TF_DIR_MAX]; + +/** + * Insert EM internal entry API + * + * returns: + * 0 - Success + */ +int +tf_em_hash_insert_int_entry(struct tf *tfp, + struct tf_insert_em_entry_parms *parms) +{ + int rc; + uint32_t gfid; + uint16_t rptr_index = 0; + uint8_t rptr_entry = 0; + uint8_t num_of_entries = 0; + struct stack *pool = &em_pool[parms->dir]; + uint32_t index; + uint32_t key0_hash; + uint32_t key1_hash; + uint64_t big_hash; + + rc = stack_pop(pool, &index); + if (rc) { + PMD_DRV_LOG(ERR, +
[dpdk-dev] [PATCH 09/58] net/bnxt: add Thor WC TCAM support
From: Jay Ding 1. Add set/get/free/alloc for WC TCAM 2. Rework the key size in slice management. 3. Add 3 FKB WC keys for WC TCAM set cli cmd 4. Add transform key function for WC TCAM FKB key 5. Add checking for key buffer length for get_tcam Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_core.c | 2 + drivers/net/bnxt/tf_core/tf_core.h | 5 +- drivers/net/bnxt/tf_core/tf_device_p4.c | 2 - drivers/net/bnxt/tf_core/tf_device_p58.c | 7 +- drivers/net/bnxt/tf_core/tf_device_p58.h | 3 + drivers/net/bnxt/tf_core/tf_msg.c| 31 ++-- drivers/net/bnxt/tf_core/tf_tcam.c | 192 --- 7 files changed, 132 insertions(+), 110 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index a3b6afbc88..573fa0b1ed 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -842,8 +842,10 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused, gparms.type = parms->tcam_tbl_type; gparms.idx = parms->idx; gparms.key = parms->key; + gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits); gparms.mask = parms->mask; gparms.result = parms->result; + gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits); rc = dev->ops->tf_dev_get_tcam(tfp, &gparms); if (rc) { diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 0cc3719a1b..fcba492dc5 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -1286,7 +1286,7 @@ struct tf_get_tcam_entry_parms { */ uint8_t *mask; /** -* [out] key size in bits +* [in/out] key size in bits */ uint16_t key_sz_in_bits; /** @@ -1294,7 +1294,7 @@ struct tf_get_tcam_entry_parms { */ uint8_t *result; /** -* [out] struct containing result size in bits +* [in/out] struct containing result size in bits */ uint16_t result_sz_in_bits; }; @@ -1961,6 +1961,7 @@ enum tf_tunnel_encap_offsets { enum tf_global_config_type { TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */ TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */ + TF_COUNTER_CFG, /**< Counter Configuration (CNTRS_CTRL) */ TF_GLOBAL_CFG_TYPE_MAX }; diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index d0bede89e3..e5c9a0 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -144,8 +144,6 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused, *num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW; if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE) return -ENOTSUP; - - *num_slices_per_row = 1; } else { /* for other type of tcam */ *num_slices_per_row = 1; } diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index 50a8d82074..65e283ed11 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -123,15 +123,14 @@ tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused, uint16_t key_sz, uint16_t *num_slices_per_row) { -#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2 -#define CFA_P58_WC_TCAM_SLICE_SIZE 12 +#define CFA_P58_WC_TCAM_SLICES_PER_ROW 1 +#define CFA_P58_WC_TCAM_SLICE_SIZE 24 if (type == TF_TCAM_TBL_TYPE_WC_TCAM) { + /* only support single slice key size now */ *num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW; if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE) return -ENOTSUP; - - *num_slices_per_row = 1; } else { /* for other type of tcam */ *num_slices_per_row = 1; } diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h index abd916985e..07f022769b 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.h +++ b/drivers/net/bnxt/tf_core/tf_device_p58.h @@ -189,5 +189,8 @@ struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = { [TF_ACTION_BLOCK] = { TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK }, + [TF_COUNTER_CFG] = { + TF_GLOBAL_CFG_CFG_HCAPI, TF_COUNTER_CFG + }, }; #endif /* _TF_DEVICE_P58_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 1af5c6d11c..ec4c7890c3 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -39,19 +39,8 @@ * array size (define above) should be checked and compared. */ #de
[dpdk-dev] [PATCH 08/58] net/bnxt: add action SRAM Translation
From: Farah Smith - Translate Truflow action types for Thor to HCAPI RM resource defined SRAM banks. - move module type enum definitions to tf_core API - Switch to subtype concept for RM. - alloc/free working for Thor SRAM table type for full AR. Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Peter Spreadborough Reviewed-by: Randy Schacher --- drivers/net/bnxt/bnxt_util.h| 3 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h | 339 +++-- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h | 387 +- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h | 411 ++ drivers/net/bnxt/tf_core/meson.build| 1 - drivers/net/bnxt/tf_core/tf_core.h | 24 + drivers/net/bnxt/tf_core/tf_device.c| 43 +- drivers/net/bnxt/tf_core/tf_device.h| 23 - drivers/net/bnxt/tf_core/tf_device_p4.c | 21 +- drivers/net/bnxt/tf_core/tf_device_p58.c| 53 +- drivers/net/bnxt/tf_core/tf_device_p58.h| 110 ++- drivers/net/bnxt/tf_core/tf_em_common.c | 4 +- drivers/net/bnxt/tf_core/tf_em_host.c | 6 +- drivers/net/bnxt/tf_core/tf_em_internal.c | 4 +- drivers/net/bnxt/tf_core/tf_identifier.c| 10 +- drivers/net/bnxt/tf_core/tf_if_tbl.c| 2 +- drivers/net/bnxt/tf_core/tf_rm.c| 508 - drivers/net/bnxt/tf_core/tf_rm.h| 109 ++- drivers/net/bnxt/tf_core/tf_shadow_tbl.c| 783 drivers/net/bnxt/tf_core/tf_shadow_tbl.h| 256 --- drivers/net/bnxt/tf_core/tf_tbl.c | 238 +- drivers/net/bnxt/tf_core/tf_tcam.c | 20 +- drivers/net/bnxt/tf_core/tf_util.c | 36 +- drivers/net/bnxt/tf_core/tf_util.h | 26 +- 24 files changed, 1130 insertions(+), 2287 deletions(-) create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.c delete mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.h diff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h index 64e97eed15..b243c21ec2 100644 --- a/drivers/net/bnxt/bnxt_util.h +++ b/drivers/net/bnxt/bnxt_util.h @@ -9,6 +9,9 @@ #ifndef BIT #define BIT(n) (1UL << (n)) #endif /* BIT */ +#ifndef BIT_MASK +#define BIT_MASK(len) (BIT(len) - 1) +#endif /* BIT_MASK */ #define PCI_SUBSYSTEM_ID_OFFSET0x2e diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h index b8c85a0fca..c67aa29ad0 100644 --- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h @@ -1,281 +1,126 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. +/* + * Copyright(c) Broadcom Limited. + * All rights reserved. */ +/*! + * \file + * \brief Exported functions for CFA HW programming + */ #ifndef _HCAPI_CFA_H_ #define _HCAPI_CFA_H_ #include +#include #include #include #include #include +#include #include "hcapi_cfa_defs.h" -/** - * Index used for the sram_entries field - */ -enum hcapi_cfa_resc_type_sram { - HCAPI_CFA_RESC_TYPE_SRAM_FULL_ACTION, - HCAPI_CFA_RESC_TYPE_SRAM_MCG, - HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_8B, - HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_16B, - HCAPI_CFA_RESC_TYPE_SRAM_ENCAP_64B, - HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC, - HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC_IPV4, - HCAPI_CFA_RESC_TYPE_SRAM_SP_SMAC_IPV6, - HCAPI_CFA_RESC_TYPE_SRAM_COUNTER_64B, - HCAPI_CFA_RESC_TYPE_SRAM_NAT_SPORT, - HCAPI_CFA_RESC_TYPE_SRAM_NAT_DPORT, - HCAPI_CFA_RESC_TYPE_SRAM_NAT_S_IPV4, - HCAPI_CFA_RESC_TYPE_SRAM_NAT_D_IPV4, - HCAPI_CFA_RESC_TYPE_SRAM_MAX -}; - -/** - * Index used for the hw_entries field in struct cfa_rm_db - */ -enum hcapi_cfa_resc_type_hw { - /* common HW resources for all chip variants */ - HCAPI_CFA_RESC_TYPE_HW_L2_CTXT_TCAM, - HCAPI_CFA_RESC_TYPE_HW_PROF_FUNC, - HCAPI_CFA_RESC_TYPE_HW_PROF_TCAM, - HCAPI_CFA_RESC_TYPE_HW_EM_PROF_ID, - HCAPI_CFA_RESC_TYPE_HW_EM_REC, - HCAPI_CFA_RESC_TYPE_HW_WC_TCAM_PROF_ID, - HCAPI_CFA_RESC_TYPE_HW_WC_TCAM, - HCAPI_CFA_RESC_TYPE_HW_METER_PROF, - HCAPI_CFA_RESC_TYPE_HW_METER_INST, - HCAPI_CFA_RESC_TYPE_HW_MIRROR, - HCAPI_CFA_RESC_TYPE_HW_UPAR, - /* Wh+/SR specific HW resources */ - HCAPI_CFA_RESC_TYPE_HW_SP_TCAM, - /* Thor, SR2 common HW resources */ - HCAPI_CFA_RESC_TYPE_HW_FKB, - /* SR specific HW resources */ - HCAPI_CFA_RESC_TYPE_HW_TBL_SCOPE, - HCAPI_CFA_RESC_TYPE_HW_L2_FUNC, - HCAPI_CFA_RESC_TYPE_HW_EPOCH0, - HCAPI_CFA_RESC_TYPE_HW_EPOCH1, - HCAPI_CFA_RESC_TYPE_HW_METADATA, - HCAPI_CFA_RESC_TYPE_HW_CT_STATE, - HCAPI_CFA_RESC_TYPE_HW_RANGE_PROF, - HCAPI_CFA_RESC_TYPE_HW_RANGE_ENTRY, - HCAPI_CFA_RESC_TYPE_HW_LAG_ENTRY, - HCAPI_CFA_RESC_TYPE_HW_MAX -}; - -struct hcapi_cfa_key
[dpdk-dev] [PATCH 07/58] net/bnxt: add L2 Context TCAM get support
From: Jay Ding - Implement TCAM get in host - Add Thor support for TCAM set/free Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Peter Spreadborough Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/hwrm_tf.h | 1 + drivers/net/bnxt/tf_core/tf_core.c | 65 +++-- drivers/net/bnxt/tf_core/tf_device.h | 12 drivers/net/bnxt/tf_core/tf_device_p4.c | 6 ++ drivers/net/bnxt/tf_core/tf_device_p58.c | 9 ++- drivers/net/bnxt/tf_core/tf_msg.c| 52 ++ drivers/net/bnxt/tf_core/tf_msg.h| 16 + drivers/net/bnxt/tf_core/tf_tcam.c | 89 +++- drivers/net/bnxt/tf_core/tf_tcam.h | 4 ++ 9 files changed, 248 insertions(+), 6 deletions(-) diff --git a/drivers/net/bnxt/tf_core/hwrm_tf.h b/drivers/net/bnxt/tf_core/hwrm_tf.h index a707cd2758..9cc9a1435c 100644 --- a/drivers/net/bnxt/tf_core/hwrm_tf.h +++ b/drivers/net/bnxt/tf_core/hwrm_tf.h @@ -65,6 +65,7 @@ typedef enum tf_subtype { #define TF_BITS2BYTES(x) (((x) + 7) >> 3) #define TF_BITS2BYTES_WORD_ALIGN(x) x) + 31) >> 5) * 4) +#define TF_BITS2BYTES_64B_WORD_ALIGN(x) x) + 63) >> 6) * 8) struct tf_set_global_cfg_input; struct tf_get_global_cfg_input; diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index ebe0fc34aa..a3b6afbc88 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -764,7 +764,8 @@ tf_set_tcam_entry(struct tf *tfp, return rc; } - if (dev->ops->tf_dev_set_tcam == NULL) { + if (dev->ops->tf_dev_set_tcam == NULL || + dev->ops->tf_dev_word_align == NULL) { rc = -EOPNOTSUPP; TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", @@ -778,7 +779,7 @@ tf_set_tcam_entry(struct tf *tfp, sparms.idx = parms->idx; sparms.key = parms->key; sparms.mask = parms->mask; - sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits); + sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits); sparms.result = parms->result; sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits); @@ -796,10 +797,66 @@ tf_set_tcam_entry(struct tf *tfp, int tf_get_tcam_entry(struct tf *tfp __rte_unused, - struct tf_get_tcam_entry_parms *parms __rte_unused) + struct tf_get_tcam_entry_parms *parms) { + int rc; + struct tf_session *tfs; + struct tf_dev_info *dev; + struct tf_tcam_get_parms gparms; + TF_CHECK_PARMS2(tfp, parms); - return -EOPNOTSUPP; + + memset(&gparms, 0, sizeof(struct tf_tcam_get_parms)); + + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup device, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + if (dev->ops->tf_dev_get_tcam == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + gparms.dir = parms->dir; + gparms.type = parms->tcam_tbl_type; + gparms.idx = parms->idx; + gparms.key = parms->key; + gparms.mask = parms->mask; + gparms.result = parms->result; + + rc = dev->ops->tf_dev_get_tcam(tfp, &gparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: TCAM get failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + parms->key_sz_in_bits = gparms.key_size * 8; + parms->result_sz_in_bits = gparms.result_size * 8; + + return 0; } int diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index cbacc09ea5..4f4120c603 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -736,6 +736,18 @@ struct tf_dev_ops { * mailbox */ int (*tf_dev_get_mailbox)(void); + + /** +* Convert length in bit to length in byte and align to word. +* The word length depends on device type. +* +* [in] size +* Size in bit +
[dpdk-dev] [PATCH 13/58] net/bnxt: change RM database type
From: Jay Ding RM databases are statically defined in each module. New static database needs to be defined in the code when multiple sessions are added. Add dynamic alloc database and associate it to each session. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_em.h | 10 ++ drivers/net/bnxt/tf_core/tf_em_internal.c | 44 +-- drivers/net/bnxt/tf_core/tf_identifier.c | 82 ++-- drivers/net/bnxt/tf_core/tf_identifier.h | 10 ++ drivers/net/bnxt/tf_core/tf_tbl.c | 151 +- drivers/net/bnxt/tf_core/tf_tbl.h | 10 ++ drivers/net/bnxt/tf_core/tf_tcam.c| 107 --- drivers/net/bnxt/tf_core/tf_tcam.h| 10 ++ 8 files changed, 351 insertions(+), 73 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index 2de1862cd9..19ad7f12be 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -133,6 +133,16 @@ struct tf_em_cfg_parms { enum tf_mem_type mem_type; }; +/** + * EM database + * + * EM rm database + * + */ +struct em_rm_db { + struct rm_db *em_db[TF_DIR_MAX]; +}; + /** * @page em EM * diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c index 043f9be4da..5a100ef1de 100644 --- a/drivers/net/bnxt/tf_core/tf_em_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_internal.c @@ -18,11 +18,6 @@ #include "bnxt.h" -/** - * EM DBs. - */ -static void *em_db[TF_DIR_MAX]; - #define TF_EM_DB_EM_REC 0 /** @@ -242,6 +237,8 @@ tf_em_int_bind(struct tf *tfp, uint8_t db_exists = 0; struct tf_rm_get_alloc_info_parms iparms; struct tf_rm_alloc_info info; + struct em_rm_db *em_db; + struct tfp_calloc_parms cparms; TF_CHECK_PARMS2(tfp, parms); @@ -251,6 +248,21 @@ tf_em_int_bind(struct tf *tfp, return -EINVAL; } + memset(&db_cfg, 0, sizeof(db_cfg)); + cparms.nitems = 1; + cparms.size = sizeof(struct em_rm_db); + cparms.alignment = 0; + if (tfp_calloc(&cparms) != 0) { + TFP_DRV_LOG(ERR, "em_rm_db alloc error %s\n", + strerror(ENOMEM)); + return -ENOMEM; + } + + em_db = cparms.mem_va; + for (i = 0; i < TF_DIR_MAX; i++) + em_db->em_db[i] = NULL; + tf_session_set_db(tfp, TF_MODULE_TYPE_EM, em_db); + db_cfg.module = TF_MODULE_TYPE_EM; db_cfg.num_elements = parms->num_elements; db_cfg.cfg = parms->cfg; @@ -277,7 +289,8 @@ tf_em_int_bind(struct tf *tfp, return rc; } - db_cfg.rm_db = &em_db[i]; + db_cfg.rm_db = (void *)&em_db->em_db[i]; + rc = tf_rm_create_db(tfp, &db_cfg); if (rc) { TFP_DRV_LOG(ERR, @@ -293,7 +306,7 @@ tf_em_int_bind(struct tf *tfp, init = 1; for (i = 0; i < TF_DIR_MAX; i++) { - iparms.rm_db = em_db[i]; + iparms.rm_db = em_db->em_db[i]; iparms.subtype = TF_EM_DB_EM_REC; iparms.info = &info; @@ -323,6 +336,8 @@ tf_em_int_unbind(struct tf *tfp) int rc; int i; struct tf_rm_free_db_parms fparms = { 0 }; + struct em_rm_db *em_db; + void *em_db_ptr = NULL; TF_CHECK_PARMS1(tfp); @@ -336,16 +351,25 @@ tf_em_int_unbind(struct tf *tfp) for (i = 0; i < TF_DIR_MAX; i++) tf_free_em_pool(i); + rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to get em_ext_db from session, rc:%s\n", + strerror(-rc)); + return rc; + } + em_db = (struct em_rm_db *)em_db_ptr; + for (i = 0; i < TF_DIR_MAX; i++) { fparms.dir = i; - fparms.rm_db = em_db[i]; - if (em_db[i] != NULL) { + fparms.rm_db = em_db->em_db[i]; + if (em_db->em_db[i] != NULL) { rc = tf_rm_free_db(tfp, &fparms); if (rc) return rc; } - em_db[i] = NULL; + em_db->em_db[i] = NULL; } init = 0; diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c index 9d0a578085..ee68b6ca58 100644 --- a/drivers/net/bnxt/tf_core/tf_identifier.c +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -11,14 +11,10 @@ #include "tf_rm.h" #include "tf_util.h" #include "tfp.h" +#include "tf_session.h" struct tf; -/** - * Identifier DBs. - */ -static void *ident_db[TF_DIR_MAX]; - /** * Init flag, set on bind and cleared on unbind */ @@ -43,6 +39,8 @@ tf_ident_bind(stru
[dpdk-dev] [PATCH 12/58] net/bnxt: modify TRUFLOW HWRM messages
From: Farah Smith - Move Bulk get to a direct HWRM message - Deprecate code based on HCAPI changes Signed-off-by: Farah Smith Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h| 72 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c | 4 +- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h | 197 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c | 116 --- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.h | 282 + drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c| 2 +- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h| 287 +- drivers/net/bnxt/tf_core/hwrm_tf.h| 196 drivers/net/bnxt/tf_core/lookup3.h| 2 +- drivers/net/bnxt/tf_core/tf_core.c| 1 - drivers/net/bnxt/tf_core/tf_core.h| 127 drivers/net/bnxt/tf_core/tf_device.c | 2 +- drivers/net/bnxt/tf_core/tf_device_p4.h | 75 +++-- drivers/net/bnxt/tf_core/tf_device_p58.h | 48 ++- drivers/net/bnxt/tf_core/tf_em.h | 4 +- drivers/net/bnxt/tf_core/tf_em_common.c | 250 ++- drivers/net/bnxt/tf_core/tf_em_common.h | 68 - drivers/net/bnxt/tf_core/tf_em_host.c | 109 +-- drivers/net/bnxt/tf_core/tf_msg.c | 263 ++-- drivers/net/bnxt/tf_core/tf_msg.h | 87 ++ drivers/net/bnxt/tf_core/tf_msg_common.h | 3 - drivers/net/bnxt/tf_core/tf_session.c | 115 +++ drivers/net/bnxt/tf_core/tf_session.h | 90 ++ drivers/net/bnxt/tf_core/tf_tbl.h | 30 -- drivers/net/bnxt/tf_core/tf_util.c| 12 - drivers/net/bnxt/tf_core/tf_util.h| 4 + drivers/net/bnxt/tf_core/tfp.c| 34 --- drivers/net/bnxt/tf_core/tfp.h| 52 28 files changed, 1202 insertions(+), 1330 deletions(-) delete mode 100644 drivers/net/bnxt/tf_core/hwrm_tf.h diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h index 0580e07c45..c67aa29ad0 100644 --- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h @@ -63,74 +63,10 @@ struct hcapi_cfa_devops { */ uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen); -int hcapi_cfa_action_hw_op(struct hcapi_cfa_hwop *op, - uint8_t *act_tbl, - struct hcapi_cfa_data *act_obj); -int hcapi_cfa_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_rm_register_client(hcapi_cfa_rm_data_t *data, -const char *client_name, -int *client_id); -int hcapi_cfa_rm_unregister_client(hcapi_cfa_rm_data_t *data, - int client_id); -int hcapi_cfa_rm_query_resources(hcapi_cfa_rm_data_t *data, -int client_id, -uint16_t chnl_id, -struct hcapi_cfa_resc_req_db *req_db); -int hcapi_cfa_rm_query_resources_one(hcapi_cfa_rm_data_t *data, -int clien_id, -struct hcapi_cfa_resc_db *resc_db); -int hcapi_cfa_rm_reserve_resources(hcapi_cfa_rm_data_t *data, - int client_id, - struct hcapi_cfa_resc_req_db *resc_req, - struct hcapi_cfa_resc_db *resc_db); -int hcapi_cfa_rm_release_resources(hcapi_cfa_rm_data_t *data, - int client_id, - struct hcapi_cfa_resc_req_db *resc_req, - struct hcapi_cfa_resc_db *resc_db); -int hcapi_cfa_rm_initialize(hcapi_cfa_rm_data_t *data); - -#if SUPPORT_CFA_HW_P4 - -int hcapi_cfa_p4_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_prof_l2ctxt_hwop(struct hcapi_cfa_hwop *op, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_prof_l2ctxtrmp_hwop(struct hcapi_cfa_hwop *op, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_prof_tcam_hwop(struct hcapi_cfa_hwop *op, -struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_prof_tcamrmp_hwop(struct hcapi_cfa_hwop *op, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op, - struct hcapi_cfa_data *obj_data); -int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op, -
[dpdk-dev] [PATCH 11/58] net/bnxt: add hashing changes for Thor
From: Peter Spreadborough - Move HCAPI hashing code to common file and add Thor support. - Change DPDK EM insert for FKB to use limited size Type 3 key. - Update FKB builder to be able to tell between EM and WC keys during transform. Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher Reviewed-by: Farah Smith --- drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h| 72 ++- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c | 85 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h | 15 +++ drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p4.c | 109 +--- drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c| 122 ++ drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.h| 6 + drivers/net/bnxt/hcapi/cfa/meson.build| 4 +- drivers/net/bnxt/tf_core/tf_device.h | 15 +++ drivers/net/bnxt/tf_core/tf_device_p4.c | 4 + drivers/net/bnxt/tf_core/tf_device_p58.c | 4 + drivers/net/bnxt/tf_core/tf_em.h | 8 +- drivers/net/bnxt/tf_core/tf_em_common.c | 42 -- .../net/bnxt/tf_core/tf_em_hash_internal.c| 22 +++- 13 files changed, 383 insertions(+), 125 deletions(-) create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_common.c create mode 100644 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_p58.c diff --git a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h index c67aa29ad0..0580e07c45 100644 --- a/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h +++ b/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h @@ -63,10 +63,74 @@ struct hcapi_cfa_devops { */ uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen); - /** hardware operation on the CFA EM key -* -* This API provides the functionality to program the exact match and -* key data to exact match record memory. +int hcapi_cfa_action_hw_op(struct hcapi_cfa_hwop *op, + uint8_t *act_tbl, + struct hcapi_cfa_data *act_obj); +int hcapi_cfa_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_rm_register_client(hcapi_cfa_rm_data_t *data, +const char *client_name, +int *client_id); +int hcapi_cfa_rm_unregister_client(hcapi_cfa_rm_data_t *data, + int client_id); +int hcapi_cfa_rm_query_resources(hcapi_cfa_rm_data_t *data, +int client_id, +uint16_t chnl_id, +struct hcapi_cfa_resc_req_db *req_db); +int hcapi_cfa_rm_query_resources_one(hcapi_cfa_rm_data_t *data, +int clien_id, +struct hcapi_cfa_resc_db *resc_db); +int hcapi_cfa_rm_reserve_resources(hcapi_cfa_rm_data_t *data, + int client_id, + struct hcapi_cfa_resc_req_db *resc_req, + struct hcapi_cfa_resc_db *resc_db); +int hcapi_cfa_rm_release_resources(hcapi_cfa_rm_data_t *data, + int client_id, + struct hcapi_cfa_resc_req_db *resc_req, + struct hcapi_cfa_resc_db *resc_db); +int hcapi_cfa_rm_initialize(hcapi_cfa_rm_data_t *data); + +#if SUPPORT_CFA_HW_P4 + +int hcapi_cfa_p4_dev_hw_op(struct hcapi_cfa_hwop *op, uint16_t tbl_id, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_prof_l2ctxt_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_prof_l2ctxtrmp_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_prof_tcam_hwop(struct hcapi_cfa_hwop *op, +struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_prof_tcamrmp_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *obj_data); +int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op, +struct hcapi_cfa_data *mirror); +int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op, +uint32_t type, +struct hcapi_cfa_data *config); +/* SUPPORT_CFA_HW_P4 */ +#elif SUPPORT_CFA_HW_P45 +int hcapi_cfa_p45_mirror_hwop(struct hcapi_cfa_hwop *op, + struct hcapi_cfa_data *mirror); +int hcapi_cfa_p45_global_cfg_hwop(struct hcapi_cfa_hwop *op, + uint32_t type, +
[dpdk-dev] [PATCH 10/58] net/bnxt: add 64B SRAM record management with RM
From: Farah Smith HCAPI RM now manages 64B records instead of 8B. Truflow core RM will manage the same. The tf_tbl core APIs now return 8B pointer addresses. These can be used directly as SRAM pointers in Action Records. When communicating with the firmware 8B addresses will be used. Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_device.h | 29 - drivers/net/bnxt/tf_core/tf_device_p4.c | 2 + drivers/net/bnxt/tf_core/tf_device_p58.c | 71 ++ drivers/net/bnxt/tf_core/tf_device_p58.h | 24 ++-- drivers/net/bnxt/tf_core/tf_rm.h | 2 +- drivers/net/bnxt/tf_core/tf_tbl.c| 158 ++- 6 files changed, 267 insertions(+), 19 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index 2cbb42fe2a..a18d59660b 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -220,9 +220,36 @@ struct tf_dev_ops { */ int (*tf_dev_search_ident)(struct tf *tfp, struct tf_ident_search_parms *parms); + /** +* Get SRAM table information. +* +* Converts an internal RM allocated element offset to +* a user address and vice versa. +* +* [in] tfp +* Pointer to TF handle +* +* [in] type +* Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD +* +* [in/out] base +* Pointer to the base address of the associated table type. +* +* [in/out] shift +* Pointer to any shift required for the associated table type. +* +* Returns +* - (0) if successful. +* - (-EINVAL) on failure. +*/ + int (*tf_dev_get_tbl_info)(struct tf *tfp, + void *tbl_db, + enum tf_tbl_type type, + uint16_t *base, + uint16_t *shift); /** -* Allocation of a table type element. +* Allocation of an index table type element. * * This API allocates the specified table type element from a * device specific table type DB. The allocated element is diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index e5c9a0..8274978bfe 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -206,6 +206,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_alloc_ident = NULL, .tf_dev_free_ident = NULL, .tf_dev_search_ident = NULL, + .tf_dev_get_tbl_info = NULL, .tf_dev_alloc_ext_tbl = NULL, .tf_dev_alloc_tbl = NULL, .tf_dev_free_ext_tbl = NULL, @@ -246,6 +247,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_alloc_ident = tf_ident_alloc, .tf_dev_free_ident = tf_ident_free, .tf_dev_search_ident = tf_ident_search, + .tf_dev_get_tbl_info = NULL, .tf_dev_alloc_tbl = tf_tbl_alloc, .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc, .tf_dev_free_tbl = tf_tbl_free, diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index 65e283ed11..b61c58e41b 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -148,6 +148,75 @@ static int tf_dev_p58_word_align(uint16_t size) return size) + 63) >> 6) * 8); } + +#define TF_DEV_P58_BANK_SZ_64B 2048 +/** + * Get SRAM table information. + * + * Converts an internal RM allocated element offset to + * a user address and vice versa. + * + * [in] tfp + * Pointer to TF handle + * + * [in] type + * Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD + * + * [in/out] base + * Pointer to the Base address of the associated SRAM bank used for + * the type of record allocated. + * + * [in/out] shift + * Pointer to the factor to be used as a multiplier to translate + * between the RM units to the user address. SRAM manages 64B entries + * Addresses must be shifted to an 8B address. + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int tf_dev_p58_get_sram_tbl_info(struct tf *tfp __rte_unused, + void *db, + enum tf_tbl_type type, + uint16_t *base, + uint16_t *shift) +{ + uint16_t hcapi_type; + struct tf_rm_get_hcapi_parms parms; + int rc; + + parms.rm_db = db; + parms.subtype = type; + parms.hcapi_type = &hcapi_type; + + rc = tf_rm_get_hcapi_type(&parms); + if (rc) + return rc; + + switch (hcapi_type) { + case CFA_RESOURCE_TYPE_P58_SR
[dpdk-dev] [PATCH 14/58] net/bnxt: add shared session support
From: Jay Ding There are 2 types of sessions - shared and non-shared. For non-shared all the allocated resources are owned and managed by a single session instance. No other applications have access to the resources owned by the non-shared session. For a shared session, resources are shared between 2 applications. The FW shared session can only be created by one application and shared by other apps. The host session that creates the FW shared session is the creator. Applications can retrieve the reserved resources through a new API tf_get_session_resc_info. Each module supports two sessions, one is shared session, the other is non-shared session. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/hsi_struct_def_dpdk.h| 281 +- drivers/net/bnxt/tf_core/bitalloc.c | 10 +- drivers/net/bnxt/tf_core/bitalloc.h | 3 +- drivers/net/bnxt/tf_core/tf_core.c| 105 drivers/net/bnxt/tf_core/tf_core.h| 177 +- drivers/net/bnxt/tf_core/tf_device.c | 76 +++--- drivers/net/bnxt/tf_core/tf_device.h | 73 ++ drivers/net/bnxt/tf_core/tf_device_p4.c | 8 + drivers/net/bnxt/tf_core/tf_device_p58.c | 8 + drivers/net/bnxt/tf_core/tf_em.h | 17 ++ drivers/net/bnxt/tf_core/tf_em_common.c | 25 -- drivers/net/bnxt/tf_core/tf_em_internal.c | 118 + drivers/net/bnxt/tf_core/tf_identifier.c | 89 +++ drivers/net/bnxt/tf_core/tf_identifier.h | 16 ++ drivers/net/bnxt/tf_core/tf_msg.c | 223 ++--- drivers/net/bnxt/tf_core/tf_msg.h | 47 +++- drivers/net/bnxt/tf_core/tf_rm.c | 277 - drivers/net/bnxt/tf_core/tf_rm.h | 34 +++ drivers/net/bnxt/tf_core/tf_session.c | 37 ++- drivers/net/bnxt/tf_core/tf_session.h | 66 + drivers/net/bnxt/tf_core/tf_tbl.c | 104 drivers/net/bnxt/tf_core/tf_tbl.h | 17 ++ drivers/net/bnxt/tf_core/tf_tcam.c| 103 drivers/net/bnxt/tf_core/tf_tcam.h| 16 ++ drivers/net/bnxt/tf_core/tfp.c| 6 +- drivers/net/bnxt/tf_core/tfp.h| 3 +- 26 files changed, 1560 insertions(+), 379 deletions(-) diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index aea9305486..046acb8de2 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -699,6 +699,8 @@ struct cmd_nums { /* Experimental */ #define HWRM_TF_SESSION_RESC_FLUSHUINT32_C(0x2cf) /* Experimental */ + #define HWRM_TF_SESSION_RESC_INFO UINT32_C(0x2d0) + /* Experimental */ #define HWRM_TF_TBL_TYPE_GET UINT32_C(0x2da) /* Experimental */ #define HWRM_TF_TBL_TYPE_SET UINT32_C(0x2db) @@ -727,6 +729,8 @@ struct cmd_nums { /* Experimental */ #define HWRM_TF_EM_HASH_INSERTUINT32_C(0x2ec) /* Experimental */ + #define HWRM_TF_EM_MOVE UINT32_C(0x2ed) + /* Experimental */ #define HWRM_TF_TCAM_SET UINT32_C(0x2f8) /* Experimental */ #define HWRM_TF_TCAM_GET UINT32_C(0x2f9) @@ -986,8 +990,8 @@ struct hwrm_err_output { #define HWRM_VERSION_MINOR 10 #define HWRM_VERSION_UPDATE 2 /* non-zero means beta version */ -#define HWRM_VERSION_RSVD 15 -#define HWRM_VERSION_STR "1.10.2.15" +#define HWRM_VERSION_RSVD 22 +#define HWRM_VERSION_STR "1.10.2.22" / * hwrm_ver_get * @@ -11971,7 +11975,7 @@ struct hwrm_func_cfg_input { /* * Function ID of the function that is being * configured. -* If set to 0xFF... (All Fs), then the configuration is +* If set to 0xFF... (All Fs), then the the configuration is * for the requesting function. */ uint16_tfid; @@ -12671,7 +12675,7 @@ struct hwrm_func_cfg_input { /* * When this bit is '1', the caller requests to disable a MPC * channel with destination to the TX configurable flow processing -* block. When this bit is ‘0’, this flag has no effect. +* block block. When this bit is ‘0’, this flag has no effect. */ #define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_DISABLE \ UINT32_C(0x20) @@ -12685,7 +12689,7 @@ struct hwrm_func_cfg_input { /* * When this bit is '1', the caller requests to disable a MPC * channel with destination to the RX configurable flow processing -* block. When this bit is ‘0’, this flag has no effect. +* block block. When this bit is ‘0’, this flag has no effect. */ #define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_DISABLE \ UINT32_C(0x80) @@ -18041,7 +18045,7 @
[dpdk-dev] [PATCH 15/58] net/bnxt: add dpool allocator for EM allocation
From: Peter Spreadborough The dpool allocator supports variable size entries and also supports defragmentation of the allocation space. EM will by default use the fixed size stack allocator. The dynamic allocator may be selected at build time. The dpool allocator supports variable size entries and also supports defragmentation of the allocation space. Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/dpool.c | 373 ++ drivers/net/bnxt/tf_core/dpool.h | 309 +++ drivers/net/bnxt/tf_core/meson.build | 1 + drivers/net/bnxt/tf_core/tf_core.h| 42 ++ drivers/net/bnxt/tf_core/tf_device.h | 34 ++ drivers/net/bnxt/tf_core/tf_device_p58.c | 5 + drivers/net/bnxt/tf_core/tf_em.h | 26 ++ .../net/bnxt/tf_core/tf_em_hash_internal.c| 102 - drivers/net/bnxt/tf_core/tf_em_internal.c | 215 -- drivers/net/bnxt/tf_core/tf_msg.c | 69 drivers/net/bnxt/tf_core/tf_msg.h | 15 + drivers/net/bnxt/tf_core/tf_session.h | 5 + 12 files changed, 1156 insertions(+), 40 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/dpool.c create mode 100644 drivers/net/bnxt/tf_core/dpool.h diff --git a/drivers/net/bnxt/tf_core/dpool.c b/drivers/net/bnxt/tf_core/dpool.c new file mode 100644 index 00..a5f9f866b7 --- /dev/null +++ b/drivers/net/bnxt/tf_core/dpool.c @@ -0,0 +1,373 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2021 Broadcom + * All rights reserved. + */ +#include +#include +#include +#include +#include + +#include + +#include "tfp.h" +#include "dpool.h" + +int dpool_init(struct dpool *dpool, + uint32_t start_index, + uint32_t size, + uint8_t max_alloc_size, + void *user_data, + int (*move_callback)(void *, uint64_t, uint32_t)) +{ + uint32_t i; + int rc; + struct tfp_calloc_parms parms; + + parms.nitems = size; + parms.size = sizeof(struct dpool_entry); + parms.alignment = 0; + + rc = tfp_calloc(&parms); + + if (rc) + return rc; + + dpool->entry = parms.mem_va; + dpool->start_index = start_index; + dpool->size = size; + dpool->max_alloc_size = max_alloc_size; + dpool->user_data = user_data; + dpool->move_callback = move_callback; + /* +* Init entries +*/ + for (i = 0; i < size; i++) { + dpool->entry[i].flags = 0; + dpool->entry[i].index = start_index; + dpool->entry[i].entry_data = 0UL; + start_index++; + } + + return 0; +} + +static int dpool_move(struct dpool *dpool, + uint32_t dst_index, + uint32_t src_index) +{ + uint32_t size; + uint32_t i; + if (DP_IS_FREE(dpool->entry[dst_index].flags)) { + size = DP_FLAGS_SIZE(dpool->entry[src_index].flags); + + dpool->entry[dst_index].flags = dpool->entry[src_index].flags; + dpool->entry[dst_index].entry_data = dpool->entry[src_index].entry_data; + + if (dpool->move_callback != NULL) { + dpool->move_callback(dpool->user_data, +dpool->entry[src_index].entry_data, +dst_index + dpool->start_index); + } + + dpool->entry[src_index].flags = 0; + dpool->entry[src_index].entry_data = 0UL; + + for (i = 1; i < size; i++) { + dpool->entry[dst_index + i].flags = size; + dpool->entry[src_index + i].flags = 0; + } + } else { + return -1; + } + + return 0; +} + + +int dpool_defrag(struct dpool *dpool, +uint32_t entry_size, +uint8_t defrag) +{ + struct dpool_free_list *free_list; + struct dpool_adj_list *adj_list; + uint32_t count; + uint32_t index; + uint32_t used; + uint32_t i; + uint32_t size; + uint32_t largest_free_index = 0; + uint32_t largest_free_size; + uint32_t max; + uint32_t max_index; + uint32_t max_size = 0; + int rc; + + free_list = rte_zmalloc("dpool_free_list", + sizeof(struct dpool_free_list), 0); + if (free_list == NULL) { + TFP_DRV_LOG(ERR, "dpool free list allocation failed\n"); + return -ENOMEM; + } + + adj_list = rte_zmalloc("dpool_adjacent_list", + sizeof(struct dpool_adj_list), 0); + if (adj_list == NULL) { + TFP_DRV_LOG(ERR, "dpool adjacent list allocation failed\n"); + return -ENOMEM; + }
[dpdk-dev] [PATCH 17/58] net/bnxt: modify resource reservation strategy
From: Jay Ding Allow an application to only reserve resources for one direction. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Ajit Kumar Khaparde Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_core.c| 4 -- drivers/net/bnxt/tf_core/tf_em_common.c | 61 +++ drivers/net/bnxt/tf_core/tf_em_internal.c | 13 +++-- drivers/net/bnxt/tf_core/tf_identifier.c | 15 +++--- drivers/net/bnxt/tf_core/tf_tbl.c | 12 +++-- drivers/net/bnxt/tf_core/tf_tcam.c| 14 -- 6 files changed, 65 insertions(+), 54 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 945e54bfdd..de2a93646f 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -1636,7 +1636,6 @@ int tf_get_session_info(struct tf *tfp, TFP_DRV_LOG(ERR, "Ident get resc info failed, rc:%s\n", strerror(-rc)); - return rc; } if (dev->ops->tf_dev_get_tbl_resc_info == NULL) { @@ -1652,7 +1651,6 @@ int tf_get_session_info(struct tf *tfp, TFP_DRV_LOG(ERR, "Tbl get resc info failed, rc:%s\n", strerror(-rc)); - return rc; } if (dev->ops->tf_dev_get_tcam_resc_info == NULL) { @@ -1668,7 +1666,6 @@ int tf_get_session_info(struct tf *tfp, TFP_DRV_LOG(ERR, "TCAM get resc info failed, rc:%s\n", strerror(-rc)); - return rc; } if (dev->ops->tf_dev_get_em_resc_info == NULL) { @@ -1684,7 +1681,6 @@ int tf_get_session_info(struct tf *tfp, TFP_DRV_LOG(ERR, "EM get resc info failed, rc:%s\n", strerror(-rc)); - return rc; } return 0; diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index ed8f6db58c..812ccb0d29 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -301,6 +301,7 @@ tf_em_page_tbl_pgcnt(uint32_t num_pages, { return roundup(num_pages, MAX_PAGE_PTRS(page_size)) / MAX_PAGE_PTRS(page_size); + return 0; } /** @@ -722,10 +723,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev, if (!mask) return -EINVAL; -#ifdef TF_EEM_DEBUG - dump_raw((uint8_t *)parms->key, TF_P4_HW_EM_KEY_MAX_SIZE + 4, "In Key"); -#endif - if (dev->ops->tf_dev_cfa_key_hash == NULL) return -EINVAL; @@ -737,10 +734,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev, key0_index = key0_hash & mask; key1_index = key1_hash & mask; -#ifdef TF_EEM_DEBUG - TFP_DRV_LOG(DEBUG, "Key0 hash:0x%08x\n", key0_hash); - TFP_DRV_LOG(DEBUG, "Key1 hash:0x%08x\n", key1_hash); -#endif /* * Use the "result" arg to populate all of the key entry then * store the byte swapped "raw" entry in a local copy ready @@ -1010,35 +1003,41 @@ tf_em_ext_common_unbind(struct tf *tfp) } ext_db = (struct em_ext_db *)ext_ptr; - entry = ext_db->tbl_scope_ll.head; - while (entry != NULL) { - tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; - entry = entry->next; - tparms.tbl_scope_id = tbl_scope_cb->tbl_scope_id; - - if (dev->ops->tf_dev_free_tbl_scope) { - dev->ops->tf_dev_free_tbl_scope(tfp, &tparms); - } else { - /* should not reach here */ - ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry); - tfp_free(tbl_scope_cb); + if (ext_db != NULL) { + entry = ext_db->tbl_scope_ll.head; + while (entry != NULL) { + tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; + entry = entry->next; + tparms.tbl_scope_id = + tbl_scope_cb->tbl_scope_id; + + if (dev->ops->tf_dev_free_tbl_scope) { + dev->ops->tf_dev_free_tbl_scope(tfp, + &tparms); + } else { + /* should not reach here */ + ll_delete(&ext_db->tbl_scope_ll, + &tbl_scope_cb->ll_entry); + tfp_free(tbl_scope_cb); + } } - } - for (i = 0; i < TF_DIR_MAX; i++) { - if (ext_db->eem_db[i] == NULL) - continue; + for (i = 0; i < TF_DIR_MAX; i++) { + if (ext_db->eem_db
[dpdk-dev] [PATCH 16/58] net/bnxt: update shared session functionality
From: Jay Ding - Distinguish the shared session on host side using PCI address - One session could be shared by multiple interfaces. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_core.c| 9 --- drivers/net/bnxt/tf_core/tf_core.h| 4 ++ drivers/net/bnxt/tf_core/tf_device.c | 28 + drivers/net/bnxt/tf_core/tf_device_p58.c | 7 ++- drivers/net/bnxt/tf_core/tf_em_internal.c | 23 drivers/net/bnxt/tf_core/tf_identifier.c | 15 ++--- drivers/net/bnxt/tf_core/tf_msg.c | 69 +-- drivers/net/bnxt/tf_core/tf_session.c | 13 - drivers/net/bnxt/tf_core/tf_session.h | 9 +-- drivers/net/bnxt/tf_core/tf_tbl.c | 57 --- drivers/net/bnxt/tf_core/tf_tcam.c| 15 ++--- drivers/net/bnxt/tf_core/tfp.c| 4 +- 12 files changed, 153 insertions(+), 100 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 69f5c10293..945e54bfdd 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -27,8 +27,6 @@ tf_open_session(struct tf *tfp, int rc; unsigned int domain, bus, slot, device; struct tf_session_open_session_parms oparms; - int name_len; - char *name; TF_CHECK_PARMS2(tfp, parms); @@ -71,13 +69,6 @@ tf_open_session(struct tf *tfp, } } - name_len = strlen(parms->ctrl_chan_name); - name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")]; - if (!strncmp(name, "tf_shared", strlen("tf_shared"))) { - memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name)); - strcpy(parms->ctrl_chan_name, "tf_share"); - } - parms->session_id.internal.domain = domain; parms->session_id.internal.bus = bus; parms->session_id.internal.device = device; diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 08a083077c..3d14dc5391 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -458,6 +458,10 @@ struct tf_session_info { */ struct tf { struct tf_session_info *session; + /** +* the pointer to the parent bp struct +*/ + void *bp; }; /** diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index fed4156200..97ae73fa5a 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -44,7 +44,11 @@ tf_dev_reservation_check(uint16_t count, rm_num = (uint16_t *)reservations + i * count; for (j = 0; j < count; j++) { if ((cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI || -cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) && +cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA || +cfg[j].cfg_type == + TF_RM_ELEM_CFG_HCAPI_BA_PARENT || +cfg[j].cfg_type == + TF_RM_ELEM_CFG_HCAPI_BA_CHILD) && rm_num[j] > 0) cnt++; } @@ -263,49 +267,49 @@ tf_dev_unbind_p4(struct tf *tfp) */ rc = tf_tcam_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, TCAM\n"); fail = true; } rc = tf_ident_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Identifier\n"); fail = true; } rc = tf_tbl_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Table Type\n"); fail = true; } rc = tf_em_ext_common_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, EEM\n"); fail = true; } rc = tf_em_int_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, EM\n"); fail = true; } rc = tf_if_tbl_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, IF Table Type\n"); fail = true; } rc = tf_global_cfg_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Global Cfg Type\n"); fail = true;
[dpdk-dev] [PATCH 19/58] net/bnxt: cleanup session open/close messages
From: Farah Smith Add profile_id to set_prof_tcam. Signed-off-by: Farah Smith Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher Reviewed-by: Peter Spreadborough --- drivers/net/bnxt/tf_core/tf_device.c | 90 --- drivers/net/bnxt/tf_core/tf_em_internal.c | 13 +--- drivers/net/bnxt/tf_core/tf_identifier.c | 15 +--- drivers/net/bnxt/tf_core/tf_if_tbl.c | 18 + drivers/net/bnxt/tf_core/tf_session.c | 18 +++-- drivers/net/bnxt/tf_core/tf_tbl.c | 18 ++--- drivers/net/bnxt/tf_core/tf_tcam.c| 12 +-- 7 files changed, 77 insertions(+), 107 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 55cf55886a..498e668b16 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -216,20 +216,20 @@ tf_dev_bind_p4(struct tf *tfp, return -ENOMEM; } - if (!tf_session_is_shared_session(tfs)) { - /* -* IF_TBL -*/ - if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; - if_tbl_cfg.cfg = tf_if_tbl_p4; - if_tbl_cfg.shadow_copy = shadow_copy; - rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "IF Table initialization failure\n"); - goto fail; - } + /* +* IF_TBL +*/ + if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; + if_tbl_cfg.cfg = tf_if_tbl_p4; + if_tbl_cfg.shadow_copy = shadow_copy; + rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "IF Table initialization failure\n"); + goto fail; + } + if (!tf_session_is_shared_session(tfs)) { /* * GLOBAL_CFG */ @@ -271,6 +271,12 @@ tf_dev_unbind_p4(struct tf *tfp) { int rc = 0; bool fail = false; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; /* Unbind all the support modules. As this is only done on * close we only report errors as everything has to be cleaned @@ -318,18 +324,20 @@ tf_dev_unbind_p4(struct tf *tfp) fail = true; } - rc = tf_if_tbl_unbind(tfp); - if (rc) { - TFP_DRV_LOG(INFO, - "Device unbind failed, IF Table Type\n"); - fail = true; - } + if (!tf_session_is_shared_session(tfs)) { + rc = tf_if_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(INFO, + "Device unbind failed, IF Table Type\n"); + fail = true; + } - rc = tf_global_cfg_unbind(tfp); - if (rc) { - TFP_DRV_LOG(INFO, - "Device unbind failed, Global Cfg Type\n"); - fail = true; + rc = tf_global_cfg_unbind(tfp); + if (rc) { + TFP_DRV_LOG(INFO, + "Device unbind failed, Global Cfg Type\n"); + fail = true; + } } if (fail) @@ -472,17 +480,17 @@ tf_dev_bind_p58(struct tf *tfp, /* * IF_TBL */ - if (!tf_session_is_shared_session(tfs)) { - if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; - if_tbl_cfg.cfg = tf_if_tbl_p58; - if_tbl_cfg.shadow_copy = shadow_copy; - rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "IF Table initialization failure\n"); - goto fail; - } + if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; + if_tbl_cfg.cfg = tf_if_tbl_p58; + if_tbl_cfg.shadow_copy = shadow_copy; + rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "IF Table initialization failure\n"); + goto fail; + } + if (!tf_session_is_shared_session(tfs)) { /* * GLOBAL_CFG */ @@ -571,14 +579,14 @@ tf_dev_unbind_p58(struct tf *tfp) fail = true; } - if (!tf_session_is_shared_session(tfs)) { - rc = tf_if_tbl_unbind(tfp); - if (rc) { - TFP_DRV_LOG(ERR, - "Device unbind failed, IF Table Type\n"); - fail = true; - } + rc = tf_if_tbl_unbind(tfp); + if (rc) { + TFP_DRV_L
[dpdk-dev] [PATCH 21/58] net/bnxt: add API to get shared table increments
From: Farah Smith Provide tf API to get the shared table increment value for a given TF table type. Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_core.c| 52 +++ drivers/net/bnxt/tf_core/tf_core.h| 34 ++- drivers/net/bnxt/tf_core/tf_device.h | 17 drivers/net/bnxt/tf_core/tf_device_p4.c | 25 +++ drivers/net/bnxt/tf_core/tf_device_p58.c | 44 +++ drivers/net/bnxt/tf_core/tf_tcam_shared.c | 22 +++--- 6 files changed, 188 insertions(+), 6 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 73dbee2940..0fbbd40252 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -1415,6 +1415,58 @@ tf_bulk_get_tbl_entry(struct tf *tfp, return rc; } +int tf_get_shared_tbl_increment(struct tf *tfp, + struct tf_get_shared_tbl_increment_parms *parms) +{ + int rc = 0; + struct tf_session *tfs; + struct tf_dev_info *dev; + + TF_CHECK_PARMS2(tfp, parms); + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup device, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Internal table type processing */ + + if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Get table increment not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + return rc; +} + int tf_alloc_tbl_scope(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms) diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 95cde2e8eb..44c30fa904 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -848,7 +848,6 @@ struct tf_get_session_info_parms { */ int tf_get_session_info(struct tf *tfp, struct tf_get_session_info_parms *parms); - /** * Experimental * @@ -1594,6 +1593,8 @@ int tf_move_tcam_shared_entries(struct tf *tfp, * @ref tf_get_tbl_entry * * @ref tf_bulk_get_tbl_entry + * + * @ref tf_get_shared_tbl_increment */ /** @@ -1844,6 +1845,37 @@ struct tf_set_tbl_entry_parms { int tf_set_tbl_entry(struct tf *tfp, struct tf_set_tbl_entry_parms *parms); +/** + * tf_get_shared_tbl_increment parameter definition + */ +struct tf_get_shared_tbl_increment_parms { + /** +* [in] Receive or transmit direction +*/ + enum tf_dir dir; + /** +* [in] Type of object to set +*/ + enum tf_tbl_type type; + /** +* [out] Value to increment by for resource type +*/ + uint32_t increment_cnt; +}; + +/** + * tf_get_shared_tbl_increment + * + * This API is currently only required for use in the shared + * session for Thor (p58) actions. An increment count is returned per + * type to indicate how much to increment the start by for each + * entry (see tf_resource_info) + * + * Returns success or failure code. + */ +int tf_get_shared_tbl_increment(struct tf *tfp, + struct tf_get_shared_tbl_increment_parms *parms); + /** * tf_get_tbl_entry parameter definition */ diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index 48ab17d56b..1893f630e7 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -446,6 +446,23 @@ struct tf_dev_ops { int (*tf_dev_get_bulk_tbl)(struct tf *tfp, struct tf_tbl_get_bulk_parms *parms); + /** +* Gets the increment value to add to the shared session resource +* start offset by for each count in the "stride" +* +* [in] tfp +* Pointer to TF ha
[dpdk-dev] [PATCH 23/58] net/bnxt: cleanup of WC TCAM shared unbind
From: Farah Smith - clean up all allocated hi or lo pool tcam regions on close - message cleanup - remove unsupported multi-slice - find next free entry should start from 0 first time - update reserved resources so cli open session can come up Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_tcam_shared.c | 333 -- 1 file changed, 179 insertions(+), 154 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c index 5139b28537..b96d9ca9dd 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c +++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c @@ -19,8 +19,6 @@ #include "tf_core.h" #include "tf_rm.h" -struct tf; - /** Shared WC TCAM pool identifiers */ enum tf_tcam_shared_wc_pool_id { @@ -288,6 +286,12 @@ tf_tcam_shared_bind(struct tf *tfp, if (rc) return rc; + if (num_slices > 1) { + TFP_DRV_LOG(ERR, + "Only single slice supported\n"); + return -EOPNOTSUPP; + } + tf_tcam_shared_create_db(&tcam_shared_wc); @@ -338,49 +342,135 @@ int tf_tcam_shared_unbind(struct tf *tfp) { int rc, dir; + struct tf_dev_info *dev; struct tf_session *tfs; void *tcam_shared_db_ptr = NULL; struct tf_tcam_shared_wc_pools *tcam_shared_wc; + enum tf_tcam_shared_wc_pool_id pool_id; + struct tf_tcam_free_parms parms; + struct bitalloc *pool; + uint16_t start; + int log_idx, phy_idx; + uint16_t hcapi_type; + struct tf_rm_alloc_info info; + int i, pool_cnt; TF_CHECK_PARMS1(tfp); - /* Perform normal unbind, this will write all the -* allocated TCAM entries in the shared session. -*/ - rc = tf_tcam_unbind(tfp); - if (rc) - return rc; - /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) return rc; - rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr); + /* If not the shared session, call the normal +* tcam unbind and exit +*/ + if (!tf_session_is_shared_session(tfs)) { + rc = tf_tcam_unbind(tfp); + return rc; + } + + /* We must be a shared session, get the database +*/ + rc = tf_session_get_tcam_shared_db(tfp, + (void *)&tcam_shared_db_ptr); if (rc) { TFP_DRV_LOG(ERR, - "Failed to get tcam_shared_db from session, rc:%s\n", + "Failed to get tcam_shared_db, rc:%s\n", strerror(-rc)); return rc; } - tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr; - /* If we are the shared session + tcam_shared_wc = + (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr; + + + /* Get the device */ - if (tf_session_is_shared_session(tfs)) { - /* If there are WC TCAM entries allocated, free them + rc = tf_session_get_device(tfs, &dev); + if (rc) + return rc; + + + /* If there are WC TCAM entries allocated, free them +*/ + for (dir = 0; dir < TF_DIR_MAX; dir++) { + /* If the database is invalid, skip */ - for (dir = 0; dir < TF_DIR_MAX; dir++) { - tf_tcam_shared_free_wc_pool(dir, - TF_TCAM_SHARED_WC_POOL_HI, - tcam_shared_wc); + if (!tf_tcam_db_valid(tfp, dir)) + continue; + + rc = tf_tcam_shared_get_rm_info(tfp, + dir, + &hcapi_type, + &info); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: TCAM shared rm info get failed\n", + tf_dir_2_str(dir)); + return rc; + } + + for (pool_id = TF_TCAM_SHARED_WC_POOL_HI; +pool_id < TF_TCAM_SHARED_WC_POOL_MAX; +pool_id++) { + pool = tcam_shared_wc->db[dir][pool_id].pool; + start = tcam_shared_wc->db[dir][pool_id].info.start; + pool_cnt = ba_inuse_count(pool); + + if (pool_cnt) { + TFP_DRV_LOG(INFO, + "%s: %s: %d residuals found, freeing\n", +
[dpdk-dev] [PATCH 20/58] net/bnxt: add WC TCAM hi/lo move support
From: Farah Smith - Add new API to move wc tcam regions from the hi pool to the low pool. - Enable shared tcam get/set functions on Thor. Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_core.c| 53 +++ drivers/net/bnxt/tf_core/tf_core.h| 39 ++ drivers/net/bnxt/tf_core/tf_device.h | 18 + drivers/net/bnxt/tf_core/tf_device_p4.c | 1 + drivers/net/bnxt/tf_core/tf_device_p58.c | 5 +- drivers/net/bnxt/tf_core/tf_session.c | 41 ++ drivers/net/bnxt/tf_core/tf_session.h | 48 +++ drivers/net/bnxt/tf_core/tf_tcam.c| 2 +- drivers/net/bnxt/tf_core/tf_tcam_shared.c | 468 -- drivers/net/bnxt/tf_core/tf_tcam_shared.h | 35 ++ 10 files changed, 673 insertions(+), 37 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index de2a93646f..73dbee2940 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -917,6 +917,59 @@ tf_free_tcam_entry(struct tf *tfp, return 0; } +#ifdef TF_TCAM_SHARED +int +tf_move_tcam_shared_entries(struct tf *tfp, + struct tf_move_tcam_shared_entries_parms *parms) +{ + int rc; + struct tf_session *tfs; + struct tf_dev_info *dev; + + TF_CHECK_PARMS2(tfp, parms); + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup device, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + if (dev->ops->tf_dev_move_tcam == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + rc = dev->ops->tf_dev_move_tcam(tfp, parms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: TCAM shared entries move failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + return 0; +} +#endif /* TF_TCAM_SHARED */ + int tf_alloc_tbl_entry(struct tf *tfp, struct tf_alloc_tbl_entry_parms *parms) diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 39a498122b..95cde2e8eb 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -1242,6 +1242,10 @@ int tf_free_tbl_scope(struct tf *tfp, * @ref tf_get_tcam_entry * * @ref tf_free_tcam_entry + * +#ifdef TF_TCAM_SHARED + * @ref tf_move_tcam_shared_entries +#endif */ /** @@ -1543,6 +1547,41 @@ struct tf_free_tcam_entry_parms { int tf_free_tcam_entry(struct tf *tfp, struct tf_free_tcam_entry_parms *parms); +#ifdef TF_TCAM_SHARED +/** + * tf_move_tcam_shared_entries parameter definition + */ +struct tf_move_tcam_shared_entries_parms { + /** +* [in] receive or transmit direction +*/ + enum tf_dir dir; + /** +* [in] TCAM table type +*/ + enum tf_tcam_tbl_type tcam_tbl_type; +}; + +/** + * Move TCAM entries + * + * This API only affects the following TCAM pools within a shared session: + * + * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH + * TF_TCAM_TBL_TYPE_WC_TCAM_LOW + * + * When called, all allocated entries from the high pool will be moved to + * the low pool. Then the allocated entries in the high pool will be + * cleared and freed. + * + * This API is not supported on a non-shared session. + * + * Returns success or failure code. + */ +int tf_move_tcam_shared_entries(struct tf *tfp, + struct tf_move_tcam_shared_entries_parms *parms); + +#endif /* TF_TCAM_SHARED */ /** * @page table Table Access * diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index ea4dcfb8e2..48ab17d56b 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -563,6 +563,24 @@ struct tf_dev_ops { int (*tf_dev_get_tcam)(struct tf *tfp, struct tf_tcam_get_parms *parms); +#ifdef TF_TCAM_SHARED + /** +* Move TCAM shared entries +* +* [in] tfp +* Pointer to TF handle +* +* [in
[dpdk-dev] [PATCH 18/58] net/bnxt: shared TCAM region support
From: Farah Smith - switch to single slice management on Wh+ - Support of shared session WC_TCAM_HIGH and WC_TCAM_LOW regions - Enable/disable using TF_TCAM_SHARED flag in tf_core.h - Fix empty session module DBs in the case that none are allocated for a given module type Signed-off-by: Farah Smith Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/meson.build | 25 +- drivers/net/bnxt/tf_core/tf_core.h| 45 +- drivers/net/bnxt/tf_core/tf_device.c | 72 ++- drivers/net/bnxt/tf_core/tf_device.h | 4 +- drivers/net/bnxt/tf_core/tf_device_p4.c | 17 +- drivers/net/bnxt/tf_core/tf_device_p58.c | 13 +- drivers/net/bnxt/tf_core/tf_identifier.c | 2 +- drivers/net/bnxt/tf_core/tf_tbl.c | 5 +- drivers/net/bnxt/tf_core/tf_tcam.c| 5 +- drivers/net/bnxt/tf_core/tf_tcam_shared.c | 744 ++ drivers/net/bnxt/tf_core/tf_tcam_shared.h | 127 drivers/net/bnxt/tf_core/tf_util.c| 6 + 12 files changed, 1014 insertions(+), 51 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.c create mode 100644 drivers/net/bnxt/tf_core/tf_tcam_shared.h diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build index 3a91f04bc0..f28e77ec2e 100644 --- a/drivers/net/bnxt/tf_core/meson.build +++ b/drivers/net/bnxt/tf_core/meson.build @@ -10,26 +10,27 @@ sources += files( 'tf_core.c', 'bitalloc.c', 'tf_msg.c', - 'dpool.c', +'ll.c', +'dpool.c', 'rand.c', 'stack.c', -'tf_em_common.c', -'tf_em_internal.c', 'tf_rm.c', 'tf_tbl.c', +'tf_em_common.c', +'tf_em_host.c', +'tf_em_internal.c', +'tf_em_hash_internal.c', 'tfp.c', -'tf_session.c', +'tf_util.c', 'tf_device.c', 'tf_device_p4.c', -'tf_device_p58.c', +'tf_global_cfg.c', 'tf_identifier.c', +'tf_if_tbl.c', +'tf_session.c', 'tf_shadow_tcam.c', 'tf_tcam.c', -'tf_util.c', -'tf_if_tbl.c', -'ll.c', -'tf_global_cfg.c', -'tf_em_host.c', -'tf_em_hash_internal.c', +'tf_tcam_shared.c', 'tf_shadow_identifier.c', -'tf_hash.c') +'tf_hash.c', +'tf_device_p58.c') diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 3d14dc5391..39a498122b 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -21,7 +21,6 @@ /** BEGIN Truflow Core DEFINITIONS **/ - #define TF_KILOBYTE 1024 #define TF_MEGABYTE (1024 * 1024) @@ -77,7 +76,6 @@ enum tf_ext_mem_chan_type { #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4) #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4) - /* * Helper Macros */ @@ -198,7 +196,6 @@ enum tf_module_type { TF_MODULE_TYPE_MAX }; - /** * Identifier resource types */ @@ -317,6 +314,41 @@ enum tf_tbl_type { TF_TBL_TYPE_MAX }; +/** Enable Shared TCAM Management + * + * This feature allows for management of high and low pools within + * the WC TCAM. These pools are only valid when this feature is enabled. + * + * For normal OVS-DPDK operation, this feature is not required and can + * be disabled by commenting out TF_TCAM_SHARED in this header file. + * + * Operation: + * + * When a shared session is created with WC TCAM entries allocated during + * tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided + * into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and + * TF_TCAM_TBL_TYPE_WC_TCAM_LOW. + * + * The user will allocate and free entries from either of these pools to obtain + * WC_TCAM entry offsets. For the WC_TCAM_HI/LO management, alloc/free is done + * using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared + * session. + * + * The use case for this feature is so that applications can have a shared + * session and use the TF core to allocate/set/free entries within a given + * region of the WC_TCAM within the shared session. Application A only writes + * to the LOW region for example and Application B only writes to the HIGH + * region during normal operation. After Application A goes down, Application + * B may decide to overwrite the LOW region with the HIGH region's entries + * and switch to the low region. + * + * For other TCAM types in the shared session, no alloc/free operations are + * permitted. Only set should be used for other TCAM table types after getting + * the range as provided by the tf_get_resource_info() API. + * + */ +#define TF_TCAM_SHARED 1 + /** * TCAM table type */ @@ -335,6 +367,12 @@ enum tf_tcam_tbl_type { TF_TCAM_TBL_TYPE_CT_RULE_TCAM, /** Virtual Edge Br
[dpdk-dev] [PATCH 26/58] net/bnxt: check FW capability to support TRUFLOW
Currently, a devarg (host-based-truflow) is passed while launching the app to enable truflow feature. However, this mechanism doesn't give a seamless experience when flow offloads has to work with firmware that doesn't/does support truflow feature. Also, it's likely that customers may not want to use devarg to enable flow offloads. This patch fixes it by checking for truflow feature support in device's capabilities and configurations field of the hwrm_ver_get's response. Signed-off-by: Venkat Duvvuru Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Somnath Kotur --- doc/guides/nics/bnxt.rst | 3 +- drivers/net/bnxt/bnxt.h| 10 +++--- drivers/net/bnxt/bnxt_ethdev.c | 56 -- drivers/net/bnxt/bnxt_hwrm.c | 7 - 4 files changed, 12 insertions(+), 64 deletions(-) diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst index 0fb2032447..fef8a7fac9 100644 --- a/doc/guides/nics/bnxt.rst +++ b/doc/guides/nics/bnxt.rst @@ -658,8 +658,7 @@ which currently supports basic packet classification in the receive path. The feature uses a newly implemented control-plane firmware interface which optimizes flow insertions and deletions. -This is a tech preview feature, and is disabled by default. It can be enabled -using bnxt devargs. For ex: "-a :0d:00.0,host-based-truflow=1”. +This is a tech preview feature. This feature is currently supported on Whitney+ and Stingray devices. diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index db67bff127..882f577848 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -645,10 +645,9 @@ struct bnxt { #define BNXT_FLAG_RX_VECTOR_PKT_MODE BIT(24) #define BNXT_FLAG_FLOW_XSTATS_EN BIT(25) #define BNXT_FLAG_DFLT_MAC_SET BIT(26) -#define BNXT_FLAG_TRUFLOW_EN BIT(27) -#define BNXT_FLAG_GFID_ENABLE BIT(28) -#define BNXT_FLAG_RFS_NEEDS_VNIC BIT(29) -#define BNXT_FLAG_FLOW_CFA_RFS_RING_TBL_IDX_V2 BIT(30) +#define BNXT_FLAG_GFID_ENABLE BIT(27) +#define BNXT_FLAG_RFS_NEEDS_VNIC BIT(28) +#define BNXT_FLAG_FLOW_CFA_RFS_RING_TBL_IDX_V2 BIT(29) #define BNXT_RFS_NEEDS_VNIC(bp)((bp)->flags & BNXT_FLAG_RFS_NEEDS_VNIC) #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF) @@ -664,7 +663,6 @@ struct bnxt { #define BNXT_HAS_RING_GRPS(bp) (!BNXT_CHIP_P5(bp)) #define BNXT_FLOW_XSTATS_EN(bp)((bp)->flags & BNXT_FLAG_FLOW_XSTATS_EN) #define BNXT_HAS_DFLT_MAC_SET(bp) ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET) -#define BNXT_TRUFLOW_EN(bp)((bp)->flags & BNXT_FLAG_TRUFLOW_EN) #define BNXT_GFID_ENABLED(bp) ((bp)->flags & BNXT_FLAG_GFID_ENABLE) uint32_tflags2; @@ -686,6 +684,8 @@ struct bnxt { #define BNXT_FW_CAP_ADV_FLOW_MGMT BIT(5) #define BNXT_FW_CAP_ADV_FLOW_COUNTERS BIT(6) #define BNXT_FW_CAP_LINK_ADMIN BIT(7) +#define BNXT_FW_CAP_TRUFLOW_EN BIT(8) +#define BNXT_TRUFLOW_EN(bp)((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN) pthread_mutex_t flow_lock; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3778e28cca..a0e0ba5884 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -87,7 +87,6 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -#define BNXT_DEVARG_TRUFLOW"host-based-truflow" #define BNXT_DEVARG_FLOW_XSTAT "flow-xstat" #define BNXT_DEVARG_MAX_NUM_KFLOWS "max-num-kflows" #define BNXT_DEVARG_REPRESENTOR"representor" @@ -100,7 +99,6 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { static const char *const bnxt_dev_args[] = { BNXT_DEVARG_REPRESENTOR, - BNXT_DEVARG_TRUFLOW, BNXT_DEVARG_FLOW_XSTAT, BNXT_DEVARG_MAX_NUM_KFLOWS, BNXT_DEVARG_REP_BASED_PF, @@ -112,12 +110,6 @@ static const char *const bnxt_dev_args[] = { NULL }; -/* - * truflow == false to disable the feature - * truflow == true to enable the feature - */ -#defineBNXT_DEVARG_TRUFLOW_INVALID(truflow)((truflow) > 1) - /* * flow_xstat == false to disable the feature * flow_xstat == true to enable the feature @@ -5182,45 +5174,6 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) return 0; } -static int -bnxt_parse_devarg_truflow(__rte_unused const char *key, - const char *value, void *opaque_arg) -{ - struct bnxt *bp = opaque_arg; - unsigned long truflow; - char *end = NULL; - - if (!value || !opaque_arg) { - PMD_DRV_LOG(ERR, - "Invalid parameter passed to truflow devargs.\n"); - return -EINVAL; - } - - truflow = strtoul(value, &end, 10); - if (end == NULL || *end != '\0' || - (truflow ==
[dpdk-dev] [PATCH 28/58] net/bnxt: add support for mapper flow database opcodes
From: Kishore Padmanabha Added support for mapper flow database opcode to enable shared resources like mirror action. This allows mapper to conditionally populate flow database based on template content. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 119 -- .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 8 ++ drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 4 + 3 files changed, 95 insertions(+), 36 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 2bb8d08699..4e9211a7ab 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -469,6 +469,80 @@ ulp_mapper_child_flow_free(struct bnxt_ulp_context *ulp, return 0; } +/* + * Process the flow database opcode action. + * returns 0 on success. + */ +static int32_t +ulp_mapper_fdb_opc_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_tbl_info *tbl, + struct ulp_flow_db_res_params *fid_parms) +{ + uint32_t push_fid, fid = 0; + uint64_t val64; + int32_t rc = 0; + + switch (tbl->fdb_opcode) { + case BNXT_ULP_FDB_OPC_PUSH: + push_fid = parms->fid; + break; + case BNXT_ULP_FDB_OPC_ALLOC_PUSH_REGFILE: + /* allocate a new fid */ + rc = ulp_flow_db_fid_alloc(parms->ulp_ctx, + BNXT_ULP_FDB_TYPE_REGULAR, + tbl->resource_func, &fid); + if (rc) { + BNXT_TF_DBG(ERR, + "Unable to allocate flow table entry\n"); + return rc; + } + /* Store the allocated fid in regfile*/ + val64 = fid; + rc = ulp_regfile_write(parms->regfile, tbl->flow_db_operand, + val64); + if (!rc) { + BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n", + tbl->flow_db_operand); + rc = -EINVAL; + goto error; + } + /* Use the allocated fid to update the flow resource */ + push_fid = fid; + break; + case BNXT_ULP_FDB_OPC_PUSH_REGFILE: + /* get the fid from the regfile */ + rc = ulp_regfile_read(parms->regfile, tbl->flow_db_operand, + &val64); + if (!rc) { + BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", + tbl->flow_db_operand); + return -EINVAL; + } + /* Use the extracted fid to update the flow resource */ + push_fid = (uint32_t)val64; + break; + default: + return rc; /* Nothing to be done */ + } + + /* Add the resource to the flow database */ + rc = ulp_flow_db_resource_add(parms->ulp_ctx, parms->flow_type, + push_fid, fid_parms); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add res to flow %x rc = %d\n", + push_fid, rc); + goto error; + } + return rc; + +error: + /* free the allocated fid */ + if (fid) + ulp_flow_db_fid_free(parms->ulp_ctx, +BNXT_ULP_FDB_TYPE_REGULAR, fid); + return rc; +} + /* * Process the identifier instruction and either store it in the flow database * or return it in the val (if not NULL) on success. If val is NULL, the @@ -524,10 +598,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_hndl = iparms.id; fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO; - rc = ulp_flow_db_resource_add(parms->ulp_ctx, - parms->flow_type, - parms->fid, - &fid_parms); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) { BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n", rc); @@ -618,10 +689,7 @@ ulp_mapper_ident_extract(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_type = ident->ident_type; fid_parms.resource_hndl = sparms.search_id; fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO; - rc = ulp_flow_db_resource_add(parms->ulp_ctx, - parms->flow_type, - parms->fid, - &fid_parms); + r
[dpdk-dev] [PATCH 22/58] net/bnxt: modify host session failure cleanup
From: Jay Ding - Close fw session if session open fails after fw session open. - Additional WC TCAM debug info to help in future debug - Reduce key/mask buffer sizes for performance - When a 64b counter is freed, clear the entry Signed-off-by: Jay Ding Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_em_internal.c | 15 +++--- drivers/net/bnxt/tf_core/tf_identifier.c | 14 -- drivers/net/bnxt/tf_core/tf_msg.c | 24 ++--- drivers/net/bnxt/tf_core/tf_msg.h | 9 +++- drivers/net/bnxt/tf_core/tf_rm.c | 59 +++ drivers/net/bnxt/tf_core/tf_session.c | 32 ++-- drivers/net/bnxt/tf_core/tf_tbl.c | 51 ++-- drivers/net/bnxt/tf_core/tf_tcam.c| 14 -- drivers/net/bnxt/tf_core/tf_tcam_shared.c | 41 9 files changed, 138 insertions(+), 121 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c index 28ffbd5876..0720bb905d 100644 --- a/drivers/net/bnxt/tf_core/tf_em_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_internal.c @@ -543,18 +543,21 @@ tf_em_get_resc_info(struct tf *tfp, TF_CHECK_PARMS2(tfp, em); rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr); - if (rc) { - TFP_DRV_LOG(INFO, - "No resource allocated for em from session\n"); - return 0; - } + if (rc == -ENOMEM) + return 0; /* db does not exist */ + else if (rc) + return rc; /* db error */ + em_db = (struct em_rm_db *)em_db_ptr; - /* check if reserved resource for WC is multiple of num_slices */ + /* check if reserved resource for EM is multiple of num_slices */ for (d = 0; d < TF_DIR_MAX; d++) { ainfo.rm_db = em_db->em_db[d]; dinfo = em[d].info; + if (!ainfo.rm_db) + continue; + ainfo.info = (struct tf_rm_alloc_info *)dinfo; ainfo.subtype = 0; rc = tf_rm_get_all_info(&ainfo, TF_EM_TBL_TYPE_MAX); diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c index 9f27a41fcf..c491f77a2b 100644 --- a/drivers/net/bnxt/tf_core/tf_identifier.c +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -369,16 +369,20 @@ tf_ident_get_resc_info(struct tf *tfp, TF_CHECK_PARMS2(tfp, ident); rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); - if (rc) { - TFP_DRV_LOG(INFO, - "No resource allocated for ident from session\n"); - return 0; - } + if (rc == -ENOMEM) + return 0; /* db doesn't exist */ + else if (rc) + return rc; /* error getting db */ + ident_db = (struct ident_rm_db *)ident_db_ptr; /* check if reserved resource for WC is multiple of num_slices */ for (d = 0; d < TF_DIR_MAX; d++) { ainfo.rm_db = ident_db->ident_db[d]; + + if (!ainfo.rm_db) + continue; + dinfo = ident[d].info; ainfo.info = (struct tf_rm_alloc_info *)dinfo; diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 18eea8338a..fbd4b1d910 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -267,31 +267,13 @@ tf_msg_session_client_unregister(struct tf *tfp, int tf_msg_session_close(struct tf *tfp, -struct tf_session *tfs) +uint8_t fw_session_id, +int mailbox) { int rc; struct hwrm_tf_session_close_input req = { 0 }; struct hwrm_tf_session_close_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; - uint8_t fw_session_id; - struct tf_dev_info *dev; - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - - rc = tf_session_get_fw_session_id(tfp, &fw_session_id); - if (rc) { - TFP_DRV_LOG(ERR, - "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); - return rc; - } /* Populate the request */ req.fw_session_id = tfp_cpu_to_le_32(fw_session_id); @@ -301,7 +283,7 @@ tf_msg_session_close(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); + parms.mailbox = mailbox; rc = tfp_send_msg_d
[dpdk-dev] [PATCH 25/58] net/bnxt: add API to clear hi/lo WC region
From: Farah Smith Provide TRUFLOW API to clear either the hi or the low region for ungraceful exit cleanup. Signed-off-by: Farah Smith Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Jay Ding Reviewed-by: Peter Spreadborough --- drivers/net/bnxt/tf_core/tf_core.c| 51 ++ drivers/net/bnxt/tf_core/tf_core.h| 39 +++- drivers/net/bnxt/tf_core/tf_device.h | 19 +++- drivers/net/bnxt/tf_core/tf_device_p4.c | 4 +- drivers/net/bnxt/tf_core/tf_device_p58.c | 1 + drivers/net/bnxt/tf_core/tf_tcam_shared.c | 111 +- drivers/net/bnxt/tf_core/tf_tcam_shared.h | 21 drivers/net/bnxt/tf_core/tf_util.h| 1 - 8 files changed, 235 insertions(+), 12 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 0fbbd40252..97e6165e92 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -968,6 +968,57 @@ tf_move_tcam_shared_entries(struct tf *tfp, return 0; } + +int +tf_clear_tcam_shared_entries(struct tf *tfp, +struct tf_clear_tcam_shared_entries_parms *parms) +{ + int rc; + struct tf_session *tfs; + struct tf_dev_info *dev; + + TF_CHECK_PARMS2(tfp, parms); + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup device, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + if (dev->ops->tf_dev_clear_tcam == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + rc = dev->ops->tf_dev_clear_tcam(tfp, parms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: TCAM shared entries clear failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + return 0; +} #endif /* TF_TCAM_SHARED */ int diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 44c30fa904..0b06bb2bb5 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -233,7 +233,7 @@ enum tf_identifier_type { */ TF_IDENT_TYPE_EM_PROF, /** -* TH +* (Future) * The L2 func is included in the ILT result and from recycling to * enable virtualization of further lookups. */ @@ -1244,6 +1244,8 @@ int tf_free_tbl_scope(struct tf *tfp, * #ifdef TF_TCAM_SHARED * @ref tf_move_tcam_shared_entries + * + * @ref tf_clear_tcam_shared_entries #endif */ @@ -1580,6 +1582,37 @@ struct tf_move_tcam_shared_entries_parms { int tf_move_tcam_shared_entries(struct tf *tfp, struct tf_move_tcam_shared_entries_parms *parms); +/** + * tf_clear_tcam_shared_entries parameter definition + */ +struct tf_clear_tcam_shared_entries_parms { + /** +* [in] receive or transmit direction +*/ + enum tf_dir dir; + /** +* [in] TCAM table type +*/ + enum tf_tcam_tbl_type tcam_tbl_type; +}; + +/** + * Clear TCAM shared entries pool + * + * This API only affects the following TCAM pools within a shared session: + * + * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH + * TF_TCAM_TBL_TYPE_WC_TCAM_LOW + * + * When called, the indicated WC TCAM high or low pool will be cleared. + * + * This API is not supported on a non-shared session. + * + * Returns success or failure code. + */ +int tf_clear_tcam_shared_entries(struct tf *tfp, + struct tf_clear_tcam_shared_entries_parms *parms); + #endif /* TF_TCAM_SHARED */ /** * @page table Table Access @@ -2108,7 +2141,7 @@ struct tf_move_em_entry_parms { uint64_t flow_handle; }; /** - * tf_search_em_entry parameter definition + * tf_search_em_entry parameter definition (Future) */ struct tf_search_em_entry_parms { /** @@ -2211,7 +2244,7 @@ int tf_delete_em_entry(struct tf *tfp, struct tf_delete_em_entry_parms *parms); /** - * search em hash entry table memory + * search em hash entry table memory (Future) * * Internal: diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/driver
[dpdk-dev] [PATCH 30/58] net/bnxt: modify TCAM opcode processing
From: Kishore Padmanabha Added TCAM table specific opcode to process TCAM entry creation and reuse. This change removes the TCAM cache mechanism and uses the generic table mechanism for reuse of TCAM entries. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 135 ++--- drivers/net/bnxt/tf_ulp/ulp_mapper.h | 15 -- .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 7 + .../tf_ulp/ulp_template_db_wh_plus_class.c| 138 -- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 1 + 5 files changed, 144 insertions(+), 152 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index d84614fcd1..c511f835ff 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -1356,20 +1356,11 @@ ulp_mapper_tcam_tbl_scan_ident_alloc(struct bnxt_ulp_mapper_parms *parms, uint32_t num_idents; uint32_t i; - /* -* Since the cache entry is responsible for allocating -* identifiers when in use, allocate the identifiers only -* during normal processing. -*/ - if (parms->tcam_tbl_opc == - BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) { - idents = ulp_mapper_ident_fields_get(parms, tbl, &num_idents); - - for (i = 0; i < num_idents; i++) { - if (ulp_mapper_ident_process(parms, tbl, -&idents[i], NULL)) - return -EINVAL; - } + idents = ulp_mapper_ident_fields_get(parms, tbl, &num_idents); + for (i = 0; i < num_idents; i++) { + if (ulp_mapper_ident_process(parms, tbl, +&idents[i], NULL)) + return -EINVAL; } return 0; } @@ -1490,14 +1481,15 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct tf_search_tcam_entry_parms searchparms = { 0 }; struct ulp_flow_db_res_params fid_parms = { 0 }; struct tf_free_tcam_entry_parms free_parms = { 0 }; - enum bnxt_ulp_search_before_alloc search_flag; uint32_t hit = 0; uint16_t tmplen = 0; uint16_t idx; - /* Skip this if was handled by the cache. */ - if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP) { - parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL; + /* Skip this if table opcode is NOP */ + if (tbl->tbl_opcode == BNXT_ULP_TCAM_TBL_OPC_NOT_USED || + tbl->tbl_opcode >= BNXT_ULP_TCAM_TBL_OPC_LAST) { + BNXT_TF_DBG(ERR, "Invalid tcam table opcode %d\n", + tbl->tbl_opcode); return 0; } @@ -1555,41 +1547,31 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, } } + /* For wild card tcam perform the post process to swap the blob */ if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM) { ulp_mapper_wc_tcam_tbl_post_process(&key, tbl->key_bit_size); ulp_mapper_wc_tcam_tbl_post_process(&mask, tbl->key_bit_size); } - if (tbl->srch_b4_alloc == BNXT_ULP_SEARCH_BEFORE_ALLOC_NO) { - /* -* No search for re-use is requested, so simply allocate the -* tcam index. -*/ - aparms.dir = tbl->direction; - aparms.tcam_tbl_type= tbl->resource_type; - aparms.search_enable= tbl->srch_b4_alloc; - aparms.key = ulp_blob_data_get(&key, &tmplen); - aparms.key_sz_in_bits = tmplen; + if (tbl->tbl_opcode == BNXT_ULP_TCAM_TBL_OPC_ALLOC_WR_REGFILE) { + /* allocate the tcam index */ + aparms.dir = tbl->direction; + aparms.tcam_tbl_type = tbl->resource_type; + aparms.key = ulp_blob_data_get(&key, &tmplen); + aparms.key_sz_in_bits = tmplen; if (tbl->blob_key_bit_size != tmplen) { BNXT_TF_DBG(ERR, "Key len (%d) != Expected (%d)\n", tmplen, tbl->blob_key_bit_size); return -EINVAL; } - aparms.mask = ulp_blob_data_get(&mask, &tmplen); + aparms.mask = ulp_blob_data_get(&mask, &tmplen); if (tbl->blob_key_bit_size != tmplen) { BNXT_TF_DBG(ERR, "Mask len (%d) != Expected (%d)\n", tmplen, tbl->blob_key_bit_size); return -EINVAL; } - - aparms.priority = tbl->priority; - - /* -* All failures after this succeeds require the entry
[dpdk-dev] [PATCH 31/58] net/bnxt: modify VXLAN decap for multichannel mode
The driver is using physical port id as the index into the tunnel inner flow table. However, this will not work in case of multichannel mode where multiple physical functions are going to share the same physical port id. When tunnel inner flow offload request comes before tunnel outer flow offload request, the driver caches the tunnel inner flow details and programs it in the hardware after installing the tunnel outer flow in the hardware. If more than one tunnel inner flow arrives before tunnel outer flow is offloaded, the driver rejects any such tunnel inner flow offload requests. This patch fixes the above two problems by 1. Using dpdk port id as the index to store tunnel inner info. 2. Caching any number of tunnel inner flow offload requests that come before offloading tunnel outer flow offload request Signed-off-by: Venkat Duvvuru Reviewed-by: Shahaji Bhosle --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c| 3 + drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 3 +- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 1 + drivers/net/bnxt/tf_ulp/ulp_tun.c | 192 -- drivers/net/bnxt/tf_ulp/ulp_tun.h | 30 ++- 5 files changed, 150 insertions(+), 79 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 5c805eef97..59fb530fb1 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -22,6 +22,7 @@ #include "ulp_flow_db.h" #include "ulp_mapper.h" #include "ulp_port_db.h" +#include "ulp_tun.h" /* Linked list of all TF sessions. */ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list = @@ -533,6 +534,8 @@ ulp_ctx_init(struct bnxt *bp, if (rc) goto error_deinit; + ulp_tun_tbl_init(ulp_data->tun_tbl); + bnxt_ulp_cntxt_tfp_set(bp->ulp_ctx, &bp->tfp); return rc; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index ddf38ed931..836e94bc60 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -79,6 +79,7 @@ bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_create_parms *mapper_cparms, struct ulp_rte_parser_params *params, enum bnxt_ulp_fdb_type flow_type) { + memset(mapper_cparms, 0, sizeof(*mapper_cparms)); mapper_cparms->flow_type= flow_type; mapper_cparms->app_priority = params->priority; mapper_cparms->dir_attr = params->dir_attr; @@ -176,7 +177,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, params.fid = fid; params.func_id = func_id; params.priority = attr->priority; - params.port_id = bnxt_get_phy_port_id(dev->data->port_id); + params.port_id = dev->data->port_id; /* Perform the rte flow post process */ ret = bnxt_ulp_rte_parser_post_process(¶ms); if (ret == BNXT_TF_RC_ERROR) diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index ee17390358..b253aefe8d 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -62,6 +62,7 @@ struct ulp_rte_act_prop { /* Structure to be used for passing all the parser functions */ struct ulp_rte_parser_params { + STAILQ_ENTRY(ulp_rte_parser_params) next; struct ulp_rte_hdr_bitmap hdr_bitmap; struct ulp_rte_hdr_bitmap hdr_fp_bit; struct ulp_rte_field_bitmap fld_bitmap; diff --git a/drivers/net/bnxt/tf_ulp/ulp_tun.c b/drivers/net/bnxt/tf_ulp/ulp_tun.c index 884692947a..6c1ae3ced2 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_tun.c +++ b/drivers/net/bnxt/tf_ulp/ulp_tun.c @@ -3,6 +3,8 @@ * All rights reserved. */ +#include + #include #include "ulp_tun.h" @@ -48,19 +50,18 @@ ulp_install_outer_tun_flow(struct ulp_rte_parser_params *params, goto err; /* Store the tunnel dmac in the tunnel cache table and use it while -* programming tunnel flow F2. +* programming tunnel inner flow. */ memcpy(tun_entry->t_dmac, ¶ms->hdr_field[ULP_TUN_O_DMAC_HDR_FIELD_INDEX].spec, RTE_ETHER_ADDR_LEN); - tun_entry->valid = true; tun_entry->tun_flow_info[params->port_id].state = BNXT_ULP_FLOW_STATE_TUN_O_OFFLD; tun_entry->outer_tun_flow_id = params->fid; - /* F1 and it's related F2s are correlated based on -* Tunnel Destination IP Address. + /* Tunnel outer flow and it's related inner flows are correlated +* based on Tunnel Destination IP Address. */ if (tun_entry->t_dst_ip_valid) goto done; @@ -89,25 +90,27 @@ ulp_install_inner_tun_flow(struct bnxt_tun_cache_entry *tun_entry, { struct bnxt_ulp_mapper_create_parms mparms = { 0 }; struct ulp_per_por
[dpdk-dev] [PATCH 29/58] net/bnxt: add conditional execution and rejection
From: Mike Baucom Conditional execution and rejection processing added for templates and tables. This allows the mapper to skip tables and reject templates based on the content without having to hard code rules. Signed-off-by: Mike Baucom Signed-off-by: Venkat Duvvuru Reviewed-by: Kishore Padmanabha --- drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 1 + drivers/net/bnxt/tf_ulp/ulp_mapper.c | 330 ++ drivers/net/bnxt/tf_ulp/ulp_mapper.h | 2 + .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 30 +- .../tf_ulp/ulp_template_db_stingray_act.c | 30 +- .../tf_ulp/ulp_template_db_stingray_class.c | 8 +- drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c | 243 + drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.h | 2 + .../bnxt/tf_ulp/ulp_template_db_wh_plus_act.c | 30 +- .../tf_ulp/ulp_template_db_wh_plus_class.c| 8 +- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 18 +- 11 files changed, 593 insertions(+), 109 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 777a6badd9..ddf38ed931 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -93,6 +93,7 @@ bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_create_parms *mapper_cparms, mapper_cparms->flow_id = params->fid; mapper_cparms->parent_flow = params->parent_flow; mapper_cparms->parent_fid = params->parent_fid; + mapper_cparms->fld_bitmap = ¶ms->fld_bitmap; } /* Function to create the rte flow. */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 4e9211a7ab..d84614fcd1 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -17,6 +17,7 @@ #include "ulp_mapper.h" #include "ulp_flow_db.h" #include "tf_util.h" +#include "ulp_template_db_tbl.h" static struct bnxt_ulp_glb_resource_info * ulp_mapper_glb_resource_info_list_get(uint32_t *num_entries) @@ -190,6 +191,12 @@ ulp_mapper_glb_template_table_get(uint32_t *num_entries) return ulp_glb_template_tbl; } +static uint8_t * +ulp_mapper_glb_field_tbl_get(uint32_t idx) +{ + return &ulp_glb_field_tbl[idx]; +} + /* * Get the size of the action property for a given index. * @@ -205,6 +212,40 @@ ulp_mapper_act_prop_size_get(uint32_t idx) return ulp_act_prop_map_table[idx]; } +static struct bnxt_ulp_mapper_cond_info * +ulp_mapper_tmpl_reject_list_get(struct bnxt_ulp_mapper_parms *mparms, + uint32_t tid, + uint32_t *num_tbls, + enum bnxt_ulp_cond_list_opc *opc) +{ + uint32_t idx; + const struct ulp_template_device_tbls *dev_tbls; + + dev_tbls = &mparms->device_params->dev_tbls[mparms->tmpl_type]; + *num_tbls = dev_tbls->tmpl_list[tid].reject_info.cond_nums; + *opc = dev_tbls->tmpl_list[tid].reject_info.cond_list_opcode; + idx = dev_tbls->tmpl_list[tid].reject_info.cond_start_idx; + + return &dev_tbls->cond_list[idx]; +} + +static struct bnxt_ulp_mapper_cond_info * +ulp_mapper_tbl_execute_list_get(struct bnxt_ulp_mapper_parms *mparms, + struct bnxt_ulp_mapper_tbl_info *tbl, + uint32_t *num_tbls, + enum bnxt_ulp_cond_list_opc *opc) +{ + uint32_t idx; + const struct ulp_template_device_tbls *dev_tbls; + + dev_tbls = &mparms->device_params->dev_tbls[mparms->tmpl_type]; + *num_tbls = tbl->execute_info.cond_nums; + *opc = tbl->execute_info.cond_list_opcode; + idx = tbl->execute_info.cond_start_idx; + + return &dev_tbls->cond_list[idx]; +} + /* * Get a list of classifier tables that implement the flow * Gets a device dependent list of tables that implement the class template id @@ -2376,61 +2417,6 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, return rc; } -/* - * Function to process the conditional opcode of the mapper table. - * returns 1 to skip the table. - * return 0 to continue processing the table. - * - * defaults to skip - */ -static int32_t -ulp_mapper_tbl_cond_opcode_process(struct bnxt_ulp_mapper_parms *parms, - struct bnxt_ulp_mapper_tbl_info *tbl) -{ - int32_t rc = 1; - - switch (tbl->cond_opcode) { - case BNXT_ULP_COND_OPCODE_NOP: - rc = 0; - break; - case BNXT_ULP_COND_OPCODE_COMP_FIELD_IS_SET: - if (tbl->cond_operand < BNXT_ULP_CF_IDX_LAST && - ULP_COMP_FLD_IDX_RD(parms, tbl->cond_operand)) - rc = 0; - break; - case BNXT_ULP_COND_OPCODE_ACTION_BIT_IS_SET: - if (ULP_BITMAP_ISSET(parms->act_bitmap->bits, -tbl->cond_operand)) -
[dpdk-dev] [PATCH 24/58] net/bnxt: add support for WC TCAM shared session
From: Jay Ding If the session shares WC TCAM entries with others, specify it in the session name by attach "-wc_tcam". Firmware will flush the shared WC TCAM entries if the last shared session using them is closed. Signed-off-by: Jay Ding Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Michael Baucom Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_msg.c | 46 +++ drivers/net/bnxt/tf_core/tf_session.c | 5 +++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index fbd4b1d910..6717710dbd 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -58,6 +58,16 @@ static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) == */ #define TF_PCI_BUF_SIZE_MAX 88 +/** + * This is the length of shared session name "tf_share" + */ +#define TF_SHARED_SESSION_NAME_LEN 8 + +/** + * This is the length of tcam shared session name "tf_shared-wc_tcam" + */ +#define TF_TCAM_SHARED_SESSION_NAME_LEN 17 + /** * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method */ @@ -126,13 +136,17 @@ tf_msg_session_open(struct bnxt *bp, struct hwrm_tf_session_open_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; int name_len; - char *name; + char *session_name; + char *tcam_session_name; /* Populate the request */ name_len = strnlen(ctrl_chan_name, TF_SESSION_NAME_MAX); - name = &ctrl_chan_name[name_len - strlen("tf_shared")]; - if (!strncmp(name, "tf_shared", strlen("tf_shared"))) - tfp_memcpy(&req.session_name, name, strlen("tf_share")); + session_name = &ctrl_chan_name[name_len - strlen("tf_shared")]; + tcam_session_name = &ctrl_chan_name[name_len - strlen("tf_shared-wc_tcam")]; + if (!strncmp(tcam_session_name, "tf_shared-wc_tcam", strlen("tf_shared-wc_tcam"))) + tfp_memcpy(&req.session_name, tcam_session_name, TF_TCAM_SHARED_SESSION_NAME_LEN); + else if (!strncmp(session_name, "tf_shared", strlen("tf_shared"))) + tfp_memcpy(&req.session_name, session_name, TF_SHARED_SESSION_NAME_LEN); else tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX); @@ -177,6 +191,9 @@ tf_msg_session_client_register(struct tf *tfp, struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; struct tf_dev_info *dev; + int name_len; + char *session_name; + char *tcam_session_name; /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); @@ -197,9 +214,24 @@ tf_msg_session_client_register(struct tf *tfp, /* Populate the request */ req.fw_session_id = tfp_cpu_to_le_32(fw_session_id); - tfp_memcpy(&req.session_client_name, - ctrl_channel_name, - TF_SESSION_NAME_MAX); + name_len = strnlen(ctrl_channel_name, TF_SESSION_NAME_MAX); + session_name = &ctrl_channel_name[name_len - strlen("tf_shared")]; + tcam_session_name = &ctrl_channel_name[name_len - + strlen("tf_shared-wc_tcam")]; + if (!strncmp(tcam_session_name, + "tf_shared-wc_tcam", + strlen("tf_shared-wc_tcam"))) + tfp_memcpy(&req.session_client_name, + tcam_session_name, + TF_TCAM_SHARED_SESSION_NAME_LEN); + else if (!strncmp(session_name, "tf_shared", strlen("tf_shared"))) + tfp_memcpy(&req.session_client_name, + session_name, + TF_SHARED_SESSION_NAME_LEN); + else + tfp_memcpy(&req.session_client_name, + ctrl_channel_name, + TF_SESSION_NAME_MAX); parms.tf_type = HWRM_TF_SESSION_REGISTER; parms.req_data = (uint32_t *)&req; diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c index 71ccb2e3e7..90b65c59e6 100644 --- a/drivers/net/bnxt/tf_core/tf_session.c +++ b/drivers/net/bnxt/tf_core/tf_session.c @@ -188,6 +188,11 @@ tf_session_create(struct tf *tfp, if (!strncmp(name, "tf_shared", strlen("tf_shared"))) session->shared_session = true; + name = &parms->open_cfg->ctrl_chan_name[name_len - + strlen("tf_shared-wc_tcam")]; + if (!strncmp(name, "tf_shared-wc_tcam", strlen("tf_shared-wc_tcam"))) + session->shared_session = true; + if (session->shared_session && shared_session_creator) { session->shared_session_creator = true; parms->open_cfg->shared_session_creator = true; -- 2.17.1
[dpdk-dev] [PATCH 36/58] net/bnxt: set shared handle for generic table
From: Kishore Padmanabha The shared handle is set in the mapper params when generic resource are created, this shall be used by application as a handle to the shared resource like mirror handle. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 1 + drivers/net/bnxt/tf_ulp/ulp_mapper.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index ad5fde9730..73a6a4cdb5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -2403,6 +2403,7 @@ ulp_mapper_gen_tbl_process(struct bnxt_ulp_mapper_parms *parms, /* increment the reference count */ ULP_GEN_TBL_REF_CNT_INC(&gen_tbl_ent); fdb_write = 1; + parms->shared_hndl = (uint64_t)tbl_idx << 32 | ckey; break; default: BNXT_TF_DBG(ERR, "Invalid table opcode %x\n", tbl->tbl_opcode); diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h index bef72696d3..b7399b8949 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h @@ -57,6 +57,7 @@ struct bnxt_ulp_mapper_parms { uint32_tparent_flow; uint8_t tun_idx; uint32_tapp_priority; + uint64_tshared_hndl; }; struct bnxt_ulp_mapper_create_parms { -- 2.17.1
[dpdk-dev] [PATCH 32/58] net/bnxt: modify table processing
From: Kishore Padmanabha 1. Added interface table specific opcode to process interface table entry creation and reuse. This allows reuse of the interface table entry for multiple flows. Changed the regfile apis to store the data in big endian format. 2. The result blob creation being done in tcam, interface, index tables are consolidate to a common method. 3. Added result blob processing for generic table write 4. Modified the index table opcode processing to support new opcodes. 5. The driver was setting key size that did not take into account the word alignment. 6. The hard coded values for critical resource is replaced with template defined values. Signed-off-by: Kishore Padmanabha Signed-off-by: Michael Baucom Signed-off-by: Venkat Duvvuru Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c | 18 +- drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h | 4 +- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 674 ++ .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 22 + .../bnxt/tf_ulp/ulp_template_db_wh_plus_act.c | 108 +-- .../tf_ulp/ulp_template_db_wh_plus_class.c| 69 +- 6 files changed, 512 insertions(+), 383 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c index 0edbe77a96..dd2b799b30 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.c @@ -5,6 +5,8 @@ #include #include +#include "tf_core.h" +#include "tfp.h" #include "ulp_mapper.h" #include "ulp_flow_db.h" @@ -163,18 +165,20 @@ ulp_mapper_gen_tbl_idx_calculate(uint32_t res_sub_type, uint32_t dir) } /* - * Set the data in the generic table entry + * Set the data in the generic table entry, Data is in Big endian format * * entry [in] - generic table entry * offset [in] - The offset in bits where the data has to be set * len [in] - The length of the data in bits to be set * data [in] - pointer to the data to be used for setting the value. + * data_size [in] - length of the data pointer in bytes. * * returns 0 on success */ int32_t ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry, - uint32_t offset, uint32_t len, uint8_t *data) + uint32_t offset, uint32_t len, uint8_t *data, + uint32_t data_size) { /* validate the null arguments */ if (!entry || !data) { @@ -183,12 +187,17 @@ ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry, } /* check the size of the buffer for validation */ - if ((offset + len) > ULP_BYTE_2_BITS(entry->byte_data_size)) { + if ((offset + len) > ULP_BYTE_2_BITS(entry->byte_data_size) || + data_size < ULP_BITS_2_BYTE(len)) { BNXT_TF_DBG(ERR, "invalid offset or length %x:%x:%x\n", offset, len, entry->byte_data_size); return -EINVAL; } + /* adjust the data pointer */ + data = data + (data_size - ULP_BITS_2_BYTE(len)); + + /* Push the data into the byte data array */ if (entry->byte_order == BNXT_ULP_BYTE_ORDER_LE) { if (ulp_bs_push_lsb(entry->byte_data, offset, len, data) != len) { @@ -208,7 +217,7 @@ ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry, } /* - * Get the data in the generic table entry + * Get the data in the generic table entry, Data is in Big endian format * * entry [in] - generic table entry * offset [in] - The offset in bits where the data has to get @@ -298,6 +307,7 @@ ulp_mapper_gen_tbl_res_free(struct bnxt_ulp_context *ulp_ctx, tbl_idx, res->resource_hndl); return -EINVAL; } + fid = tfp_be_to_cpu_32(fid); /* Destroy the flow associated with the shared flow id */ if (ulp_mapper_flow_destroy(ulp_ctx, BNXT_ULP_FDB_TYPE_REGULAR, diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h b/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h index c8a1112af4..701a8d10e5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h +++ b/drivers/net/bnxt/tf_ulp/ulp_gen_tbl.h @@ -104,12 +104,14 @@ ulp_mapper_gen_tbl_idx_calculate(uint32_t res_sub_type, uint32_t dir); * offset [in] - The offset in bits where the data has to be set * len [in] - The length of the data in bits to be set * data [in] - pointer to the data to be used for setting the value. + * data_size [in] - length of the data pointer in bytes. * * returns 0 on success */ int32_t ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry, - uint32_t offset, uint32_t len, uint8_t *data); + uint32_t offset, uint32_t len, uint8_t *data, + uint32_t data_size); /* * Get the data in the generic table entry diff --git a/drivers/net/bnxt/tf_ulp/ul
[dpdk-dev] [PATCH 40/58] net/bnxt: add partial header field processing
From: Kishore Padmanabha For support for wild card TCAM, some of the header fields have to be partially written, hence this new opcode is added. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Ajit Kumar Khaparde Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 64 +-- .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 13 ++-- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index c2e36823bf..555a5c5d91 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -927,7 +927,7 @@ ulp_mapper_field_process(struct bnxt_ulp_mapper_parms *parms, uint32_t val_size = 0, field_size = 0; uint64_t hdr_bit, act_bit, regval; uint16_t write_idx = blob->write_idx; - uint16_t idx, size_idx, bitlen; + uint16_t idx, size_idx, bitlen, offset; uint8_t *val = NULL; uint8_t tmpval[16]; uint8_t bit; @@ -1340,6 +1340,46 @@ ulp_mapper_field_process(struct bnxt_ulp_mapper_parms *parms, break; case BNXT_ULP_FIELD_SRC_REJECT: return -EINVAL; + case BNXT_ULP_FIELD_SRC_SUB_HF: + if (!ulp_operand_read(fld_src_oper, + (uint8_t *)&idx, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "%s operand read failed\n", name); + return -EINVAL; + } + idx = tfp_be_to_cpu_16(idx); + /* get the index from the global field list */ + if (ulp_mapper_glb_field_tbl_get(parms, idx, &bit)) { + BNXT_TF_DBG(ERR, "invalid ulp_glb_field_tbl idx %d\n", + idx); + return -EINVAL; + } + + /* get the offset next */ + if (!ulp_operand_read(&fld_src_oper[sizeof(uint16_t)], + (uint8_t *)&offset, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "%s operand read failed\n", name); + return -EINVAL; + } + offset = tfp_be_to_cpu_16(offset); + if ((offset + bitlen) > + ULP_BYTE_2_BITS(parms->hdr_field[bit].size) || + ULP_BITS_IS_BYTE_NOT_ALIGNED(offset)) { + BNXT_TF_DBG(ERR, "Hdr field[%s] oob\n", name); + return -EINVAL; + } + offset = ULP_BITS_2_BYTE_NR(offset); + + /* write the value into blob */ + if (is_key) + val = &parms->hdr_field[bit].spec[offset]; + else + val = &parms->hdr_field[bit].mask[offset]; + + if (!ulp_blob_push(blob, val, bitlen)) { + BNXT_TF_DBG(ERR, "%s push to blob failed\n", name); + return -EINVAL; + } + break; default: BNXT_TF_DBG(ERR, "%s invalid field opcode 0x%x at %d\n", name, fld_src, write_idx); @@ -1630,25 +1670,9 @@ ulp_mapper_tcam_tbl_entry_write(struct bnxt_ulp_mapper_parms *parms, return rc; } -#define BNXT_ULP_WC_TCAM_SLICE_SIZE 80 /* internal function to post process the key/mask blobs for wildcard tcam tbl */ -static void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob, - uint32_t len) +static void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob) { - uint8_t mode[2] = {0x0, 0x0}; - uint32_t mode_len = len / BNXT_ULP_WC_TCAM_SLICE_SIZE; - uint32_t size, idx; - - /* Add the mode bits to the key and mask*/ - if (mode_len == 2) - mode[1] = 2; - else if (mode_len > 2) - mode[1] = 3; - - size = BNXT_ULP_WC_TCAM_SLICE_SIZE + ULP_BYTE_2_BITS(sizeof(mode)); - for (idx = 0; idx < mode_len; idx++) - ulp_blob_insert(blob, (size * idx), mode, - ULP_BYTE_2_BITS(sizeof(mode))); ulp_blob_perform_64B_word_swap(blob); ulp_blob_perform_64B_byte_swap(blob); } @@ -1736,8 +1760,8 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, /* For wild card tcam perform the post process to swap the blob */ if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM) { - ulp_mapper_wc_tcam_tbl_post_process(&key, tbl->key_bit_size); - ulp_mapper_wc_tcam_tbl_post_process(&mask, tbl->key_bit_size); + ulp_mapper_wc_tcam_tbl_post_process(&key); + ulp_mapper_wc_tcam_tbl_post_process(&mask); } if (tbl->tbl_opcode == BNXT_ULP_TCAM_TBL_OPC_ALLOC_WR_REGFILE) { diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db
[dpdk-dev] [PATCH 42/58] net/bnxt: add support for GRE flows
This patch does the following to support GRE flows: 1. RTE_FLOW_ITEM_TYPE_ANY & RTE_FLOW_ITEM_TYPE_GRE processing 2. Calculate the absolute function ID from the logical VF ID passed as part of RTE_FLOW_ACTION_TYPE_VF action. 3. Move bnxt_get_bp API to bnxt_ethdev.c Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c| 26 +++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 75 ++- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 9 +++ drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 2 + 5 files changed, 110 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 882f577848..d3ab57ab8d 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -982,6 +982,7 @@ bnxt_ulp_create_vfr_default_rules(struct rte_eth_dev *vfr_ethdev); int32_t bnxt_ulp_delete_vfr_default_rules(struct bnxt_representor *vfr); uint16_t bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type); +struct bnxt *bnxt_get_bp(uint16_t port); uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif, enum bnxt_ulp_intf_type type); uint16_t bnxt_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index a0e0ba5884..ebb326b0d1 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -4787,6 +4787,32 @@ static void bnxt_config_vf_req_fwd(struct bnxt *bp) BNXT_HWRM_CMD_TO_FORWARD(HWRM_OEM_CMD); } +struct bnxt * +bnxt_get_bp(uint16_t port) +{ + struct bnxt *bp; + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port)) { + PMD_DRV_LOG(ERR, "Invalid port %d\n", port); + return NULL; + } + + dev = &rte_eth_devices[port]; + if (!is_bnxt_supported(dev)) { + PMD_DRV_LOG(ERR, "Device %d not supported\n", port); + return NULL; + } + + bp = (struct bnxt *)dev->data->dev_private; + if (!BNXT_TRUFLOW_EN(bp)) { + PMD_DRV_LOG(ERR, "TRUFLOW not enabled\n"); + return NULL; + } + + return bp; +} + uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif, enum bnxt_ulp_intf_type type) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 554123679e..5a2249f349 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -1008,6 +1008,9 @@ ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item, ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, 1); } + if (proto == IPPROTO_GRE) + ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_T_GRE); + /* Update the field protocol hdr bitmap */ ulp_rte_l3_proto_type_update(params, proto, inner_flag); ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L3_HDR_CNT, ++cnt); @@ -1146,6 +1149,9 @@ ulp_rte_ipv6_hdr_handler(const struct rte_flow_item *item, ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_O_L3, 1); } + if (proto == IPPROTO_GRE) + ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_T_GRE); + /* Update the field protocol hdr bitmap */ ulp_rte_l3_proto_type_update(params, proto, inner_flag); ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L3_HDR_CNT, ++cnt); @@ -1420,6 +1426,57 @@ ulp_rte_vxlan_hdr_handler(const struct rte_flow_item *item, return BNXT_TF_RC_SUCCESS; } +/* Function to handle the parsing of RTE Flow item GRE Header. */ +int32_t +ulp_rte_gre_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params) +{ + const struct rte_flow_item_gre *gre_spec = item->spec; + const struct rte_flow_item_gre *gre_mask = item->mask; + struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap; + uint32_t idx = params->field_idx; + uint32_t size; + struct ulp_rte_hdr_field *field; + + if (!gre_spec && !gre_mask) { + BNXT_TF_DBG(ERR, "Parse Error: GRE item is invalid\n"); + return BNXT_TF_RC_ERROR; + } + + if (gre_spec) { + size = sizeof(gre_spec->c_rsvd0_ver); + field = ulp_rte_parser_fld_copy(¶ms->hdr_field[idx], + &gre_spec->c_rsvd0_ver, + size); + size = sizeof(gre_spec->protocol); + field = ulp_rte_parser_fld_copy(field, + &gre_spec->protocol, + size); + } + if (gre_mask) { + ulp_rte_prsr_mask_copy(params, &idx, + &gre_mask->c_rsvd
[dpdk-dev] [PATCH 44/58] net/bnxt: refactor ULP mapper and parser
From: Kishore Padmanabha 1. The internal and external exact match table resource types is combined since the resource handle contains the encoded type whether it is internal or external exact match entry. 2. When a flow doesn't hit the offloaded rules, the default action is to send it to the kernel (L2 driver interface). In order to do that, TRUFLOW must know the kernel interface's (PF's) default vnic id. This patch fetches the PF's default vnic id from the dpdk core and stores it in port database. It also stores the mac addr for the future usage. Renamed compute field for layer 4 port enums. Added support for port database opcode that can get port details like mac address which can then be populated in the l2 context entry. 3. Both active and default bit set need to considered to check if a specific flow type is enabled or not. 4. ulp mapper fetches the dpdk port id from the compute field index BNXT_ULP_CF_IDX_DEV_PORT_ID which is used to get the interface’s mac address eventually. However, the compute field array is not populated with dpdk port id at the index BNXT_ULP_CF_IDX_DEV_PORT_ID. The problem fixed by populating the compute field array correctly. 5. Some dpdk applications may accumulate the flow counters while some may not. In cases where the application is accumulating the counters the PMD need not do the accumulation itself and viceversa to report the correct flow counters. 6. Pointer to bp is added to open session parms to support shared session. Signed-off-by: Venkat Duvvuru Signed-off-by: Kishore Padmanabha Signed-off-by: Jay Ding Reviewed-by: Lance Richardson Reviewed-by: Ajit Kumar Khaparde Reviewed-by: Michael Baucom Reviewed-by: Somnath Kotur Reviewed-by: Randy Schacher --- drivers/net/bnxt/bnxt.h | 6 + drivers/net/bnxt/bnxt_ethdev.c| 86 +++ drivers/net/bnxt/tf_ulp/bnxt_ulp.c| 5 + drivers/net/bnxt/tf_ulp/bnxt_ulp.h| 1 + drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 2 + drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 25 +- drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 95 +--- drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 5 +- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 52 +++- drivers/net/bnxt/tf_ulp/ulp_port_db.c | 37 +++ drivers/net/bnxt/tf_ulp/ulp_port_db.h | 15 ++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 114 +++-- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 8 + .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 59 +++-- .../tf_ulp/ulp_template_db_stingray_class.c | 4 +- .../tf_ulp/ulp_template_db_wh_plus_class.c| 48 ++-- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 3 +- drivers/net/bnxt/tf_ulp/ulp_tun.c | 227 +- drivers/net/bnxt/tf_ulp/ulp_tun.h | 44 ++-- 19 files changed, 637 insertions(+), 199 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index d3ab57ab8d..246f51fddf 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -668,8 +668,11 @@ struct bnxt { uint32_tflags2; #define BNXT_FLAGS2_PTP_TIMESYNC_ENABLED BIT(0) #define BNXT_FLAGS2_PTP_ALARM_SCHEDULEDBIT(1) +#defineBNXT_FLAGS2_ACCUM_STATS_EN BIT(2) #define BNXT_P5_PTP_TIMESYNC_ENABLED(bp) \ ((bp)->flags2 & BNXT_FLAGS2_PTP_TIMESYNC_ENABLED) +#defineBNXT_ACCUM_STATS_EN(bp) \ + ((bp)->flags2 & BNXT_FLAGS2_ACCUM_STATS_EN) uint16_tchip_num; #define CHIP_NUM_58818 0xd818 @@ -981,7 +984,10 @@ int32_t bnxt_ulp_create_vfr_default_rules(struct rte_eth_dev *vfr_ethdev); int32_t bnxt_ulp_delete_vfr_default_rules(struct bnxt_representor *vfr); +void bnxt_get_iface_mac(uint16_t port, enum bnxt_ulp_intf_type type, + uint8_t *mac, uint8_t *parent_mac); uint16_t bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type); +uint16_t bnxt_get_parent_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type); struct bnxt *bnxt_get_bp(uint16_t port); uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif, enum bnxt_ulp_intf_type type); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ebb326b0d1..1c0eeb76b7 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -87,6 +87,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { { .vendor_id = 0, /* sentinel */ }, }; +#defineBNXT_DEVARG_ACCUM_STATS "accum-stats" #define BNXT_DEVARG_FLOW_XSTAT "flow-xstat" #define BNXT_DEVARG_MAX_NUM_KFLOWS "max-num-kflows" #define BNXT_DEVARG_REPRESENTOR"representor" @@ -99,6 +100,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { static const char *const bnxt_dev_args[] = { BNXT_DEVARG_REPRESENTOR, + BNXT_DEVARG_ACCUM_STATS, BNXT_DEVARG_FLOW_XSTAT, BNXT_DEVARG_MAX_NUM_KFLOWS,
[dpdk-dev] [PATCH 41/58] net/bnxt: add support for wild card pattern match
From: Kishore Padmanabha The computational field is enabled for wild card pattern support. The template checks the computational field to add a flow as wild card entry or exact match entry. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Venkat Duvvuru Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 4 ++-- drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index f491405a9e..554123679e 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -50,8 +50,8 @@ ulp_rte_parser_field_bitmap_update(struct ulp_rte_parser_params *params, ULP_INDEX_BITMAP_SET(params->fld_bitmap.bits, idx); /* Not exact match */ if (!ulp_bitmap_is_ones(field->mask, field->size)) - ULP_BITMAP_SET(params->fld_bitmap.bits, - BNXT_ULP_MATCH_TYPE_BITMASK_WM); + ULP_COMP_FLD_IDX_WR(params, + BNXT_ULP_CF_IDX_WC_MATCH, 1); } else { ULP_INDEX_BITMAP_RESET(params->fld_bitmap.bits, idx); } diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h index e1ceb42f30..89cbbc0a9e 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -180,7 +180,8 @@ enum bnxt_ulp_cf_idx { BNXT_ULP_CF_IDX_FID = 49, BNXT_ULP_CF_IDX_HDR_SIG_ID = 50, BNXT_ULP_CF_IDX_FLOW_SIG_ID = 51, - BNXT_ULP_CF_IDX_LAST = 52 + BNXT_ULP_CF_IDX_WC_MATCH = 52, + BNXT_ULP_CF_IDX_LAST = 53 }; enum bnxt_ulp_cond_list_opc { -- 2.17.1
[dpdk-dev] [PATCH 48/58] net/bnxt: add shared session support to ULP
From: Mike Baucom Shared session permits cooperative sharing of prescribed resources between applications. - devargs added for app-id in order to enable sharing session resources across applications - shared session management added - tf resource reservations are now app and device dependent Signed-off-by: Mike Baucom Signed-off-by: Venkat Duvvuru Reviewed-by: Kishore Padmanabha --- drivers/net/bnxt/bnxt.h |2 + drivers/net/bnxt/bnxt_ethdev.c| 50 + drivers/net/bnxt/tf_ulp/bnxt_ulp.c| 645 +++-- drivers/net/bnxt/tf_ulp/bnxt_ulp.h| 39 + drivers/net/bnxt/tf_ulp/ulp_mapper.c | 186 +- drivers/net/bnxt/tf_ulp/ulp_mapper.h |1 + .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 13 +- drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c | 2177 + drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 33 + 9 files changed, 2909 insertions(+), 237 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 246f51fddf..9309eb68b7 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -831,9 +831,11 @@ struct bnxt { uint16_tport_svif; struct tf tfp; + struct tf tfp_shared; struct bnxt_ulp_context *ulp_ctx; struct bnxt_flow_stat_info *flow_stat; uint16_tmax_num_kflows; + uint8_t app_id; uint16_ttx_cfa_action; }; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 1c0eeb76b7..fdde9b2720 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -97,6 +97,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { #define BNXT_DEVARG_REP_Q_F2R "rep-q-f2r" #define BNXT_DEVARG_REP_FC_R2F "rep-fc-r2f" #define BNXT_DEVARG_REP_FC_F2R "rep-fc-f2r" +#define BNXT_DEVARG_APP_ID "app-id" static const char *const bnxt_dev_args[] = { BNXT_DEVARG_REPRESENTOR, @@ -109,6 +110,7 @@ static const char *const bnxt_dev_args[] = { BNXT_DEVARG_REP_Q_F2R, BNXT_DEVARG_REP_FC_R2F, BNXT_DEVARG_REP_FC_F2R, + BNXT_DEVARG_APP_ID, NULL }; @@ -118,6 +120,11 @@ static const char *const bnxt_dev_args[] = { */ #defineBNXT_DEVARG_ACCUM_STATS_INVALID(accum_stats)((accum_stats) > 1) +/* + * app-id = an non-negative 8-bit number + */ +#define BNXT_DEVARG_APP_ID_INVALID(val)((val) > 255) + /* * flow_xstat == false to disable the feature * flow_xstat == true to enable the feature @@ -5351,6 +5358,42 @@ bnxt_parse_devarg_max_num_kflows(__rte_unused const char *key, return 0; } +static int +bnxt_parse_devarg_app_id(__rte_unused const char *key, +const char *value, void *opaque_arg) +{ + struct bnxt *bp = opaque_arg; + unsigned long app_id; + char *end = NULL; + + if (!value || !opaque_arg) { + PMD_DRV_LOG(ERR, + "Invalid parameter passed to app-id " + "devargs.\n"); + return -EINVAL; + } + + app_id = strtoul(value, &end, 10); + if (end == NULL || *end != '\0' || + (app_id == ULONG_MAX && errno == ERANGE)) { + PMD_DRV_LOG(ERR, + "Invalid parameter passed to app_id " + "devargs.\n"); + return -EINVAL; + } + + if (BNXT_DEVARG_APP_ID_INVALID(app_id)) { + PMD_DRV_LOG(ERR, "Invalid app-id(%d) devargs.\n", + (uint16_t)app_id); + return -EINVAL; + } + + bp->app_id = app_id; + PMD_DRV_LOG(INFO, "app-id=%d feature enabled.\n", (uint16_t)app_id); + + return 0; +} + static int bnxt_parse_devarg_rep_is_pf(__rte_unused const char *key, const char *value, void *opaque_arg) @@ -5612,6 +5655,13 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs) goto err; err: + /* +* Handler for "app-id" devarg. +* Invoked as for ex: "-a 000:00:0d.0,app-id=1" +*/ + rte_kvargs_process(kvlist, BNXT_DEVARG_APP_ID, + bnxt_parse_devarg_app_id, bp); + rte_kvargs_free(kvlist); return ret; } diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index dd992a246b..632334674c 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -68,240 +68,336 @@ bnxt_ulp_devid_get(struct bnxt *bp, return 0; } +struct bnxt_ulp_app_capabilities_info * +bnxt_ulp_app_cap_list_get(uint32_t *num_entries) +{ + if (!num_entries) + return NULL; + *num_entries = BNXT_ULP_APP_CAP_TBL_MAX_SZ; + return ulp_app_cap_info_list; +} + +struct bnxt_ulp_resource_resv_info * +bnxt_ulp_r
[dpdk-dev] [PATCH 51/58] net/bnxt: process resource lists before session open
From: Mike Baucom Shared sessions require both named and unnamed resources to be requested during a tf_open_session. ULP uses named resources for global resources that are pre-allocated and remain through the life of the application. Unnamed resources are generally per flow resources and allocated on demand. The sum of both named and unnamed resources must be requested when initializing the session. The ulp_init now processes both lists prior to calling tf_open_session for both shared and regular sessions. Signed-off-by: Mike Baucom Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c| 177 -- drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 4 +- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 37 ++-- .../net/bnxt/tf_ulp/ulp_template_db_enum.h| 1 + drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c | 36 drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 6 + 6 files changed, 183 insertions(+), 78 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 632334674c..98b86f2c52 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -77,6 +77,15 @@ bnxt_ulp_app_cap_list_get(uint32_t *num_entries) return ulp_app_cap_info_list; } +static struct bnxt_ulp_resource_resv_info * +bnxt_ulp_app_resource_resv_list_get(uint32_t *num_entries) +{ + if (num_entries == NULL) + return NULL; + *num_entries = BNXT_ULP_APP_RESOURCE_RESV_LIST_MAX_SZ; + return ulp_app_resource_resv_list; +} + struct bnxt_ulp_resource_resv_info * bnxt_ulp_resource_resv_list_get(uint32_t *num_entries) { @@ -96,23 +105,18 @@ bnxt_ulp_app_glb_resource_info_list_get(uint32_t *num_entries) } static int32_t -bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx, - struct tf_session_resources *res) +bnxt_ulp_named_resources_calc(struct bnxt_ulp_context *ulp_ctx, + struct bnxt_ulp_glb_resource_info *info, + uint32_t num, + struct tf_session_resources *res) { - struct bnxt_ulp_resource_resv_info *info = NULL; - uint32_t dev_id, res_type, i, num; + uint32_t dev_id, res_type, i; enum tf_dir dir; uint8_t app_id; int32_t rc = 0; - if (!ulp_ctx || !res) { - BNXT_TF_DBG(ERR, "Invalid arguments to get resources.\n"); - return -EINVAL; - } - - info = bnxt_ulp_resource_resv_list_get(&num); - if (!info) { - BNXT_TF_DBG(ERR, "Unable to get resource reservation list.\n"); + if (ulp_ctx == NULL || info == NULL || res == NULL || num == 0) { + BNXT_TF_DBG(ERR, "Invalid parms to named resources calc.\n"); return -EINVAL; } @@ -124,31 +128,33 @@ bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx, rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id); if (rc) { - BNXT_TF_DBG(ERR, "Unable to get the device id from ulp.\n"); + BNXT_TF_DBG(ERR, "Unable to get the dev id from ulp.\n"); return -EINVAL; } for (i = 0; i < num; i++) { - if (app_id != info[i].app_id || dev_id != info[i].device_id) + if (dev_id != info[i].device_id || app_id != info[i].app_id) continue; dir = info[i].direction; res_type = info[i].resource_type; switch (info[i].resource_func) { case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER: - res->ident_cnt[dir].cnt[res_type] = info[i].count; + res->ident_cnt[dir].cnt[res_type]++; break; case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE: - res->tbl_cnt[dir].cnt[res_type] = info[i].count; + res->tbl_cnt[dir].cnt[res_type]++; break; case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE: - res->tcam_cnt[dir].cnt[res_type] = info[i].count; + res->tcam_cnt[dir].cnt[res_type]++; break; case BNXT_ULP_RESOURCE_FUNC_EM_TABLE: - res->em_cnt[dir].cnt[res_type] = info[i].count; + res->em_cnt[dir].cnt[res_type]++; break; default: - break; + BNXT_TF_DBG(ERR, "Unknown resource func (0x%x)\n,", + info[i].resource_func); + continue; } } @@ -156,14 +162,20 @@ bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx, } static int32_t -bnxt_ulp_tf_shared_session_resources_get(struct bnxt_ulp_context *ulp_ctx, -
[dpdk-dev] [PATCH 53/58] net/bnxt: add HA support in ULP
From: Mike Baucom Added the ability for cooperative applications to share resources and perform some high availability functions. Signed-off-by: Mike Baucom Signed-off-by: Venkat Duvvuru Reviewed-by: Shahaji Bhosle Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 59 +++ drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 10 + drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 15 +- drivers/net/bnxt/tf_ulp/meson.build | 1 + drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c| 551 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h| 67 +++ drivers/net/bnxt/tf_ulp/ulp_mapper.c| 52 ++- 7 files changed, 745 insertions(+), 10 deletions(-) create mode 100644 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c create mode 100644 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.h diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 0daa8e4c29..972bf8b992 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -23,6 +23,7 @@ #include "ulp_mapper.h" #include "ulp_port_db.h" #include "ulp_tun.h" +#include "ulp_ha_mgr.h" /* Linked list of all TF sessions. */ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list = @@ -315,6 +316,9 @@ bnxt_ulp_cntxt_app_caps_init(struct bnxt_ulp_context *ulp_ctx, if (info[i].flags & BNXT_ULP_APP_CAP_SHARED_EN) ulp_ctx->cfg_data->ulp_flags |= BNXT_ULP_SHARED_SESSION_ENABLED; + if (info[i].flags & BNXT_ULP_APP_CAP_HOT_UPGRADE_EN) + ulp_ctx->cfg_data->ulp_flags |= + BNXT_ULP_HIGH_AVAIL_ENABLED; } if (!found) { BNXT_TF_DBG(ERR, "APP ID %d, Device ID: 0x%x not supported.\n", @@ -1137,9 +1141,18 @@ static void bnxt_ulp_deinit(struct bnxt *bp, struct bnxt_ulp_session_state *session) { + bool ha_enabled; + if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data) return; + ha_enabled = bnxt_ulp_cntxt_ha_enabled(bp->ulp_ctx); + if (ha_enabled && session->session_opened) { + int32_t rc = ulp_ha_mgr_close(bp->ulp_ctx); + if (rc) + BNXT_TF_DBG(ERR, "Failed to close HA (%d)\n", rc); + } + /* clean up default flows */ bnxt_ulp_destroy_df_rules(bp, true); @@ -1179,6 +1192,9 @@ bnxt_ulp_deinit(struct bnxt *bp, /* free the flow db lock */ pthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock); + if (ha_enabled) + ulp_ha_mgr_deinit(bp->ulp_ctx); + /* Delete the ulp context and tf session and free the ulp context */ ulp_ctx_deinit(bp, session); BNXT_TF_DBG(DEBUG, "ulp ctx has been deinitialized\n"); @@ -1275,6 +1291,19 @@ bnxt_ulp_init(struct bnxt *bp, BNXT_TF_DBG(ERR, "Failed to set tx global configuration\n"); goto jump_to_error; } + + if (bnxt_ulp_cntxt_ha_enabled(bp->ulp_ctx)) { + rc = ulp_ha_mgr_init(bp->ulp_ctx); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to initialize HA %d\n", rc); + goto jump_to_error; + } + rc = ulp_ha_mgr_open(bp->ulp_ctx); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to Process HA Open %d\n", rc); + goto jump_to_error; + } + } BNXT_TF_DBG(DEBUG, "ulp ctx has been initialized\n"); return rc; @@ -1828,3 +1857,33 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx) pthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock); } + +/* Function to set the ha info into the context */ +int32_t +bnxt_ulp_cntxt_ptr2_ha_info_set(struct bnxt_ulp_context *ulp_ctx, + struct bnxt_ulp_ha_mgr_info *ulp_ha_info) +{ + if (ulp_ctx == NULL || ulp_ctx->cfg_data == NULL) { + BNXT_TF_DBG(ERR, "Invalid ulp context data\n"); + return -EINVAL; + } + ulp_ctx->cfg_data->ha_info = ulp_ha_info; + return 0; +} + +/* Function to retrieve the ha info from the context. */ +struct bnxt_ulp_ha_mgr_info * +bnxt_ulp_cntxt_ptr2_ha_info_get(struct bnxt_ulp_context *ulp_ctx) +{ + if (ulp_ctx == NULL || ulp_ctx->cfg_data == NULL) + return NULL; + return ulp_ctx->cfg_data->ha_info; +} + +bool +bnxt_ulp_cntxt_ha_enabled(struct bnxt_ulp_context *ulp_ctx) +{ + if (ulp_ctx == NULL || ulp_ctx->cfg_data == NULL) + return false; + return !!ULP_HIGH_AVAIL_IS_ENABLED(ulp_ctx->cfg_data->ulp_flags); +} diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h index 1ba67ed9f6..b1f090a5cb 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h @@ -67,6 +67,7 @@ struct bnxt_ulp_data { void*mapper_data;
[dpdk-dev] [PATCH 54/58] net/bnxt: add support for icmp6 ULP parsing
From: Kishore Padmanabha This patch adds support for parsing rte_flow items for icmp6 flows. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c | 4 +- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 48 +++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 5 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c index 7bd499faa6..35e9858727 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c @@ -346,8 +346,8 @@ struct bnxt_ulp_rte_hdr_info ulp_hdr_info[] = { .proto_hdr_func = NULL }, [RTE_FLOW_ITEM_TYPE_ICMP6] = { - .hdr_type= BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, - .proto_hdr_func = NULL + .hdr_type= BNXT_ULP_HDR_TYPE_SUPPORTED, + .proto_hdr_func = ulp_rte_icmp6_hdr_handler }, [RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS] = { .hdr_type= BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 0d52c0b93b..a55655a5bd 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -1599,6 +1599,54 @@ ulp_rte_icmp_hdr_handler(const struct rte_flow_item *item, return BNXT_TF_RC_SUCCESS; } +/* Function to handle the parsing of RTE Flow item ICMP6 Header. */ +int32_t +ulp_rte_icmp6_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params) +{ + const struct rte_flow_item_icmp6 *icmp_spec = item->spec; + const struct rte_flow_item_icmp6 *icmp_mask = item->mask; + struct ulp_rte_hdr_bitmap *hdr_bitmap = ¶ms->hdr_bitmap; + uint32_t idx = 0; + uint32_t size; + + if (ulp_rte_prsr_fld_size_validate(params, &idx, + BNXT_ULP_PROTO_HDR_ICMP_NUM)) { + BNXT_TF_DBG(ERR, "Error parsing protocol header\n"); + return BNXT_TF_RC_ERROR; + } + + size = sizeof(((struct rte_flow_item_icmp6 *)NULL)->type); + ulp_rte_prsr_fld_mask(params, &idx, size, + ulp_deference_struct(icmp_spec, type), + ulp_deference_struct(icmp_mask, type), + ULP_PRSR_ACT_DEFAULT); + + size = sizeof(((struct rte_flow_item_icmp6 *)NULL)->code); + ulp_rte_prsr_fld_mask(params, &idx, size, + ulp_deference_struct(icmp_spec, code), + ulp_deference_struct(icmp_mask, code), + ULP_PRSR_ACT_DEFAULT); + + size = sizeof(((struct rte_flow_item_icmp6 *)NULL)->checksum); + ulp_rte_prsr_fld_mask(params, &idx, size, + ulp_deference_struct(icmp_spec, checksum), + ulp_deference_struct(icmp_mask, checksum), + ULP_PRSR_ACT_DEFAULT); + + if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_IPV4)) { + BNXT_TF_DBG(ERR, "Error: incorrect icmp version\n"); + return BNXT_TF_RC_ERROR; + } + + /* Update the hdr_bitmap with ICMP */ + if (ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_L3_TUN)) + ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_I_ICMP); + else + ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_O_ICMP); + return BNXT_TF_RC_SUCCESS; +} + /* Function to handle the parsing of RTE Flow item void Header */ int32_t ulp_rte_void_hdr_handler(const struct rte_flow_item *item __rte_unused, diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index 66abe8e656..bbba10108c 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -147,6 +147,11 @@ int32_t ulp_rte_icmp_hdr_handler(const struct rte_flow_item *item, struct ulp_rte_parser_params *params); +/* Function to handle the parsing of RTE Flow item ICMP6 Header. */ +int32_t +ulp_rte_icmp6_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params); + /* Function to handle the parsing of RTE Flow item void Header. */ int32_t ulp_rte_void_hdr_handler(const struct rte_flow_item *item, -- 2.17.1
[dpdk-dev] [PATCH 55/58] net/bnxt: add support for ULP context list for timers
From: Kishore Padmanabha The alarm callback needs to have a valid context pointer when it is invoked, the context could become invalid if the port goes down and the callback is invoked before it is cancelled. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 95 drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 12 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 30 ++--- drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 37 +-- 4 files changed, 144 insertions(+), 30 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 972bf8b992..5f1540027c 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "bnxt.h" #include "bnxt_ulp.h" @@ -32,6 +33,17 @@ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list = /* Mutex to synchronize bnxt_ulp_session_list operations. */ static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER; +/* Spin lock to protect context global list */ +rte_spinlock_t bnxt_ulp_ctxt_lock; +TAILQ_HEAD(cntx_list_entry_list, ulp_context_list_entry); +static struct cntx_list_entry_list ulp_cntx_list = + TAILQ_HEAD_INITIALIZER(ulp_cntx_list); + +/* Static function declarations */ +static int32_t bnxt_ulp_cntxt_list_init(void); +static int32_t bnxt_ulp_cntxt_list_add(struct bnxt_ulp_context *ulp_ctx); +static void bnxt_ulp_cntxt_list_del(struct bnxt_ulp_context *ulp_ctx); + /* * Allow the deletion of context only for the bnxt device that * created the session. @@ -743,6 +755,16 @@ ulp_ctx_init(struct bnxt *bp, int32_t rc = 0; enum bnxt_ulp_device_id devid; + /* Initialize the context entries list */ + bnxt_ulp_cntxt_list_init(); + + /* Add the context to the context entries list */ + rc = bnxt_ulp_cntxt_list_add(bp->ulp_ctx); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add the context list entry\n"); + return -ENOMEM; + } + /* Allocate memory to hold ulp context data. */ ulp_data = rte_zmalloc("bnxt_ulp_data", sizeof(struct bnxt_ulp_data), 0); @@ -878,6 +900,13 @@ ulp_ctx_attach(struct bnxt *bp, /* update the session details in bnxt tfp */ bp->tfp.session = session->g_tfp->session; + /* Add the context to the context entries list */ + rc = bnxt_ulp_cntxt_list_add(bp->ulp_ctx); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add the context list entry\n"); + return -EINVAL; + } + /* * The supported flag will be set during the init. Use it now to * know if we should go through the attach. @@ -1448,6 +1477,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp) BNXT_TF_DBG(DEBUG, "BNXT Port:%d ULP port deinit\n", bp->eth_dev->data->port_id); + /* Free the ulp context in the context entry list */ + bnxt_ulp_cntxt_list_del(bp->ulp_ctx); + /* Get the session details */ pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device); pci_addr = &pci_dev->addr; @@ -1887,3 +1919,66 @@ bnxt_ulp_cntxt_ha_enabled(struct bnxt_ulp_context *ulp_ctx) return false; return !!ULP_HIGH_AVAIL_IS_ENABLED(ulp_ctx->cfg_data->ulp_flags); } + +static int32_t +bnxt_ulp_cntxt_list_init(void) +{ + /* Create the cntxt spin lock */ + rte_spinlock_init(&bnxt_ulp_ctxt_lock); + + return 0; +} + +static int32_t +bnxt_ulp_cntxt_list_add(struct bnxt_ulp_context *ulp_ctx) +{ + struct ulp_context_list_entry *entry; + + entry = rte_zmalloc(NULL, sizeof(struct ulp_context_list_entry), 0); + if (entry == NULL) { + BNXT_TF_DBG(ERR, "unable to allocate memory\n"); + return -ENOMEM; + } + + rte_spinlock_lock(&bnxt_ulp_ctxt_lock); + entry->ulp_ctx = ulp_ctx; + TAILQ_INSERT_TAIL(&ulp_cntx_list, entry, next); + rte_spinlock_unlock(&bnxt_ulp_ctxt_lock); + return 0; +} + +static void +bnxt_ulp_cntxt_list_del(struct bnxt_ulp_context *ulp_ctx) +{ + struct ulp_context_list_entry *entry, *temp; + + rte_spinlock_lock(&bnxt_ulp_ctxt_lock); + TAILQ_FOREACH_SAFE(entry, &ulp_cntx_list, next, temp) { + if (entry->ulp_ctx == ulp_ctx) { + TAILQ_REMOVE(&ulp_cntx_list, entry, next); + rte_free(entry); + break; + } + } + rte_spinlock_unlock(&bnxt_ulp_ctxt_lock); +} + +struct bnxt_ulp_context * +bnxt_ulp_cntxt_entry_acquire(void) +{ + struct ulp_context_list_entry *entry; + + /* take a lock and get the first ulp context available */ + if (rte_spinlock_trylock(&bnxt_ulp_ctxt_lock)) { + TAILQ_FOREACH(entry, &ulp_cntx_list, n
[dpdk-dev] [PATCH] net/mlx5: support flow dump value
Currently the flow dump provides few information about actions - just the pointers. Add implementations to display details for counter, modify_hdr and encap_decap actions. For counter, the regular flow operation query is engaged and the counter content information is provided, including hits and bytes values.For modify_hdr, encap_and decap actions, the information stored in the ipool objects is dumped. There are the formats of information presented in the dump: Counter: rec_type,id,hits,bytes Modify_hdr: rec_type,id,actions_number,actions Encap_decap: rec_type,id,buf Signed-off-by: Haifei Luo --- drivers/net/mlx5/mlx5.h | 15 drivers/net/mlx5/mlx5_flow.c | 165 ++- 2 files changed, 179 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 32b2817bf2..c958fd7a9a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1397,6 +1397,13 @@ struct rte_hairpin_peer_info { uint16_t manual_bind; }; +#define BUF_SIZE 1024 +enum dr_dump_rec_type { + DR_DUMP_REC_TYPE_PMD_PKT_REFORMAT = 4410, + DR_DUMP_REC_TYPE_PMD_MODIFY_HDR = 4420, + DR_DUMP_REC_TYPE_PMD_COUNTER = 4430, +}; + /* mlx5.c */ int mlx5_getenv_int(const char *); @@ -1628,6 +1635,14 @@ int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt, bool clear, uint64_t *pkts, uint64_t *bytes); int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow, FILE *file, struct rte_flow_error *error); +int save_dump_file(const unsigned char *data, uint32_t size, + uint32_t type, uint32_t id, void *arg, FILE *file); +int mlx5_flow_query_counter(struct rte_eth_dev *dev, struct rte_flow *flow, + struct rte_flow_query_count *count, struct rte_flow_error *error); +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +int mlx5_flow_dev_dump_ipool(struct rte_eth_dev *dev, struct rte_flow *flow, + FILE *file, struct rte_flow_error *error); +#endif void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev); int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index dbeca571b6..b6902a3cf1 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7846,6 +7846,157 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev) return 0; } +int +save_dump_file(const uint8_t *data, uint32_t size, + uint32_t type, uint32_t id, void *arg, FILE *file) +{ + char line[BUF_SIZE]; + uint32_t out = 0; + uint32_t k; + uint32_t actions_num; + struct rte_flow_query_count *count; + + memset(line, 0, BUF_SIZE); + switch (type) { + case DR_DUMP_REC_TYPE_PMD_MODIFY_HDR: + actions_num = *(uint32_t *)(arg); + out += snprintf(line + out, BUF_SIZE - out, "%d,0x%x,%d,", + type, id, actions_num); + break; + case DR_DUMP_REC_TYPE_PMD_PKT_REFORMAT: + out += snprintf(line + out, BUF_SIZE - out, "%d,0x%x,", + type, id); + break; + case DR_DUMP_REC_TYPE_PMD_COUNTER: + count = (struct rte_flow_query_count *)arg; + fprintf(file, "%d,0x%x,%" PRIu64 ",%" PRIu64 "\n", type, + id, count->hits, count->bytes); + return 0; + default: + return -1; + } + + for (k = 0; k < size; k++) { + /* Make sure we do not overrun the line buffer length. */ + if (out >= BUF_SIZE - 4) { + line[out] = '\0'; + break; + } + out += snprintf(line + out, BUF_SIZE - out, "%02x", + (data[k]) & 0xff); + } + fprintf(file, "%s\n", line); + return 0; +} + +int +mlx5_flow_query_counter(struct rte_eth_dev *dev, struct rte_flow *flow, + struct rte_flow_query_count *count, struct rte_flow_error *error) +{ + struct rte_flow_action action[2]; + enum mlx5_flow_drv_type ftype; + const struct mlx5_flow_driver_ops *fops; + + if (!flow) { + return rte_flow_error_set(error, ENOENT, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "invalid flow handle"); + } + action[0].type = RTE_FLOW_ACTION_TYPE_COUNT; + action[1].type = RTE_FLOW_ACTION_TYPE_END; + if (flow->counter) { + memset(count, 0, sizeof(struct rte_flow_query_count)); + ftype = (enum mlx5_flow_drv_type)(flow->drv_type); + MLX5_ASSERT(ftype > MLX5_FLOW_TYPE_MIN && + ftype < MLX5_FLOW_TYPE_MAX);
Re: [dpdk-dev] [RFC PATCH] ethdev: add support for testpmd-compliant flow rule dumping
On Sun, 30 May 2021 07:27:32 + Ori Kam wrote: > > > > DPDK applications (for example, OvS) or tests which use RTE flow API need to > > log created or rejected flow rules to help to recognise what goes right or > > wrong. From this standpoint, testpmd-compliant format is nice for the > > purpose because it allows to copy-paste the flow rules and debug using > > testpmd. > > > > Recognisable pattern items: > > VOID, VF, PF, PHY_PORT, PORT_ID, ETH, VLAN, IPV4, IPV6, UDP, TCP, VXLAN, > > NVGRE, GENEVE, MARK, PPPOES, PPPOED. > > > > Recognisable actions: > > VOID, JUMP, MARK, FLAG, QUEUE, DROP, COUNT, RSS, PF, VF, PHY_PORT, > > PORT_ID, OF_POP_VLAN, OF_PUSH_VLAN, OF_SET_VLAN_VID, > > OF_SET_VLAN_PCP, VXLAN_ENCAP, VXLAN_DECAP. > > > > Recognisable RSS types (action RSS): > > IPV4, FRAG_IPV4, NONFRAG_IPV4_TCP, NONFRAG_IPV4_UDP, > > NONFRAG_IPV4_OTHER, IPV6, FRAG_IPV6, NONFRAG_IPV6_TCP, > > NONFRAG_IPV6_UDP, NONFRAG_IPV6_OTHER, IPV6_EX, IPV6_TCP_EX, > > IPV6_UDP_EX, L3_SRC_ONLY, L3_DST_ONLY, L4_SRC_ONLY, L4_DST_ONLY. > > > > Unrecognised parts of the flow specification are represented by tokens > > "{unknown}" and "{unknown bits}". Interested parties are welcome to > > extend this tool to recognise more items and actions. > > > > Signed-off-by: Ivan Malov > > --- > > lib/ethdev/meson.build|1 + > > lib/ethdev/rte_flow.h | 33 + > > lib/ethdev/rte_flow_snprint.c | 1681 > > + > > lib/ethdev/version.map|3 + > > 4 files changed, 1718 insertions(+) > > create mode 100644 lib/ethdev/rte_flow_snprint.c > > > > diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index > > 0205c853df..97bba4fa1b 100644 > > --- a/lib/ethdev/meson.build > > +++ b/lib/ethdev/meson.build > > @@ -8,6 +8,7 @@ sources = files( > > 'rte_class_eth.c', > > 'rte_ethdev.c', > > 'rte_flow.c', > > + 'rte_flow_snprint.c', > > 'rte_mtr.c', > > 'rte_tm.c', > > ) > > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index > > 961a5884fe..cd5e9ef631 100644 > > --- a/lib/ethdev/rte_flow.h > > +++ b/lib/ethdev/rte_flow.h > > @@ -4288,6 +4288,39 @@ rte_flow_tunnel_item_release(uint16_t port_id, > > struct rte_flow_item *items, > > uint32_t num_of_items, > > struct rte_flow_error *error); > > + > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * Dump testpmd-compliant textual representation of the flow rule. > > + * Invoke this with zero-size buffer to learn the string size and > > + * invoke this for the second time to actually dump the flow rule. > > + * The buffer size on the second invocation = the string size + 1. > > + * > > + * @param[out] buf > > + * Buffer to save the dump in, or NULL > > + * @param buf_size > > + * Buffer size, or 0 > > + * @param[out] nb_chars_total > > + * Resulting string size (excluding the terminating null byte) > > + * @param[in] attr > > + * Flow rule attributes. > > + * @param[in] pattern > > + * Pattern specification (list terminated by the END pattern item). > > + * @param[in] actions > > + * Associated actions (list terminated by the END action). > > + * > > + * @return > > + * 0 on success, a negative errno value otherwise > > + */ > > +__rte_experimental > > +int > > +rte_flow_snprint(char *buf, size_t buf_size, size_t *nb_chars_total, > > +const struct rte_flow_attr *attr, > > +const struct rte_flow_item pattern[], > > +const struct rte_flow_action actions[]); > > + The code would be clearer and simpler if you adopted the same return value as snprintf. Then lots of places could be just tail calls and the nb_chars_total would be unnecessary.
[dpdk-dev] [PATCH v1] raw/ifpga/base: check address before assigning
In max10_staging_area_init(), variable "start" from fdt_get_reg() may be invalid, it should be checked before assigning to member variable "staging_area_base" of structure "intel_max10_device". Coverity issue: 367480, 367482 Fixes: a05bd1b40bde ("raw/ifpga: add FPGA RSU APIs") Cc: sta...@dpdk.org Signed-off-by: Wei Huang Acked-by: Tianfei Zhang --- drivers/raw/ifpga/base/opae_intel_max10.c | 14 ++ drivers/raw/ifpga/base/opae_intel_max10.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c index c223faf..9d82fb0 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.c +++ b/drivers/raw/ifpga/base/opae_intel_max10.c @@ -593,10 +593,16 @@ static int max10_staging_area_init(struct intel_max10_device *dev) continue; ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); - if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { - dev->staging_area_base = start; - dev->staging_area_size = size; - } + if (ret) + return ret; + + if ((start & 0x3) || (start > MAX_STAGING_AREA_BASE) || + (size > MAX_STAGING_AREA_SIZE)) + return -EINVAL; + + dev->staging_area_base = start; + dev->staging_area_size = size; + return ret; } diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h index e7142d6..e761d7e 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.h +++ b/drivers/raw/ifpga/base/opae_intel_max10.h @@ -182,6 +182,7 @@ struct opae_retimer_status { #define SBUS_VERSION GENMASK(31, 16) #define DFT_MAX_SIZE 0x7e +#define MAX_STAGING_AREA_BASE 0x #define MAX_STAGING_AREA_SIZE 0x380 int max10_reg_read(struct intel_max10_device *dev, -- 1.8.3.1
[dpdk-dev] [PATCH v2 0/4] support AVF RSS and FDIR for GTPoGRE packet
Support AVF RSS and FDIR for GTPoGRE packet. Lingyu Liu (4): net/iavf: support flow pattern for GTPoGRE common/iavf: add header types for GRE net/iavf: support AVF FDIR for GTPoGRE tunnel packet net/iavf: support AVF RSS for GTPoGRE packet --- V2 change: - append new protocol to the tail - correct commit message title drivers/common/iavf/virtchnl.h | 1 + drivers/net/iavf/iavf_fdir.c | 42 drivers/net/iavf/iavf_generic_flow.c | 288 +++ drivers/net/iavf/iavf_generic_flow.h | 40 drivers/net/iavf/iavf_hash.c | 24 +++ 5 files changed, 395 insertions(+) -- 2.25.1
[dpdk-dev] [PATCH v2 1/4] net/iavf: support flow pattern for GTPoGRE
Add GTPoGRE pattern support for AVF FDIR and RSS. Signed-off-by: Lingyu Liu --- drivers/net/iavf/iavf_generic_flow.c | 288 +++ drivers/net/iavf/iavf_generic_flow.h | 40 2 files changed, 328 insertions(+) diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_generic_flow.c index 242bb4abc5..aec9281677 100644 --- a/drivers/net/iavf/iavf_generic_flow.c +++ b/drivers/net/iavf/iavf_generic_flow.c @@ -433,6 +433,294 @@ enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv4_icmp[] = { RTE_FLOW_ITEM_TYPE_END, }; +/* IPV4 GRE IPv4 UDP GTPU IPv4*/ +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_udp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_tcp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_TCP, + RTE_FLOW_ITEM_TYPE_END, +}; + +/* IPV4 GRE IPv4 UDP GTPU IPv6*/ +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_udp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_tcp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_TCP, + RTE_FLOW_ITEM_TYPE_END, +}; + +/* IPV4 GRE IPv6 UDP GTPU IPv4*/ +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_udp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_tcp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_TCP, + RTE_FLOW_ITEM_TYPE_END, +}; + +/* IPV4 GRE IPv4 UDP GTPU IPv6*/ +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_udp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_GTPU, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, +}; + +enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_tcp[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_
[dpdk-dev] [PATCH v2 2/4] common/iavf: add header types for GRE
Add a virtchnl protocol header type to support AVF FDIR and RSS for GRE. Signed-off-by: Lingyu Liu --- drivers/common/iavf/virtchnl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/common/iavf/virtchnl.h b/drivers/common/iavf/virtchnl.h index 3a60faff93..197edce8a1 100644 --- a/drivers/common/iavf/virtchnl.h +++ b/drivers/common/iavf/virtchnl.h @@ -1504,6 +1504,7 @@ enum virtchnl_proto_hdr_type { */ VIRTCHNL_PROTO_HDR_IPV4_FRAG, VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, + VIRTCHNL_PROTO_HDR_GRE, }; /* Protocol header field within a protocol header. */ -- 2.25.1
[dpdk-dev] [PATCH v2 3/4] net/iavf: support AVF FDIR for GTPoGRE tunnel packet
Support AVF FDIR for inner header of GTPoGRE tunnel packet. +---+---+ | Pattern |Input Set | +---+---+ |eth/ipv4/gre/ipv4/udp/gtpu/ipv4|inner: src/dst ip | |eth/ipv4/gre/ipv4/udp/gtpu/ipv4/udp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv4/udp/gtpu/ipv4/tcp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv4/udp/gtpu/ipv6|inner: src/dst ip | |eth/ipv4/gre/ipv4/udp/gtpu/ipv6/udp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv4/udp/gtpu/ipv6/tcp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv6/udp/gtpu/ipv4|inner: src/dst ip | |eth/ipv4/gre/ipv6/udp/gtpu/ipv4/udp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv6/udp/gtpu/ipv4/tcp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv6/udp/gtpu/ipv6|inner: src/dst ip | |eth/ipv4/gre/ipv6/udp/gtpu/ipv6/udp|inner: src/dst ip, src/dst port| |eth/ipv4/gre/ipv6/udp/gtpu/ipv6/tcp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv4/udp/gtpu/ipv4|inner: src/dst ip | |eth/ipv6/gre/ipv4/udp/gtpu/ipv4/udp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv4/udp/gtpu/ipv4/tcp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv4/udp/gtpu/ipv6|inner: src/dst ip | |eth/ipv6/gre/ipv4/udp/gtpu/ipv6/udp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv4/udp/gtpu/ipv6/tcp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv6/udp/gtpu/ipv4|inner: src/dst ip | |eth/ipv6/gre/ipv6/udp/gtpu/ipv4/udp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv6/udp/gtpu/ipv4/tcp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv6/udp/gtpu/ipv6|inner: src/dst ip | |eth/ipv6/gre/ipv6/udp/gtpu/ipv6/udp|inner: src/dst ip, src/dst port| |eth/ipv6/gre/ipv6/udp/gtpu/ipv6/tcp|inner: src/dst ip, src/dst port| +---+---+ Signed-off-by: Lingyu Liu --- drivers/net/iavf/iavf_fdir.c | 42 1 file changed, 42 insertions(+) diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index f238a83c84..75f2d75143 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -164,6 +164,30 @@ static struct iavf_pattern_match_item iavf_fdir_pattern[] = { {iavf_pattern_eth_ipv4_gtpu_eh_ipv6, IAVF_FDIR_INSET_GTPU_IPV6, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_gtpu_eh_ipv6_udp, IAVF_FDIR_INSET_GTPU_IPV6_UDP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_gtpu_eh_ipv6_tcp, IAVF_FDIR_INSET_GTPU_IPV6_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4, IAVF_FDIR_INSET_GTPU_IPV4, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_udp, IAVF_FDIR_INSET_GTPU_IPV4_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_tcp, IAVF_FDIR_INSET_GTPU_IPV4_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6, IAVF_FDIR_INSET_GTPU_IPV6, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_udp, IAVF_FDIR_INSET_GTPU_IPV6_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_tcp, IAVF_FDIR_INSET_GTPU_IPV6_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4, IAVF_FDIR_INSET_GTPU_IPV4, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_udp, IAVF_FDIR_INSET_GTPU_IPV4_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_tcp, IAVF_FDIR_INSET_GTPU_IPV4_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6, IAVF_FDIR_INSET_GTPU_IPV6, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_udp, IAVF_FDIR_INSET_GTPU_IPV6_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_tcp, IAVF_FDIR_INSET_GTPU_IPV6_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4, IAVF_FDIR_INSET_GTPU_IPV4, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4_udp, IAVF_FDIR_INSET_GTPU_IPV4_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4_tcp, IAVF_FDIR_INSET_GTPU_IPV4_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6, IAVF_FDIR_INSET_GTPU_IPV6, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6_udp, IAVF_FDIR_INSET_GTPU_IPV6_UDP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6_tcp, IAVF_FDIR_INSET_GTPU_IPV6_TCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv4, IAVF_FDIR_INSET_GTPU_IPV4, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv4_udp, IAVF_FDIR_INSET_GTPU_IPV4_UD
[dpdk-dev] [PATCH v2 4/4] net/iavf: support AVF RSS for GTPoGRE packet
Support AVF RSS for inner most header of GTPoGRE packet. It supports RSS based on inner most IP src + dst address and TCP/UDP src + dst port. Signed-off-by: Lingyu Liu --- drivers/net/iavf/iavf_hash.c | 24 1 file changed, 24 insertions(+) diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index 5d3d62839b..b98e4ffc7e 100644 --- a/drivers/net/iavf/iavf_hash.c +++ b/drivers/net/iavf/iavf_hash.c @@ -420,6 +420,30 @@ static struct iavf_pattern_match_item iavf_hash_pattern_list[] = { {iavf_pattern_eth_ipv6_gtpu_eh_ipv4, IAVF_RSS_TYPE_GTPU_IPV4,&inner_ipv4_tmplt}, {iavf_pattern_eth_ipv6_gtpu_eh_ipv4_udp, IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt}, {iavf_pattern_eth_ipv6_gtpu_eh_ipv4_tcp, IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4, IAVF_RSS_TYPE_GTPU_IPV4,&inner_ipv4_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_udp, IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv4_tcp, IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6, IAVF_RSS_TYPE_GTPU_IPV6,&inner_ipv6_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_udp, IAVF_RSS_TYPE_GTPU_IPV6_UDP,&inner_ipv6_udp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv4_udp_gtpu_ipv6_tcp, IAVF_RSS_TYPE_GTPU_IPV6_TCP,&inner_ipv6_tcp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4, IAVF_RSS_TYPE_GTPU_IPV4,&inner_ipv4_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_udp, IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv4_tcp, IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6, IAVF_RSS_TYPE_GTPU_IPV6,&inner_ipv6_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_udp, IAVF_RSS_TYPE_GTPU_IPV6_UDP,&inner_ipv6_udp_tmplt}, + {iavf_pattern_eth_ipv4_gre_ipv6_udp_gtpu_ipv6_tcp, IAVF_RSS_TYPE_GTPU_IPV6_TCP,&inner_ipv6_tcp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4, IAVF_RSS_TYPE_GTPU_IPV4,&inner_ipv4_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4_udp, IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv4_tcp, IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6, IAVF_RSS_TYPE_GTPU_IPV6,&inner_ipv6_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6_udp, IAVF_RSS_TYPE_GTPU_IPV6_UDP,&inner_ipv6_udp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv4_udp_gtpu_ipv6_tcp, IAVF_RSS_TYPE_GTPU_IPV6_TCP,&inner_ipv6_tcp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv4, IAVF_RSS_TYPE_GTPU_IPV4,&inner_ipv4_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv4_udp, IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv4_tcp, IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv6, IAVF_RSS_TYPE_GTPU_IPV6,&inner_ipv6_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv6_udp, IAVF_RSS_TYPE_GTPU_IPV6_UDP,&inner_ipv6_udp_tmplt}, + {iavf_pattern_eth_ipv6_gre_ipv6_udp_gtpu_ipv6_tcp, IAVF_RSS_TYPE_GTPU_IPV6_TCP,&inner_ipv6_tcp_tmplt}, {iavf_pattern_eth_ipv4_esp, IAVF_RSS_TYPE_IPV4_ESP, &ipv4_esp_tmplt}, {iavf_pattern_eth_ipv4_udp_esp, IAVF_RSS_TYPE_IPV4_ESP, &ipv4_udp_esp_tmplt}, {iavf_pattern_eth_ipv4_ah, IAVF_RSS_TYPE_IPV4_AH, &ipv4_ah_tmplt}, -- 2.25.1
[dpdk-dev] [PATCH v1] lib/vhost: enable IOMMU for async vhost
From: Xuan Ding For async copy, it is unsafe to directly use the physical address. and current address translation from GPA to HPA via SW also takes CPU cycles, these can all benefit from IOMMU. Since the existing DMA engine supports to use platform IOMMU, this patch enables IOMMU for async vhost, which defines IOAT devices to use virtual address instead of physical address. When set memory table, the frontend's memory will be mapped to the default container of DPDK where IOAT devices has been added into. When DMA copy fails, the virtual address provided to IOAT devices also allow us fallback to SW copy or PA copy. With IOMMU enabled, to use IOAT devices: 1. IOAT devices must be binded to vfio-pci, rather than igb_uio. 2. DPDK must use "--iova-mode=va". Signed-off-by: Xuan Ding --- doc/guides/prog_guide/vhost_lib.rst | 17 + lib/vhost/vhost_user.c | 102 lib/vhost/virtio_net.c | 30 +++- 3 files changed, 41 insertions(+), 108 deletions(-) diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst index d18fb98910..6b7206bc1d 100644 --- a/doc/guides/prog_guide/vhost_lib.rst +++ b/doc/guides/prog_guide/vhost_lib.rst @@ -420,3 +420,20 @@ Finally, a set of device ops is defined for device specific operations: * ``get_notify_area`` Called to get the notify area info of the queue. + + Vhost async data path + --- +* Address mode +Modern IOAT devices supports to use the IOMMU, which can avoid using +the unsafe HPA. Besides, the CPU cycles took by SW to translate from +GPA to HPA can also be saved. So IOAT devices are defined to use +virtual address instead of physical address. + +With IOMMU enabled, to use IOAT devices: +1. IOAT devices must be binded to vfio-pci, rather than igb_uio. +2. DPDK must use ``--iova-mode=va``. + +* Fallback +When the DMA copy fails, the user who implements the transfer_data +callback can fallback to SW copy or fallback to PA through +rte_mem_virt2iova(). diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 8f0eba6412..4d562e0091 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "iotlb.h" #include "vhost.h" @@ -866,87 +867,6 @@ vhost_user_set_vring_base(struct virtio_net **pdev, return RTE_VHOST_MSG_RESULT_OK; } -static int -add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, - uint64_t host_phys_addr, uint64_t size) -{ - struct guest_page *page, *last_page; - struct guest_page *old_pages; - - if (dev->nr_guest_pages == dev->max_guest_pages) { - dev->max_guest_pages *= 2; - old_pages = dev->guest_pages; - dev->guest_pages = rte_realloc(dev->guest_pages, - dev->max_guest_pages * sizeof(*page), - RTE_CACHE_LINE_SIZE); - if (dev->guest_pages == NULL) { - VHOST_LOG_CONFIG(ERR, "cannot realloc guest_pages\n"); - rte_free(old_pages); - return -1; - } - } - - if (dev->nr_guest_pages > 0) { - last_page = &dev->guest_pages[dev->nr_guest_pages - 1]; - /* merge if the two pages are continuous */ - if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; - return 0; - } - } - - page = &dev->guest_pages[dev->nr_guest_pages++]; - page->guest_phys_addr = guest_phys_addr; - page->host_phys_addr = host_phys_addr; - page->size = size; - - return 0; -} - -static int -add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg, - uint64_t page_size) -{ - uint64_t reg_size = reg->size; - uint64_t host_user_addr = reg->host_user_addr; - uint64_t guest_phys_addr = reg->guest_phys_addr; - uint64_t host_phys_addr; - uint64_t size; - - host_phys_addr = rte_mem_virt2iova((void *)(uintptr_t)host_user_addr); - size = page_size - (guest_phys_addr & (page_size - 1)); - size = RTE_MIN(size, reg_size); - - if (add_one_guest_page(dev, guest_phys_addr, host_phys_addr, size) < 0) - return -1; - - host_user_addr += size; - guest_phys_addr += size; - reg_size -= size; - - while (reg_size > 0) { - size = RTE_MIN(reg_size, page_size); - host_phys_addr = rte_mem_virt2iova((void *)(uintptr_t) - host_user_addr); - if (add_one_guest_page(dev, guest_phys_addr, host_phys_addr, - size) < 0) - return -