From patchwork Mon Jul 6 08:24:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 73202 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 900EBA00C5; Mon, 6 Jul 2020 10:30:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C55A1DA6C; Mon, 6 Jul 2020 10:30:12 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 0F43E1D70F for ; Mon, 6 Jul 2020 10:30:04 +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 39F7A29848B; Mon, 6 Jul 2020 01:30:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 39F7A29848B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1594024203; bh=QQkL/K3fVD/7YbY3uhcwEOCmf8QXP3dH1vsLjDf0UeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BoL7bxmOfO9v0ErrKwOk92TXNa8aRgYSZf/tRFJXxuog1NXWnBDENVOQOVOWNTNAu F03hsuTWWymLZVBAKk2mSybxsLF8WfBeZT/YOSAkrjOsXqHlVDc92ctVoRXjIBvERV uasxnETnBmGmMxGbx72cC586vv7qDHYifNLkAPGk= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Mon, 6 Jul 2020 13:54:46 +0530 Message-Id: <20200706082502.26935-5-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 04/20] net/bnxt: add validations to dpdk port id and phy port parsing 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 Added validations to the ulp parser to validate the dpdk port id and phy port index during the flow creation. Signed-off-by: Kishore Padmanabha Reviewed-by: Michael Baucom Signed-off-by: Somnath Kotur Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 50 ++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index a4dbd84..b8146c8 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -297,8 +297,13 @@ ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, * Copy the rte_flow_item for Port into hdr_field using port id * header fields. */ - if (port_spec) + if (port_spec) { svif = (uint16_t)port_spec->id; + if (svif >= RTE_MAX_ETHPORTS) { + BNXT_TF_DBG(ERR, "ParseErr:Portid is not valid\n"); + return BNXT_TF_RC_PARSE_ERR; + } + } if (port_mask) mask = (uint16_t)port_mask->id; @@ -314,6 +319,8 @@ ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item, const struct rte_flow_item_phy_port *port_spec = item->spec; const struct rte_flow_item_phy_port *port_mask = item->mask; uint32_t svif = 0, mask = 0; + struct bnxt_ulp_device_params *dparms; + uint32_t dev_id; /* Copy the rte_flow_item for phy port into hdr_field */ if (port_spec) @@ -321,6 +328,22 @@ ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item, if (port_mask) mask = port_mask->index; + if (bnxt_ulp_cntxt_dev_id_get(params->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 (svif > dparms->num_phy_ports) { + BNXT_TF_DBG(ERR, "ParseErr:Phy Port is not valid\n"); + return BNXT_TF_RC_PARSE_ERR; + } + /* Update the SVIF details */ return ulp_rte_parser_svif_set(params, item->type, svif, mask); } @@ -1330,7 +1353,12 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, "ParseErr:Portid Original not supported\n"); return BNXT_TF_RC_PARSE_ERR; } - /* TBD: Update the computed VNIC using port conversion */ + /* 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); pid = rte_cpu_to_be_32(pid); memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], @@ -1349,6 +1377,8 @@ ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item, { const struct rte_flow_action_phy_port *phy_port; uint32_t vport; + struct bnxt_ulp_device_params *dparms; + uint32_t dev_id; phy_port = action_item->conf; if (phy_port) { @@ -1357,6 +1387,22 @@ ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item, "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; + } + /* Get the vport of the physical port */ /* TBD: shall be changed later to portdb call */ vport = 1 << phy_port->index;