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 1D1E7432B3; Mon, 6 Nov 2023 02:23:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE6A44027A; Mon, 6 Nov 2023 02:23:17 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mails.dpdk.org (Postfix) with ESMTP id 2B9E14025D; Mon, 6 Nov 2023 02:23:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699233795; x=1730769795; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=228IXpaRDLvZo9Sw6VtfrTVffokciH2sAouC5RllQsw=; b=eMans1P7V29ZnJK/OnCjv8b5dFKwHB77tRkc98OO9x76kz9d2KlgFw+d JKfR3nBOaRlNPb+uP2bWHb3az5liGp1hPoM2ubh3ee3FiH+hP5v/MIVcO +Bet6bJXoR/qS/VlyyPOMxcdzIxkHFl5k2UenPX3YpzS5NsXSsoQtKeuD TCLMvsTznWsfQ6eaTqjFIOFwV8jwP3QKhu//aAHULqQpjX/ZW8st8Xkup AIIgzdsgGuLNfgkWz6etO5+HcynYos7TLt9k9o4Cqig2PBgmeDAvt1pvi PINddR439CTNbcFPbfaXYvA7glbKove74vyVh3r5Kivn3FeYTNij3z3an g==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="10727576" X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="10727576" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 17:23:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="738653514" X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="738653514" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 05 Nov 2023 17:23:13 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Sun, 5 Nov 2023 17:23:13 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Sun, 5 Nov 2023 17:23:13 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Sun, 5 Nov 2023 17:23:12 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jph6aD5xPVRG9pN2eajkhtNJkfmWVLbfJDZhxkJfXTlThENaXVcN/XjyllWN2qYSEc4+rGsMLcSPQCmjFCylqbu0JPQZSaryZmxDDJLd/VX9sUG3rEXBJTmykMBTv/80paE1IQNiESCIITbfc0ZkioC+cq8H0lS/XqiPyVr2VFVVvZh4mf6o36Um3OKLuWWeYg69PXhsz6J7rwU6/BKLY9IAob011nYDMV37j/y3n7eMt52AThkA3gvQ9DR3Muerg44l4TsLYVzkL/bsGmkyrQiw9aDwpWMFfzVyho/KLjEbkLERZKbCld4KMDmhRVj18/cX7ZDXjdgCXNkiW8U1cQ== 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=h6Sgb7mRXRqjqoZfc3bZ+LlbpJrcm4b+g8nSZvwHRAw=; b=PcWQICBOEPPOgabd1dRqkW8sW1tcy52VsmuHcjn77Oy/xASG1Q2yR1zryYQpq6L8l3eiqRVl/HGLvmrTWgPfmklloUBfz7rJuZ2aca/idFH0pibFohY43gTyi+wjDeqdDDw58Y3doWFq/FpCE6q4tiYBxcpdQsv0MeDEtRM+fq6zw2C5IEasYGuVtLJapi6k5a9VHj4mgl8x3avxRX4w/eJlJVioApyargZUCQ0b5wHT9nMy6BwXnhsVYVtn6RN+UqBfyYtIDjgL32JTgQp0WD64z9JSMZD+PmawL2mwOYWvxxgJwwK//DwiT3PP0NXNcvI9WC5KwJ6lFmwT8ntYsg== 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 SJ1PR11MB6155.namprd11.prod.outlook.com (2603:10b6:a03:45e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.24; Mon, 6 Nov 2023 01:23:10 +0000 Received: from DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::62e2:b53a:6a07:f136]) by DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::62e2:b53a:6a07:f136%6]) with mapi id 15.20.6954.024; Mon, 6 Nov 2023 01:23:10 +0000 From: "Zhang, Qi Z" To: "Ye, MingjinX" , "dev@dpdk.org" CC: "Yang, Qiming" , "Zhou, YidingX" , "stable@dpdk.org" Subject: RE: [PATCH v4] net/ice: fix crash on closing representor ports Thread-Topic: [PATCH v4] net/ice: fix crash on closing representor ports Thread-Index: AQHaDXZbKh4bsZyF5UaV9GG+h5FjxLBsfz7g Date: Mon, 6 Nov 2023 01:23:10 +0000 Message-ID: References: <20231101101347.3570418-1-mingjinx.ye@intel.com> <20231102101103.3707173-1-mingjinx.ye@intel.com> In-Reply-To: <20231102101103.3707173-1-mingjinx.ye@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_|SJ1PR11MB6155:EE_ x-ms-office365-filtering-correlation-id: c88699f8-9c42-44e0-d279-08dbde66f06f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Wsb1/NezLYIObefCu6/jYC2w3ueg7DR0fondvoEPoPVxL4VIZjuMFDEyshQfOMH4cpafPDz7908hoyuvhtdTxIMvCoI6njsjUw3A9Rz8EUxmakjDHdUcQuOWMdV1fOv2dXmG58CaWsA17CLMESGjvH0obNasxC1CE6vw2P5NBbgijU06qlKLGHR74WeVH5nvfDb6dI2JXFD3/G1Uwb6gFf7pDI2qMnTpKcZ8aD4ZOlXs+Pw94vxHBL9ic872ZIsp+1+tcsf7AKlhCkM6agQf+FwStDeiMn55leKES80GGiF2jyApbR0owjfjvOc2TGemkUX12L8Q6YcxV5IYvdq+OvvxViESYO8QFk28MRsrTUHKs1HgdDGtqP7veKadHnw+Dd7kqwM0vC6pWQYBmcelsheoXzrZHR/VZzrrgx7LRax1WwHdJrrEXgGpAOyUYIHnPtoYM8xwAPatdwXm3H703vJKPo7oMLp2vCl1sFmO0G/f3UZvZXcZAG6CXPk58qGuB9uwLiC8Ft2E1OSD1++05kaQB18iiZ2ukQizQOmx7RGQsxyKwB6nmEczMOmmk/kKJ8pksf9uQmEXSdxEUFAC1WG0QJ0Ofz3jJPwSiq0HTabg7MDzx+eSzZ4HX/MaahRP 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)(366004)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(38100700002)(66476007)(86362001)(54906003)(316002)(64756008)(66446008)(450100002)(66556008)(110136005)(66946007)(76116006)(8676002)(2906002)(83380400001)(8936002)(5660300002)(52536014)(4326008)(6506007)(9686003)(7696005)(53546011)(82960400001)(122000001)(55016003)(478600001)(71200400001)(26005)(38070700009)(33656002)(41300700001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?m95pkan0UYd9LTolsbyWIm+X3fxXW+YBesg+/ouA/4ExnCaq7eebFZd/vfwr?= =?us-ascii?Q?0bLJaDRASfnfXrHfOcgaodZ8nULKoxENqkUQY/jItXqgYpRXaj69vyu1nPGH?= =?us-ascii?Q?tf2Dif2pcq7Ub/b+UNtvEQYMwo2obUcn5k5HoasduWQwk7FWOms2OQef5wqb?= =?us-ascii?Q?8r/a6DWkwgpwpqZ0y7GOsOunyrv8N/sCAM5Qo8oFkycaDZBmdmM+0TNLINlO?= =?us-ascii?Q?unQgD0ZGnndA9/7TgMfgnNEiUEJ/CRJBjeXU2iVDc5aP0XLySi9WSu9CDA0Z?= =?us-ascii?Q?d74HTt8KEzkqrU66wtfOWa0dgMi/rKM13kF9FVIh+FBm/6i6eTJJWG0EgQgM?= =?us-ascii?Q?tBqJgq6cO4Ccl37Jw8sLZR3KkoYzj1jKwSWw7ZzsKot+st3qcUI/L1vF+bxy?= =?us-ascii?Q?NnmLjRGpfHlCaDTpHveFzFyShTg02DgygtC6zDH7IoA2cqKK7u1KSz9cda5J?= =?us-ascii?Q?UQfTvxwQ4Xy2Xbz7P7BYzi4jw84+aSJs8brllHKIlY0DGAsp8SE0SZO6husU?= =?us-ascii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Cqc07+90hQDAcDs4YQRO?= =?us-ascii?Q?sY0wwbxjyNOKBbDtkhLBZhdneI0NpPuhETFivzrZbZ7rMBBl1MBHzJ0UIQnz?= =?us-ascii?Q?p0i/xAM6LGNzUro7ehI+5FSWVxBCCFv/W7elEeKDB2bA5Q8oZWPdzU1kHEZG?= =?us-ascii?Q?9KNFr5oTQgFUObNETPdiS3bcogkee7Kf9vvurMt0?= 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: c88699f8-9c42-44e0-d279-08dbde66f06f X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2023 01:23:10.4752 (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: cQDeb6vzG5rVrCvD209SN/3QnSuOjq04lVbzCpxr4Eki8BYKJ/K5pxeKf7ov6oMb+dv/3Ahzc2t6B1tlqT0wmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR11MB6155 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: Ye, MingjinX > Sent: Thursday, November 2, 2023 6:11 PM > To: dev@dpdk.org > Cc: Yang, Qiming ; Zhou, YidingX > ; Ye, MingjinX ; > stable@dpdk.org; Zhang, Qi Z > Subject: [PATCH v4] net/ice: fix crash on closing representor ports >=20 > Since the representor port needs to access the resource of the associated= DCF > when it is closing. Therefore, all the representor port should be closed = first, > and then close the associated DCF port. >=20 > If the DCF port is closed before the representor port on PMD exit. > This will result in accessing freed resources and eventually a core dump = will > occur. >=20 > This patch fixes this issue by notifying each other to unassociate when t= he > DCF port and the representor port are closed. >=20 > Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling") > Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling") > Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing") > Cc: stable@dpdk.org >=20 > Signed-off-by: Mingjin Ye > --- > v2: Reformat code to remove unneeded fixlines. > --- > v3: New solution. > --- > v4: Optimize v2 patch. > --- > drivers/net/ice/ice_dcf_ethdev.c | 20 ++++++++++++++++++++ > drivers/net/ice/ice_dcf_ethdev.h | 2 ++ > drivers/net/ice/ice_dcf_vf_representor.c | 23 ++++++++++++++++++----- > 3 files changed, 40 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_e= thdev.c > index 065ec728c2..63e63a23de 100644 > --- a/drivers/net/ice/ice_dcf_ethdev.c > +++ b/drivers/net/ice/ice_dcf_ethdev.c > @@ -1618,6 +1618,26 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter > *dcf_adapter) > } > } >=20 > +int > +ice_dcf_handle_vf_repr_uninit(struct ice_dcf_adapter *dcf_adapter, > + uint16_t vf_id) > +{ > + struct ice_dcf_repr_info *vf_rep_info; > + > + if (dcf_adapter->num_reprs >=3D vf_id) { > + PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id); > + return -1; > + } > + > + if (!dcf_adapter->repr_infos) > + return 0; > + > + vf_rep_info =3D &dcf_adapter->repr_infos[vf_id]; > + vf_rep_info->vf_rep_eth_dev =3D NULL; > + > + return 0; > +} > + > static int > ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter) { diff --gi= t > a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h > index 4baaec4b8b..094e2a36db 100644 > --- a/drivers/net/ice/ice_dcf_ethdev.h > +++ b/drivers/net/ice/ice_dcf_ethdev.h > @@ -60,6 +60,7 @@ struct ice_dcf_vf_repr { > struct rte_ether_addr mac_addr; > uint16_t switch_domain_id; > uint16_t vf_id; > + bool dcf_valid; >=20 > struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN > */ }; @@ -81,5 +82,6 @@ int ice_dcf_vf_repr_uninit(struct rte_eth_dev > *vf_rep_eth_dev); int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev > *vf_rep_eth_dev); void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter > *dcf_adapter); bool ice_dcf_adminq_need_retry(struct ice_adapter *ad); > +int ice_dcf_handle_vf_repr_uninit(struct ice_dcf_adapter *dcf_adapter, > +uint16_t vf_id); >=20 > #endif /* _ICE_DCF_ETHDEV_H_ */ > diff --git a/drivers/net/ice/ice_dcf_vf_representor.c > b/drivers/net/ice/ice_dcf_vf_representor.c > index b9fcfc80ad..167abaa780 100644 > --- a/drivers/net/ice/ice_dcf_vf_representor.c > +++ b/drivers/net/ice/ice_dcf_vf_representor.c > @@ -45,6 +45,9 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev) > static int ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) { > + struct ice_dcf_vf_repr *repr =3D dev->data->dev_private; > + > + repr->dcf_valid =3D false; Is this correct ?=20 ice_dcf_handle_vf_repr_uninit will not be called, if we stop a representor port (call ice_dcf_vf_repr_dev_stop), then close i= t (call ice_dcf_vf_repr_uninit) while DCF still be active. if you want to use dcf_valid as a notification flag sent from dcf to each r= epresentors, never set it in a representer's own callback function. Btw, besides set dcf_valid to true in ice_dcf_vf_repr_init, you may also co= nsider the case when a DCF reset happen, dcf_valid need to be reset to true= for each active representor.=20 ... > *init_param) int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_= dev) > { > + struct ice_dcf_vf_repr *repr =3D vf_rep_eth_dev->data->dev_private; > + struct ice_dcf_adapter *dcf_adapter; > + > + if (repr->dcf_valid) { > + dcf_adapter =3D repr->dcf_eth_dev->data->dev_private; > + ice_dcf_handle_vf_repr_uninit(dcf_adapter, repr->vf_id); > + } > + > vf_rep_eth_dev->data->mac_addrs =3D NULL; >=20 > return 0;