From patchwork Fri Jun 12 13:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 71436 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D065A00BE; Fri, 12 Jun 2020 15:51:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C8E861D182; Fri, 12 Jun 2020 15:35:07 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id B0C701D162 for ; Fri, 12 Jun 2020 15:35:03 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 87E401BD7DF; Fri, 12 Jun 2020 06:35:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 87E401BD7DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968903; bh=Ebbp/vlSweehkFFfKdI1JqK3UyhaN01lLdV0JaITHgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BSbqcFz8BF5bxCuod05+w0ZwuJYU7dtj5MIDgmCwWqSEv7kFzoB1CEgWY0GVzXDTS VUME6tNgoZlcL6oos6/hlRL8lY4jQzWlKABOirSTgpk9TSNWKNc6+MCwoAY8wNJEt9 VMCRreCkYyd9p0yqs422qEAQ1F5dFK0OE8uh5KrY= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:59:28 +0530 Message-Id: <20200612132934.16488-45-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200612132934.16488-1-somnath.kotur@broadcom.com> References: <20200612132934.16488-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 44/50] net/bnxt: fill mapper parameters with default rules info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Venkat Duvvuru Default rules are needed for the packets to be punted between the following entities in the non-offloaded path 1. Device PORT to DPDK App 2. DPDK App to Device PORT 3. VF Representor to VF 4. VF to VF Representor This patch fills all the relevant information in the computed fields & the act_prop fields for the flow mapper to create the necessary tables in the hardware to enable the default rules. Signed-off-by: Venkat Duvvuru Reviewed-by: Ajit Kumar Khaparde Signed-off-by: Somnath Kotur --- config/common_base | 4 +- drivers/net/bnxt/bnxt_ethdev.c | 6 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bnxt/tf_ulp/Makefile | 1 + drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 24 ++ drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 30 +- drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 385 +++++++++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_mapper.c | 10 +- drivers/net/bnxt/tf_ulp/ulp_mapper.h | 3 +- drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h | 5 + 10 files changed, 447 insertions(+), 22 deletions(-) create mode 100644 drivers/net/bnxt/tf_ulp/ulp_def_rules.c diff --git a/config/common_base b/config/common_base index ccd03aa..30fb3a4 100644 --- a/config/common_base +++ b/config/common_base @@ -104,7 +104,7 @@ CONFIG_RTE_LOG_HISTORY=256 CONFIG_RTE_BACKTRACE=y CONFIG_RTE_LIBEAL_USE_HPET=n CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n -CONFIG_RTE_EAL_IGB_UIO=n +CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 CONFIG_RTE_MAX_VFIO_CONTAINERS=64 @@ -1137,3 +1137,5 @@ CONFIG_RTE_APP_CRYPTO_PERF=y # Compile the eventdev application # CONFIG_RTE_APP_EVENTDEV=y + +CONFIG_RTE_LIBRTE_BNXT_TRUFLOW_DEBUG=y diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0b38c84..de8e11a 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1275,9 +1275,6 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - if (BNXT_TRUFLOW_EN(bp)) - bnxt_ulp_deinit(bp); - eth_dev->data->dev_started = 0; /* Prevent crashes when queues are still in use */ eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts; @@ -1333,6 +1330,9 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp); bnxt_cancel_fc_thread(bp); + if (BNXT_TRUFLOW_EN(bp)) + bnxt_ulp_deinit(bp); + if (eth_dev->data->dev_started) bnxt_dev_stop_op(eth_dev); diff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build index 8f6ed41..2939857 100644 --- a/drivers/net/bnxt/meson.build +++ b/drivers/net/bnxt/meson.build @@ -61,6 +61,7 @@ sources = files('bnxt_cpr.c', 'tf_ulp/ulp_rte_parser.c', 'tf_ulp/bnxt_ulp_flow.c', 'tf_ulp/ulp_port_db.c', + 'tf_ulp/ulp_def_rules.c', 'rte_pmd_bnxt.c') diff --git a/drivers/net/bnxt/tf_ulp/Makefile b/drivers/net/bnxt/tf_ulp/Makefile index 57341f8..3f1b43b 100644 --- a/drivers/net/bnxt/tf_ulp/Makefile +++ b/drivers/net/bnxt/tf_ulp/Makefile @@ -16,3 +16,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mark_mgr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_flow_db.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_def_rules.c diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h index eecc09c..3563f63 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h @@ -12,6 +12,8 @@ #include "rte_ethdev.h" +#include "ulp_template_db_enum.h" + struct bnxt_ulp_data { uint32_t tbl_scope_id; struct bnxt_ulp_mark_tbl *mark_tbl; @@ -49,6 +51,12 @@ struct rte_tf_flow { uint32_t flow_id; }; +struct ulp_tlv_param { + enum bnxt_ulp_df_param_type type; + uint32_t length; + uint8_t value[16]; +}; + /* * Allow the deletion of context only for the bnxt device that * created the session @@ -127,4 +135,20 @@ bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx, struct bnxt_ulp_port_db * bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx); +/* Function to create default flows. */ +int32_t +ulp_default_flow_create(struct rte_eth_dev *eth_dev, + struct ulp_tlv_param *param_list, + uint32_t ulp_class_tid, + uint32_t *flow_id); + +/* Function to destroy default flows. */ +int32_t +ulp_default_flow_destroy(struct rte_eth_dev *eth_dev, + uint32_t flow_id); + +int +bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, + struct rte_flow_error *error); + #endif /* _BNXT_ULP_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 138b0b7..7ef306e 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -207,7 +207,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev, } /* Function to destroy the rte flow. */ -static int +int bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) @@ -220,9 +220,10 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev); if (!ulp_ctx) { BNXT_TF_DBG(ERR, "ULP context is not initialized\n"); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Failed to destroy flow."); + if (error) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to destroy flow."); return -EINVAL; } @@ -233,17 +234,22 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) == false) { BNXT_TF_DBG(ERR, "Incorrect device params\n"); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Failed to destroy flow."); + if (error) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to destroy flow."); return -EINVAL; } - ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id); - if (ret) - rte_flow_error_set(error, -ret, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Failed to destroy flow."); + ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id, + BNXT_ULP_REGULAR_FLOW_TABLE); + if (ret) { + BNXT_TF_DBG(ERR, "Failed to destroy flow.\n"); + if (error) + rte_flow_error_set(error, -ret, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to destroy flow."); + } return ret; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c new file mode 100644 index 0000000..46b558f --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c @@ -0,0 +1,385 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include "bnxt_tf_common.h" +#include "ulp_template_struct.h" +#include "ulp_template_db_enum.h" +#include "ulp_template_db_field.h" +#include "ulp_utils.h" +#include "ulp_port_db.h" +#include "ulp_flow_db.h" +#include "ulp_mapper.h" + +struct bnxt_ulp_def_param_handler { + int32_t (*vfr_func)(struct bnxt_ulp_context *ulp_ctx, + struct ulp_tlv_param *param, + struct bnxt_ulp_mapper_create_parms *mapper_params); +}; + +static int32_t +ulp_set_svif_in_comp_fld(struct bnxt_ulp_context *ulp_ctx, + uint32_t ifindex, uint8_t svif_type, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t svif; + uint8_t idx; + int rc; + + rc = ulp_port_db_svif_get(ulp_ctx, ifindex, svif_type, &svif); + if (rc) + return rc; + + if (svif_type == BNXT_ULP_PHY_PORT_SVIF) + idx = BNXT_ULP_CF_IDX_PHY_PORT_SVIF; + else if (svif_type == BNXT_ULP_DRV_FUNC_SVIF) + idx = BNXT_ULP_CF_IDX_DRV_FUNC_SVIF; + else + idx = BNXT_ULP_CF_IDX_VF_FUNC_SVIF; + + ULP_COMP_FLD_IDX_WR(mapper_params, idx, svif); + + return 0; +} + +static int32_t +ulp_set_spif_in_comp_fld(struct bnxt_ulp_context *ulp_ctx, + uint32_t ifindex, uint8_t spif_type, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t spif; + uint8_t idx; + int rc; + + rc = ulp_port_db_spif_get(ulp_ctx, ifindex, spif_type, &spif); + if (rc) + return rc; + + if (spif_type == BNXT_ULP_PHY_PORT_SPIF) + idx = BNXT_ULP_CF_IDX_PHY_PORT_SPIF; + else if (spif_type == BNXT_ULP_DRV_FUNC_SPIF) + idx = BNXT_ULP_CF_IDX_DRV_FUNC_SPIF; + else + idx = BNXT_ULP_CF_IDX_VF_FUNC_SPIF; + + ULP_COMP_FLD_IDX_WR(mapper_params, idx, spif); + + return 0; +} + +static int32_t +ulp_set_parif_in_comp_fld(struct bnxt_ulp_context *ulp_ctx, + uint32_t ifindex, uint8_t parif_type, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t parif; + uint8_t idx; + int rc; + + rc = ulp_port_db_parif_get(ulp_ctx, ifindex, parif_type, &parif); + if (rc) + return rc; + + if (parif_type == BNXT_ULP_PHY_PORT_PARIF) + idx = BNXT_ULP_CF_IDX_PHY_PORT_PARIF; + else if (parif_type == BNXT_ULP_DRV_FUNC_PARIF) + idx = BNXT_ULP_CF_IDX_DRV_FUNC_PARIF; + else + idx = BNXT_ULP_CF_IDX_VF_FUNC_PARIF; + + ULP_COMP_FLD_IDX_WR(mapper_params, idx, parif); + + return 0; +} + +static int32_t +ulp_set_vport_in_comp_fld(struct bnxt_ulp_context *ulp_ctx, uint32_t ifindex, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t vport; + int rc; + + rc = ulp_port_db_vport_get(ulp_ctx, ifindex, &vport); + if (rc) + return rc; + + ULP_COMP_FLD_IDX_WR(mapper_params, BNXT_ULP_CF_IDX_PHY_PORT_VPORT, + vport); + return 0; +} + +static int32_t +ulp_set_vnic_in_comp_fld(struct bnxt_ulp_context *ulp_ctx, + uint32_t ifindex, uint8_t vnic_type, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t vnic; + uint8_t idx; + int rc; + + rc = ulp_port_db_default_vnic_get(ulp_ctx, ifindex, vnic_type, &vnic); + if (rc) + return rc; + + if (vnic_type == BNXT_ULP_DRV_FUNC_VNIC) + idx = BNXT_ULP_CF_IDX_DRV_FUNC_VNIC; + else + idx = BNXT_ULP_CF_IDX_VF_FUNC_VNIC; + + ULP_COMP_FLD_IDX_WR(mapper_params, idx, vnic); + + return 0; +} + +static int32_t +ulp_set_vlan_in_act_prop(uint16_t port_id, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + struct ulp_rte_act_prop *act_prop = mapper_params->act_prop; + + if (ULP_BITMAP_ISSET(mapper_params->act->bits, + BNXT_ULP_ACTION_BIT_SET_VLAN_VID)) { + BNXT_TF_DBG(ERR, + "VLAN already set, multiple VLANs unsupported\n"); + return BNXT_TF_RC_ERROR; + } + + port_id = rte_cpu_to_be_16(port_id); + + ULP_BITMAP_SET(mapper_params->act->bits, + BNXT_ULP_ACTION_BIT_SET_VLAN_VID); + + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG], + &port_id, sizeof(port_id)); + + return 0; +} + +static int32_t +ulp_set_mark_in_act_prop(uint16_t port_id, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + if (ULP_BITMAP_ISSET(mapper_params->act->bits, + BNXT_ULP_ACTION_BIT_MARK)) { + BNXT_TF_DBG(ERR, + "MARK already set, multiple MARKs unsupported\n"); + return BNXT_TF_RC_ERROR; + } + + ULP_COMP_FLD_IDX_WR(mapper_params, BNXT_ULP_CF_IDX_DEV_PORT_ID, + port_id); + + return 0; +} + +static int32_t +ulp_df_dev_port_handler(struct bnxt_ulp_context *ulp_ctx, + struct ulp_tlv_param *param, + struct bnxt_ulp_mapper_create_parms *mapper_params) +{ + uint16_t port_id; + uint32_t ifindex; + int rc; + + port_id = param->value[0] | param->value[1]; + + rc = ulp_port_db_dev_port_to_ulp_index(ulp_ctx, port_id, &ifindex); + if (rc) { + BNXT_TF_DBG(ERR, + "Invalid port id\n"); + return BNXT_TF_RC_ERROR; + } + + /* Set port SVIF */ + rc = ulp_set_svif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_PHY_PORT_SVIF, + mapper_params); + if (rc) + return rc; + + /* Set DRV Func SVIF */ + rc = ulp_set_svif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_DRV_FUNC_SVIF, + mapper_params); + if (rc) + return rc; + + /* Set VF Func SVIF */ + rc = ulp_set_svif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_VF_FUNC_SVIF, + mapper_params); + if (rc) + return rc; + + /* Set port SPIF */ + rc = ulp_set_spif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_PHY_PORT_SPIF, + mapper_params); + if (rc) + return rc; + + /* Set DRV Func SPIF */ + rc = ulp_set_spif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_DRV_FUNC_SPIF, + mapper_params); + if (rc) + return rc; + + /* Set VF Func SPIF */ + rc = ulp_set_spif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_DRV_FUNC_SPIF, + mapper_params); + if (rc) + return rc; + + /* Set port PARIF */ + rc = ulp_set_parif_in_comp_fld(ulp_ctx, ifindex, + BNXT_ULP_PHY_PORT_PARIF, mapper_params); + if (rc) + return rc; + + /* Set DRV Func PARIF */ + rc = ulp_set_parif_in_comp_fld(ulp_ctx, ifindex, + BNXT_ULP_DRV_FUNC_PARIF, mapper_params); + if (rc) + return rc; + + /* Set VF Func PARIF */ + rc = ulp_set_parif_in_comp_fld(ulp_ctx, ifindex, BNXT_ULP_VF_FUNC_PARIF, + mapper_params); + if (rc) + return rc; + + /* Set uplink VNIC */ + rc = ulp_set_vnic_in_comp_fld(ulp_ctx, ifindex, true, mapper_params); + if (rc) + return rc; + + /* Set VF VNIC */ + rc = ulp_set_vnic_in_comp_fld(ulp_ctx, ifindex, false, mapper_params); + if (rc) + return rc; + + /* Set VPORT */ + rc = ulp_set_vport_in_comp_fld(ulp_ctx, ifindex, mapper_params); + if (rc) + return rc; + + /* Set VLAN */ + rc = ulp_set_vlan_in_act_prop(port_id, mapper_params); + if (rc) + return rc; + + /* Set MARK */ + rc = ulp_set_mark_in_act_prop(port_id, mapper_params); + if (rc) + return rc; + + return 0; +} + +struct bnxt_ulp_def_param_handler ulp_def_handler_tbl[] = { + [BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID] = { + .vfr_func = ulp_df_dev_port_handler } +}; + +/* + * Function to create default rules for the following paths + * 1) Device PORT to DPDK App + * 2) DPDK App to Device PORT + * 3) VF Representor to VF + * 4) VF to VF Representor + * + * eth_dev [in] Ptr to rte eth device. + * param_list [in] Ptr to a list of parameters (Currently, only DPDK port_id). + * ulp_class_tid [in] Class template ID number. + * flow_id [out] Ptr to flow identifier. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_default_flow_create(struct rte_eth_dev *eth_dev, + struct ulp_tlv_param *param_list, + uint32_t ulp_class_tid, + uint32_t *flow_id) +{ + struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX]; + uint32_t comp_fld[BNXT_ULP_CF_IDX_LAST]; + struct bnxt_ulp_mapper_create_parms mapper_params = { 0 }; + struct ulp_rte_act_prop act_prop; + struct ulp_rte_act_bitmap act = { 0 }; + struct bnxt_ulp_context *ulp_ctx; + uint32_t type; + int rc; + + memset(&mapper_params, 0, sizeof(mapper_params)); + memset(hdr_field, 0, sizeof(hdr_field)); + memset(comp_fld, 0, sizeof(comp_fld)); + memset(&act_prop, 0, sizeof(act_prop)); + + mapper_params.hdr_field = hdr_field; + mapper_params.act = &act; + mapper_params.act_prop = &act_prop; + mapper_params.comp_fld = comp_fld; + + ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev); + if (!ulp_ctx) { + BNXT_TF_DBG(ERR, "ULP context is not initialized. " + "Failed to create default flow.\n"); + return -EINVAL; + } + + type = param_list->type; + while (type != BNXT_ULP_DF_PARAM_TYPE_LAST) { + if (ulp_def_handler_tbl[type].vfr_func) { + rc = ulp_def_handler_tbl[type].vfr_func(ulp_ctx, + param_list, + &mapper_params); + if (rc) { + BNXT_TF_DBG(ERR, + "Failed to create default flow.\n"); + return rc; + } + } + + param_list++; + type = param_list->type; + } + + mapper_params.class_tid = ulp_class_tid; + + rc = ulp_mapper_flow_create(ulp_ctx, &mapper_params, flow_id); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to create default flow.\n"); + return rc; + } + + return 0; +} + +/* + * Function to destroy default rules for the following paths + * 1) Device PORT to DPDK App + * 2) DPDK App to Device PORT + * 3) VF Representor to VF + * 4) VF to VF Representor + * + * eth_dev [in] Ptr to rte eth device. + * flow_id [in] Flow identifier. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_default_flow_destroy(struct rte_eth_dev *eth_dev, uint32_t flow_id) +{ + struct bnxt_ulp_context *ulp_ctx; + int rc; + + ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev); + if (!ulp_ctx) { + BNXT_TF_DBG(ERR, "ULP context is not initialized\n"); + return -EINVAL; + } + + rc = ulp_mapper_flow_destroy(ulp_ctx, flow_id, + BNXT_ULP_DEFAULT_FLOW_TABLE); + if (rc) + BNXT_TF_DBG(ERR, "Failed to destroy flow.\n"); + + return rc; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index f293a90..b7b528b 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -2275,16 +2275,15 @@ ulp_mapper_glb_resource_info_deinit(struct bnxt_ulp_context *ulp_ctx, } int32_t -ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid) +ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid, + enum bnxt_ulp_flow_db_tables flow_tbl_type) { if (!ulp_ctx) { BNXT_TF_DBG(ERR, "Invalid parms, unable to free flow\n"); return -EINVAL; } - return ulp_mapper_resources_free(ulp_ctx, - fid, - BNXT_ULP_REGULAR_FLOW_TABLE); + return ulp_mapper_resources_free(ulp_ctx, fid, flow_tbl_type); } /* Function to handle the default global templates that are allocated during @@ -2487,7 +2486,8 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, flow_error: /* Free all resources that were allocated during flow creation */ - trc = ulp_mapper_flow_destroy(ulp_ctx, parms.fid); + trc = ulp_mapper_flow_destroy(ulp_ctx, parms.fid, + BNXT_ULP_REGULAR_FLOW_TABLE); if (trc) BNXT_TF_DBG(ERR, "Failed to free all resources rc=%d\n", trc); diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h index 5f89a0e..f1399dc 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h @@ -108,7 +108,8 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, /* Function that frees all resources associated with the flow. */ int32_t -ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid); +ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid, + enum bnxt_ulp_flow_db_tables flow_tbl_type); /* * Function that frees all resources and can be called on default or regular 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 27628a5..2346797 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -145,6 +145,11 @@ enum bnxt_ulp_device_id { BNXT_ULP_DEVICE_ID_LAST = 4 }; +enum bnxt_ulp_df_param_type { + BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID = 0, + BNXT_ULP_DF_PARAM_TYPE_LAST = 1 +}; + enum bnxt_ulp_direction { BNXT_ULP_DIRECTION_INGRESS = 0, BNXT_ULP_DIRECTION_EGRESS = 1,