From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8463145D35; Mon, 18 Nov 2024 10:14:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 161A840669; Mon, 18 Nov 2024 10:14:00 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 6261B400D6 for ; Mon, 18 Nov 2024 10:13:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731921239; x=1763457239; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=apDIIaRyGNLDKKIH72XcV1JESdOGg+PWKNGupTa6fTY=; b=n4l7JYaXgnjaEAR6F69Dk7nC5Bg2ufABtvcakq3RBBJrCR4eiId2HcOP 003ykYNJQ7gpSvgz2hK/H6fXPB0qvc/Z5cY14ncu/ZlfjoaX09CKncZ/a 7gXg+P+QBKaiEtuQPkFpoCQ2AZrdMLRBdFMKWPd4DdjTswvGrE3T9qSsy Od6G2rlP3WcXlw04pb/eP7CpZWW1DN4qk7blEFq+F1GuvfvED3bLRqSGP zoxYbHEYjAw/K/vBoWbRresYVBk8H5mC1HjwjFpHFF9ICWx21uNfffxQw OA44fcZ5h2Ac4TxxL/sbR88ltKi+9NhPHHr2gWiRKe9nvOgrN56EXYt0d g==; X-CSE-ConnectionGUID: RpBQYpX2QGKmafBGKLhk6Q== X-CSE-MsgGUID: yleNauBrRB2G+pG0ruZwPA== X-IronPort-AV: E=McAfee;i="6700,10204,11259"; a="32104664" X-IronPort-AV: E=Sophos;i="6.12,163,1728975600"; d="scan'208";a="32104664" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2024 01:13:57 -0800 X-CSE-ConnectionGUID: igAcJp8qRIeja1/P4yXuSQ== X-CSE-MsgGUID: oVCi98EbRPSozxFmczpIbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,163,1728975600"; d="scan'208";a="89577945" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2024 01:13:56 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: Mingjin Ye Subject: [PATCH] net/ice: add devargs to control link update Date: Mon, 18 Nov 2024 08:51:49 +0000 Message-Id: <20241118085150.2587595-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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. This patch is based on DPDK 24.07.0 [b3485f4293997d35b6daecc3437bb0c183a51fb3], for customer cherry-pick. Signed-off-by: Mingjin Ye --- v2: Fix using the wrong variable. --- v3: Callback only when link state changes. --- doc/guides/nics/ice.rst | 7 +++ drivers/net/ice/ice_ethdev.c | 113 ++++++++++++++++++++++++++++++++++- drivers/net/ice/ice_ethdev.h | 4 ++ 3 files changed, 122 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index ae975d19ad..1f47c81baf 100644 --- a/doc/guides/nics/ice.rst +++ b/doc/guides/nics/ice.rst @@ -273,6 +273,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 304f959b7e..7e332e74bc 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -13,6 +13,7 @@ #include #include +#include #include "eal_firmware.h" @@ -36,6 +37,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 @@ -52,6 +54,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 }; @@ -1385,6 +1388,70 @@ ice_handle_aq_msg(struct rte_eth_dev *dev) } #endif +static void +ice_link_cycle_update(void *cb_arg) +{ + int ret; + struct timespec sys_time; + 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 && adapter->link_status != dev->data->dev_link.link_status) { + clock_gettime(CLOCK_REALTIME, &sys_time); + PMD_DRV_LOG(INFO, "Current SYS Time: %.24s %.9ld ns", + ctime(&sys_time.tv_sec), sys_time.tv_nsec); + + rte_eth_dev_callback_process + (dev, RTE_ETH_EVENT_INTR_LSC, NULL); + + adapter->link_status = dev->data->dev_link.link_status; + } + + /* 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->link_cycle_update) + return; + + adapter->link_cycle_update = true; + + 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"); + adapter->link_cycle_update = false; + } + } +} + +static void +ice_link_cycle_update_uninit(struct rte_eth_dev *dev) +{ + struct ice_adapter *adapter = + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + + adapter->link_cycle_update = false; + + if (rte_eal_alarm_cancel(&ice_link_cycle_update, (void *)dev)) + PMD_DRV_LOG(ERR, "Failed to cancel cycle link update"); + + PMD_DRV_LOG(INFO, "Cancel cycle link update"); +} /** * Interrupt handler triggered by NIC for handling * specific interrupt. @@ -1401,6 +1468,8 @@ static void ice_interrupt_handler(void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + struct ice_adapter *adapter = + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); uint32_t oicr; uint32_t reg; @@ -1411,6 +1480,7 @@ ice_interrupt_handler(void *param) #ifdef ICE_LSE_SPT uint32_t int_fw_ctl; #endif + struct timespec sys_time; /* Disable interrupt */ ice_pf_disable_irq0(hw); @@ -1433,12 +1503,20 @@ ice_interrupt_handler(void *param) ice_handle_aq_msg(dev); } #else - if (oicr & PFINT_OICR_LINK_STAT_CHANGE_M) { + if (oicr & PFINT_OICR_LINK_STAT_CHANGE_M && + adapter->devargs.link_update_period <= 0) { PMD_DRV_LOG(INFO, "OICR: link state change event"); ret = ice_link_update(dev, 0); - if (!ret) + if (!ret && adapter->link_status != dev->data->dev_link.link_status) { + clock_gettime(CLOCK_REALTIME, &sys_time); + PMD_DRV_LOG(INFO, "Current SYS Time: %.24s %.9ld ns", + ctime(&sys_time.tv_sec), sys_time.tv_nsec); + rte_eth_dev_callback_process (dev, RTE_ETH_EVENT_INTR_LSC, NULL); + adapter->link_status = dev->data->dev_link.link_status; + } + } #endif @@ -2153,6 +2231,27 @@ 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 = strtoul(value, NULL, 10); + if (errno == EINVAL || errno == ERANGE || + 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 = @@ -2214,6 +2313,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); @@ -2525,6 +2630,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: @@ -2676,6 +2783,7 @@ ice_dev_close(struct rte_eth_dev *dev) ice_interrupt_handler, dev); ret = ice_dev_stop(dev); + ice_link_cycle_update_uninit(dev); if (!ad->is_safe_mode) ice_flow_uninit(ad); @@ -3864,6 +3972,7 @@ ice_dev_start(struct rte_eth_dev *dev) /* Call get_link_info aq command to enable/disable LSE */ ice_link_update(dev, 1); + ad->link_status = dev->data->dev_link.link_status; pf->adapter_stopped = false; diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 3ea9f37dc8..d0230b839d 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -568,6 +568,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; }; /** @@ -618,6 +619,9 @@ struct ice_adapter { uint64_t time_hw; struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS]; struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS]; + /* cache link status */ + bool link_status; + bool link_cycle_update; /* True if DCF state of the associated PF is on */ RTE_ATOMIC(bool) dcf_state_on; /* Set bit if the engine is disabled */ -- 2.25.1