DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC] net/ice: add devargs to control link update
@ 2024-10-22  6:20 Mingjin Ye
  2024-10-22  6:38 ` [RFC v2] " Mingjin Ye
  2024-10-22 15:23 ` [RFC] " Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Mingjin Ye @ 2024-10-22  6:20 UTC (permalink / raw)
  To: dev; +Cc: Mingjin Ye

This patch adds the ‘link_period’ devargs to adjust the link update
period (microseconds), when the value is less than or equal to 0
it will be disabled, by default it is not enabled.

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
 doc/guides/nics/ice.rst      |  7 ++++
 drivers/net/ice/ice_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h |  1 +
 3 files changed, 77 insertions(+)

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index 91b5a9b461..ccfff3f294 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -303,6 +303,13 @@ Runtime Configuration
   * ``segment``: Check number of mbuf segments does not exceed HW limits.
   * ``offload``: Check for use of an unsupported offload flag.
 
+- ``Cycle link update`` (default ``not enabled``)
+
+  Cyclic link update is enabled when the PMD status changes to STARTED. Setting
+  the ``devargs`` parameter ``link_period`` adjusts the link update period in
+  microseconds, and is disabled when the value set is less than or equal to 0.
+  For example ``-a 81:00.0,link_period=5000`` or ``-a 81:00.0,link_period=0``.
+
 Driver compilation and testing
 ------------------------------
 
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 70298ac330..a1ef0c0d39 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -15,6 +15,7 @@
 
 #include <rte_tailq.h>
 #include <rte_os_shim.h>
+#include <rte_alarm.h>
 
 #include "eal_firmware.h"
 
@@ -38,6 +39,7 @@
 #define ICE_ONE_PPS_OUT_ARG       "pps_out"
 #define ICE_RX_LOW_LATENCY_ARG    "rx_low_latency"
 #define ICE_MBUF_CHECK_ARG       "mbuf_check"
+#define ICE_LINK_UPDATE_ARG       "link_period"
 
 #define ICE_CYCLECOUNTER_MASK  0xffffffffffffffffULL
 
@@ -54,6 +56,7 @@ static const char * const ice_valid_args[] = {
 	ICE_RX_LOW_LATENCY_ARG,
 	ICE_DEFAULT_MAC_DISABLE,
 	ICE_MBUF_CHECK_ARG,
+	ICE_LINK_UPDATE_ARG,
 	NULL
 };
 
@@ -1389,6 +1392,44 @@ ice_handle_aq_msg(struct rte_eth_dev *dev)
 }
 #endif
 
+static void
+ice_link_cycle_update(void *cb_arg)
+{
+	int ret;
+	struct rte_eth_dev *dev = cb_arg;
+	struct ice_adapter *adapter =
+		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	ret = ice_link_update(dev, 0);
+	if (!ret)
+		rte_eth_dev_callback_process
+			(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+
+	if (dev->data->dev_started) {
+		/* re-alarm link update */
+		if (rte_eal_alarm_set(adapter->devargs.link_update_period,
+					&ice_link_cycle_update, (void *)adapter))
+			PMD_DRV_LOG(ERR, "Failed to enable cycle link update");
+	}
+}
+
+static void
+ice_link_cycle_update_init(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *adapter =
+		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	if (adapter->devargs.link_update_period <= 0) {
+		PMD_DRV_LOG(INFO, "Device cycle link update is disabled");
+	} else {
+		PMD_DRV_LOG(INFO, "Enabling cycle link update, period is %dμs",
+					adapter->devargs.link_update_period);
+		if (rte_eal_alarm_set(adapter->devargs.link_update_period,
+					&ice_link_cycle_update, (void *)dev))
+			PMD_DRV_LOG(ERR, "Failed to enable cycle link update");
+	}
+}
+
 /**
  * Interrupt handler triggered by NIC for handling
  * specific interrupt.
@@ -2196,6 +2237,26 @@ ice_parse_mbuf_check(__rte_unused const char *key, const char *value, void *args
 	return ret;
 }
 
+static int
+ice_parse_clean_subtask_period(__rte_unused const char *key,
+		const char *value, void *args)
+{
+	int *num = (int *)args;
+	int tmp;
+
+	errno = 0;
+	tmp = atoi(value);
+	if (tmp < 0) {
+		PMD_DRV_LOG(WARNING, "%s: \"%s\" is not greater than or equal to zero",
+						key, value);
+		return -1;
+	}
+
+	*num = tmp;
+
+	return 0;
+}
+
 static int ice_parse_devargs(struct rte_eth_dev *dev)
 {
 	struct ice_adapter *ad =
@@ -2257,6 +2318,12 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	if (ret)
 		goto bail;
 
+	ret = rte_kvargs_process(kvlist, ICE_LINK_UPDATE_ARG,
+				 &ice_parse_clean_subtask_period,
+				 &ad->devargs.link_update_period);
+	if (ret)
+		goto bail;
+
 	ret = rte_kvargs_process(kvlist, ICE_RX_LOW_LATENCY_ARG,
 				 &parse_bool, &ad->devargs.rx_low_latency);
 
@@ -2598,6 +2665,8 @@ ice_dev_init(struct rte_eth_dev *dev)
 	/* reset all stats of the device, including pf and main vsi */
 	ice_stats_reset(dev);
 
+	ice_link_cycle_update_init(dev);
+
 	return 0;
 
 err_flow_init:
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 57087c98ed..4cbe119ac4 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -569,6 +569,7 @@ struct ice_devargs {
 	/* Name of the field. */
 	char xtr_field_name[RTE_MBUF_DYN_NAMESIZE];
 	uint64_t mbuf_check;
+	uint32_t link_update_period;
 };
 
 /**
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC v2] net/ice: add devargs to control link update
  2024-10-22  6:20 [RFC] net/ice: add devargs to control link update Mingjin Ye
@ 2024-10-22  6:38 ` Mingjin Ye
  2024-10-22 15:23 ` [RFC] " Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Mingjin Ye @ 2024-10-22  6:38 UTC (permalink / raw)
  To: dev; +Cc: Mingjin Ye

This patch adds the ‘link_period’ devargs to adjust the link update
period (microseconds), when the value is less than or equal to 0
it will be disabled, by default it is not enabled.

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
v2: Fix using the wrong variable.
---
 doc/guides/nics/ice.rst      |  7 ++++
 drivers/net/ice/ice_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h |  1 +
 3 files changed, 77 insertions(+)

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index 91b5a9b461..ccfff3f294 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -303,6 +303,13 @@ Runtime Configuration
   * ``segment``: Check number of mbuf segments does not exceed HW limits.
   * ``offload``: Check for use of an unsupported offload flag.
 
+- ``Cycle link update`` (default ``not enabled``)
+
+  Cyclic link update is enabled when the PMD status changes to STARTED. Setting
+  the ``devargs`` parameter ``link_period`` adjusts the link update period in
+  microseconds, and is disabled when the value set is less than or equal to 0.
+  For example ``-a 81:00.0,link_period=5000`` or ``-a 81:00.0,link_period=0``.
+
 Driver compilation and testing
 ------------------------------
 
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 70298ac330..3d7443c5ec 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -15,6 +15,7 @@
 
 #include <rte_tailq.h>
 #include <rte_os_shim.h>
+#include <rte_alarm.h>
 
 #include "eal_firmware.h"
 
@@ -38,6 +39,7 @@
 #define ICE_ONE_PPS_OUT_ARG       "pps_out"
 #define ICE_RX_LOW_LATENCY_ARG    "rx_low_latency"
 #define ICE_MBUF_CHECK_ARG       "mbuf_check"
+#define ICE_LINK_UPDATE_ARG       "link_period"
 
 #define ICE_CYCLECOUNTER_MASK  0xffffffffffffffffULL
 
@@ -54,6 +56,7 @@ static const char * const ice_valid_args[] = {
 	ICE_RX_LOW_LATENCY_ARG,
 	ICE_DEFAULT_MAC_DISABLE,
 	ICE_MBUF_CHECK_ARG,
+	ICE_LINK_UPDATE_ARG,
 	NULL
 };
 
@@ -1389,6 +1392,44 @@ ice_handle_aq_msg(struct rte_eth_dev *dev)
 }
 #endif
 
+static void
+ice_link_cycle_update(void *cb_arg)
+{
+	int ret;
+	struct rte_eth_dev *dev = cb_arg;
+	struct ice_adapter *adapter =
+		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	ret = ice_link_update(dev, 0);
+	if (!ret)
+		rte_eth_dev_callback_process
+			(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+
+	if (dev->data->dev_started) {
+		/* re-alarm link update */
+		if (rte_eal_alarm_set(adapter->devargs.link_update_period,
+					&ice_link_cycle_update, cb_arg))
+			PMD_DRV_LOG(ERR, "Failed to enable cycle link update");
+	}
+}
+
+static void
+ice_link_cycle_update_init(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *adapter =
+		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	if (adapter->devargs.link_update_period <= 0) {
+		PMD_DRV_LOG(INFO, "Device cycle link update is disabled");
+	} else {
+		PMD_DRV_LOG(INFO, "Enabling cycle link update, period is %dμs",
+					adapter->devargs.link_update_period);
+		if (rte_eal_alarm_set(adapter->devargs.link_update_period,
+					&ice_link_cycle_update, (void *)dev))
+			PMD_DRV_LOG(ERR, "Failed to enable cycle link update");
+	}
+}
+
 /**
  * Interrupt handler triggered by NIC for handling
  * specific interrupt.
@@ -2196,6 +2237,26 @@ ice_parse_mbuf_check(__rte_unused const char *key, const char *value, void *args
 	return ret;
 }
 
+static int
+ice_parse_clean_subtask_period(__rte_unused const char *key,
+		const char *value, void *args)
+{
+	int *num = (int *)args;
+	int tmp;
+
+	errno = 0;
+	tmp = atoi(value);
+	if (tmp < 0) {
+		PMD_DRV_LOG(WARNING, "%s: \"%s\" is not greater than or equal to zero",
+						key, value);
+		return -1;
+	}
+
+	*num = tmp;
+
+	return 0;
+}
+
 static int ice_parse_devargs(struct rte_eth_dev *dev)
 {
 	struct ice_adapter *ad =
@@ -2257,6 +2318,12 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	if (ret)
 		goto bail;
 
+	ret = rte_kvargs_process(kvlist, ICE_LINK_UPDATE_ARG,
+				 &ice_parse_clean_subtask_period,
+				 &ad->devargs.link_update_period);
+	if (ret)
+		goto bail;
+
 	ret = rte_kvargs_process(kvlist, ICE_RX_LOW_LATENCY_ARG,
 				 &parse_bool, &ad->devargs.rx_low_latency);
 
@@ -2598,6 +2665,8 @@ ice_dev_init(struct rte_eth_dev *dev)
 	/* reset all stats of the device, including pf and main vsi */
 	ice_stats_reset(dev);
 
+	ice_link_cycle_update_init(dev);
+
 	return 0;
 
 err_flow_init:
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 57087c98ed..4cbe119ac4 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -569,6 +569,7 @@ struct ice_devargs {
 	/* Name of the field. */
 	char xtr_field_name[RTE_MBUF_DYN_NAMESIZE];
 	uint64_t mbuf_check;
+	uint32_t link_update_period;
 };
 
 /**
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] net/ice: add devargs to control link update
  2024-10-22  6:20 [RFC] net/ice: add devargs to control link update Mingjin Ye
  2024-10-22  6:38 ` [RFC v2] " Mingjin Ye
@ 2024-10-22 15:23 ` Stephen Hemminger
  2024-10-23  7:17   ` Ye, MingjinX
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2024-10-22 15:23 UTC (permalink / raw)
  To: Mingjin Ye; +Cc: dev

On Tue, 22 Oct 2024 06:20:43 +0000
Mingjin Ye <mingjinx.ye@intel.com> wrote:

> +static int
> +ice_parse_clean_subtask_period(__rte_unused const char *key,
> +		const char *value, void *args)
> +{
> +	int *num = (int *)args;
Cast of void * unnecessary in C.
You probably want period to be unsigned not signed.

> +	int tmp;
> +
> +	errno = 0;
> +	tmp = atoi(value);
> +	if (tmp < 0) {
> +		PMD_DRV_LOG(WARNING, "%s: \"%s\" is not greater than or equal to zero",
> +						key, value);
> +		return -1;
> +	}
> +
> +	*num = tmp;
> +
> +	return 0;
> +}

Prefer strtoul() when parsing values, it allows for better error handling.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [RFC] net/ice: add devargs to control link update
  2024-10-22 15:23 ` [RFC] " Stephen Hemminger
@ 2024-10-23  7:17   ` Ye, MingjinX
  0 siblings, 0 replies; 4+ messages in thread
From: Ye, MingjinX @ 2024-10-23  7:17 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, October 22, 2024 11:23 PM
> To: Ye, MingjinX <mingjinx.ye@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [RFC] net/ice: add devargs to control link update
> 
> On Tue, 22 Oct 2024 06:20:43 +0000
> Mingjin Ye <mingjinx.ye@intel.com> wrote:
> 
> > +static int
> > +ice_parse_clean_subtask_period(__rte_unused const char *key,
> > +		const char *value, void *args)
> > +{
> > +	int *num = (int *)args;
> Cast of void * unnecessary in C.
> You probably want period to be unsigned not signed.
> 
> > +	int tmp;
> > +
> > +	errno = 0;
> > +	tmp = atoi(value);
> > +	if (tmp < 0) {
> > +		PMD_DRV_LOG(WARNING, "%s: \"%s\" is not greater than
> or equal to zero",
> > +						key, value);
> > +		return -1;
> > +	}
> > +
> > +	*num = tmp;
> > +
> > +	return 0;
> > +}
> 
> Prefer strtoul() when parsing values, it allows for better error handling.
Thank you. Good suggestion.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-23  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-22  6:20 [RFC] net/ice: add devargs to control link update Mingjin Ye
2024-10-22  6:38 ` [RFC v2] " Mingjin Ye
2024-10-22 15:23 ` [RFC] " Stephen Hemminger
2024-10-23  7:17   ` Ye, MingjinX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).