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 1424AA2F18 for ; Thu, 3 Oct 2019 01:28:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45BF61BFF5; Thu, 3 Oct 2019 01:26:47 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (unknown [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 445582C02 for ; Thu, 3 Oct 2019 01:26:11 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 6D92F30C2CC; Wed, 2 Oct 2019 16:24:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 6D92F30C2CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1570058697; bh=/CffxNuaM3IGpTT5GwKgzDmshKv6wT4+21hQCI6BEBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GIonFUHwB9LRF9Jva8eD4S4xgiiBM54QKUtdVWBU5175XWRPkpgN9D8S4gtpwzz2+ CAyrDwzZ+XI/ZKRXedfsquVtvASVqZ5cRCfXQgZ7LwjBHkQibBcjArcjoKRfQbg5Xa SHmjzGBR0V9CCcSMyB76EXDwiDxdi8ARBh/rcuy8= Received: from localhost.localdomain (unknown [10.230.30.225]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id DBE3A14008D; Wed, 2 Oct 2019 16:26:09 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Rahul Gupta , Venkat Duvvuru , Kalesh Anakkur Purayil Date: Wed, 2 Oct 2019 16:25:56 -0700 Message-Id: <20191002232601.22715-16-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191002232601.22715-1-ajit.khaparde@broadcom.com> References: <20191002232601.22715-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 15/20] net/bnxt: handle cleanup if flow creation fails 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" If flow creation fails because of an HWRM command failure or or some other reason, reset the vnic and rxq info set earlier. Reviewed-by: Rahul Gupta Reviewed-by: Venkat Duvvuru Reviewed-by: Kalesh Anakkur Purayil Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_flow.c | 66 +++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index 7fdd50d706..938d24be61 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -177,6 +177,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!item->spec || !item->mask) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "spec/mask is NULL"); + return -rte_errno; + } + switch (item->type) { case RTE_FLOW_ITEM_TYPE_ANY: inner = @@ -971,11 +979,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, bnxt_flow_non_void_action(actions); struct bnxt *bp = dev->data->dev_private; struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic = NULL, *vnic0 = NULL; const struct rte_flow_action_queue *act_q; const struct rte_flow_action_vf *act_vf; struct bnxt_filter_info *filter1 = NULL; const struct rte_flow_action_rss *rss; - struct bnxt_vnic_info *vnic, *vnic0; struct bnxt_rx_queue *rxq = NULL; int dflt_vnic, vnic_id; unsigned int rss_idx; @@ -1077,8 +1085,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, PMD_DRV_LOG(DEBUG, "VNIC found\n"); rc = bnxt_vnic_prep(bp, vnic); - if (rc) + if (rc) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "VNIC prep fail"); + rc = -rte_errno; goto ret; + } PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n", @@ -1091,7 +1106,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, filter->dst_id = vnic->fw_vnic_id; filter1 = bnxt_get_l2_filter(bp, filter, vnic); if (filter1 == NULL) { - rc = -ENOSPC; + rte_flow_error_set(error, + ENOSPC, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "Filter not available"); + rc = -rte_errno; goto ret; } @@ -1119,7 +1139,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic0 = &bp->vnic_info[0]; filter1 = bnxt_get_l2_filter(bp, filter, vnic0); if (filter1 == NULL) { - rc = -ENOSPC; + rte_flow_error_set(error, + ENOSPC, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "New filter not available"); + rc = -rte_errno; goto ret; } @@ -1182,6 +1207,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic0 = &bp->vnic_info[0]; filter1 = bnxt_get_l2_filter(bp, filter, vnic0); if (filter1 == NULL) { + rte_flow_error_set(error, + ENOSPC, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "New filter not available"); rc = -ENOSPC; goto ret; } @@ -1278,8 +1308,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic->func_default = 0; //This is not a default VNIC. rc = bnxt_vnic_prep(bp, vnic); - if (rc) + if (rc) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "VNIC prep fail"); + rc = -rte_errno; goto ret; + } PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n", @@ -1334,6 +1371,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, filter->dst_id = vnic->fw_vnic_id; filter1 = bnxt_get_l2_filter(bp, filter, vnic); if (filter1 == NULL) { + rte_flow_error_set(error, + ENOSPC, + RTE_FLOW_ERROR_TYPE_ACTION, + act, + "New filter not available"); rc = -ENOSPC; goto ret; } @@ -1367,7 +1409,18 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, rc = -rte_errno; goto ret; } + + return rc; ret: + + //TODO: Cleanup according to ACTION TYPE. + if (rte_errno) { + if (vnic && STAILQ_EMPTY(&vnic->filter)) + vnic->rx_queue_cnt = 0; + + if (rxq && !vnic->rx_queue_cnt) + rxq->vnic = &bp->vnic_info[0]; + } return rc; } @@ -1414,6 +1467,8 @@ bnxt_flow_validate(struct rte_eth_dev *dev, ret = bnxt_validate_and_parse_flow(dev, pattern, actions, attr, error, filter); + if (ret) + goto exit; vnic = find_matching_vnic(bp, filter); if (vnic) { @@ -1434,6 +1489,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev, else bnxt_hwrm_clear_l2_filter(bp, filter); +exit: /* No need to hold on to this filter if we are just validating flow */ filter->fw_l2_filter_id = UINT64_MAX; bnxt_free_filter(bp, filter); -- 2.20.1 (Apple Git-117)