From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0DCC843719; Thu, 21 Dec 2023 03:43:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BBEB402F1; Thu, 21 Dec 2023 03:43:48 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A0459402EA; Thu, 21 Dec 2023 03:43:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703126626; x=1734662626; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=8XSeNzEuRrqpY+QnVpMMBQNYymHyzEW9ecRYnscM3AQ=; b=Zjv6mfGtoBYyZjJyG1Wvy3G4Cmy/gE4c8XQONN+sqoUQ7QoKjJmNdpwh i5A5k2xKFJSVURVd1/sm53OLZGq/GcgBxlS5qy9RkNA4LMt0nBx1Uy0Kq lYIRx0dDBRrhvAkVKpOCVgC+rNxmdehqkXWWU7hA0y/UB2kPXnitj85ib kbNa8YZU4g2cMzyY3fGfjvmxc7MJXSyyJxBQ2ydvunA2I7ScjvkW/4vbv DB6EBsLBTrcxLNvoJ9UfGzh2GpdsQnfDZ8fuRvo6brzMBixJZoUilR/7i eAUb/KzU0uq2NkhuRV+32+FHas2WKmReejLodkr1+VUTLE/mrnWs1UOrp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="386336130" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="386336130" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 18:43:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="776557945" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="776557945" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Dec 2023 18:43:42 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 20 Dec 2023 18:43:41 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 20 Dec 2023 18:43:41 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 20 Dec 2023 18:43:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ERw7+ItOF1wQMeK5PiZdGjGWSHyqUUIqne9Y++1JEPmaKm3SKLtG7J0ieJzQ4DHUUzus41f2uVf9yCOZbcDQtJaAQ2zTNoNfcMDxkXM+SQwCtqpX7d8O7+tYn351G9vEsYJr37NIPIkrhGn9t0F6wuRKCPORyC2fc/wodYJ9fnPiHjrINxii/FMtGUXPTWFZiDVVY48La+tsrV6z/RKOOzZ5DPs3l64dUfhN/HTataZXS08BZVIZHTKDwV9c/PHMR8zzyeznQJB+qNy5BS82+EaE6h30gALcMBpn8jOYcA5ZvDpi/jCyyF2sgvHjaUzzm4ue3g/47+8QWOQv+1dc/g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rp7KFgdoOU838fO5uk9gewnnCdISExSmGZNVzoz+9vc=; b=HZMxoshOaHMfgdcUAv2vhh2TLXZbEU0MgGBgSE0WaJSc64jLgrCPhomfvRmn1oHz/TfPkUVEkAOubsfQhKo3vPv0k34l14Sz+05X0rX/uESLkN/PZPUNgRJaO4guHhJOp7O0T0Un/SNCxZsz2j15wje6bfDAwhpd/T0fiztO6noDYElpnU7ommldyUbS+2+Wefqocun1LqySMWMVaBjTYAQSONJFH1DhtC9XSHmuEP8CDzTShmdZVbN/ErRYiYgaxVXB6G3z2t/WkUoRR/koJQD3zm20IHVQVpTGaWMkLCiNPpTejG8OmJNYQmOiaIyEo9xAuKaVFD7RTdo6xkrBZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB5994.namprd11.prod.outlook.com (2603:10b6:8:5d::20) by DS0PR11MB6376.namprd11.prod.outlook.com (2603:10b6:8:c8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.19; Thu, 21 Dec 2023 02:43:34 +0000 Received: from DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::fc91:526:bead:4f73]) by DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::fc91:526:bead:4f73%4]) with mapi id 15.20.7113.016; Thu, 21 Dec 2023 02:43:34 +0000 From: "Zhang, Qi Z" To: "Yang, Qiming" CC: "dev@dpdk.org" , "stable@dpdk.org" Subject: RE: [PATCH v2] net/ice: fix link update Thread-Topic: [PATCH v2] net/ice: fix link update Thread-Index: AQHaLiNaeO36eCvuRkWXTH9hnhj7F7CzAg6AgAAQk8A= Date: Thu, 21 Dec 2023 02:43:34 +0000 Message-ID: References: <20231214084054.2593194-1-qi.z.zhang@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB5994:EE_|DS0PR11MB6376:EE_ x-ms-office365-filtering-correlation-id: bcca257d-358c-40f9-e7a8-08dc01cea053 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: bYpZtjfWPwD8xnkDysZXee0wl77CoD9AnVP5EzPlAfk/nrz7RmEfgVF/nUWaQ7JUpTbk+dPmk3+xFLCEP1jj0mkHjnbK87pU7W+3S349joxgzBA1u7fUAiHxei2xYvFPR9C46DGBQzBzonSCp/nvdjsz6Mwk46y4IeeRyGa3LUki52cNcG3SwsjWKW/zFzGwbG8a7tiAh/qu9DnMkX2FNlREjUHd8PSvpGgdnW8ItfmOni03xy6KmrkDK93a/fJWdbZCrsd34szPuwdBiNpn6bMF0yGdKk43ivWnvivuph3gB7rHPL8o+GLldDdmXrNrIsnrg6shFg/MKbutSdF6MmpLzS3SUi/QVYWdl3cZMx3E6yOjv86G1wvZU6+Lh6SaiH2WDqbrYYo7PvNqbr8VgFLjcDI/ADquLnw2hOIgdMkcJMDZaMeMdrlMHAPMs9eJoF20wxik3zngfQO/R2aV4a9VV5GAJI3MYOin+gEw/RDO+7juF1h1C8xEKn6QFuoza+JbqfZIi2yeMh1ifbXoiOb0tGqyteVOtR12/grL5FdszPCNZVIn1ULZBbnPo/WET2Lu4P3heDu6hSoaioDB9YFkDkP3Arci3lJETqCwQesu0Jgch3hbqG+mU2lzJj8K3TqzGfJl63XN2FemnbTzNq/nhuwfoHZBmPhUjB8XJoE= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5994.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(376002)(346002)(136003)(366004)(39860400002)(230173577357003)(230273577357003)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(122000001)(478600001)(82960400001)(64756008)(6636002)(66476007)(66556008)(66446008)(76116006)(66946007)(71200400001)(316002)(38100700002)(54906003)(53546011)(55016003)(7696005)(5660300002)(2906002)(86362001)(9686003)(83380400001)(15650500001)(6506007)(38070700009)(33656002)(52536014)(4326008)(450100002)(6862004)(8676002)(8936002)(26005)(41300700001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cMLH9lOr6MmhPWicC7BqZX/Xe0LCLwusstDLhlFTlzmz+mJ5B1G/Xi2b78bU?= =?us-ascii?Q?coukQ713xyywYppzqzIOFfJcDm8rYZsKwYlxJ2qb1CYNLNPBTLwGH/2BKalv?= =?us-ascii?Q?iVfnPjV56JkX9c11x/U3bdK+eeZIVXIKAgK6HowAy019OD2Aqz9cVH3Ka2IU?= =?us-ascii?Q?K17IZKalAI+RZE2JS83sC55rIXiwXDaKwsrERftf8u8QefXRMj0Zi7zh+iZK?= =?us-ascii?Q?nsjCP4eIUel4WfyWZVUP9HjEp10Bzcu9Q93VrqO2UfWpIsYqcH5Zrk7z6mWY?= =?us-ascii?Q?xhDxEpVAuS+JUQt9Ql2Qk+vxBnQCUd7fdWW9aIg7Pilkroe4Um793v2D04Xy?= =?us-ascii?Q?O7qHPzynDJoCShn2zxGd96Ege6OR8qlPCivvv7ws5yIohiPqq4V2vwO7KKtn?= =?us-ascii?Q?l+GG1wTe1XLG1Z+lkARhaU9UI1/uaVl5LuWvuKeCHCZFCJF1OQiVImvpNjsQ?= =?us-ascii?Q?5azp6aertryrDNSRrAyLWF83zxLGNAuzqD/Hr0h1jf0U60MxEvhLYbVewQ8n?= =?us-ascii?Q?98oC0feuEO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wVWvYHPsWaldzKhi+ueKVTe1Yx?= =?us-ascii?Q?AmD9pPyAPNn3DUEv3ECWnW7ByBUZLfdslzscUF88tuaxz25Pop0qpL8rS3SP?= =?us-ascii?Q?dcYWbLpFHKL3u06Tg2x++GCr+Zcj/scHe3w7i84ElLoUmPcqDajENIWveH0r?= =?us-ascii?Q?Ap19qMkJY7EgqE3atp/+JSfgjcZ2Bl8zffGooWz8?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5994.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcca257d-358c-40f9-e7a8-08dc01cea053 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Dec 2023 02:43:34.4218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fjRK0sBmUpNus3D2g86pduDXeymTQNpQObINa54eNo5heZsi61S72Nk10EFwnuoCLQq39tCntmZdZ4vbqHEBuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB6376 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Yang, Qiming > Sent: Thursday, December 21, 2023 9:44 AM > To: Zhang, Qi Z > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH v2] net/ice: fix link update >=20 > hi >=20 > > -----Original Message----- > > From: Zhang, Qi Z > > Sent: Thursday, December 14, 2023 4:41 PM > > To: Yang, Qiming > > Cc: dev@dpdk.org; Zhang, Qi Z ; stable@dpdk.org > > Subject: [PATCH v2] net/ice: fix link update > > > > The ice_aq_get_link_info function is not thread-safe. However, it is > > possible to simultaneous invocations during both the dev_start and the > > LSC interrupt handler, potentially leading to unexpected adminq > > errors. This patch addresses the issue by introducing a thread-safe > > wrapper that utilizes a spinlock. > > > > Fixes: cf911d90e366 ("net/ice: support link update") > > Cc: stable@dpdk.org > > > > Signed-off-by: Qi Zhang > > --- > > v2: > > - fix coding style warning. > > > > drivers/net/ice/ice_ethdev.c | 26 ++++++++++++++++++++------ > > drivers/net/ice/ice_ethdev.h | 4 ++++ > > 2 files changed, 24 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/ice/ice_ethdev.c > > b/drivers/net/ice/ice_ethdev.c index 3ccba4db80..1f8ab5158a 100644 > > --- a/drivers/net/ice/ice_ethdev.c > > +++ b/drivers/net/ice/ice_ethdev.c > > @@ -1804,6 +1804,7 @@ ice_pf_setup(struct ice_pf *pf) > > } > > > > pf->main_vsi =3D vsi; > > + rte_spinlock_init(&pf->link_lock); > > > > return 0; > > } > > @@ -3621,17 +3622,31 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev) > > return 0; > > } > > > > +static enum ice_status > > +ice_get_link_info_safe(struct ice_pf *pf, bool ena_lse, > > + struct ice_link_status *link) { > > + struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > > + int ret; > > + > > + rte_spinlock_lock(&pf->link_lock); > > + > > + ret =3D ice_aq_get_link_info(hw->port_info, ena_lse, link, NULL); > > + > > + rte_spinlock_unlock(&pf->link_lock); > > + > > + return ret; > > +} > > + > > static void > > ice_get_init_link_status(struct rte_eth_dev *dev) { > > - struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > > >dev_private); > > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data- > > >dev_private); > > bool enable_lse =3D dev->data->dev_conf.intr_conf.lsc ? true : false; > > struct ice_link_status link_status; > > int ret; > > > > - ret =3D ice_aq_get_link_info(hw->port_info, enable_lse, > > - &link_status, NULL); > > + ret =3D ice_get_link_info_safe(pf, enable_lse, &link_status); > > if (ret !=3D ICE_SUCCESS) { > > PMD_DRV_LOG(ERR, "Failed to get link info"); > > pf->init_link_up =3D false; > > @@ -3996,7 +4011,7 @@ ice_link_update(struct rte_eth_dev *dev, int > > wait_to_complete) { #define CHECK_INTERVAL 50 /* 50ms */ #define > > MAX_REPEAT_TIME 40 /* 2s (40 * 50ms) in total */ > > - struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > > >dev_private); > > + struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data- > > >dev_private); > > struct ice_link_status link_status; > > struct rte_eth_link link, old; > > int status; > > @@ -4010,8 +4025,7 @@ ice_link_update(struct rte_eth_dev *dev, int > > wait_to_complete) > > > > do { > > /* Get link status information from hardware */ > > - status =3D ice_aq_get_link_info(hw->port_info, enable_lse, > > - &link_status, NULL); > > + status =3D ice_get_link_info_safe(pf, enable_lse, &link_status); > > if (status !=3D ICE_SUCCESS) { > > link.link_speed =3D RTE_ETH_SPEED_NUM_100M; > > link.link_duplex =3D RTE_ETH_LINK_FULL_DUPLEX; diff - > -git > > a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index > > abe6dcdc23..d607f028e0 100644 > > --- a/drivers/net/ice/ice_ethdev.h > > +++ b/drivers/net/ice/ice_ethdev.h > > @@ -548,6 +548,10 @@ struct ice_pf { > > uint64_t rss_hf; > > struct ice_tm_conf tm_conf; > > uint16_t outer_ethertype; > > + /* lock prevent race condition between lsc interrupt handler > > + * and link status update during dev_start. > > + */ > > + rte_spinlock_t link_lock; > > }; > > > > #define ICE_MAX_QUEUE_NUM 2048 > > -- > > 2.31.1 >=20 >=20 > Acked-by: Qiming Yang Applied to dpdk-next-net-intel. Thanks Qi