[dpdk-dev] [PATCH 13/17] net/bnxt: handle flow flush handling

Ajit Khaparde ajit.khaparde at broadcom.com
Tue Sep 3 04:18:57 CEST 2019


We are not freeing all the flows when a flow_flush is called.
Iterate through all the flows belonging to all the VNICs in use and
free the filters.

Signed-off-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta at broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru at broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil at broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 56 ++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 71a5266ce..9d943cd14 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -907,7 +907,6 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	const struct rte_flow_action *act =
 		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;
 	const struct rte_flow_action_queue *act_q;
 	const struct rte_flow_action_rss *rss;
 	const struct rte_flow_action_vf *act_vf;
@@ -982,9 +981,6 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 
 		rxq = bp->rx_queues[act_q->index];
 
-		if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq)
-			goto use_vnic;
-
 		//if (!rxq ||
 		    //bp->vnic_info[0].fw_grp_ids[act_q->index] !=
 		    //INVALID_HW_RING_ID ||
@@ -1567,25 +1563,6 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 
 	vnic = find_matching_vnic(bp, filter);
 done:
-	if (!ret) {
-		flow->filter = filter;
-		flow->vnic = vnic;
-		/* VNIC is set only in case of queue or RSS action */
-		if (vnic) {
-			/*
-			 * RxQ0 is not used for flow filters.
-			 */
-
-			if (update_flow) {
-				ret = -EXDEV;
-				goto free_flow;
-			}
-			STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
-		}
-		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
-		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
-		return flow;
-	}
 	if (!ret) {
 		flow->filter = filter;
 		flow->vnic = vnic;
@@ -1593,10 +1570,13 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 			ret = -EXDEV;
 			goto free_flow;
 		}
+
+		STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
 		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
 		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
 		return flow;
 	}
+
 free_filter:
 	bnxt_free_filter(bp, filter);
 free_flow:
@@ -1727,6 +1707,7 @@ static int
 bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 {
 	struct bnxt *bp = dev->data->dev_private;
+	struct bnxt_filter_info *filter = NULL;
 	struct bnxt_vnic_info *vnic;
 	struct rte_flow *flow;
 	unsigned int i;
@@ -1734,11 +1715,12 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
-		if (vnic->fw_vnic_id == INVALID_VNIC_ID)
+		if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID)
 			continue;
 
-		STAILQ_FOREACH(flow, &vnic->flow_list, next) {
-			struct bnxt_filter_info *filter = flow->filter;
+		while (!STAILQ_EMPTY(&vnic->flow_list)) {
+			flow = STAILQ_FIRST(&vnic->flow_list);
+			filter = flow->filter;
 
 			if (filter->filter_type ==
 			    HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
@@ -1757,7 +1739,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				ret = bnxt_hwrm_clear_em_filter(bp, filter);
 			if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
 				ret = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-			else if (!i)
+			else if (i)
 				ret = bnxt_hwrm_clear_l2_filter(bp, filter);
 
 			if (ret) {
@@ -1770,10 +1752,28 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				return -rte_errno;
 			}
 done:
-			bnxt_free_filter(bp, filter);
 			STAILQ_REMOVE(&vnic->flow_list, flow,
 				      rte_flow, next);
+
+			STAILQ_REMOVE(&vnic->filter,
+				      filter,
+				      bnxt_filter_info,
+				      next);
+			bnxt_free_filter(bp, filter);
+
 			rte_free(flow);
+
+			/* If this was the last flow associated with this vnic,
+			 * switch the queue back to RSS pool.
+			 */
+			if (STAILQ_EMPTY(&vnic->flow_list)) {
+				rte_free(vnic->fw_grp_ids);
+				if (vnic->rx_queue_cnt > 1)
+					bnxt_hwrm_vnic_ctx_free(bp, vnic);
+				bnxt_hwrm_vnic_free(bp, vnic);
+				vnic->rx_queue_cnt = 0;
+				bp->nr_vnics--;
+			}
 		}
 	}
 
-- 
2.20.1 (Apple Git-117)



More information about the dev mailing list