From patchwork Tue Apr 18 05:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhichao Zeng X-Patchwork-Id: 126206 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26B5642977; Tue, 18 Apr 2023 07:37:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC19D40EDF; Tue, 18 Apr 2023 07:37:09 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id B762B40E09 for ; Tue, 18 Apr 2023 07:37:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681796227; x=1713332227; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZDQZFr1ytl9nVz1Ft9pl1HaTNqLWYwxx/+5RhBxQ/Fk=; b=a+tXzT7FBmgwudvcuFFhbNVd9E8JoBOtI6Tct7rlToa2J8tfjvN5DpOK ZW5t6wk2VQssUFdA+pE2ZLYYBkvC7D+bWmmQbGd0KbKNkFXGg8yVfMRiY wGI1i1mjHVr8c89gRGiLiWnAqtusa4RskvtZqpJVtSPDi7fTx24OCZ9lb Dc7hGJ9jfzQF8IJB4wZDR9tyV98vY+shjAn1fzhxobEtfkO2q+z0Aol+g gwxkphU89RBJDyQmIYs9g8uL+Oxhuw2adGoNxPkqWrwj1E04fHqN/yrd8 4cQU6czC4QS7ooaR5TZk9Fk6+riE166L6W0w9wimF3avP71wMRDdJGjlM g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="342574297" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="342574297" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 22:37:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="802412763" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="802412763" Received: from unknown (HELO localhost.localdomain) ([10.239.252.103]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 22:37:04 -0700 From: Zhichao Zeng To: dev@dpdk.org Cc: qi.z.zhang@intel.com, Zhichao Zeng , Jingjing Wu , Beilei Xing Subject: [PATCH] net/iavf: add devargs to enable watchdog Date: Tue, 18 Apr 2023 13:42:20 +0800 Message-Id: <20230418054221.1076945-1-zhichaox.zeng@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 devargs to enable reset watchdog for iavf, use '-a {pci:xxxx:xx:xx:x},watchdog_period={microseconds}' to enable watchdog. If the watchdog period is configured through the IAVF_DEV_WATCHDOG_PERIOD and devargs at the same time, the IAVF_DEV_WATCHDOG_PERIOD will prevail. Signed-off-by: Zhichao Zeng --- drivers/net/iavf/iavf.h | 1 + drivers/net/iavf/iavf_ethdev.c | 54 ++++++++++++++++++++++++++++++++-- drivers/net/iavf/iavf_vchnl.c | 9 ++++-- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index aa18650ffa..fc0ce529ce 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -304,6 +304,7 @@ struct iavf_devargs { uint8_t proto_xtr_dflt; uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM]; uint16_t quanta_size; + uint32_t watchdog_period; /* microseconds */ }; struct iavf_security_ctx; diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index f6d68403ce..f7c7ee3348 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -36,6 +36,7 @@ /* devargs */ #define IAVF_PROTO_XTR_ARG "proto_xtr" #define IAVF_QUANTA_SIZE_ARG "quanta_size" +#define IAVF_RESET_WATCHDOG_ARG "watchdog_period" uint64_t iavf_timestamp_dynflag; int iavf_timestamp_dynfield_offset = -1; @@ -43,6 +44,7 @@ int iavf_timestamp_dynfield_offset = -1; static const char * const iavf_valid_args[] = { IAVF_PROTO_XTR_ARG, IAVF_QUANTA_SIZE_ARG, + IAVF_RESET_WATCHDOG_ARG, NULL }; @@ -301,15 +303,23 @@ iavf_dev_watchdog(void *cb_arg) /* enter reset state with VFLR event */ adapter->vf.vf_reset = true; + adapter->vf.link_up = false; rte_eth_dev_callback_process(adapter->vf.eth_dev, RTE_ETH_EVENT_INTR_RESET, NULL); } } +#if (IAVF_DEV_WATCHDOG_PERIOD > 0) /* re-alarm watchdog */ rc = rte_eal_alarm_set(IAVF_DEV_WATCHDOG_PERIOD, &iavf_dev_watchdog, cb_arg); +#else + /* re-alarm watchdog by devargs */ + if (adapter->devargs.watchdog_period) + rc = rte_eal_alarm_set(adapter->devargs.watchdog_period, + &iavf_dev_watchdog, cb_arg); +#endif if (rc) PMD_DRV_LOG(ERR, "Failed \"%s\" to reset device watchdog alarm", @@ -317,23 +327,37 @@ iavf_dev_watchdog(void *cb_arg) } static void -iavf_dev_watchdog_enable(struct iavf_adapter *adapter __rte_unused) +iavf_dev_watchdog_enable(struct iavf_adapter *adapter) { #if (IAVF_DEV_WATCHDOG_PERIOD > 0) - PMD_DRV_LOG(INFO, "Enabling device watchdog"); + PMD_DRV_LOG(INFO, "Enabling device watchdog, macro: %dμs", IAVF_DEV_WATCHDOG_PERIOD); adapter->vf.watchdog_enabled = true; if (rte_eal_alarm_set(IAVF_DEV_WATCHDOG_PERIOD, &iavf_dev_watchdog, (void *)adapter)) PMD_DRV_LOG(ERR, "Failed to enabled device watchdog"); +#else + if (adapter->devargs.watchdog_period) { + PMD_DRV_LOG(INFO, "Enabling device watchdog, devargs: %dμs", + adapter->devargs.watchdog_period); + adapter->vf.watchdog_enabled = true; + if (rte_eal_alarm_set(adapter->devargs.watchdog_period, + &iavf_dev_watchdog, (void *)adapter)) + PMD_DRV_LOG(ERR, "Failed to enabled device watchdog"); + } #endif } static void -iavf_dev_watchdog_disable(struct iavf_adapter *adapter __rte_unused) +iavf_dev_watchdog_disable(struct iavf_adapter *adapter) { #if (IAVF_DEV_WATCHDOG_PERIOD > 0) PMD_DRV_LOG(INFO, "Disabling device watchdog"); adapter->vf.watchdog_enabled = false; +#else + if (adapter->devargs.watchdog_period) { + PMD_DRV_LOG(INFO, "Disabling device watchdog"); + adapter->vf.watchdog_enabled = false; + } #endif } @@ -2201,6 +2225,25 @@ parse_u16(__rte_unused const char *key, const char *value, void *args) return 0; } +static int +iavf_parse_watchdog_period(__rte_unused const char *key, const char *value, void *args) +{ + u32 *num = (u32 *)args; + u32 tmp; + + errno = 0; + tmp = strtoul(value, NULL, 10); + if (errno || !tmp) { + PMD_DRV_LOG(WARNING, "%s: \"%s\" is not a valid u32", + key, value); + return -1; + } + + *num = tmp; + + return 0; +} + static int iavf_parse_devargs(struct rte_eth_dev *dev) { struct iavf_adapter *ad = @@ -2232,6 +2275,11 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev) if (ret) goto bail; + ret = rte_kvargs_process(kvlist, IAVF_RESET_WATCHDOG_ARG, + &iavf_parse_watchdog_period, &ad->devargs.watchdog_period); + if (ret) + goto bail; + if (ad->devargs.quanta_size != 0 && (ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 || ad->devargs.quanta_size & 0x40)) { diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 9adaadb173..402261ba9c 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -433,9 +433,12 @@ iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg, switch (pf_msg->event) { case VIRTCHNL_EVENT_RESET_IMPENDING: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event"); - vf->vf_reset = true; - iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET, - NULL, 0); + vf->link_up = false; + if (!vf->vf_reset) { + vf->vf_reset = true; + iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET, + NULL, 0); + } break; case VIRTCHNL_EVENT_LINK_CHANGE: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");