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 7D964A0583; Thu, 19 Mar 2020 03:43:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6AACF1BE51; Thu, 19 Mar 2020 03:43:53 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id C2811E07; Thu, 19 Mar 2020 03:43:50 +0100 (CET) IronPort-SDR: 1FNlLhs5+Cu0SaIFtF03uMXZOcaAXzj2EK4wXP9O9MlDfWmm0O+9I9Q1We7i0DFJYTMb1MHcpF h16K/hYLZNpA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2020 19:43:48 -0700 IronPort-SDR: MuAkJXqch0CfolKYDrzfaCrhMgPjJTh0nWTD1Q89V1ZWCvq+QIU7yqEKIkZlwfMbuBVJQlSU8r +qoaixafe4Ew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,570,1574150400"; d="scan'208";a="391656787" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 18 Mar 2020 19:43:48 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 18 Mar 2020 19:43:48 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 18 Mar 2020 19:43:47 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.137]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.43]) with mapi id 14.03.0439.000; Thu, 19 Mar 2020 10:43:44 +0800 From: "Zhu, TaoX" To: "Jiang, YuX" CC: "'dev@dpdk.org'" , "'stable@dpdk.org'" , "Ananyev, Konstantin" , "Lu, Wenzhuo" , "Ye, Xiaolong" Thread-Topic: [PATCH] net/ixgbe: fix link status inconsistencies Thread-Index: AQHV7J1MR4J1l3dMl02amzwKqCu6F6g2JSgQgBkx1YA= Date: Thu, 19 Mar 2020 02:43:43 +0000 Message-ID: <60652C6914E08D41B9AA1580751B3CA9015E5CE0@SHSMSX103.ccr.corp.intel.com> References: <20200226120637.13109-1-taox.zhu@intel.com> <60652C6914E08D41B9AA1580751B3CA9015E27AD@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <60652C6914E08D41B9AA1580751B3CA9015E27AD@SHSMSX103.ccr.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: fix link status inconsistencies 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" +Jiang Yu BR, Zhu, Tao > -----Original Message----- > From: Zhu, TaoX > Sent: Tuesday, March 3, 2020 10:00 AM > To: Ananyev, Konstantin ; Lu, Wenzhuo > ; Ye, Xiaolong > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH] net/ixgbe: fix link status inconsistencies >=20 > +Xiaolong >=20 > BR, > Zhu, Tao >=20 > > -----Original Message----- > > From: Zhu, TaoX > > Sent: Wednesday, February 26, 2020 8:07 PM > > To: Ananyev, Konstantin ; Lu, Wenzhuo > > > > Cc: dev@dpdk.org; Zhu, TaoX ; stable@dpdk.org > > Subject: [PATCH] net/ixgbe: fix link status inconsistencies > > > > From: Zhu Tao > > > > Setting LINK UP or LINK DOWN is divided into two parts, with the main > > task done in a separate thread, which can take up to 9 seconds. If > > cancel the thread in execution, may cause state inconsistencies. > > Therefore, must wait for the previous setting to exit normally before > setting the new state. > > > > Note: before using threads, use alarm to handle main tasks. > > When canceling alarm, the execution of alarm will not be interrupted. > > > > Fixes: 819d0d1d57 ("net/ixgbe: fix blocking system events") > > Cc: stable@dpdk.org > > > > Signed-off-by: Zhu Tao > > --- > > drivers/net/ixgbe/ixgbe_ethdev.c | 24 ++++++++++++++++++++++-- > > 1 file changed, 22 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > > b/drivers/net/ixgbe/ixgbe_ethdev.c > > index 23b3f5b0c..2c5797635 100644 > > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > > @@ -4143,16 +4143,35 @@ ixgbevf_check_link(struct ixgbe_hw *hw, > > ixgbe_link_speed *speed, > > return ret_val; > > } > > > > +/* return 1: setup complete, return 0: setup not complete, and wait > > +timeout*/ static int ixgbe_dev_wait_setup_link_complete(struct > > +rte_eth_dev *dev) { #define DELAY_INTERVAL 100 /* 100ms */ > > +#define MAX_TIMEOUT 90 /* 9s (90 * 100ms) in total */ > > + struct ixgbe_adapter *ad =3D dev->data->dev_private; > > + int timeout =3D MAX_TIMEOUT; > > + > > + while (rte_atomic32_read(&ad->link_thread_running) && timeout) { > > + msec_delay(DELAY_INTERVAL); > > + timeout--; > > + } > > + > > + > > + return !!timeout; > > +} > > + > > static void > > ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) { > > struct ixgbe_adapter *ad =3D dev->data->dev_private; > > void *retval; > > > > - if (rte_atomic32_read(&ad->link_thread_running)) { > > + if (!ixgbe_dev_wait_setup_link_complete(dev)) { > > pthread_cancel(ad->link_thread_tid); > > pthread_join(ad->link_thread_tid, &retval); > > rte_atomic32_clear(&ad->link_thread_running); > > + PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); > > } > > } > > > > @@ -4263,7 +4282,8 @@ ixgbe_dev_link_update_share(struct > rte_eth_dev > > *dev, > > if (link_up =3D=3D 0) { > > if (ixgbe_get_media_type(hw) =3D=3D ixgbe_media_type_fiber) > { > > intr->flags |=3D IXGBE_FLAG_NEED_LINK_CONFIG; > > - if (rte_atomic32_test_and_set(&ad- > > >link_thread_running)) { > > + if (ixgbe_dev_wait_setup_link_complete(dev) && > > + rte_atomic32_test_and_set(&ad- > > >link_thread_running)) { > > if (rte_ctrl_thread_create(&ad- > > >link_thread_tid, > > "ixgbe-link-handler", > > NULL, > > -- > > 2.17.1