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 DCE0DA04B3; Mon, 16 Dec 2019 03:30:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DE0341BFD4; Mon, 16 Dec 2019 03:29:59 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id A1B211BFD2; Mon, 16 Dec 2019 03:29:57 +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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2019 18:29:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,320,1571727600"; d="scan'208";a="246860244" Received: from intel.sh.intel.com ([10.239.255.129]) by fmsmga002.fm.intel.com with ESMTP; 15 Dec 2019 18:29:54 -0800 From: Lunyuan Cui To: dev@dpdk.org Cc: Wenzhuo Lu , Qiming Yang , Ananyev@dpdk.org, Konstantin , Lunyuan Cui , stable@dpdk.org Date: Mon, 16 Dec 2019 02:24:18 +0000 Message-Id: <20191216022418.109608-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 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" 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