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 A1BE741D87 for ; Mon, 27 Feb 2023 01:56:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95AC1410FB; Mon, 27 Feb 2023 01:56:34 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id B084E40A7D; Mon, 27 Feb 2023 01:56:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677459392; x=1708995392; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=zen42Q9XQlZP5A/BgAq88/VKG7bnTp79I8Wa5aQ4weY=; b=f5x4IIxdgiVazzbRks10w2H/01sXMqucy7yb0V2nLOrl9q2VUxmPw4H4 l0JG63qb9jafRdjER+wYIPgVhfM+JumJr7xSNrLY/NoQ0zu4zqenfu6/u xN8icnucIUMP/KT59BvROhAHLNcHpc7jmeqz6ExkW8CGFWVezQ8wTU1Xi LJAWmuPgnAbwRhhMiq2mNozfeJdwI/jbwLDd02ZQEpAWCZeVfsugNcgRG 1Tn66+ey5lCBKpmcJLmVasUsN2pSGYmJSUneUF3cPqZlPCSbRbZ7fb12g VmNHw7+R4dPf5mUbvNqwmHpFkJeD4iwpO+aJnLRZODKzJNEifkJwY7h/B g==; X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="333797809" X-IronPort-AV: E=Sophos;i="5.97,330,1669104000"; d="scan'208";a="333797809" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2023 16:56:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="1002514677" X-IronPort-AV: E=Sophos;i="5.97,330,1669104000"; d="scan'208";a="1002514677" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga005.fm.intel.com with ESMTP; 26 Feb 2023 16:56:23 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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 16:56:22 -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 16:56:22 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 16:56:22 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.102) by edgegateway.intel.com (134.134.137.100) 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 16:56:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LimRvY8BnCETHN2Xlhp9qv6w9D3qVVYC+KTvU2CQGpwdqw5XnusR4bgA8dtWA3tpk2VLSDrJ03aNvOzgk+hYcCrqWWYoizDT7LmPubLgTkl4jUp79t4sb39FtnTGPPvtOHkq/zoMWI1QKNVfau+UcPRDVW2Npzr91ZIO2KY9lXGuS6MX0Cs2zFopI9k6vco3/wci1JpX8MZLvnm68egznsdUUe1BQBcO3fr+cFOIDaJa7n1dEyLvD3/16mppS8hGvr0y3oGLYnQYAiLXWMVLCa6hvvhWc0TOzXsgxtKj6IOlN+f+4TsQ2mx7l1brJasoUkb8ZUamfDkQd79MKMmHhg== 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=p4nM+U7TBA6+lD24IqrQvUu3JWo1TYv92zY2C0Imhfw=; b=i36g9sK/SQKdU77iHukthXXHrqC+oHFV+nHMWhhpfsPXp3vOMznWdOtxC2MRtuco3sezjnXLfxu6Pg8ddQjT//hJCJoUQ/pH9j49vDo4hLrsDTVK793hhwhduAtjfRXMwAi3nAi2a6OnC/6dYw1BuoaKGbnAHC7j+svsA2Y63Cd4gX9IONzO/fU/cmQ2UEySx05+Q0q5ZKQ91xBPSdGeUkVsdv0tMIdDAhn45FUpYH9CK5Ht0A7NnxDDOibbNPqdNC+dXaGutRUh6IPsgZbdNw0cQ3KypD3Qz750/1ZkYZJ059xnAgnzPIKfixrQJifg41kD1R8lbWDBYqN6q87W/g== 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 MW4PR11MB5799.namprd11.prod.outlook.com (2603:10b6:303:181::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.26; Mon, 27 Feb 2023 00:56:17 +0000 Received: from DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::2c5d:49cd:a9b4:f764]) by DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::2c5d:49cd:a9b4:f764%7]) with mapi id 15.20.6134.026; Mon, 27 Feb 2023 00:56:17 +0000 From: "Zhang, Qi Z" 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 Thread-Topic: [PATCH] net/iavf: fix iavf query stats in intr thread Thread-Index: AQHZRnwPs1VvAmi1G0mjRhz0Z2YUZK7h/Yug Date: Mon, 27 Feb 2023 00:56:17 +0000 Message-ID: References: <20230222044001.1241845-1-kaiwenx.deng@intel.com> In-Reply-To: <20230222044001.1241845-1-kaiwenx.deng@intel.com> 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_|MW4PR11MB5799:EE_ x-ms-office365-filtering-correlation-id: f6d3ad94-3713-4800-882f-08db185d6eef x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dSJ8L/2p5dkJTi/F+8pwRGDaqtgZE3k91uR1VfaYq9VpRlsE7bOuqj+jhsMEj7kJY/VmqbgsfVQII69siJVyeEfEhKtuOv9HlmQp6hNnVd3fwFgovleZOy2p2zeb3icbOwvd6utiTyNXDoINXnzv6GOYS6CN/QzEhhd9OgdC7ssDI8HHbwyofyWhsOTtScOycsHDcp9GEbcN1xVNrXL8enPhzvV67ksdYTdb+M/P9JYnaEaVdnGB3Z+CwunpVLF7QK0cuJOu2Z8UJx2U10LP5CY29gtJHrcsI6cAX1dv7Cb9rFhADRrOIiVN5dHHwP06oMP2LG8aV2anSVUNimAJ+aafnnRhGQRQM6Iekl78qy+VjPr7yC53JkWEhnk0z70K5dIqVxjiFcMNQhmwPsoup8vOhWoZiwZLJ+uiVFeYpXaVJh7pTvA398bb+06aJP8Vc0KTAwncFBKvNqkBvz4EpxPhcILKvcLSJZKA+fmoaDubSP6VYQGCenzWL1DDJV1gM+Twu7n2AdPI08g4hXS8M8/9w8S6mKVLShKl9Mcxa+EKGut6PW1BP+IZjr8fUs07x8E+LrLatmC1c+2y7A2PyaJ6UzC5+aBYAHm24JtfkdEt+HPoe/WxZEIIoteGxK5SU8lvda4wkZIF9XosZxWhA+kWQwlMYI+hS6jmh8130UU8aylz+cEx37RcXlPacnWStwEgt9NU7mcB9ES1Kgvvew== 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:(13230025)(39860400002)(396003)(376002)(346002)(136003)(366004)(451199018)(110136005)(316002)(41300700001)(54906003)(38100700002)(55016003)(83380400001)(122000001)(86362001)(8936002)(5660300002)(52536014)(2906002)(450100002)(66556008)(64756008)(66446008)(66946007)(66476007)(4326008)(76116006)(8676002)(478600001)(26005)(71200400001)(38070700005)(7696005)(186003)(6506007)(9686003)(107886003)(53546011)(82960400001)(33656002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?/8hwuxI4ZENzrBvdgKspuk4lzOY+MxjpAKNZcR0M7cBxzYcrSvpBiTyJ5Pwn?= =?us-ascii?Q?8+WcUoQZG27ZXXlStAarWIgMiW4miViMZvM0m1xjuYeH/TqXFrG8Di+13Plz?= =?us-ascii?Q?cd91U4k8Q2NgvslSu9PdPEQG4/5G0cLfjwjKvdpzgUiRGhUk4YWuSxWt+l49?= =?us-ascii?Q?5VtXo6oc19a9BnjbnVU5ynv2ggM5WRpMEvMw1G8mV7k7oBhTq+7UJqPZQ5NG?= =?us-ascii?Q?4Y0F2mowo7R/bkPpbxqxGeLW7khcYJkqd8r4NfUYjwPrfatPWdj7865PuTLu?= =?us-ascii?Q?FNtA6+pHz0LyBibF+GjschF9KcB8MmWtifCBOhmetnzn4CCndaVwn4ZGf6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gltNi52EzrTNN74mAqDh8GCI4Y/oViE93?= =?us-ascii?Q?Q52KYB1Nl21oTCwqlysbljuaF22eG95qwcg5r7j7S2sPLGVAe7rtDiqhy0iw?= =?us-ascii?Q?osO8gvn0RPF9HrfcMMz93wplDv8wKvKBC3JGJwogA8FRuYHlpeXtwKq/hYsB?= =?us-ascii?Q?dwATt3Tt2PxvBxiPqZ6icG/AD5TR8OqG84uiH243xLjh/oL+UDMMZls1M8d0?= =?us-ascii?Q?6bsB3X9mQOMyvEF1TVIQnXYybqzSmEsREfEvBaAf+qZYFd4tVXevztGhbxsH?= =?us-ascii?Q?6EtHUZimj9fxDZWSdI4eUK2ZaX2oiXucThfuaQR402xLlDixV08no0prEufr?= =?us-ascii?Q?FTvTHBjPwRyTfnLkqMoHFE1Uu92tDuSRexU+GLqK?= 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: f6d3ad94-3713-4800-882f-08db185d6eef X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2023 00:56:17.4805 (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: GWiTIsEgZCfg4s2Yw4dPrI07aVUY9AgRVFoLEsINZ3B0TlObaNeT4/m6+9V7sIF634Vgb/4WOq+yqh27s+MB1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5799 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: 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 ; Z= hang, > Qi Z > Subject: [PATCH] net/iavf: fix iavf query stats in intr thread >=20 > When iavf send query-stats command in eal-intr-thread through virtual > channel, there will be no response received from iavf_dev_virtchnl_handle= r > for this command during block and wait. > Because iavf_dev_virtchnl_handler is also registered in eal-intr-thread. >=20 > 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. >=20 > 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-virtchnl-thr= ead. >=20 > Fixes: cb5c1b91f76f ("net/iavf: add thread for event callbacks") > Fixes: 22b123a36d07 ("net/avf: initialize PMD") > Cc: stable@dpdk.org >=20 > Signed-off-by: Kaiwen Deng > --- > drivers/net/iavf/iavf.h | 9 ++- > drivers/net/iavf/iavf_ethdev.c | 24 ++++++-- drivers/net/iavf/iavf_vch= nl.c | > 107 ++++++++++++++++++++++++--------- > 3 files changed, 104 insertions(+), 36 deletions(-) >=20 > 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; > }; >=20 > struct rte_flow; > @@ -325,6 +326,8 @@ struct iavf_adapter { > struct iavf_devargs devargs; > }; >=20 > +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_ad= apter > *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); } >=20 > +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 *)a= rgs; > + 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; I assume this is going to return a copy of outdated stats, then the stats w= ill be updated it in future and this happens in another thread, is it corre= ct? 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? > + } 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 :