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 B7F08A0563 for ; Sun, 22 Mar 2020 18:07:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9B9862C15; Sun, 22 Mar 2020 18:07:00 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2068.outbound.protection.outlook.com [40.107.20.68]) by dpdk.org (Postfix) with ESMTP id 9CB14F94; Thu, 19 Mar 2020 11:51:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kNfo3iIjdVSyhltjQXzfiChmty53r0YKxWULhmh8bH8=; b=Ut5LijHxq49p3wvX2VrLFE13l7P0MPW5xZfLsmlj0F7+o9Qw1bIAgo9cnrG5xQvzYCpHNOGNKDLUrKPzQUf/C7WIvUA8LssTTFo2Fcw4jPZ1noNlMEGmvIb5LMuPbgsG5EWb26fyKNuQzr7/GV4u6nigM8tfbmFhQ80ag/yoeKw= Received: from AM5PR0202CA0013.eurprd02.prod.outlook.com (2603:10a6:203:69::23) by AM0PR08MB4066.eurprd08.prod.outlook.com (2603:10a6:208:125::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18; Thu, 19 Mar 2020 10:51:29 +0000 Received: from AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::d2) by AM5PR0202CA0013.outlook.office365.com (2603:10a6:203:69::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15 via Frontend Transport; Thu, 19 Mar 2020 10:51:29 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT048.mail.protection.outlook.com (10.152.17.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Thu, 19 Mar 2020 10:51:28 +0000 Received: ("Tessian outbound d57d25b72657:v48"); Thu, 19 Mar 2020 10:51:28 +0000 X-CR-MTA-TID: 64aa7808 Received: from e88e70a2db5b.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F982601B-DAEA-48B7-B070-B7B0513A7FD9.1; Thu, 19 Mar 2020 10:51:23 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e88e70a2db5b.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 19 Mar 2020 10:51:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A71BDNmSrkDJLExrFAjLwt8ujCKSWK9ZAqNLlxhqcSd3QxOS9MSzslZ3K7Ufu1o9tZ+GEEs5O7BQRVggUrXAlGoFYx8ImndtoYMARvJeJ4hHRweHWELIobYuZLwMImumZptE1E4dcsSKKyUDR/b9L77Re1FjxMZl71widZNbcxKGIGa4Ys36WTljAeB0LgvCLf5CTnkGrzoQOMRzejXNLCc5NTMSxlHJbtLX6asGVvB7/etb9QDMXyMUjR2OwanbFkUTH1gRWVVtTtM6IJhUzl5b1zkJNVGb463oiDewVySOfjoQFkkzS5mI37smYEALmoCNGD0MeQh+O0b9MWwH+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kNfo3iIjdVSyhltjQXzfiChmty53r0YKxWULhmh8bH8=; b=GYGE4stl/90clLgjaW08jYTWwsCYsdw8ZLs4lt+rIDac6l14sAxVk+Kq+oZfct5sw9kjzP46o5pbsnVSbVXU6IPa9ptZLnAS866Ga+jIh/rBV7fv57vNzKQHFYiN8pPiFYsBE6HwBMOgyWTFAFbxsKjXlgQiZ9Deq2VZZGGray+mLeG3qTQ/sjct2FI0hxLKrqZo7O+wes+JCxvkbHPjXwd+ecwFXPmmLVgA2rLDorfZaElDstjAdNYd6ADvtcne/81DNws0Cb7kVQRa65sYjvGjLt6gx/Hw4cQ6GK2t7CHYMdPrZbPf0eFedQEZNfxbUaseUM+C1YPwP5dhAkijqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kNfo3iIjdVSyhltjQXzfiChmty53r0YKxWULhmh8bH8=; b=Ut5LijHxq49p3wvX2VrLFE13l7P0MPW5xZfLsmlj0F7+o9Qw1bIAgo9cnrG5xQvzYCpHNOGNKDLUrKPzQUf/C7WIvUA8LssTTFo2Fcw4jPZ1noNlMEGmvIb5LMuPbgsG5EWb26fyKNuQzr7/GV4u6nigM8tfbmFhQ80ag/yoeKw= Received: from VI1PR08MB4269.eurprd08.prod.outlook.com (20.179.25.75) by VI1PR08MB5389.eurprd08.prod.outlook.com (52.133.246.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18; Thu, 19 Mar 2020 10:51:21 +0000 Received: from VI1PR08MB4269.eurprd08.prod.outlook.com ([fe80::5d4e:a8a7:cdce:5c28]) by VI1PR08MB4269.eurprd08.prod.outlook.com ([fe80::5d4e:a8a7:cdce:5c28%7]) with mapi id 15.20.2814.025; Thu, 19 Mar 2020 10:51:21 +0000 From: Lijian Zhang To: Phil Yang , "dev@dpdk.org" , "konstantin.ananyev@intel.com" , "wenzhuo.lu@intel.com" CC: "qi.z.zhang@intel.com" , Gavin Hu , Honnappa Nagarahalli , nd , "stable@dpdk.org" Thread-Topic: [PATCH] net/ixgbe: fix link state timing issue on fiber ports Thread-Index: AQHV/di6/4CjoXe1qUavNeXoW/SsWKhPtn5Q Date: Thu, 19 Mar 2020 10:51:21 +0000 Message-ID: References: <1584600111-17412-1-git-send-email-phil.yang@arm.com> In-Reply-To: <1584600111-17412-1-git-send-email-phil.yang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 5f30cfff-8d26-4815-9e7c-27b495c4f6c2.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Lijian.Zhang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b331741e-d80c-4fd7-fbb3-08d7cbf37a94 x-ms-traffictypediagnostic: VI1PR08MB5389:|VI1PR08MB5389:|AM0PR08MB4066: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; x-forefront-prvs: 0347410860 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(39860400002)(396003)(346002)(136003)(376002)(199004)(8676002)(316002)(54906003)(81166006)(53546011)(8936002)(186003)(64756008)(66476007)(4326008)(478600001)(6506007)(55236004)(26005)(86362001)(110136005)(76116006)(7696005)(66946007)(66446008)(66556008)(2906002)(9686003)(33656002)(55016002)(52536014)(81156014)(71200400001)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB5389; H:VI1PR08MB4269.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: lx19BjJ2OYBTrIw0pDtWU04K6l24PswG79LO728tDXhdhY2SLEHvdaBJPAOclop4uxrpVMp2u425IsHITQxcORF1NAgcoYHIj+FgzNzzhQsV+kaDqyjU4eej9TrQjJWQF0miESGT9tKMO29GLD888pZw9j7syxUXyx/fLbIzK7FyORaVPWT39xZR1XNQMrC1Hm48DU1YReAMS8/VaeX5K7hQJHdtSuu6KcGXX40nV5qYR3Saef3ZY5JyJt/c2l82WlpOW1DtbrTJZrW0Z18zt0iAbalc76T1cdK0VK16XD9ucPzzt+4fqVuYs5dRIqct90nbLTh2y3Yqp4ji/GtTnxzQkEaDwlHgl36HS0YXlSKTcMWx1r2wbdBZcYGcrSVjeduMFzNRQbT16zHcpwSXRahibjjra44WGGKbJAZChRNx0DwHpItumMnl5MIVtEiM x-ms-exchange-antispam-messagedata: QKZ3ICQL7zMBzzN3VsotZKcfYKhYSiDXgPk2wkEHpU52aX7bQ1uFVyEUCIOkHmbjsjGbA+ZaXXQ8ep8sqjlpQdeYP/iOiTj3FS2jCxFHEj5PaCo7OYswKM4+KzIgmJXseZ+OdrAKhgji6dhY2krJHg== Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5389 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Lijian.Zhang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(136003)(396003)(376002)(199004)(46966005)(86362001)(33656002)(52536014)(81156014)(70206006)(478600001)(53546011)(6506007)(7696005)(26826003)(336012)(356004)(5660300002)(70586007)(8676002)(450100002)(186003)(8936002)(54906003)(110136005)(47076004)(55016002)(4326008)(81166006)(9686003)(316002)(26005)(36906005)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4066; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: dbc9eb51-ff43-43dc-7979-08d7cbf37601 X-Forefront-PRVS: 0347410860 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tiir0utDNqX3ZVD5pU9TT6CBJmoiV3t708MW5hu0jHXnUdJITTmi8n8ZxjWL+3WPV4DHPA87DM2CSpS6VleN+zVIkIacyM+I5c1XGwOENtj0w7vCP6U3yITB/HQRI928TSZIrYdoM2DV39JzhUieK51k9NGQsH3Zq5Y3s4GlwHlAg7moA/GdL9RZdZnopL042kzkeL8rsb/vUMeQDOj/iLPsk0tTGSxWcbKmUYyRE5wMLiyvegwO0WO/dx4J/sNr6ccC0YTnuMvkm0AjgKs73iDEoXcYzbvfDFwoWD6q4e9Y+TRC8uIQUIw33fw0ArevQyWgyn/4fnJBy7qpkDWzg2K5KHoRmsnhIV+jhBh2zvYMZAUdFW+K9yiUi0rzGAffkqKzD0Vk+HntrWopJJDCCvEHzvwTWhw2YbfTxnKzHwE359Lr6xIuF2w/dqLTzTPJRJpj6OySKQ62eXPzRDih/dixD0V568rgjFZsF0rohoNA9KVUPxFw+O0XWUc0D+YtOgPYH/coBT/mAVSh+j/JtQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2020 10:51:28.9359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b331741e-d80c-4fd7-fbb3-08d7cbf37a94 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4066 X-Mailman-Approved-At: Sun, 22 Mar 2020 18:06:59 +0100 Subject: Re: [dpdk-stable] [PATCH] net/ixgbe: fix link state timing issue on fiber ports X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" This issue is firstly observed with an ixgbe NIC in VPP project, which is s= oftware switching application based on DPDK. There's a daemon thread running in background keeping polling hardware link= status, using ixgbe_dev_link_update_share(). Once flag IXGBE_FLAG_NEED_LINK_CONFIG is set, ixgbe_dev_link_update_share()= will just return link down status without actually polling hardware status= . In the issue, flag IXGBE_FLAG_NEED_LINK_CONFIG is always set, and never be = cleared, meaning ixgbe_dev_link_update_share() cannot get hardware status, = but always get link down status. The condition causing IXGBE_FLAG_NEED_LINK_CONFIG always set is as below. The ixgbe_dev_link_update_share() is always running in the background. 1. In the beginning, IXGBE_FLAG_NEED_LINK_CONFIG is 0 and it is link down s= tatus. 2. ixgbe_dev_link_update_share() will set IXGBE_FLAG_NEED_LINK_CONFIG to 1 3. Then it triggers ixgbe_dev_setup_link_thread_handler() thread to configu= re the interface. 4. At the end of configuring thread, ixgbe_dev_setup_link_thread_handler() = will clear the flag IXGBE_FLAG_NEED_LINK_CONFIG. 5. With IXGBE_FLAG_NEED_LINK_CONFIG being cleared, ixgbe_dev_link_update_sh= are() can poll hardware link status in the next round. But when the user is setting interface link up or down in the CLI, it will = call ixgbe_dev_start() or ixgbe_dev_stop(). In both function, they will cal= l ixgbe_dev_cancel_link_thread() to interrupt any running configuring threa= d (which is running in above step 3 and step 4), without clearing the flag = IXGBE_FLAG_NEED_LINK_CONFIG. This will leave IXGBE_FLAG_NEED_LINK_CONFIG al= ways set, and ixgbe_dev_link_update_share() cannot get hardware status. Thanks. > -----Original Message----- > From: Phil Yang > Sent: 2020=1B$BG/=1B(B3=1B$B7n=1B(B19=1B$BF|=1B(B 14:42 > To: dev@dpdk.org; konstantin.ananyev@intel.com; wenzhuo.lu@intel.com > Cc: qi.z.zhang@intel.com; Lijian Zhang ; Gavin Hu > ; Honnappa Nagarahalli > ; nd ; stable@dpdk.org > Subject: [PATCH] net/ixgbe: fix link state timing issue on fiber ports >=20 > With some models of fiber ports (e.g. X520-2 device ID 0x10fb), it is pos= sible > when a port is started to experience a timing issue which prevents the li= nk > from ever being fully set up. >=20 > In ixgbe_dev_link_update_share(), if the media type is fiber and the link= is > down, a flag (IXGBE_FLAG_NEED_LINK_CONFIG) is set. A callback to > ixgbe_dev_setup_link_thread_handler() is scheduled which should try to se= t up > the link and clear the flag afterwards. >=20 > If the device is started before the flag is cleared, the scheduled callba= ck is > cancelled. This causes the flag to remain set and subsequent calls to > ixgbe_dev_link_update_share() return without trying to retrieve the link = state > because the flag is set. >=20 > In ixgbe_dev_cancel_link_thread(), after cancelling the callback, unset t= he flag > on the device to avoid this condition. >=20 > Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") > Cc: stable@dpdk.org >=20 > Bugzilla ID: 388 >=20 > Signed-off-by: Phil Yang > Signed-off-by: Lijian Zhang > Reviewed-by: Gavin Hu > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 23b3f5b..2b65750 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -4147,11 +4147,19 @@ static void > ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) { > struct ixgbe_adapter *ad =3D dev->data->dev_private; > + struct ixgbe_interrupt *intr =3D > + IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); > void *retval; >=20 > if (rte_atomic32_read(&ad->link_thread_running)) { > pthread_cancel(ad->link_thread_tid); > pthread_join(ad->link_thread_tid, &retval); > + /* clear this flag once the thread has been > + * cancelled, to avoid link status error in > + * case unfinished threads cannot clean up > + * this flag. > + */ > + intr->flags &=3D ~IXGBE_FLAG_NEED_LINK_CONFIG; > rte_atomic32_clear(&ad->link_thread_running); > } > } > @@ -4262,8 +4270,12 @@ ixgbe_dev_link_update_share(struct rte_eth_dev > *dev, >=20 > 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)) { > + /* To avoid race condition between threads, > set > + * the IXGBE_FLAG_NEED_LINK_CONFIG flag > only > + * when there is no link thread running. > + */ > + intr->flags |=3D > IXGBE_FLAG_NEED_LINK_CONFIG; > if (rte_ctrl_thread_create(&ad- > >link_thread_tid, > "ixgbe-link-handler", > NULL, > -- > 2.7.4