From patchwork Fri Dec 13 02:36:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cui, LunyuanX" X-Patchwork-Id: 63833 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04BD9A04F5; Fri, 13 Dec 2019 03:39:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 07FD51BF96; Fri, 13 Dec 2019 03:39:31 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3489D1BF92; Fri, 13 Dec 2019 03:39:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2019 18:39:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,308,1571727600"; d="scan'208";a="245972395" Received: from intel.sh.intel.com ([10.239.255.129]) by fmsmga002.fm.intel.com with ESMTP; 12 Dec 2019 18:39:25 -0800 From: Lunyuan Cui To: dev@dpdk.org Cc: Wenzhuo Lu , Qiming Yang , Ananyev@dpdk.org, Konstantin , Lunyuan Cui , stable@dpdk.org Date: Fri, 13 Dec 2019 02:36:21 +0000 Message-Id: <20191213023621.38787-1-lunyuanx.cui@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191212111714.533-1-lunyuanx.cui@intel.com> References: <20191212111714.533-1-lunyuanx.cui@intel.com> Subject: [dpdk-dev] [PATCH v2] net/ixgbe: fixed port can not link up in FreeBSD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In FreeBSD environment, nic_uio drivers do not support interrupts, rte_intr_callback_register() will fail to register interrupts. We can not make link status to change from down to up by interrupt callback. So we need to wait for the controller to acquire link when ports start. Through multiple tests, 5s should be enough. Fixes: b9bd0f09fa15 ("ethdev: fix link status query") Cc: stable@dpdk.org Signed-off-by: Lunyuan Cui --- v2 changes: * Put waiting into a separate function to keep start() code clean. --- drivers/net/ixgbe/ixgbe_ethdev.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c6fd0f13..fba666186 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2801,6 +2801,13 @@ ixgbe_dev_start(struct rte_eth_dev *dev) "please call hierarchy_commit() " "before starting the port"); +#ifdef RTE_EXEC_ENV_FREEBSD + /* wait for the controller to acquire link */ + err = ixgbe_wait_for_link_up(hw); + if (err) + goto error; +#endif + /* * Update link status right before return, because it may * start link configuration process in a separate thread. @@ -4114,6 +4121,31 @@ ixgbe_dev_setup_link_alarm_handler(void *param) intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; } +#ifdef RTE_EXEC_ENV_FREEBSD +/* + * In freebsd environment, nic_uio drivers do not support interrupts, + * rte_intr_callback_register() will fail to register interrupts. + * We can not make link status to change from down to up by interrupt + * callback. So we need to wait for the controller to acquire link + * when ports start. + * It returns 0 on link up. + */ +int32_t ixgbe_wait_for_link_up(struct ixgbe_hw *hw) +{ + int err, i, link_up = 0; + uint32_t speed = 0; + for (i = 0; i < 25; i++) { + err = ixgbe_check_link(hw, &speed, &link_up, 0); + if (err) + return err; + if (link_up) + return 0; + msec_delay(200); + } + return 0; +} +#endif + /* return 0 means link status changed, -1 means not changed */ int ixgbe_dev_link_update_share(struct rte_eth_dev *dev, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 76a1b9d18..9a1d8c54c 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -700,6 +700,9 @@ int ixgbe_dev_link_update_share(struct rte_eth_dev *dev, int wait_to_complete, int vf); +#ifdef RTE_EXEC_ENV_FREEBSD +int32_t ixgbe_wait_for_link_up(struct ixgbe_hw *hw); +#endif /* * misc function prototypes */