Skip to contentSkip to conversation

net/ice: add devargs for disabling mac filter

PATCH Superseded Ke Zhang 3 participants 16 messages Nov 25, 2022 – Feb 13, 2023 Network drivers

lore
Share & tools
lore

Ke Zhang

author
#0 lore raw

PATCH 1/1 net/ice: add devargs for disabling mac filter

From: "ke1x.zhang" <[email protected]>

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.

---
 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(+)
drivers/net/ice/ice_ethdev.c +13 -0
index 0bc739daf0..0c9f66eb88 100644
@@ -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);
drivers/net/ice/ice_ethdev.h +1 -0
index c8311be179..0350c6584a 100644
@@ -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;
drivers/net/ice/ice_generic_flow.c +15 -0
index d496c28dec..bca38f5a52 100644
@@ -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,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 29 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Friday, November 25, 2022 10:51 AM
To: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>
Subject: [PATCH] net/ice: add devargs for disabling mac filter

From: "ke1x.zhang" <[email protected]>

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.

---
 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(+)
drivers/net/ice/ice_ethdev.c index renamed from drivers/net/ice/ice_ethdev.c +0 -0

0bc739daf0..0c9f66eb88 100644

drivers/net/ice/ice_ethdev.c line 31

Quoted 4 lines
drivers/net/ice/ice_ethdev.c +1 -0
@@ -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.

Quoted 107 lines
drivers/net/ice/ice_ethdev.c +6 -0
 #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);
drivers/net/ice/ice_ethdev.c +5 -0
 	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,
drivers/net/ice/ice_ethdev.c +0 -0
 				 &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>"

drivers/net/ice/ice_ethdev.c +1 -0
 			      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

drivers/net/ice/ice_ethdev.h +1 -0
@@ -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;
drivers/net/ice/ice_generic_flow.c +2 -0
index d496c28dec..bca38f5a52 100644
@@ -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;
drivers/net/ice/ice_generic_flow.c +0 -0
 	int ret;
 	struct ice_flow_engine *engine = NULL; @@ -2476,6 +2478,14 @@

ice_flow_create(struct rte_eth_dev *dev,

drivers/net/ice/ice_generic_flow.c +3 -0
 		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)) {

drivers/net/ice/ice_generic_flow.c +5 -0
+			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,

drivers/net/ice/ice_generic_flow.c +5 -1
 		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

#2 lore raw
In reply to Ke Zhang

drivers/net/ice/ice_ethdev.h struct ice_devargs { · line 566

Quoted 9 lines · On Fri, 25 Nov 2022 10:51:24 +0800 Ke Zhang <[email protected]> wrote:
drivers/net/ice/ice_ethdev.h +1 -0
index c8311be179..0350c6584a 100644
@@ -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.

#3 lore raw

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

Quoted 22 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 13, 2022 11:51 AM
To: Zhang, Ke1X <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter

drivers/net/ice/ice_ethdev.h struct ice_devargs { · line 566

Quoted 9 lines · On Fri, 25 Nov 2022 10:51:24 +0800 Ke Zhang <[email protected]> wrote:
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -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.

#4 lore raw
In reply to Stephen Hemminger
Quoted 11 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 13, 2022 11:51 AM
To: Zhang, Ke1X <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter

On Fri, 25 Nov 2022 10:51:24 +0800
Ke Zhang <[email protected]> wrote:

Quoted 11 lines

drivers/net/ice/ice_ethdev.h struct ice_devargs { · line 566

Quoted 9 lines
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -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?

#5 lore raw
In reply to Stephen Hemminger
Quoted 13 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 13, 2022 11:51 AM
To: Zhang, Ke1X <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter

On Fri, 25 Nov 2022 10:51:24 +0800
Ke Zhang <[email protected]> wrote:

Quoted 11 lines

drivers/net/ice/ice_ethdev.h struct ice_devargs { · line 566

Quoted 9 lines
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -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.

#6 lore raw
Quoted 43 lines · On Sat, 17 Dec 2022 15:22:21 +0000 "Zhang, Ke1X" <[email protected]> wrote:
Quoted 11 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 13, 2022 11:51 AM
To: Zhang, Ke1X <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ice: add devargs for disabling mac filter

On Fri, 25 Nov 2022 10:51:24 +0800
Ke Zhang <[email protected]> wrote:

Quoted 11 lines

drivers/net/ice/ice_ethdev.h struct ice_devargs { · line 566

Quoted 9 lines
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.h index c8311be179..0350c6584a 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -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);

Quoted 2 lines

It seems that bitfields members aren't addressable.

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

author
#7 lore raw

PATCH v2 1/1 net/ice: add devargs for disabling mac filter

In reply to Ke Zhang

From: "ke1x.zhang" <[email protected]>

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.

---
 doc/guides/nics/ice.rst            | 11 +++++++++++
 drivers/net/ice/ice_ethdev.c       | 13 +++++++++++++
 drivers/net/ice/ice_ethdev.h       |  1 +
 drivers/net/ice/ice_generic_flow.c | 15 +++++++++++++++
 4 files changed, 40 insertions(+)
doc/guides/nics/ice.rst +11 -0
index ce075e067c..18b4d12048 100644
@@ -105,6 +105,17 @@ Runtime Config Options
 
     -a 80:00.0,pipeline-mode-support=1
 
+- ``Disable Mac Filter Support`` (default ``0``)
+
+  Add the feature that 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, user can choose to disable the mac filter
+  by setting ``devargs`` parameter ``mac-filter-disable``,
+  for example::
+    
+    -a 80:00.0,mac-filter-disable=1
+
 - ``Protocol extraction for per queue``
 
   Configure the RX queues to do protocol extraction into mbuf for protocol
drivers/net/ice/ice_ethdev.c +13 -0
index 0bc739daf0..0c9f66eb88 100644
@@ -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);
drivers/net/ice/ice_ethdev.h +1 -0
index c8311be179..b4036d5fb0 100644
@@ -563,6 +563,7 @@ struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	uint8_t mac_filter_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
drivers/net/ice/ice_generic_flow.c +15 -0
index d496c28dec..bca38f5a52 100644
@@ -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,
Signature · 1 line
2.34.1
#8 lore raw
Quoted 30 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Wednesday, December 21, 2022 11:58 AM
To: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>
Subject: [PATCH v2] net/ice: add devargs for disabling mac filter

From: "ke1x.zhang" <[email protected]>

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.

---
 doc/guides/nics/ice.rst            | 11 +++++++++++
 drivers/net/ice/ice_ethdev.c       | 13 +++++++++++++
 drivers/net/ice/ice_ethdev.h       |  1 +
 drivers/net/ice/ice_generic_flow.c | 15 +++++++++++++++
 4 files changed, 40 insertions(+)
doc/guides/nics/ice.rst index renamed from doc/guides/nics/ice.rst +0 -0

ce075e067c..18b4d12048 100644

doc/guides/nics/ice.rst Runtime Config Options · line 108

Quoted 4 lines
doc/guides/nics/ice.rst +1 -0
@@ -105,6 +105,17 @@ Runtime Config Options
 
     -a 80:00.0,pipeline-mode-support=1
 
+- ``Disable Mac Filter Support`` (default ``0``)

I think better to name the feature as "No default Mac" , as we still support add/del MAC filter.

doc/guides/nics/ice.rst Runtime Config Options · line 112

Quoted 4 lines
doc/guides/nics/ice.rst +4 -0
+
+  Add the feature that support to disable mac filter which will be used
+ by ice driver  when setting dpdk_devargs config field in the TRex config file.
+

No need to mention TRex here, just describe what's the expected behavior when user set this flag.

Quoted 103 lines
doc/guides/nics/ice.rst +6 -0
+  Mac filter is not disabled in default, user can choose to disable the
+ mac filter  by setting ``devargs`` parameter ``mac-filter-disable``,
+ for example::
+
+    -a 80:00.0,mac-filter-disable=1
+
 - ``Protocol extraction for per queue``
 
   Configure the RX queues to do protocol extraction into mbuf for protocol
drivers/net/ice/ice_ethdev.c index renamed from drivers/net/ice/ice_ethdev.c +0 -0

0bc739daf0..0c9f66eb88 100644

drivers/net/ice/ice_ethdev.c +7 -0
@@ -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);
drivers/net/ice/ice_ethdev.c +5 -0
 	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,
drivers/net/ice/ice_ethdev.c +0 -0
 				 &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>"

drivers/net/ice/ice_ethdev.c +1 -0
 			      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..b4036d5fb0 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -563,6 +563,7 @@ struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	uint8_t mac_filter_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
drivers/net/ice/ice_generic_flow.c +2 -0
index d496c28dec..bca38f5a52 100644
@@ -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;
drivers/net/ice/ice_generic_flow.c +0 -0
 	int ret;
 	struct ice_flow_engine *engine = NULL; @@ -2476,6 +2478,14 @@

ice_flow_create(struct rte_eth_dev *dev,

drivers/net/ice/ice_generic_flow.c +3 -0
 		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)) {

drivers/net/ice/ice_generic_flow.c ice_flow_create(struct rte_eth_dev *dev, · line 2487

Quoted 4 lines
drivers/net/ice/ice_generic_flow.c +4 -0
+			flow->rule = NULL;
+			return flow;
+		}
+	}

Why we need this?

We don't need to mix this patch with the rte_flow "drop any" rule.

#9 lore raw
Quoted 40 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Monday, December 26, 2022 2:15 PM
To: Zhang, Ke1X <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: RE: [PATCH v2] net/ice: add devargs for disabling mac filter

Quoted 29 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Wednesday, December 21, 2022 11:58 AM
To: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>
Subject: [PATCH v2] net/ice: add devargs for disabling mac filter

From: "ke1x.zhang" <[email protected]>

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.

---
 doc/guides/nics/ice.rst            | 11 +++++++++++
 drivers/net/ice/ice_ethdev.c       | 13 +++++++++++++
 drivers/net/ice/ice_ethdev.h       |  1 +
 drivers/net/ice/ice_generic_flow.c | 15 +++++++++++++++
 4 files changed, 40 insertions(+)
doc/guides/nics/ice.rst index renamed from doc/guides/nics/ice.rst +0 -0

ce075e067c..18b4d12048 100644

doc/guides/nics/ice.rst +0 -0
@@ -105,6 +105,17 @@ Runtime Config Options
 
Quoted 6 lines

doc/guides/nics/ice.rst Runtime Config Options · line 108

Quoted 3 lines
doc/guides/nics/ice.rst +1 -0
     -a 80:00.0,pipeline-mode-support=1
 
+- ``Disable Mac Filter Support`` (default ``0``)

I think better to name the feature as "No default Mac" , as we still support add/del MAC filter.

Thanks for your comments, there is a question:
If we still support add/del MAC filter, what should do in ice_add_mac_filter()? In ice_add_mac_filter(), I don't know the caller, maybe it is a initiliazer to add defaut mac or add mac filter command.

Quoted 123 lines

doc/guides/nics/ice.rst Runtime Config Options · line 111

Quoted 4 lines
doc/guides/nics/ice.rst +3 -0
+
+  Add the feature that support to disable mac filter which will be
+ used by ice driver  when setting dpdk_devargs config field in the TRex

config file.

doc/guides/nics/ice.rst Runtime Config Options · line 112

Quoted 1 line
doc/guides/nics/ice.rst +1 -0
+

No need to mention TRex here, just describe what's the expected behavior when user set this flag.

Quoted 104 lines
doc/guides/nics/ice.rst +6 -0
+  Mac filter is not disabled in default, user can choose to disable
+ the mac filter  by setting ``devargs`` parameter
+ ``mac-filter-disable``, for example::
+
+    -a 80:00.0,mac-filter-disable=1
+
 - ``Protocol extraction for per queue``
 
   Configure the RX queues to do protocol extraction into mbuf for

protocol diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 0bc739daf0..0c9f66eb88 100644

drivers/net/ice/ice_ethdev.c +7 -0
@@ -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);
drivers/net/ice/ice_ethdev.c +5 -0
 	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,
drivers/net/ice/ice_ethdev.c +0 -0
 				 &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>"

drivers/net/ice/ice_ethdev.c +1 -0
 			      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..b4036d5fb0 100644

drivers/net/ice/ice_ethdev.h +1 -0
@@ -563,6 +563,7 @@ struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	uint8_t mac_filter_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
drivers/net/ice/ice_generic_flow.c +2 -0
index d496c28dec..bca38f5a52 100644
@@ -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;
drivers/net/ice/ice_generic_flow.c +0 -0
 	int ret;
 	struct ice_flow_engine *engine = NULL; @@ -2476,6 +2478,14 @@

ice_flow_create(struct rte_eth_dev *dev,

drivers/net/ice/ice_generic_flow.c +3 -0
 		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)) {

drivers/net/ice/ice_generic_flow.c ice_flow_create(struct rte_eth_dev *dev, · line 2487

Quoted 4 lines
drivers/net/ice/ice_generic_flow.c +4 -0
+			flow->rule = NULL;
+			return flow;
+		}
+	}

Why we need this?

We don't need to mix this patch with the rte_flow "drop any" rule.

author
#10 lore raw

PATCH v3 1/1 net/ice: add devargs for disabling default mac

In reply to Ke Zhang

From: "ke1x.zhang" <[email protected]>

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Default mac is not disabled in default, user can choose to disable the default mac
by setting ``devargs`` parameter ``default-mac-disable``,

for example::

     -a 80:00.0,default-mac-disable=1
---
 doc/guides/nics/ice.rst      | 11 +++++++++++
 drivers/net/ice/ice_ethdev.c | 21 ++++++++++++++++++---
 drivers/net/ice/ice_ethdev.h |  1 +
 3 files changed, 30 insertions(+), 3 deletions(-)
doc/guides/nics/ice.rst +11 -0
index ce075e067c..860ed1430d 100644
@@ -105,6 +105,17 @@ Runtime Config Options
 
     -a 80:00.0,pipeline-mode-support=1
 
+- ``Default Mac Disable`` (default ``0``)
+
+  Add the feature that support to disable default mac which will be used by ice driver
+  when setting dpdk_devargs config field.
+
+  Default mac is not disabled in default, user can choose to disable the default mac
+  by setting ``devargs`` parameter ``default-mac-disable``,
+  for example::
+
+    -a 80:00.0,default-mac-disable=1
+
 - ``Protocol extraction for per queue``
 
   Configure the RX queues to do protocol extraction into mbuf for protocol
drivers/net/ice/ice_ethdev.c +18 -3
index 0bc739daf0..0d011bbffa 100644
@@ -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_DEFAULT_MAC_DISABLE   "default-mac-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_DEFAULT_MAC_DISABLE,
 	NULL
 };
 
@@ -916,6 +918,7 @@ static int
 ice_init_mac_address(struct rte_eth_dev *dev)
 {
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_adapter *ad = (struct ice_adapter *)hw->back;
 
 	if (!rte_is_unicast_ether_addr
 		((struct rte_ether_addr *)hw->port_info[0].mac.lan_addr)) {
@@ -935,9 +938,9 @@ ice_init_mac_address(struct rte_eth_dev *dev)
 		return -ENOMEM;
 	}
 	/* store it to dev data */
-	rte_ether_addr_copy(
-		(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr,
-		&dev->data->mac_addrs[0]);
+	if (ad->devargs.default_mac_disable != 1)
+		rte_ether_addr_copy((struct rte_ether_addr *)hw->port_info[0].mac.perm_addr,
+			&dev->data->mac_addrs[0]);
 	return 0;
 }
 
@@ -962,8 +965,14 @@ 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.default_mac_disable == 1 && rte_is_same_ether_addr(mac_addr,
+			(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr)) {
+		PMD_DRV_LOG(ERR, "This Default 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 +2084,11 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	if (ret)
 		goto bail;
 
+	ret = rte_kvargs_process(kvlist, ICE_DEFAULT_MAC_DISABLE,
+				&parse_bool, &ad->devargs.default_mac_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 +6064,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_DEFAULT_MAC_DISABLE "=<0|1>"
 			      ICE_RX_LOW_LATENCY_ARG "=<0|1>");
 
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_init, init, NOTICE);
drivers/net/ice/ice_ethdev.h +1 -0
index c8311be179..9140f3af79 100644
@@ -563,6 +563,7 @@ struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	uint8_t default_mac_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH v3] net/ice: add devargs for disabling default mac

Quoted 6 lines · On Thu, 12 Jan 2023 15:55:38 +0800 Ke Zhang <[email protected]> wrote:

From: "ke1x.zhang" <[email protected]>

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Quoted 8 lines

Default mac is not disabled in default, user can choose to disable the default mac
by setting ``devargs`` parameter ``default-mac-disable``,

for example::

     -a 80:00.0,default-mac-disable=1

Why is the driver specific option needed? Can't it be handled more generally by the application.

#12 lore raw

RE: [PATCH v3] net/ice: add devargs for disabling default mac

Quoted 21 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, January 12, 2023 11:32 PM
To: Zhang, Ke1X <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Subject: Re: [PATCH v3] net/ice: add devargs for disabling default mac

Quoted 8 lines · On Thu, 12 Jan 2023 15:55:38 +0800 Ke Zhang <[email protected]> wrote:

From: "ke1x.zhang" <[email protected]>

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Default mac is not disabled in default, user can choose to disable the default mac by setting ``devargs`` parameter ``default-mac-disable``,

Quoted 7 lines
Quoted 4 lines

for example::

     -a 80:00.0,default-mac-disable=1

Why is the driver specific option needed? Can't it be handled more generally by the application.

Thanks for your comments.

This patch is to support the latency function of a trex, for example:

Trex wants to send a packet with tos=1. After the peer forwards it back, it only receives packets with tos=1. Other packets will be dropped in the switch stage of pipeline.

1.If the following rules are set as below:
flow create 0 ingress pattern eth / ipv4 tos is 1 / end actions queue index 1 / end

result: the packets will pass as long as the destination mac address matches the default mac address.

2.If the following rules are set as below:
flow create 0 ingress pattern any / end actions drop / end
flow create 0 ingress pattern eth / ipv4 tos is 1 / end actions queue index 1 / end

result: all packages will be dropped.

3.The current solution is to disable the default mac address during initialization, and then set the following rules:
flow create 0 ingress pattern eth / ipv4 tos is 1 / end actions queue index 1 / end

result: only packages with tos=1 can pass。

Would you please share a better solution for me? @Stephen Hemminger Thanks.

#13 lore raw

RE: [PATCH v3] net/ice: add devargs for disabling default mac

In reply to Ke Zhang
Quoted 36 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Thursday, January 12, 2023 3:56 PM
To: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>
Subject: [PATCH v3] net/ice: add devargs for disabling default mac

From: "ke1x.zhang" <[email protected]>

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Default mac is not disabled in default, user can choose to disable the default mac by setting ``devargs`` parameter ``default-mac-disable``,

for example::

     -a 80:00.0,default-mac-disable=1
---
 doc/guides/nics/ice.rst      | 11 +++++++++++
 drivers/net/ice/ice_ethdev.c | 21 ++++++++++++++++++---
drivers/net/ice/ice_ethdev.h |  1 +
 3 files changed, 30 insertions(+), 3 deletions(-)
doc/guides/nics/ice.rst index renamed from doc/guides/nics/ice.rst +0 -0

ce075e067c..860ed1430d 100644

doc/guides/nics/ice.rst +0 -0
@@ -105,6 +105,17 @@ Runtime Config Options
 
     -a 80:00.0,pipeline-mode-support=1
 

doc/guides/nics/ice.rst Runtime Config Options · line 117

Quoted 10 lines
doc/guides/nics/ice.rst +10 -0
+- ``Default Mac Disable`` (default ``0``)
+
+  Add the feature that support to disable default mac which will be
+ used by ice driver  when setting dpdk_devargs config field.
+
+  Default mac is not disabled in default, user can choose to disable
+ the default mac  by setting ``devargs`` parameter
+ ``default-mac-disable``,  for example::
+
+    -a 80:00.0,default-mac-disable=1

At least we need to explain what's the typical usage with this feature in general.

author
#14 lore raw

PATCH v4 1/1 net/ice: add devargs for disabling default mac

In reply to Ke Zhang

From: "ke1x.zhang" <[email protected]>

There is a requirement that if a flow rule is created, received packet is permitted to pass if rule matching, or else drop. But in default, a mac filter will be created and the default mac will be added into lookup table during driver initialization, it makes drop action impossilbe.

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Default mac is not disabled in default, user can choose to disable the default mac
by setting ``devargs`` parameter ``default-mac-disable``,

for example::

     -a 80:00.0,default-mac-disable=1

---
v4: explain what's the typical usage with this feature in general
v3: rename the feature name
remove some unecessary codes.

---
 doc/guides/nics/ice.rst      | 16 ++++++++++++++++
 drivers/net/ice/ice_ethdev.c | 21 ++++++++++++++++++---
 drivers/net/ice/ice_ethdev.h |  1 +
 3 files changed, 35 insertions(+), 3 deletions(-)
doc/guides/nics/ice.rst +16 -0
index 335b558338..24bbd5b145 100644
@@ -107,6 +107,22 @@ Runtime Config Options
 
     -a 80:00.0,pipeline-mode-support=1
 
+- ``Default Mac Disable`` (default ``0``)
+
+  There is a requirement that if a flow rule is created, received packet is permitted
+  to pass if rule matching, or else drop.
+  But in default, a mac filter will be created and the default mac will be added into
+  lookup table during driver initialization, it makes drop action impossilbe.
+
+  Add the feature that support to disable default mac which will be used by ice driver
+  when setting dpdk_devargs config field.
+
+  Default mac is not disabled in default, user can choose to disable the default mac
+  by setting ``devargs`` parameter ``default-mac-disable``,
+  for example::
+
+    -a 80:00.0,default-mac-disable=1
+
 - ``Protocol extraction for per queue``
 
   Configure the RX queues to do protocol extraction into mbuf for protocol
drivers/net/ice/ice_ethdev.c +18 -3
index 0bc739daf0..0d011bbffa 100644
@@ -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_DEFAULT_MAC_DISABLE   "default-mac-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_DEFAULT_MAC_DISABLE,
 	NULL
 };
 
@@ -916,6 +918,7 @@ static int
 ice_init_mac_address(struct rte_eth_dev *dev)
 {
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_adapter *ad = (struct ice_adapter *)hw->back;
 
 	if (!rte_is_unicast_ether_addr
 		((struct rte_ether_addr *)hw->port_info[0].mac.lan_addr)) {
@@ -935,9 +938,9 @@ ice_init_mac_address(struct rte_eth_dev *dev)
 		return -ENOMEM;
 	}
 	/* store it to dev data */
-	rte_ether_addr_copy(
-		(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr,
-		&dev->data->mac_addrs[0]);
+	if (ad->devargs.default_mac_disable != 1)
+		rte_ether_addr_copy((struct rte_ether_addr *)hw->port_info[0].mac.perm_addr,
+			&dev->data->mac_addrs[0]);
 	return 0;
 }
 
@@ -962,8 +965,14 @@ 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.default_mac_disable == 1 && rte_is_same_ether_addr(mac_addr,
+			(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr)) {
+		PMD_DRV_LOG(ERR, "This Default 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 +2084,11 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	if (ret)
 		goto bail;
 
+	ret = rte_kvargs_process(kvlist, ICE_DEFAULT_MAC_DISABLE,
+				&parse_bool, &ad->devargs.default_mac_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 +6064,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_DEFAULT_MAC_DISABLE "=<0|1>"
 			      ICE_RX_LOW_LATENCY_ARG "=<0|1>");
 
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_init, init, NOTICE);
drivers/net/ice/ice_ethdev.h +1 -0
index c8311be179..9140f3af79 100644
@@ -563,6 +563,7 @@ struct ice_devargs {
 	int safe_mode_support;
 	uint8_t proto_xtr_dflt;
 	int pipe_mode_support;
+	uint8_t default_mac_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;
Signature · 1 line
2.25.1
Acked-by on v4 1/1 Applied
#15 lore raw

RE: [PATCH v4] net/ice: add devargs for disabling default mac

Quoted 17 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Friday, February 3, 2023 10:02 AM
To: Zhang, Qi Z <[email protected]>; Zhang, Yuying <[email protected]>; Liu, Yong <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>
Subject: [PATCH v4] net/ice: add devargs for disabling default mac

From: "ke1x.zhang" <[email protected]>

There is a requirement that if a flow rule is created, received packet is permitted to pass if rule matching, or else drop.
But in default, a mac filter will be created and the default mac will be added into lookup table during driver initialization, it makes drop action impossilbe.

Quoted 5 lines

Add the feature that support to disable default mac which will be used by ice driver when setting dpdk_devargs config field.

Default mac is not disabled in default, user can choose to disable the default mac by setting ``devargs`` parameter ``default-mac-disable``,

Reworded to

Disable the default MAC make the device drop all packets by default, only packets hit on filter rules will pass.

Default Mac can be disabled by setting ``devargs`` parameter ``default-mac-disable``, for example::

Applied to dpdk-next-net-intel.

Thanks
Qi