From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id EBDE49E3 for ; Fri, 28 Apr 2017 02:44:00 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2017 17:43:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,386,1488873600"; d="scan'208";a="93088794" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by orsmga005.jf.intel.com with ESMTP; 27 Apr 2017 17:43:58 -0700 Received: from pgsmsx106.gar.corp.intel.com ([169.254.9.228]) by PGSMSX108.gar.corp.intel.com ([169.254.8.249]) with mapi id 14.03.0319.002; Fri, 28 Apr 2017 08:43:58 +0800 From: "Dai, Wei" To: Laurent Hardy , "dev@dpdk.org" CC: "Yigit, Ferruh" , "Zhang, Helin" , "Ananyev, Konstantin" , "olivier.matz@6wind.com" Thread-Topic: [PATCH v4] net/ixgbe: ensure link status is updated Thread-Index: AQHSv2eQ8cvohgjyJk+8QW/OlYl4rKHZ8hYw Date: Fri, 28 Apr 2017 00:43:57 +0000 Message-ID: <49759EB36A64CF4892C1AFEC9231E8D650A77CCA@PGSMSX106.gar.corp.intel.com> References: <49759EB36A64CF4892C1AFEC9231E8D650A662DC@PGSMSX101.gar.corp.intel.com> <1493305422-10611-1-git-send-email-laurent.hardy@6wind.com> In-Reply-To: <1493305422-10611-1-git-send-email-laurent.hardy@6wind.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzExNTU5MDktNDY3Ny00YTJlLTk5YTQtMjYzNDcwNzM0MTM1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImRtZVJjeGFxK1NIaU1iV1dXVWJQQm93RjRVZitGa25uTjZqaElIdm5Wc3c9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [172.30.20.205] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4] net/ixgbe: ensure link status is updated 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: , X-List-Received-Date: Fri, 28 Apr 2017 00:44:01 -0000 > -----Original Message----- > From: Laurent Hardy [mailto:laurent.hardy@6wind.com] > Sent: Thursday, April 27, 2017 11:04 PM > To: dev@dpdk.org; Dai, Wei > Cc: Yigit, Ferruh ; Zhang, Helin > ; Ananyev, Konstantin > ; olivier.matz@6wind.com > Subject: [PATCH v4] net/ixgbe: ensure link status is updated >=20 > In case of fiber and link speed set to 1Gb at peer side (with autoneg > or with defined speed), link status could be not properly updated at > time cable is plugged-in. > Indeed if cable was not plugged when device has been configured and > started then link status will not be updated properly with new speed > as no link setup will be triggered. >=20 > To avoid this issue, IXGBE_FLAG_NEED_LINK_CONFIG is set to try a link > setup each time link_update() is triggered and current link status is > down. When cable is plugged-in, link setup will be performed via > ixgbe_setup_link(). >=20 > Signed-off-by: Laurent Hardy Acked-by: Wei Dai > --- > Hi Wei, please find enclosed patch v4, tested using testpmd. >=20 > v1 -> v2: > - rebase on top of head (change flag to 1<<4) > - fix regression with copper links: only update link for fiber links >=20 > v2 -> v3: > - remove unnescessary check on speed mask if autoneg is false >=20 > v3 -> v4: > - remove default speed set to 10Gb if autoneg is false, rely on > ixgbe_get_link_capabilities( ) instead. > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++++++++ > drivers/net/ixgbe/ixgbe_ethdev.h | 1 + > 2 files changed, 15 insertions(+) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 7b856bb..8a0c0a7 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -3782,8 +3782,12 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, > int wait_to_complete) > struct ixgbe_hw *hw =3D > IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); > struct rte_eth_link link, old; > ixgbe_link_speed link_speed =3D IXGBE_LINK_SPEED_UNKNOWN; > + struct ixgbe_interrupt *intr =3D > + IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); > int link_up; > int diag; > + u32 speed =3D 0; > + bool autoneg =3D false; >=20 > link.link_status =3D ETH_LINK_DOWN; > link.link_speed =3D 0; > @@ -3793,6 +3797,14 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, > int wait_to_complete) >=20 > hw->mac.get_link_status =3D true; >=20 > + if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) && > + hw->mac.ops.get_media_type(hw) =3D=3D ixgbe_media_type_fiber) { > + speed =3D hw->phy.autoneg_advertised; > + if (!speed) > + ixgbe_get_link_capabilities(hw, &speed, &autoneg); > + ixgbe_setup_link(hw, speed, true); > + } > + > /* check if it needs to wait to complete, if lsc interrupt is enabled *= / > if (wait_to_complete =3D=3D 0 || dev->data->dev_conf.intr_conf.lsc !=3D= 0) > diag =3D ixgbe_check_link(hw, &link_speed, &link_up, 0); > @@ -3810,10 +3822,12 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, > int wait_to_complete) >=20 > if (link_up =3D=3D 0) { > rte_ixgbe_dev_atomic_write_link_status(dev, &link); > + intr->flags |=3D IXGBE_FLAG_NEED_LINK_CONFIG; > if (link.link_status =3D=3D old.link_status) > return -1; > return 0; > } > + intr->flags &=3D ~IXGBE_FLAG_NEED_LINK_CONFIG; > link.link_status =3D ETH_LINK_UP; > link.link_duplex =3D ETH_LINK_FULL_DUPLEX; >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h > b/drivers/net/ixgbe/ixgbe_ethdev.h > index 5176b02..b576a6f 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.h > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h > @@ -45,6 +45,7 @@ > #define IXGBE_FLAG_MAILBOX (uint32_t)(1 << 1) > #define IXGBE_FLAG_PHY_INTERRUPT (uint32_t)(1 << 2) > #define IXGBE_FLAG_MACSEC (uint32_t)(1 << 3) > +#define IXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4) >=20 > /* > * Defines that were not part of ixgbe_type.h as they are not used by th= e > -- > 2.1.4