Skip to contentSkip to conversation

net/i40e: select fdir config automatically

PATCH Superseded Xiaoyun Li 3 participants 11 messages Sep 28, 2018 – Sep 30, 2018 Network drivers

lore
Share & tools
lore

Xiaoyun Li

author
#0 lore raw

PATCH 1/1 net/i40e: select fdir config automatically

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically.

---
 drivers/net/i40e/i40e_flow.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_flow.c +28 -5
index c67b264de..70ff33ac0 100644
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }
 
 /* Parse to get the action info of a tunnel filter
@@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_FIRST(&pf->fdir.fdir_list)) {
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
Signature · 1 line
2.17.1
#1 lore raw
Quoted 71 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Friday, September 28, 2018 3:25 PM
To: Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/i40e: select fdir config automatically

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically.

---
 drivers/net/i40e/i40e_flow.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_flow.c index renamed from drivers/net/i40e/i40e_flow.c +0 -0

c67b264de..70ff33ac0 100644

drivers/net/i40e/i40e_flow.c +1 -0
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev
 *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data-
 >dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
drivers/net/i40e/i40e_flow.c +20 -5
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev
 *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode =
 RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }

/* Parse to get the action info of a tunnel filter @@ -4708,6 +4724,13 @@
i40e_flow_destroy(struct rte_eth_dev *dev,

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4729

Quoted 6 lines
drivers/net/i40e/i40e_flow.c +3 -0
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_FIRST(&pf->fdir.fdir_list)) {

How about TAILQ_EMPTY which is more intuitive?

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4733

Quoted 4 lines
drivers/net/i40e/i40e_flow.c +4 -0
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}

Do you consider FDIR teardown after FDIR flush?

Quoted 5 lines
drivers/net/i40e/i40e_flow.c +0 -1
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
--

2.17.1

#2 lore raw

Will correct it in v2. Thanks.

Quoted 104 lines

-----Original Message-----
From: Xing, Beilei
Sent: Friday, September 28, 2018 16:40
To: Li, Xiaoyun <[email protected]>; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Subject: RE: [PATCH] net/i40e: select fdir config automatically

Quoted 9 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Friday, September 28, 2018 3:25 PM
To: Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/i40e: select fdir config automatically

Quoted 3 lines

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config

automatically.

drivers/net/i40e/i40e_flow.c i40e_flow_parse_fdir_filter(struct

Quoted 22 lines
---
 drivers/net/i40e/i40e_flow.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_flow.c index
c67b264de..70ff33ac0 100644

drivers/net/i40e/i40e_flow.c +1 -0
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev
 *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data-
 >dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
drivers/net/i40e/i40e_flow.c +0 -0
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct

rte_eth_dev

Quoted 37 lines
drivers/net/i40e/i40e_flow.c +20 -5
 *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode =
 RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }

/* Parse to get the action info of a tunnel filter @@ -4708,6
+4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4729

Quoted 6 lines
drivers/net/i40e/i40e_flow.c +3 -0
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_FIRST(&pf->fdir.fdir_list)) {

How about TAILQ_EMPTY which is more intuitive?

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4733

Quoted 4 lines
drivers/net/i40e/i40e_flow.c +4 -0
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}

Do you consider FDIR teardown after FDIR flush?

Quoted 5 lines
drivers/net/i40e/i40e_flow.c +0 -1
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
--

2.17.1

author
#3 lore raw

PATCH v2 1/1 net/i40e: select fdir config automatically

In reply to Xiaoyun Li

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically. And remove the workaround in flow_filtering example.

---
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver will
* set the fdir config automatically.

---
 drivers/net/i40e/i40e_flow.c   | 35 +++++++++++++++++++++++++++++-----
 examples/flow_filtering/main.c | 16 ----------------
 2 files changed, 30 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_flow.c +30 -5
index c67b264de..68ae00a27 100644
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }
 
 /* Parse to get the action info of a tunnel filter
@@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) {
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
@@ -4900,6 +4923,8 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 			pf->fdir.inset_flag[pctype] = 0;
 	}
 
+	i40e_fdir_teardown(pf);
+
 	return ret;
 }
 
examples/flow_filtering/main.c +0 -16
index b3f85b563..a73d120e3 100644
@@ -131,22 +131,6 @@ init_port(void)
 				DEV_TX_OFFLOAD_SCTP_CKSUM  |
 				DEV_TX_OFFLOAD_TCP_TSO,
 		},
-		/*
-		 * Initialize fdir_conf of rte_eth_conf.
-		 * Fdir is used in flow filtering for I40e,
-		 * so rte_flow rules involve some fdir
-		 * configurations. In long term it's better
-		 * that drivers don't require any fdir
-		 * configuration for rte_flow, but we need to
-		 * get this workaround so that sample app can
-		 * run on I40e.
-		 */
-		.fdir_conf = {
-			.mode = RTE_FDIR_MODE_PERFECT,
-			.pballoc = RTE_FDIR_PBALLOC_64K,
-			.status = RTE_FDIR_REPORT_STATUS,
-			.drop_queue = 127,
-		},
 	};
 	struct rte_eth_txconf txq_conf;
 	struct rte_eth_rxconf rxq_conf;
Signature · 1 line
2.17.1
#4 lore raw
Quoted 79 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Friday, September 28, 2018 7:03 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>
Subject: [PATCH v2] net/i40e: select fdir config automatically

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically. And remove the workaround in flow_filtering example.

---
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver will
* set the fdir config automatically.

---
 drivers/net/i40e/i40e_flow.c   | 35 +++++++++++++++++++++++++++++-----
 examples/flow_filtering/main.c | 16 ----------------
 2 files changed, 30 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_flow.c index renamed from drivers/net/i40e/i40e_flow.c +0 -0

c67b264de..68ae00a27 100644

drivers/net/i40e/i40e_flow.c +1 -0
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev
 *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data-
 >dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
drivers/net/i40e/i40e_flow.c +20 -5
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev
 *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode =
 RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }

/* Parse to get the action info of a tunnel filter @@ -4708,6 +4724,13 @@
i40e_flow_destroy(struct rte_eth_dev *dev,

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4729

Quoted 6 lines
drivers/net/i40e/i40e_flow.c +3 -0
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) {

Should be if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) here?

Quoted 45 lines
drivers/net/i40e/i40e_flow.c +4 -0
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev, @@ -4900,6 +4923,8

@@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)

drivers/net/i40e/i40e_flow.c +2 -0
 			pf->fdir.inset_flag[pctype] = 0;
 	}
 
+	i40e_fdir_teardown(pf);
+
 	return ret;
 }
examples/flow_filtering/main.c +0 -17
index b3f85b563..a73d120e3 100644
@@ -131,22 +131,6 @@ init_port(void)
 				DEV_TX_OFFLOAD_SCTP_CKSUM  |
 				DEV_TX_OFFLOAD_TCP_TSO,
 		},
-		/*
-		 * Initialize fdir_conf of rte_eth_conf.
-		 * Fdir is used in flow filtering for I40e,
-		 * so rte_flow rules involve some fdir
-		 * configurations. In long term it's better
-		 * that drivers don't require any fdir
-		 * configuration for rte_flow, but we need to
-		 * get this workaround so that sample app can
-		 * run on I40e.
-		 */
-		.fdir_conf = {
-			.mode = RTE_FDIR_MODE_PERFECT,
-			.pballoc = RTE_FDIR_PBALLOC_64K,
-			.status = RTE_FDIR_REPORT_STATUS,
-			.drop_queue = 127,
-		},
 	};
 	struct rte_eth_txconf txq_conf;
 	struct rte_eth_rxconf rxq_conf;
--

2.17.1

#5 lore raw
Quoted 26 lines

-----Original Message-----
From: Xing, Beilei
Sent: Saturday, September 29, 2018 16:37
To: Li, Xiaoyun <[email protected]>; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v2] net/i40e: select fdir config automatically

Quoted 8 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Friday, September 28, 2018 7:03 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>
Subject: [PATCH v2] net/i40e: select fdir config automatically

Quoted 4 lines

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically. And remove the workaround in flow_filtering

example.

Quoted 1 line
Quoted 13 lines

drivers/net/i40e/i40e_flow.c i40e_flow_destroy(struct rte_eth_dev *dev, · line 4729

Quoted 11 lines

---
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver
will
* set the fdir config automatically.

drivers/net/i40e/i40e_flow.c +3 -0
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) {

Should be if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) here?

Yes. Sorry about that. Will correct it.

Quoted 3 lines
Quoted 3 lines

--
2.17.1

author
#6 lore raw

PATCH v3 1/1 net/i40e: select fdir config automatically

In reply to Xiaoyun Li

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver select the config automatically. And remove the workaround in flow_filtering example.

---
v3:
* Fixed fdir config doesn't automatically remove when last flow is
* destroyed.
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver will
* set the fdir config automatically.

---
 drivers/net/i40e/i40e_flow.c   | 35 +++++++++++++++++++++++++++++-----
 examples/flow_filtering/main.c | 16 ----------------
 2 files changed, 30 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_flow.c +30 -5
index 6487596da..d811b3891 100644
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }
 
 /* Parse to get the action info of a tunnel filter
@@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) {
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
@@ -4900,6 +4923,8 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 			pf->fdir.inset_flag[pctype] = 0;
 	}
 
+	i40e_fdir_teardown(pf);
+
 	return ret;
 }
 
examples/flow_filtering/main.c +0 -16
index b3f85b563..a73d120e3 100644
@@ -131,22 +131,6 @@ init_port(void)
 				DEV_TX_OFFLOAD_SCTP_CKSUM  |
 				DEV_TX_OFFLOAD_TCP_TSO,
 		},
-		/*
-		 * Initialize fdir_conf of rte_eth_conf.
-		 * Fdir is used in flow filtering for I40e,
-		 * so rte_flow rules involve some fdir
-		 * configurations. In long term it's better
-		 * that drivers don't require any fdir
-		 * configuration for rte_flow, but we need to
-		 * get this workaround so that sample app can
-		 * run on I40e.
-		 */
-		.fdir_conf = {
-			.mode = RTE_FDIR_MODE_PERFECT,
-			.pballoc = RTE_FDIR_PBALLOC_64K,
-			.status = RTE_FDIR_REPORT_STATUS,
-			.drop_queue = 127,
-		},
 	};
 	struct rte_eth_txconf txq_conf;
 	struct rte_eth_rxconf rxq_conf;
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v4 1/1 net/i40e: config fdir automatically

In reply to Xiaoyun Li

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver config fdir automatically. And remove the workaround in flow filtering example.

---
v4:
* Polished commit log.
* Added comments that the original fdir config codes should be removed
* when the legacy filter API is deprecated.
v3:
* Fixed fdir config doesn't automatically remove when last flow is
* destroyed.
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver will
* set the fdir config automatically.

---
 drivers/net/i40e/i40e_ethdev.c | 10 +++++++++-
 drivers/net/i40e/i40e_flow.c   | 35 +++++++++++++++++++++++++++++-----
 examples/flow_filtering/main.c | 16 ----------------
 3 files changed, 39 insertions(+), 22 deletions(-)
drivers/net/i40e/i40e_ethdev.c +9 -1
index de25de650..3fd0d5dbf 100644
@@ -1787,6 +1787,10 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 	ad->tx_simple_allowed = true;
 	ad->tx_vec_allowed = true;
 
+	/* Only legacy filter API needs the following fdir config. So when the
+	 * legacy filter API is deprecated, the following codes should also be
+	 * removed.
+	 */
 	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT) {
 		ret = i40e_fdir_setup(pf);
 		if (ret != I40E_SUCCESS) {
@@ -1844,7 +1848,11 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 	rte_free(pf->vmdq);
 	pf->vmdq = NULL;
 err:
-	/* need to release fdir resource if exists */
+	/* Need to release fdir resource if exists.
+	 * Only legacy filter API needs the following fdir config. So when the
+	 * legacy filter API is deprecated, the following code should also be
+	 * removed.
+	 */
 	i40e_fdir_teardown(pf);
 	return ret;
 }
drivers/net/i40e/i40e_flow.c +30 -5
index c67b264de..68ae00a27 100644
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }
 
 /* Parse to get the action info of a tunnel filter
@@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) {
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
@@ -4900,6 +4923,8 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 			pf->fdir.inset_flag[pctype] = 0;
 	}
 
+	i40e_fdir_teardown(pf);
+
 	return ret;
 }
 
examples/flow_filtering/main.c +0 -16
index b3f85b563..a73d120e3 100644
@@ -131,22 +131,6 @@ init_port(void)
 				DEV_TX_OFFLOAD_SCTP_CKSUM  |
 				DEV_TX_OFFLOAD_TCP_TSO,
 		},
-		/*
-		 * Initialize fdir_conf of rte_eth_conf.
-		 * Fdir is used in flow filtering for I40e,
-		 * so rte_flow rules involve some fdir
-		 * configurations. In long term it's better
-		 * that drivers don't require any fdir
-		 * configuration for rte_flow, but we need to
-		 * get this workaround so that sample app can
-		 * run on I40e.
-		 */
-		.fdir_conf = {
-			.mode = RTE_FDIR_MODE_PERFECT,
-			.pballoc = RTE_FDIR_PBALLOC_64K,
-			.status = RTE_FDIR_REPORT_STATUS,
-			.drop_queue = 127,
-		},
 	};
 	struct rte_eth_txconf txq_conf;
 	struct rte_eth_rxconf rxq_conf;
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v5 1/1 net/i40e: config fdir automatically

In reply to Xiaoyun Li

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver config fdir automatically. And remove the workaround in flow filtering example.

---
v5:
* Added missing comment in v4.
v4:
* Polished commit log.
* Added comments that the original fdir config codes should be removed
* when the legacy filter API is deprecated.
v3:
* Fixed fdir config doesn't automatically remove when last flow is
* destroyed.
v2:
* Added fdir teardown in i40e_flow_flush_fdir_filter.
* Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive.
* Remove the workaround in flow_filtering example since the driver will
* set the fdir config automatically.

---
 drivers/net/i40e/i40e_ethdev.c | 15 ++++++++++++++-
 drivers/net/i40e/i40e_flow.c   | 35 +++++++++++++++++++++++++++++-----
 examples/flow_filtering/main.c | 16 ----------------
 3 files changed, 44 insertions(+), 22 deletions(-)
drivers/net/i40e/i40e_ethdev.c +14 -1
index de25de650..63e5b4c85 100644
@@ -1787,6 +1787,10 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 	ad->tx_simple_allowed = true;
 	ad->tx_vec_allowed = true;
 
+	/* Only legacy filter API needs the following fdir config. So when the
+	 * legacy filter API is deprecated, the following codes should also be
+	 * removed.
+	 */
 	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT) {
 		ret = i40e_fdir_setup(pf);
 		if (ret != I40E_SUCCESS) {
@@ -1844,7 +1848,11 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 	rte_free(pf->vmdq);
 	pf->vmdq = NULL;
 err:
-	/* need to release fdir resource if exists */
+	/* Need to release fdir resource if exists.
+	 * Only legacy filter API needs the following fdir config. So when the
+	 * legacy filter API is deprecated, the following code should also be
+	 * removed.
+	 */
 	i40e_fdir_teardown(pf);
 	return ret;
 }
@@ -2482,6 +2490,11 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_pf_disable_irq0(hw);
 	rte_intr_disable(intr_handle);
 
+	/*
+	 * Only legacy filter API needs the following fdir config. So when the
+	 * legacy filter API is deprecated, the following code should also be
+	 * removed.
+	 */
 	i40e_fdir_teardown(pf);
 
 	/* shutdown and destroy the HMC */
drivers/net/i40e/i40e_flow.c +30 -5
index c67b264de..68ae00a27 100644
@@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    union i40e_filter_t *filter)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_fdir_filter_conf *fdir_filter =
 		&filter->fdir_filter;
 	int ret;
@@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 
 	if (dev->data->dev_conf.fdir_conf.mode !=
 	    RTE_FDIR_MODE_PERFECT) {
-		rte_flow_error_set(error, ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-				   NULL,
-				   "Check the mode in fdir_conf.");
-		return -rte_errno;
+		/* Enable fdir when fdir flow is added at first time. */
+		ret = i40e_fdir_setup(pf);
+		if (ret != I40E_SUCCESS) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to setup fdir.");
+			return -rte_errno;
+		}
+		ret = i40e_fdir_configure(dev);
+		if (ret < 0) {
+			rte_flow_error_set(error, ENOTSUP,
+					   RTE_FLOW_ERROR_TYPE_HANDLE,
+					   NULL, "Failed to configure fdir.");
+			goto err;
+		}
+
+		dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
 	}
 
 	return 0;
+err:
+	i40e_fdir_teardown(pf);
+	return -rte_errno;
 }
 
 /* Parse to get the action info of a tunnel filter
@@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_FDIR:
 		ret = i40e_flow_add_del_fdir_filter(dev,
 		       &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
+
+		/* If the last flow is destroyed, disable fdir. */
+		if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) {
+			i40e_fdir_teardown(pf);
+			dev->data->dev_conf.fdir_conf.mode =
+				   RTE_FDIR_MODE_NONE;
+		}
 		break;
 	case RTE_ETH_FILTER_HASH:
 		ret = i40e_config_rss_filter_del(dev,
@@ -4900,6 +4923,8 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 			pf->fdir.inset_flag[pctype] = 0;
 	}
 
+	i40e_fdir_teardown(pf);
+
 	return ret;
 }
 
examples/flow_filtering/main.c +0 -16
index b3f85b563..a73d120e3 100644
@@ -131,22 +131,6 @@ init_port(void)
 				DEV_TX_OFFLOAD_SCTP_CKSUM  |
 				DEV_TX_OFFLOAD_TCP_TSO,
 		},
-		/*
-		 * Initialize fdir_conf of rte_eth_conf.
-		 * Fdir is used in flow filtering for I40e,
-		 * so rte_flow rules involve some fdir
-		 * configurations. In long term it's better
-		 * that drivers don't require any fdir
-		 * configuration for rte_flow, but we need to
-		 * get this workaround so that sample app can
-		 * run on I40e.
-		 */
-		.fdir_conf = {
-			.mode = RTE_FDIR_MODE_PERFECT,
-			.pballoc = RTE_FDIR_PBALLOC_64K,
-			.status = RTE_FDIR_REPORT_STATUS,
-			.drop_queue = 127,
-		},
 	};
 	struct rte_eth_txconf txq_conf;
 	struct rte_eth_rxconf rxq_conf;
Signature · 1 line
2.17.1
Acked-by on v5 1/1
#9 lore raw

Re: [PATCH v5] net/i40e: config fdir automatically

Quoted 10 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Sunday, September 30, 2018 10:30 AM
To: Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH v5] net/i40e: config fdir automatically

Quoted 6 lines

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver config fdir automatically. And remove the workaround in flow filtering example.

Applied
#10 lore raw

Re: [PATCH v5] net/i40e: config fdir automatically

Quoted 23 lines

-----Original Message-----
From: Xing, Beilei
Sent: Sunday, September 30, 2018 10:41 AM
To: Li, Xiaoyun <[email protected]>; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Subject: RE: [PATCH v5] net/i40e: config fdir automatically

Quoted 9 lines

-----Original Message-----
From: Li, Xiaoyun
Sent: Sunday, September 30, 2018 10:30 AM
To: Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH v5] net/i40e: config fdir automatically

Quoted 3 lines

I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver config fdir

Quoted 6 lines

automatically.

Quoted 3 lines

And remove the workaround in flow filtering example.

Applied to dpdk-next-net-intel.

Thanks
Qi