net/ice: add devargs for disabling mac filter

Message ID 20221125025124.805466-1-ke1x.zhang@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Qi Zhang
Headers
Series net/ice: add devargs for disabling mac filter |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Zhang, Ke1X Nov. 25, 2022, 2:51 a.m. UTC
  From: "ke1x.zhang" <ke1x.zhang@intel.com>

This patch adds support to disable mac filter which will
be used by ice driver when setting dpdk_devargs config
field in the TRex config file.

Mac filter is not disabled in default.

Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>
---
 drivers/net/ice/ice_ethdev.c       | 13 +++++++++++++
 drivers/net/ice/ice_ethdev.h       |  1 +
 drivers/net/ice/ice_generic_flow.c | 15 +++++++++++++++
 3 files changed, 29 insertions(+)
  

Comments

Qi Zhang Dec. 13, 2022, 2:03 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, Ke1X <ke1x.zhang@intel.com>
> Sent: Friday, November 25, 2022 10:51 AM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; dev@dpdk.org
> Cc: Zhang, Ke1X <ke1x.zhang@intel.com>
> Subject: [PATCH] net/ice: add devargs for disabling mac filter
> 
> From: "ke1x.zhang" <ke1x.zhang@intel.com>
> 
> This patch adds support to disable mac filter which will be used by ice driver
> when setting dpdk_devargs config field in the TRex config file.
> 
> Mac filter is not disabled in default.
> 
> Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c       | 13 +++++++++++++
>  drivers/net/ice/ice_ethdev.h       |  1 +
>  drivers/net/ice/ice_generic_flow.c | 15 +++++++++++++++
>  3 files changed, 29 insertions(+)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 0bc739daf0..0c9f66eb88 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -28,6 +28,7 @@
>  /* devargs */
>  #define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support"
>  #define ICE_PIPELINE_MODE_SUPPORT_ARG  "pipeline-mode-support"
> +#define ICE_MAC_FILTER_DISABLE  "mac-filter-disable"

Document also need to be updated for the new devargs.

>  #define ICE_PROTO_XTR_ARG         "proto_xtr"
>  #define ICE_FIELD_OFFS_ARG		  "field_offs"
>  #define ICE_FIELD_NAME_ARG		  "field_name"
> @@ -49,6 +50,7 @@ static const char * const ice_valid_args[] = {
>  	ICE_HW_DEBUG_MASK_ARG,
>  	ICE_ONE_PPS_OUT_ARG,
>  	ICE_RX_LOW_LATENCY_ARG,
> +	ICE_MAC_FILTER_DISABLE,
>  	NULL
>  };
> 
> @@ -962,8 +964,13 @@ ice_add_mac_filter(struct ice_vsi *vsi, struct
> rte_ether_addr *mac_addr)
>  	struct ice_mac_filter *f;
>  	struct LIST_HEAD_TYPE list_head;
>  	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
> +	struct ice_adapter *ad = (struct ice_adapter *)hw->back;
>  	int ret = 0;
> 
> +	if (ad->devargs.mac_filter_disable == 1) {
> +		PMD_DRV_LOG(ERR, "This MAC filter is disabled.");
> +		return 0;
> +	}
>  	/* If it's added and configured, return */
>  	f = ice_find_mac_filter(vsi, mac_addr);
>  	if (f) {
> @@ -2075,6 +2082,11 @@ static int ice_parse_devargs(struct rte_eth_dev
> *dev)
>  	if (ret)
>  		goto bail;
> 
> +	ret = rte_kvargs_process(kvlist, ICE_MAC_FILTER_DISABLE,
> +				&parse_bool, &ad-
> >devargs.mac_filter_disable);
> +	if (ret)
> +		goto bail;
> +
>  	ret = rte_kvargs_process(kvlist, ICE_HW_DEBUG_MASK_ARG,
>  				 &parse_u64, &ad->hw.debug_mask);
>  	if (ret)
> @@ -6050,6 +6062,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
>  			      ICE_PROTO_XTR_ARG
> "=[queue:]<vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset>"
>  			      ICE_SAFE_MODE_SUPPORT_ARG "=<0|1>"
>  			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
> +			      ICE_MAC_FILTER_DISABLE "=<0|1>"
>  			      ICE_RX_LOW_LATENCY_ARG "=<0|1>");
> 
>  RTE_LOG_REGISTER_SUFFIX(ice_logtype_init, init, NOTICE); diff --git
> a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index
> c8311be179..0350c6584a 100644
> --- a/drivers/net/ice/ice_ethdev.h
> +++ b/drivers/net/ice/ice_ethdev.h
> @@ -563,6 +563,7 @@ struct ice_devargs {
>  	int safe_mode_support;
>  	uint8_t proto_xtr_dflt;
>  	int pipe_mode_support;
> +	int mac_filter_disable;
>  	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
>  	uint8_t pin_idx;
>  	uint8_t pps_out_ena;
> diff --git a/drivers/net/ice/ice_generic_flow.c
> b/drivers/net/ice/ice_generic_flow.c
> index d496c28dec..bca38f5a52 100644
> --- a/drivers/net/ice/ice_generic_flow.c
> +++ b/drivers/net/ice/ice_generic_flow.c
> @@ -2464,6 +2464,8 @@ ice_flow_create(struct rte_eth_dev *dev,
>  		struct rte_flow_error *error)
>  {
>  	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data-
> >dev_private);
> +	struct ice_adapter *ad =
> +			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data-
> >dev_private);
>  	struct rte_flow *flow = NULL;
>  	int ret;
>  	struct ice_flow_engine *engine = NULL; @@ -2476,6 +2478,14 @@
> ice_flow_create(struct rte_eth_dev *dev,
>  		return flow;
>  	}
> 
> +	if (ad->devargs.mac_filter_disable == 1) {
> +		if ((pattern[0].type == RTE_FLOW_ITEM_TYPE_ANY)
> +			&& (actions[0].type ==
> RTE_FLOW_ACTION_TYPE_DROP)) {
> +			flow->rule = NULL;
> +			return flow;
> +		}
> +	}
> +
>  	rte_spinlock_lock(&pf->flow_ops_lock);
> 
>  	ret = ice_flow_process_filter(dev, flow, attr, pattern, actions, @@ -
> 2506,6 +2516,11 @@ ice_flow_destroy(struct rte_eth_dev *dev,
>  		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
>  	int ret = 0;
> 
> +	if ((ad->devargs.mac_filter_disable == 1)
> +		&& (flow->rule == NULL)) {
> +		return 0;
> +	}
> +
>  	if (!flow || !flow->engine || !flow->engine->destroy) {
>  		rte_flow_error_set(error, EINVAL,
>  				RTE_FLOW_ERROR_TYPE_HANDLE,
> --
> 2.34.1
  
Stephen Hemminger Dec. 13, 2022, 3:51 a.m. UTC | #2
On Fri, 25 Nov 2022 10:51:24 +0800
Ke Zhang <ke1x.zhang@intel.com> wrote:

> diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
> index c8311be179..0350c6584a 100644
> --- a/drivers/net/ice/ice_ethdev.h
> +++ b/drivers/net/ice/ice_ethdev.h
> @@ -563,6 +563,7 @@ struct ice_devargs {
>  	int safe_mode_support;
>  	uint8_t proto_xtr_dflt;
>  	int pipe_mode_support;
> +	int mac_filter_disable;
 
Why use 4 bytes for a flag when a single bit would do.
  
Zhang, Ke1X Dec. 13, 2022, 5:43 a.m. UTC | #3
Hi Stephen:

Thanks for your comments.
I just follow the definition of other variables like pipe_mode_support, safe_mode_support.
And when I run the testpmd , I could write the command like this:

./dpdk-testpmd -l 16-32 -a ca:00.0,mac-filter-disable=1 -a ca:00.1 -- -i
The value could 1 or 0.

Would you please give me some guidance about the definition of the variable?

BR
Zhang Ke

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, December 13, 2022 11:51 AM
> To: Zhang, Ke1X <ke1x.zhang@intel.com>
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter
> 
> On Fri, 25 Nov 2022 10:51:24 +0800
> Ke Zhang <ke1x.zhang@intel.com> wrote:
> 
> > diff --git a/drivers/net/ice/ice_ethdev.h
> > b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644
> > --- a/drivers/net/ice/ice_ethdev.h
> > +++ b/drivers/net/ice/ice_ethdev.h
> > @@ -563,6 +563,7 @@ struct ice_devargs {
> >  	int safe_mode_support;
> >  	uint8_t proto_xtr_dflt;
> >  	int pipe_mode_support;
> > +	int mac_filter_disable;
> 
> Why use 4 bytes for a flag when a single bit would do.
  
Zhang, Ke1X Dec. 13, 2022, 5:44 a.m. UTC | #4
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, December 13, 2022 11:51 AM
> To: Zhang, Ke1X <ke1x.zhang@intel.com>
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter
> 
> On Fri, 25 Nov 2022 10:51:24 +0800
> Ke Zhang <ke1x.zhang@intel.com> wrote:
> 
> > diff --git a/drivers/net/ice/ice_ethdev.h
> > b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644
> > --- a/drivers/net/ice/ice_ethdev.h
> > +++ b/drivers/net/ice/ice_ethdev.h
> > @@ -563,6 +563,7 @@ struct ice_devargs {
> >  	int safe_mode_support;
> >  	uint8_t proto_xtr_dflt;
> >  	int pipe_mode_support;
> > +	int mac_filter_disable;
> 
> Why use 4 bytes for a flag when a single bit would do.

Thanks for your comments.
I just follow the definition of other variables like pipe_mode_support, safe_mode_support.
And when I run the testpmd , I could write the command like this:

./dpdk-testpmd -l 16-32 -a ca:00.0,mac-filter-disable=1 -a ca:00.1 -- -i The value could 1 or 0.

Would you please give me some guidance about the definition of the variable?
  
Zhang, Ke1X Dec. 17, 2022, 3:22 p.m. UTC | #5
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, December 13, 2022 11:51 AM
> To: Zhang, Ke1X <ke1x.zhang@intel.com>
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter
> 
> On Fri, 25 Nov 2022 10:51:24 +0800
> Ke Zhang <ke1x.zhang@intel.com> wrote:
> 
> > diff --git a/drivers/net/ice/ice_ethdev.h
> > b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644
> > --- a/drivers/net/ice/ice_ethdev.h
> > +++ b/drivers/net/ice/ice_ethdev.h
> > @@ -563,6 +563,7 @@ struct ice_devargs {
> >  	int safe_mode_support;
> >  	uint8_t proto_xtr_dflt;
> >  	int pipe_mode_support;
> > +	int mac_filter_disable;
> 
> Why use 4 bytes for a flag when a single bit would do.

After modifying the code like this:
struct ice_devargs {
	int rx_low_latency : 1;
	int safe_mode_support : 1;
	int pipe_mode_support : 1;
	int mac_filter_disable : 1;

I met a issue when compiling the code:
../drivers/net/ice/ice_ethdev.c:2076:19: error: cannot take address of bit-field 'safe_mode_support'
 2076 |      &parse_bool, &ad->devargs.safe_mode_support);
      |                   ^
../drivers/net/ice/ice_ethdev.c:2081:19: error: cannot take address of bit-field 'pipe_mode_support'
 2081 |      &parse_bool, &ad->devargs.pipe_mode_support);
      |                   ^
../drivers/net/ice/ice_ethdev.c:2086:18: error: cannot take address of bit-field 'mac_filter_disable'
 2086 |     &parse_bool, &ad->devargs.mac_filter_disable);
      |                  ^
../drivers/net/ice/ice_ethdev.c:2101:19: error: cannot take address of bit-field 'rx_low_latency'
 2101 |      &parse_bool, &ad->devargs.rx_low_latency);

It seems that bitfields members aren't addressable.
  
Stephen Hemminger Dec. 17, 2022, 5:20 p.m. UTC | #6
On Sat, 17 Dec 2022 15:22:21 +0000
"Zhang, Ke1X" <ke1x.zhang@intel.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Tuesday, December 13, 2022 11:51 AM
> > To: Zhang, Ke1X <ke1x.zhang@intel.com>
> > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Yuying
> > <yuying.zhang@intel.com>; dev@dpdk.org
> > Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter
> > 
> > On Fri, 25 Nov 2022 10:51:24 +0800
> > Ke Zhang <ke1x.zhang@intel.com> wrote:
> >   
> > > diff --git a/drivers/net/ice/ice_ethdev.h
> > > b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644
> > > --- a/drivers/net/ice/ice_ethdev.h
> > > +++ b/drivers/net/ice/ice_ethdev.h
> > > @@ -563,6 +563,7 @@ struct ice_devargs {
> > >  	int safe_mode_support;
> > >  	uint8_t proto_xtr_dflt;
> > >  	int pipe_mode_support;
> > > +	int mac_filter_disable;  
> > 
> > Why use 4 bytes for a flag when a single bit would do.  
> 
> After modifying the code like this:
> struct ice_devargs {
> 	int rx_low_latency : 1;
> 	int safe_mode_support : 1;
> 	int pipe_mode_support : 1;
> 	int mac_filter_disable : 1;
> 
> I met a issue when compiling the code:
> ../drivers/net/ice/ice_ethdev.c:2076:19: error: cannot take address of bit-field 'safe_mode_support'
>  2076 |      &parse_bool, &ad->devargs.safe_mode_support);
>       |                   ^
> ../drivers/net/ice/ice_ethdev.c:2081:19: error: cannot take address of bit-field 'pipe_mode_support'
>  2081 |      &parse_bool, &ad->devargs.pipe_mode_support);
>       |                   ^
> ../drivers/net/ice/ice_ethdev.c:2086:18: error: cannot take address of bit-field 'mac_filter_disable'
>  2086 |     &parse_bool, &ad->devargs.mac_filter_disable);
>       |                  ^
> ../drivers/net/ice/ice_ethdev.c:2101:19: error: cannot take address of bit-field 'rx_low_latency'
>  2101 |      &parse_bool, &ad->devargs.rx_low_latency);
> 
> It seems that bitfields members aren't addressable.
> 

Would a uint8_t work?   Also parse_bool might make assumptions about size.
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0bc739daf0..0c9f66eb88 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -28,6 +28,7 @@ 
 /* devargs */
 #define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support"
 #define ICE_PIPELINE_MODE_SUPPORT_ARG  "pipeline-mode-support"
+#define ICE_MAC_FILTER_DISABLE  "mac-filter-disable"
 #define ICE_PROTO_XTR_ARG         "proto_xtr"
 #define ICE_FIELD_OFFS_ARG		  "field_offs"
 #define ICE_FIELD_NAME_ARG		  "field_name"
@@ -49,6 +50,7 @@  static const char * const ice_valid_args[] = {
 	ICE_HW_DEBUG_MASK_ARG,
 	ICE_ONE_PPS_OUT_ARG,
 	ICE_RX_LOW_LATENCY_ARG,
+	ICE_MAC_FILTER_DISABLE,
 	NULL
 };
 
@@ -962,8 +964,13 @@  ice_add_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
 	struct ice_mac_filter *f;
 	struct LIST_HEAD_TYPE list_head;
 	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_adapter *ad = (struct ice_adapter *)hw->back;
 	int ret = 0;
 
+	if (ad->devargs.mac_filter_disable == 1) {
+		PMD_DRV_LOG(ERR, "This MAC filter is disabled.");
+		return 0;
+	}
 	/* If it's added and configured, return */
 	f = ice_find_mac_filter(vsi, mac_addr);
 	if (f) {
@@ -2075,6 +2082,11 @@  static int ice_parse_devargs(struct rte_eth_dev *dev)
 	if (ret)
 		goto bail;
 
+	ret = rte_kvargs_process(kvlist, ICE_MAC_FILTER_DISABLE,
+				&parse_bool, &ad->devargs.mac_filter_disable);
+	if (ret)
+		goto bail;
+
 	ret = rte_kvargs_process(kvlist, ICE_HW_DEBUG_MASK_ARG,
 				 &parse_u64, &ad->hw.debug_mask);
 	if (ret)
@@ -6050,6 +6062,7 @@  RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PROTO_XTR_ARG "=[queue:]<vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset>"
 			      ICE_SAFE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
+			      ICE_MAC_FILTER_DISABLE "=<0|1>"
 			      ICE_RX_LOW_LATENCY_ARG "=<0|1>");
 
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_init, init, NOTICE);
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index c8311be179..0350c6584a 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -563,6 +563,7 @@  struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	int mac_filter_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index d496c28dec..bca38f5a52 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2464,6 +2464,8 @@  ice_flow_create(struct rte_eth_dev *dev,
 		struct rte_flow_error *error)
 {
 	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_adapter *ad =
+			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct rte_flow *flow = NULL;
 	int ret;
 	struct ice_flow_engine *engine = NULL;
@@ -2476,6 +2478,14 @@  ice_flow_create(struct rte_eth_dev *dev,
 		return flow;
 	}
 
+	if (ad->devargs.mac_filter_disable == 1) {
+		if ((pattern[0].type == RTE_FLOW_ITEM_TYPE_ANY)
+			&& (actions[0].type == RTE_FLOW_ACTION_TYPE_DROP)) {
+			flow->rule = NULL;
+			return flow;
+		}
+	}
+
 	rte_spinlock_lock(&pf->flow_ops_lock);
 
 	ret = ice_flow_process_filter(dev, flow, attr, pattern, actions,
@@ -2506,6 +2516,11 @@  ice_flow_destroy(struct rte_eth_dev *dev,
 		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	int ret = 0;
 
+	if ((ad->devargs.mac_filter_disable == 1)
+		&& (flow->rule == NULL)) {
+		return 0;
+	}
+
 	if (!flow || !flow->engine || !flow->engine->destroy) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_HANDLE,