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 9C952A0C48; Tue, 6 Jul 2021 19:49:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 126844128B; Tue, 6 Jul 2021 19:49:50 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 365564120E for ; Tue, 6 Jul 2021 19:49:49 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="209208993" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="209208993" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 10:49:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="560022925" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP; 06 Jul 2021 10:49:47 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) 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.2242.10; Tue, 6 Jul 2021 10:49:46 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Tue, 6 Jul 2021 10:49:46 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Tue, 6 Jul 2021 10:49:46 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.170) 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.2242.4; Tue, 6 Jul 2021 10:49:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JvWiyE+liYQefMFNDp9KafjgmLXw5JFLtVVzorDTtTXQrL9/unYQUZj0+3rnX6EdUSi45trdrb8YmMs49kXUpI04pci5/8LJL2ZNWfYOV6U2QR/q8YST2f1CxkWCd12lI+Nc44GnVTawUUFFrZP0MFi43PasaympSEpncuc70FED3urQiZly125uYZT/BVHORWAB2C+9M9oww4TBlrDXwXrogYsr31SoInop8CxOxM6/oDU+pbqFWV2UtchsBuLPO4NrH614u9gZ7KgcYS1yCAZlaSZXPaTEXRXQ9dpIyj84AGEW8S36z0AQBnsld7D7QlpmPoK76PbzqTjnv2dcvQ== 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=iD+jAIuIPNsPM4Xzd91KMBWIJEZjZ9JsC41dc7LEQnM=; b=n0IIOkHzbIvkIt1SLs8FGDfVUEggikK8KPw+ZmBzvL6jNM4zZmX1HNX95bu10GEIQ+ecpMI0rnk0knnw2W5cnhPfkfFMUQEXeDD8a5Pew1BpkMbX+Xo/Cq5qqmnr/pYIr8QNTEe0HYwvSz4K6GkY+UjuxuoP9l/YJeK6kHX6mDc1asfb/OXalQUC1d06cUj9U3sW1LFFiNIU0niQ2IU0R6VW4BbbCLDVt/YxTMb/T1LYGolfHVTtNvKTSo4aqU+qM+kbSegnoXmmqyU1yRstivPjsu2iEaYsEN1bgZBSMpYtGQYc+CUNtMvosIxGCx6h7N889S4hLL75u6HVA1o7TA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iD+jAIuIPNsPM4Xzd91KMBWIJEZjZ9JsC41dc7LEQnM=; b=YzU5IFAV0/K/ZMZVWQJNdacGRBU3oOBp1qnYQxZYQlegh48E5JnZJ2ATfAdLzkfZvhW/JEG/P2bZxjNWqo33uxFg6F+yJ5nzQljVh1RQf9MmgXHGvxmbTPf7H9MuKHtOPOnb5IHoZn0cZlY48OhSqctJrTLlW8H+KOjdK6iVpF4= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM5PR11MB1753.namprd11.prod.outlook.com (2603:10b6:3:10d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Tue, 6 Jul 2021 17:49:44 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48%7]) with mapi id 15.20.4287.033; Tue, 6 Jul 2021 17:49:44 +0000 From: "Ananyev, Konstantin" To: Huisong Li , "dev@dpdk.org" CC: "thomas@monjalon.net" , "Yigit, Ferruh" , "andrew.rybchenko@oktetlabs.ru" Thread-Topic: [PATCH V2] ethdev: add dev configured flag Thread-Index: AQHXchzwzMl5jqIB00++YImlAeijB6s2OiyA Date: Tue, 6 Jul 2021 17:49:43 +0000 Message-ID: References: <1620460836-38506-1-git-send-email-lihuisong@huawei.com> <1625544608-30590-1-git-send-email-lihuisong@huawei.com> In-Reply-To: <1625544608-30590-1-git-send-email-lihuisong@huawei.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 105db5c0-234e-42d6-7545-08d940a6702b x-ms-traffictypediagnostic: DM5PR11MB1753: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: G4qLRZzZymfxqKdoRXRcjCKtK5q7aNrFwUQEEG07MBY6xcmwsg+MvuZbKqDQXrZtqCJcFQTL8wt/9lHmYh8q+Oao7JdOT1qrjr7Wr/n00JeuLYgdMtAGz6joU8Q9VOt6g2/UFe3I99GoghwFPELatEhHeX0cujTdYqkHmEJyWU9/mu0LUnvhWIw+DybLzAEe3VZ8QxgFlxpcaY65TK3M4DxBiDfeikBKtNgu7swBmsNhLakWXQnOKGqjk1MqwyuyTkwRToThhmj8hIuzsUKoHgvcBVgkFUsgU9BJ9wqXfwQoU669SsWLg3kG7dGE6zo22LhCj32nOeL9frjoyQKG3+c0F1XNXGF7y+dvI6J7CvI45U2lo7H1db5J3+4EpCP0OA1sqWEMBOAjMd7CFA6IXQf3A1DBHkV7GAx6WGiBEhGaue/PhGu9rYL9Zw6cw3AsAw518lX0M9t1QOhZ/SIF4f8GaZFTRvdO0Vb08zwklR78M7MXyB3q69go5cfK7DG/JmYFTyO+Q6+KdvLBZBlm4flrtPC8Z0SMRJGxK6ceef6En3tSBQRukfntSlGZifVaBBy/fs/41CGjTgMk+rKPOCN7n68msEyueoAO+RgRCnFiktE/0+Wycg0iJbW/dHv6pulLWgNFv/PzPsskn0fCLg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(366004)(346002)(396003)(376002)(38100700002)(8676002)(26005)(316002)(478600001)(2906002)(66946007)(66556008)(7696005)(122000001)(52536014)(9686003)(66446008)(5660300002)(83380400001)(76116006)(64756008)(86362001)(8936002)(54906003)(4326008)(110136005)(33656002)(6506007)(66476007)(71200400001)(55016002)(186003)(55236004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7pWKVoFjvRMarNkFGRvKzXxdUBHowZvAYKGnxT5SKZ37d1wTdanDp1wZCpB6?= =?us-ascii?Q?unkymdNR7lkhA1qZKAluNXViy5br3AVUfvHboWy5ReYxabAzB9r8LnFFEIA1?= =?us-ascii?Q?o9CH+tKDnk+1ohEns4rKN4iSbAW7oKV9QtXt3FMBJBfLbMOsASzR1U6DonxB?= =?us-ascii?Q?Bn4wq0HsHT9D5AM44+Il4TG0/W1358BpV6WtaSy5JMHS2oM8RqP34+ZhJh3Z?= =?us-ascii?Q?gntySGJZh/j4Itwv691v89y/G40CXxm5OfhA571bzei3/UkJreJLSf+sq+SD?= =?us-ascii?Q?ZTkBquNTwoXnpItI96SfQyQF14RitiqcEiC4nh+CV+UqgF1Xm50iaBwdyhxJ?= =?us-ascii?Q?ncmE4tE2UHRyaV0YAZeZ+hAG8fp9vLnVPihJGSAjrENLKbeymFBTMAzM0o31?= =?us-ascii?Q?4eNaMIhOLCvi25poALifGn1U5gQQKL0ARkU1rsn77kQ/fFgPmTDNeJyq2NFO?= =?us-ascii?Q?KEB15OEWNJPQ3c792WypahHLfD97iCAMYAfaq5kTqmPju0dy7CID9TpgoN1q?= =?us-ascii?Q?PpFQm5/Wryq8jtS5geC+skpJUvuYx2WB8ntcDuCqk/j0yAVckEyoWiyoO0Ht?= =?us-ascii?Q?ZqHaMe8+M4W25jnEmtc3nAXDF0LLJ5R8UdGlKHNQpSCiosIRKoTH08XflgWi?= =?us-ascii?Q?vKu6wPI/+LxdDvZyLKfFY6iXrf7oB+K4hHktEy0sPb96TfgjPJ8B0+oJTupZ?= =?us-ascii?Q?f7wrkiU2gI37sZhbsonBqG2dIzWW5Ob2xd89CvfPjD/UnhIJdU156+w967HO?= =?us-ascii?Q?Aw+Z1FnGYZNOSruLQJm8o90txEH/ZjeTCLYyC2d8hImgIuAoNZUDhSl4h130?= =?us-ascii?Q?hK3MAY2qI7yOLFWA6awBHiRIAIvVn93EfqNZzworfNSOuNdHjdG9ZyymzsMx?= =?us-ascii?Q?+v61TSg+7HJXELORy+uxJSGwhBdf5SN+bk3DL3YFRcGMf9FlRMHfHSYUz0jg?= =?us-ascii?Q?zffJfJaBReNd56xUm5Ox0H9vlIJ0WzUfF+iWZykRULKF7R1JyAnefXzbTUok?= =?us-ascii?Q?+CSJyIDSuCCMIMyxTmD4gBtVhFvq3y0DezbwMPQ1kWS6K8zv6YrmfUP2J5Ta?= =?us-ascii?Q?3mMzoDvik/qaD07uX/ByZkJd5DAbQmsau+A1XEXPjJNebBdG+9FHcdvs0inu?= =?us-ascii?Q?jqsLT//6f0pPQuglIgV+wU8xZPkTYVDq3DtSbsbv5CaMoOUqIPnEJkRsaz5v?= =?us-ascii?Q?ucFFBWq8YXZNr1Z/k8Y0fj/tvvxJ1Es0ZDXkJAyxPhKsPUFHlbZBbEqYVFKE?= =?us-ascii?Q?iwykQp4fNsMk+bDs4NCsRf8BG/ysWH2hjty3Chh1cY2L4lmGW5OfpKiylv4i?= =?us-ascii?Q?hvYwPbWLUB+eGiqdBH9LVeyV?= 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: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 105db5c0-234e-42d6-7545-08d940a6702b X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jul 2021 17:49:43.8981 (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: 2hXq8tjtqMoVqmkAJoYiM+EDzttFNP3H2nl3Sji4Koc7vlzaJTeZrtLoQ5JcMwaFIIpEwgJUhhHhaeEs/fywDRvWCNXEUxlKn+DfB3WPBls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1753 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag 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 Sender: "dev" > Currently, if dev_configure is not called or fails to be called, users > can still call dev_start successfully. So it is necessary to have a flag > which indicates whether the device is configured, to control whether > dev_start can be called and eliminate dependency on user invocation order= . >=20 > The flag stored in "struct rte_eth_dev_data" is more reasonable than > "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the > primary and secondary processes, and can be independently controlled. > However, the secondary process does not make resource allocations and > does not call dev_configure(). These are done by the primary process > and can be obtained or used by the secondary process. So this patch > adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started". >=20 > Signed-off-by: Huisong Li > --- > v1 -> v2: > - adjusting the description of patch. >=20 > --- > lib/ethdev/rte_ethdev.c | 16 ++++++++++++++++ > lib/ethdev/rte_ethdev_core.h | 6 +++++- > 2 files changed, 21 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index c607eab..6540432 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t n= b_rx_q, uint16_t nb_tx_q, > return -EBUSY; > } >=20 > + /* > + * Ensure that "dev_configured" is always 0 each time prepare to do > + * dev_configure() to avoid any non-anticipated behaviour. > + * And set to 1 when dev_configure() is executed successfully. > + */ > + dev->data->dev_configured =3D 0; > + > /* Store original config, as rollback required on failure */ > memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf)); >=20 > @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb= _rx_q, uint16_t nb_tx_q, > } >=20 > rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0); > + dev->data->dev_configured =3D 1; > + > return 0; > reset_queues: > eth_dev_rx_queue_config(dev, 0); > @@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id) >=20 > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP); >=20 > + if (dev->data->dev_configured =3D=3D 0) { > + RTE_ETHDEV_LOG(INFO, > + "Device with port_id=3D%"PRIu16" is not configured.\n", > + port_id); > + return -EINVAL; > + } > + > if (dev->data->dev_started !=3D 0) { > RTE_ETHDEV_LOG(INFO, > "Device with port_id=3D%"PRIu16" already started\n", > diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h > index 4679d94..edf96de 100644 > --- a/lib/ethdev/rte_ethdev_core.h > +++ b/lib/ethdev/rte_ethdev_core.h > @@ -167,7 +167,11 @@ struct rte_eth_dev_data { > scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */ > all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */ > dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */ > - lro : 1; /**< RX LRO is ON(1) / OFF(0) */ > + lro : 1, /**< RX LRO is ON(1) / OFF(0) */ > + dev_configured : 1; > + /**< Indicates whether the device is configured. > + * CONFIGURED(1) / NOT CONFIGURED(0). > + */ > uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; > /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */ > uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT]; > -- Acked-by: Konstantin Ananyev > 2.7.4