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(+)
@@ -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
------------------------------
@@ -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:
@@ -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;
};
/**