From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A712EA00C5; Mon, 6 Jul 2020 10:32:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6B9B1DAC2; Mon, 6 Jul 2020 10:30:21 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 242961D594 for ; Mon, 6 Jul 2020 10:30:06 +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 57EEF2985AB; Mon, 6 Jul 2020 01:30:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 57EEF2985AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1594024205; bh=J5eqMsD5f4C8KVkYP3Q9IeU1u16JfGPuVEkoweNb6iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=APJfRj7+Vq4R5A2gqzJX8L5ozScfXGrvv5paTovZmj23iXx8Qg8gdAgmj52ZA3Skr DPnHKdOZl/mnPIIpdJe9vwabpWDRYswb2Q6qGOgr8di9Pty9nYcBmpEW6Vijxk4hC4 MyRMlL7/htt8HIdPsfcSDy3iMKo5AHbhK7R0S5Kk= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Mon, 6 Jul 2020 13:54:52 +0530 Message-Id: <20200706082502.26935-11-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200706082502.26935-1-somnath.kotur@broadcom.com> References: <20200706082502.26935-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 10/20] net/bnxt: remove vnic and vport act bits from template matching 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: Kishore Padmanabha Removed the vnic and vport bitmaps from template matching. It is assumed that these will be populated implicitly and based on the direction the appropriate action property shall be used. Signed-off-by: Kishore Padmanabha Reviewed-by: Michael Baucom Reviewed-by: Ajit Kumar Khaparde Signed-off-by: Somnath Kotur Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/tf_ulp/ulp_port_db.c | 27 ++++++- drivers/net/bnxt/tf_ulp/ulp_port_db.h | 15 ++++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 133 ++++++++++++++++++++----------- 3 files changed, 127 insertions(+), 48 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c index 659cefa..3c5a218 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c @@ -71,7 +71,7 @@ int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt) "Failed to allocate mem for phy port list\n"); goto error_free; } - + port_db->phy_port_cnt = port_cnt; return 0; error_free: @@ -436,3 +436,28 @@ ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt, *vport = port_db->phy_port_list[phy_port_id].port_vport; return 0; } + +/* + * Api to get the vport for a given physical port. + * + * ulp_ctxt [in] Ptr to ulp context + * phy_port [in] physical port index + * out_port [out] the port of the given physical index + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t phy_port, + uint16_t *out_port) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db || phy_port >= port_db->phy_port_cnt) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + *out_port = port_db->phy_port_list[phy_port].port_vport; + return 0; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h index b1419a3..e3870f9 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h @@ -71,6 +71,7 @@ struct bnxt_ulp_port_db { /* dpdk device external port list */ uint16_t dev_port_list[RTE_MAX_ETHPORTS]; struct ulp_phy_port_info *phy_port_list; + uint16_t phy_port_cnt; struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC]; }; @@ -203,4 +204,18 @@ int32_t ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, uint16_t *vport); +/* + * Api to get the vport for a given physical port. + * + * ulp_ctxt [in] Ptr to ulp context + * phy_port [in] physical port index + * out_port [out] the port of the given physical index + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t phy_port, + uint16_t *out_port); + #endif /* _ULP_PORT_DB_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 8d35429..b4bf431 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -238,8 +238,17 @@ ulp_rte_parser_vnic_process(struct ulp_rte_parser_params *params) struct ulp_rte_act_bitmap *act = ¶ms->act_bitmap; if (ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VNIC) || - ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VPORT)) + ULP_BITMAP_ISSET(act->bits, BNXT_ULP_ACTION_BIT_VPORT)) { + /* + * Reset the vnic/vport action bitmaps + * it is not required for match + */ + ULP_BITMAP_RESET(params->act_bitmap.bits, + BNXT_ULP_ACTION_BIT_VNIC); + ULP_BITMAP_RESET(params->act_bitmap.bits, + BNXT_ULP_ACTION_BIT_VPORT); return BNXT_TF_RC_SUCCESS; + } /* Update the vnic details */ ulp_rte_pf_act_handler(NULL, params); @@ -1344,28 +1353,59 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, struct ulp_rte_parser_params *param) { const struct rte_flow_action_port_id *port_id; + struct ulp_rte_act_prop *act; uint32_t pid; + int32_t rc; + uint32_t ifindex; + uint16_t pid_s; port_id = act_item->conf; - if (port_id) { - if (port_id->original) { - BNXT_TF_DBG(ERR, - "ParseErr:Portid Original not supported\n"); - return BNXT_TF_RC_PARSE_ERR; - } - /* Update the computed VNIC using port conversion */ - if (port_id->id >= RTE_MAX_ETHPORTS) { - BNXT_TF_DBG(ERR, - "ParseErr:Portid is not valid\n"); - return BNXT_TF_RC_PARSE_ERR; - } - pid = bnxt_get_vnic_id(port_id->id, BNXT_ULP_INTF_TYPE_INVALID); + if (!port_id) { + BNXT_TF_DBG(ERR, + "ParseErr: Invalid Argument\n"); + return BNXT_TF_RC_PARSE_ERR; + } + if (port_id->original) { + BNXT_TF_DBG(ERR, + "ParseErr:Portid Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + + /* Get the port db ifindex */ + rc = ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, + port_id->id, + &ifindex); + if (rc) { + BNXT_TF_DBG(ERR, "Invalid port id\n"); + return BNXT_TF_RC_ERROR; + } + + act = ¶m->act_prop; + if (param->dir == ULP_DIR_EGRESS) { + rc = ulp_port_db_vport_get(param->ulp_ctx, + ifindex, &pid_s); + if (rc) + return BNXT_TF_RC_ERROR; + + pid = pid_s; pid = rte_cpu_to_be_32(pid); - memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], + memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], + &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); + } else { + rc = ulp_port_db_default_vnic_get(param->ulp_ctx, + ifindex, + BNXT_ULP_DRV_FUNC_VNIC, + &pid_s); + if (rc) + return BNXT_TF_RC_ERROR; + + pid = pid_s; + pid = rte_cpu_to_be_32(pid); + memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], &pid, BNXT_ULP_ACT_PROP_SZ_VNIC); } - /* Update the hdr_bitmap with count */ + /*Update the hdr_bitmap with vnic */ ULP_BITMAP_SET(param->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VNIC); return BNXT_TF_RC_SUCCESS; } @@ -1376,42 +1416,41 @@ ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item, struct ulp_rte_parser_params *prm) { const struct rte_flow_action_phy_port *phy_port; - uint32_t vport; - struct bnxt_ulp_device_params *dparms; - uint32_t dev_id; + uint32_t pid; + int32_t rc; + uint16_t pid_s; phy_port = action_item->conf; - if (phy_port) { - if (phy_port->original) { - BNXT_TF_DBG(ERR, - "Parse Err:Port Original not supported\n"); - return BNXT_TF_RC_PARSE_ERR; - } - if (bnxt_ulp_cntxt_dev_id_get(prm->ulp_ctx, &dev_id)) { - BNXT_TF_DBG(DEBUG, "Failed to get device id\n"); - return -EINVAL; - } - - dparms = bnxt_ulp_device_params_get(dev_id); - if (!dparms) { - BNXT_TF_DBG(DEBUG, "Failed to get device parms\n"); - return -EINVAL; - } - - if (phy_port->index > dparms->num_phy_ports) { - BNXT_TF_DBG(ERR, "ParseErr:Phy Port is not valid\n"); - return BNXT_TF_RC_PARSE_ERR; - } + if (!phy_port) { + BNXT_TF_DBG(ERR, + "ParseErr: Invalid Argument\n"); + return BNXT_TF_RC_PARSE_ERR; + } - /* Get the vport of the physical port */ - /* TBD: shall be changed later to portdb call */ - vport = 1 << phy_port->index; - vport = rte_cpu_to_be_32(vport); - memcpy(&prm->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], - &vport, BNXT_ULP_ACT_PROP_SZ_VPORT); + if (phy_port->original) { + BNXT_TF_DBG(ERR, + "Parse Err:Port Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + if (prm->dir != ULP_DIR_EGRESS) { + BNXT_TF_DBG(ERR, + "Parse Err:Phy ports are valid only for egress\n"); + return BNXT_TF_RC_PARSE_ERR; + } + /* Get the physical port details from port db */ + rc = ulp_port_db_phy_port_vport_get(prm->ulp_ctx, phy_port->index, + &pid_s); + if (rc) { + BNXT_TF_DBG(DEBUG, "Failed to get port details\n"); + return -EINVAL; } - /* Update the hdr_bitmap with count */ + pid = pid_s; + pid = rte_cpu_to_be_32(pid); + memcpy(&prm->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], + &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); + + /* update the hdr_bitmap with vport */ ULP_BITMAP_SET(prm->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VPORT); return BNXT_TF_RC_SUCCESS; } -- 2.7.4