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 739A941D8B for ; Mon, 27 Feb 2023 07:02:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6857341140; Mon, 27 Feb 2023 07:02:57 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 1E28040A7D; Mon, 27 Feb 2023 07:02:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677477774; x=1709013774; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=1cVEV4Wtje+BxuwRcTgvnY4gtjzPdVWGM/VnLRxNeMc=; b=M1eQPPKb9gMMf5L+sJXNpkVQuGKPDObkQrd7TobtjtibCeWlNgikRPF8 +nhYM7SpMwLyFP95GrSnQtlOX17O2YVo62eOqmH/PpUGPpi0fROr+9SRe ihM2vwP/W0FmFCWb7St1VFKsUspyOREGoaARQEWB0QjzUhn3ll0sqIMNO jUlKuGYUosDJilCr1YyOFqmkEnVbUGMo/wED7TaIjajU/uNUQ6SbpCAmY FqA+egGwdbDKGguPL34aNzUIWlpBdynZJVwCq+H2hgnCSBmdpTSOqyoQw RIIGWeGZ4rVbyFyysY5OLdvNSYIwjP3f9R6MgpWVUpHy7GPH9r3/N2bOe g==; X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="333827747" X-IronPort-AV: E=Sophos;i="5.97,331,1669104000"; d="scan'208";a="333827747" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2023 22:02:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="816492828" X-IronPort-AV: E=Sophos;i="5.97,331,1669104000"; d="scan'208";a="816492828" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2023 22:02:52 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.16; Sun, 26 Feb 2023 22:02:52 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Sun, 26 Feb 2023 22:02:51 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Sun, 26 Feb 2023 22:02:51 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Sun, 26 Feb 2023 22:02:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPkWvS0NRkr9ePZGOCWAWhOi8eZO8C3OBFsroXiu2Jl1+H04ewrmRgxd4EEXPBb6f9uvj+b2KGRVtAw/6Fd8pkIBVtSYgdkkqHxcul4VKMAC3OKkRHYEoxv3A1hF7XmGehnU50+rRPizzTPqU+9gCwYkZWOs2oArktCEmHURNbb7p35XlRAdUbIQRfPeKCXTStVqUyj/uj6kksok1Ais5TkjV605lE2kYgw4ImaQ2uSwultmm1PBt+97Qxll4NZgiZF1HLm4C/mRZojAVAvUCfx/QztKFUTxDwh5aU63K2cX0+EahcUtPV8ixBK3oV+uNHl1xygBM67gJH7kpRpw7w== 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=U1sN8gNpbT6Cb/MAMzaSafOFH2S4FUOMig+kfTXktsU=; b=OdaP9Nt4dRZUHU/JT1Jo3TlMIjWD3XuVCJLBOWIXTzgN0+f7i3IQmGNP8B6N4SdzufGh6Z/4i+qIsoiYSe4JSlm86mKJOGGjQVSHQDNi6rrFJKDc9+eeHg0aUEDljkdTIQ0NwsNBXlKz2H2KoL0J3RggqDsEdtyAXgEB43A0Aoiv6jhtWIyL6k0KWEgNntS/5egC8xNC1TDoHXFswwDI3a1pZeDY4w6C/62Oewai88P/TxQxMiYuGLU9201eHmDjHCk0r9pALKm0ARbktQ+pbp+9hg31iPCOHMCKDx/x0KLBe7VK0iDB9UXqXc9RhtVww0Q+k6fFF3W/LyRd51m19Q== 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 BYAPR11MB2903.namprd11.prod.outlook.com (2603:10b6:a03:89::31) by PH0PR11MB5642.namprd11.prod.outlook.com (2603:10b6:510:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 06:02:49 +0000 Received: from BYAPR11MB2903.namprd11.prod.outlook.com ([fe80::920b:1f50:3c66:a388]) by BYAPR11MB2903.namprd11.prod.outlook.com ([fe80::920b:1f50:3c66:a388%3]) with mapi id 15.20.6134.025; Mon, 27 Feb 2023 06:02:49 +0000 From: "Deng, KaiwenX" To: "Zhang, Qi Z" , "dev@dpdk.org" CC: "stable@dpdk.org" , "Yang, Qiming" , "Zhou, YidingX" , "Wu, Jingjing" , "Xing, Beilei" Subject: RE: [PATCH] net/iavf: fix iavf query stats in intr thread Thread-Topic: [PATCH] net/iavf: fix iavf query stats in intr thread Thread-Index: AQHZRnwPXF0A6biPeEOgBAjGk8jAU67h/6CAgAAWAYA= Date: Mon, 27 Feb 2023 06:02:48 +0000 Message-ID: References: <20230222044001.1241845-1-kaiwenx.deng@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: BYAPR11MB2903:EE_|PH0PR11MB5642:EE_ x-ms-office365-filtering-correlation-id: a9d12713-2278-4202-6cb9-08db1888410d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EQnbclrqRTVmWS5yYfiUcdq910Wia580f9DAkEmv3gtBlZ38pOwQ+8FLREgS9mRiENsnI0IIbFoiKxhUwLfZ0oupnBObjUSoDD+M3QdsYxmHwl9Up5IyXCCfDwfHW48xXJ74BEww47+HR7U31PuBIv20oe+PDJSzxfwxqByPEYevKDocE92s78A8mKZSXYYP2QdlYWZjFc7uBLZ8kNNXLk5ZXlbtkNj2DNyRwKa0gshKu/MadWHdNm3qJKwKqBXwpAX1AEXjpM5g+M+qvXc8PYYXL/ZO9n8Vd1pvARgw44UjsH8TVTBhwUeVy3n6yh94TFMiwW2EZeQHokClLM34AawcIdsHaS2Gav58Aaee5HVrpKovf7cMys/bjcXLgW6Mn3UbTGGjardrvjKKtBloUoW1dqcyasO0uhkyfcfckCrrDJB46mNmjkRDG4VleRj+f4sA3lAePOwYL6KszMgNjo5QCgoHaHByj+L0AuG/R1D05ve3fR6MuzXvUPvV2ph/LnRHIjzH1XASUHxbwNWoW2Nhnub136uFXTzLfAeERgck0efP1877BVSToMAp87B55rzagUGzBZT5aNJoUoWNSQ8EYo31rgSgy0ZXZ3/hR7ATRZb0BFxr/PTXZIHu5p8iwCH7uamBsRGclqHSwJZA6S3/hdrBIH62+G7pheGV1VZCeQWfFWAc5fv/baUMTVi4VQ+L+3OrhpEH0nxouHVNlg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2903.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(346002)(376002)(396003)(39860400002)(136003)(451199018)(316002)(110136005)(54906003)(33656002)(86362001)(55016003)(38100700002)(122000001)(82960400001)(6506007)(107886003)(53546011)(83380400001)(9686003)(186003)(26005)(38070700005)(5660300002)(71200400001)(8936002)(2906002)(7696005)(52536014)(478600001)(41300700001)(4326008)(450100002)(8676002)(76116006)(66946007)(66556008)(66476007)(66446008)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?jmdb2NX8GYti6psDkTHW97/bbl69qmyVvjmqwZYGLwhs0LQG+J6Qz6ODLxsS?= =?us-ascii?Q?lEY3nWbmhcptoIi4c9Br09G3cd1g6b+dCvRiYx/y9HajisEanFJirruNvCAw?= =?us-ascii?Q?NfAgA1fkUficZEWv9yMmmCAn4sTZIZq35uFNh6fUiYRLtO6v4MUh4864SFzU?= =?us-ascii?Q?UpeKsar1k8v87wHFejlIX9yd6kM/AF2o1st9IhzV24EX+UdiPbaNIuIzsV/8?= =?us-ascii?Q?tyl+Ciny+XZp6Cu4MGVS9aTJYXOQFgscg38fFpwQaCpyTDbCUZeJOoZPbK4Z?= =?us-ascii?Q?UNOIsgWYCzPt8BtmbicaCsGf1Bj3AsRBBZUmjwrVTp3lAyX0vsdZMpCOlhMx?= =?us-ascii?Q?bFFhI3kW92SMrTvTdkPdmhJE0pFAG3iS7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78G3xYZD08WcDe+DGlQBFMqz29IoyGl3TV3RfeN2GNLxXWI1I11fxRh0?= =?us-ascii?Q?UNoPq40g6P2mAwHb5twUoMHqItmNc5VckpwiL2Vlv+We5wXDqRXazLnik1wJ?= =?us-ascii?Q?sfiYkPgv6I1akj5yrdNWoweVDp/KOP5rDUXlBbcX1p3V1LpoL6oV5bSlJXTm?= =?us-ascii?Q?uIf3gE3YtczEACYljVFUMlJkktiwVL4saco3p2HFa6NQmYXJs1bC8FRZIJ02?= =?us-ascii?Q?oXX4iN1QjZiF4Pi9XcuqlbtJXa+D+20tr+TX0nCiEoOQ2SZ8D5L6o5z6cf6K?= =?us-ascii?Q?cmIqnGpF6wiXp4akfvOeaXHhXerBn7Se1Bo1sGqI?= 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: BYAPR11MB2903.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9d12713-2278-4202-6cb9-08db1888410d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2023 06:02:48.8606 (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: Q+l6Xqmx90otQjtFTYj3QkuKLyZvf3iTmnBOz1VlWtgPT1r58x0NNc+RW9EIGMqUfaDyRH/SUWilQEK3FKJGkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5642 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 > -----Original Message----- > From: Zhang, Qi Z > Sent: Monday, February 27, 2023 8:56 AM > To: Deng, KaiwenX ; dev@dpdk.org > Cc: stable@dpdk.org; Yang, Qiming ; Zhou, YidingX > ; Wu, Jingjing ; Xing, > Beilei > Subject: RE: [PATCH] net/iavf: fix iavf query stats in intr thread >=20 >=20 >=20 > > -----Original Message----- > > From: Deng, KaiwenX > > Sent: Wednesday, February 22, 2023 12:40 PM > > To: dev@dpdk.org > > Cc: stable@dpdk.org; Yang, Qiming ; Zhou, > > YidingX ; Deng, KaiwenX > > ; Wu, Jingjing ; Xing, > > Beilei ; Zhang, Qi Z > > Subject: [PATCH] net/iavf: fix iavf query stats in intr thread > > > > When iavf send query-stats command in eal-intr-thread through virtual > > channel, there will be no response received from > > iavf_dev_virtchnl_handler for this command during block and wait. > > Because iavf_dev_virtchnl_handler is also registered in eal-intr-thread= . > > > > When vf device is bonded as BONDING_MODE_TLB mode, the slave > update > > callback will registered in alarm and called by eal-intr-thread, it > > would also raise the above issue. > > > > This commit add local stats return to iavf_dev_stats_get immediately > > when it is called by eal-intr-thread. And update local stats in iavf-vi= rtchnl- > thread. > > > > Fixes: cb5c1b91f76f ("net/iavf: add thread for event callbacks") > > Fixes: 22b123a36d07 ("net/avf: initialize PMD") > > Cc: stable@dpdk.org > > > > Signed-off-by: Kaiwen Deng > > --- > > drivers/net/iavf/iavf.h | 9 ++- > > drivers/net/iavf/iavf_ethdev.c | 24 ++++++-- > > drivers/net/iavf/iavf_vchnl.c | > > 107 ++++++++++++++++++++++++--------- > > 3 files changed, 104 insertions(+), 36 deletions(-) > > > > diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index > > 1edebab8dc..3a249b90a3 100644 > > --- a/drivers/net/iavf/iavf.h > > +++ b/drivers/net/iavf/iavf.h > > @@ -128,6 +128,7 @@ struct iavf_vsi { > > uint16_t base_vector; > > uint16_t msix_intr; /* The MSIX interrupt binds to VSI */ > > struct iavf_eth_xstats eth_stats_offset; > > + struct virtchnl_eth_stats eth_stats; > > }; > > > > struct rte_flow; > > @@ -325,6 +326,8 @@ struct iavf_adapter { > > struct iavf_devargs devargs; > > }; > > > > +typedef void (*virtchnl_callback)(struct rte_eth_dev *dev, void > > +*args); > > + > > /* IAVF_DEV_PRIVATE_TO */ > > #define IAVF_DEV_PRIVATE_TO_ADAPTER(adapter) \ > > ((struct iavf_adapter *)adapter) > > @@ -424,8 +427,10 @@ _atomic_set_async_response_cmd(struct > iavf_info > > *vf, enum virtchnl_ops ops) } int iavf_check_api_version(struct > > iavf_adapter *adapter); int iavf_get_vf_resource(struct iavf_adapter > > *adapter); -void iavf_dev_event_handler_fini(void); > > -int iavf_dev_event_handler_init(void); > > +void iavf_dev_virtchnl_handler_fini(void); > > +void iavf_dev_virtchnl_callback_post(struct rte_eth_dev *dev, > > + virtchnl_callback cb, void *args); int > > +iavf_dev_virtchnl_handler_init(void); > > void iavf_handle_virtchnl_msg(struct rte_eth_dev *dev); int > > iavf_enable_vlan_strip(struct iavf_adapter *adapter); int > > iavf_disable_vlan_strip(struct iavf_adapter *adapter); diff --git > > a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c > > index 3196210f2c..fcbab5b26a 100644 > > --- a/drivers/net/iavf/iavf_ethdev.c > > +++ b/drivers/net/iavf/iavf_ethdev.c > > @@ -1729,6 +1729,17 @@ iavf_update_stats(struct iavf_vsi *vsi, struct > > virtchnl_eth_stats *nes) > > iavf_stat_update_32(&oes->tx_discards, &nes->tx_discards); } > > > > +static void iavf_dev_stats_get_callback(struct rte_eth_dev *dev, void > > +*args) { > > + struct virtchnl_eth_stats *eth_stats =3D (struct virtchnl_eth_stats > *)args; > > + struct virtchnl_eth_stats *pstats =3D NULL; > > + struct iavf_adapter *adapter =3D > > + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); > > + int ret =3D iavf_query_stats(adapter, &pstats); > > + if (ret =3D=3D 0) > > + rte_memcpy(eth_stats, pstats, sizeof(struct > > virtchnl_eth_stats)); } > > + > > static int > > iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats > > *stats) { @@ -1738,8 +1749,13 @@ iavf_dev_stats_get(struct rte_eth_dev > > *dev, struct rte_eth_stats *stats) > > struct iavf_vsi *vsi =3D &vf->vsi; > > struct virtchnl_eth_stats *pstats =3D NULL; > > int ret; > > - > > - ret =3D iavf_query_stats(adapter, &pstats); > > + if (rte_thread_is_intr()) { > > + pstats =3D &vsi->eth_stats; > > + iavf_dev_virtchnl_callback_post(dev, > > iavf_dev_stats_get_callback, (void *)pstats); > > + ret =3D 0; >=20 >=20 > I assume this is going to return a copy of outdated stats, then the stats= will be > updated it in future and this happens in another thread, is it correct? > If true, then will be 2 issues. > 1. How the caller know when the updated data will be ready? > 2. even caller will consume the outdated stats directly, is that will be = a race > condition if the virtchnl thread update the stats at the same time? >=20 > > + } else { > > + ret =3D iavf_query_stats(adapter, &pstats); > > + } > > if (ret =3D=3D 0) { > > uint8_t crc_stats_len =3D (dev->data- > > >dev_conf.rxmode.offloads & > > RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? > > 0 :