From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C3C3A04F0; Wed, 18 Dec 2019 03:52:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 042F41BE9E; Wed, 18 Dec 2019 03:52:28 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 936F62C17; Wed, 18 Dec 2019 03:52:25 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2019 18:52:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,327,1571727600"; d="scan'208";a="205695102" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by orsmga007.jf.intel.com with ESMTP; 17 Dec 2019 18:52:22 -0800 Date: Wed, 18 Dec 2019 10:47:35 +0800 From: Ye Xiaolong To: Lunyuan Cui Cc: dev@dpdk.org, Wenzhuo Lu , Qiming Yang , Ananyev@dpdk.org, Konstantin , stable@dpdk.org Message-ID: <20191218024735.GR59123@intel.com> References: <20191212111714.533-1-lunyuanx.cui@intel.com> <20191216022418.109608-1-lunyuanx.cui@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191216022418.109608-1-lunyuanx.cui@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v3] net/ixgbe: fix 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" On 12/16, Lunyuan Cui wrote: >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 >--- > >v3 changes: >* Hide ifdef inside the function > >v2 changes: >* Put waiting into a separate function to keep start() code clean. >--- > drivers/net/ixgbe/ixgbe_ethdev.c | 36 ++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > >diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c >index 2c6fd0f13..d9b0c5b02 100644 >--- a/drivers/net/ixgbe/ixgbe_ethdev.c >+++ b/drivers/net/ixgbe/ixgbe_ethdev.c >@@ -378,6 +378,7 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, > struct rte_eth_udp_tunnel *udp_tunnel); > static int ixgbe_filter_restore(struct rte_eth_dev *dev); > static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev); >+static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw); > > /* > * Define VF Stats MACRO for Non "cleared on read" register >@@ -2801,6 +2802,11 @@ ixgbe_dev_start(struct rte_eth_dev *dev) > "please call hierarchy_commit() " > "before starting the port"); > >+ /* wait for the controller to acquire link */ >+ err = ixgbe_wait_for_link_up(hw); >+ if (err) >+ goto error; >+ > /* > * Update link status right before return, because it may > * start link configuration process in a separate thread. >@@ -4114,6 +4120,36 @@ ixgbe_dev_setup_link_alarm_handler(void *param) > intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; > } > >+/* >+ * 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. >+ */ >+static int >+ixgbe_wait_for_link_up(struct ixgbe_hw *hw) >+{ >+#ifdef RTE_EXEC_ENV_FREEBSD >+ const int nb_iter = 25; >+#else >+ const int nb_iter = 0; >+#endif >+ int err, i, link_up = 0; >+ uint32_t speed = 0; >+ >+ for (i = 0; i < nb_iter; i++) { >+ err = ixgbe_check_link(hw, &speed, &link_up, 0); >+ if (err) >+ return err; >+ if (link_up) >+ return 0; >+ msec_delay(200); >+ } >+ return 0; >+} >+ > /* return 0 means link status changed, -1 means not changed */ > int > ixgbe_dev_link_update_share(struct rte_eth_dev *dev, >-- >2.17.1 > Acked-by: Xiaolong Ye Applied to dpdk-next-net-intel, Thanks.