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

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

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-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Zhang, Ke1X Jan. 12, 2023, 7:55 a.m. UTC
  From: "ke1x.zhang" <ke1x.zhang@intel.com>

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

Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>
---
 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(-)
  

Comments

Stephen Hemminger Jan. 12, 2023, 4:32 p.m. UTC | #1
On Thu, 12 Jan 2023 15:55:38 +0800
Ke Zhang <ke1x.zhang@intel.com> wrote:

> From: "ke1x.zhang" <ke1x.zhang@intel.com>
> 
> 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
> 
> Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>

Why is the driver specific option needed? Can't it be handled
more generally by the application.
  
Zhang, Ke1X Jan. 16, 2023, 1:38 p.m. UTC | #2
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, January 12, 2023 11:32 PM
> 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 v3] net/ice: add devargs for disabling default mac
> 
> On Thu, 12 Jan 2023 15:55:38 +0800
> Ke Zhang <ke1x.zhang@intel.com> wrote:
> 
> > From: "ke1x.zhang" <ke1x.zhang@intel.com>
> >
> > 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
> >
> > Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>
> 
> 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.
  
Qi Zhang Feb. 1, 2023, 8:22 a.m. UTC | #3
> -----Original Message-----
> From: Zhang, Ke1X <ke1x.zhang@intel.com>
> Sent: Thursday, January 12, 2023 3:56 PM
> 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 v3] net/ice: add devargs for disabling default mac
> 
> From: "ke1x.zhang" <ke1x.zhang@intel.com>
> 
> 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
> 
> Signed-off-by: ke1x.zhang <ke1x.zhang@intel.com>
> ---
>  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(-)
> 
> diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index
> ce075e067c..860ed1430d 100644
> --- a/doc/guides/nics/ice.rst
> +++ b/doc/guides/nics/ice.rst
> @@ -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

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

Patch

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index ce075e067c..860ed1430d 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -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
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0bc739daf0..0d011bbffa 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_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);
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index c8311be179..9140f3af79 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;
+	uint8_t default_mac_disable;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 	uint8_t pin_idx;
 	uint8_t pps_out_ena;