From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88138A0564; Sun, 15 Mar 2020 08:45:17 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C0551BF95; Sun, 15 Mar 2020 08:45:16 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150081.outbound.protection.outlook.com [40.107.15.81]) by dpdk.org (Postfix) with ESMTP id DC2511AFF; Sun, 15 Mar 2020 08:45:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRU5xOiCM+wMhEbuazBU+maMEgyJN0G2nzrT2YK6WQhV4h7gM9SVA1fk9C7Xv237C/b7zPnG3rPjjGes7jpfy/56CUi/H+uX+dcoHmxhRXmP9me2zIYvXDngkpNmZb2oIU8vZrS6cXWpSgx3xtXARfKEuLxmpFZo5bhRGlaUFdh7CRVLRvYFvqVCHyrFFTNDoHIoKbipuFSK0j3khWJNc7by7GA6Ry0zWIKFNJ0aMBVJPy6wxzjTS/9UqIHA3zMvYQtMmLwMyvVxX1AxPOZx13mOBkp+nt2GKJV1r7zSlX2aC+sWcfzXjsgviolTGahvD+VvvJwxvFvD2D3vLxS2ww== 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=iQwYRDqNaQri1wXQ+RpfNkqSztjuEwagK3PeTSCS0vc=; b=nxLWumw0O255gTmZTLKmuAAhuj/ehUsclpim0o1+02VjBar9AraFThKTd9kCoz3/dZy8cgpTQbPWDjufupNd1C15xVN2s56xoIvmgxAh6OfDiE6XcsgjLBb1VFzrcPR6bfl81ZUjqSaf88Ed5ztHp5vem8CzM0WW4TtDynsl0NNptz7SHNxezmz+8pbcbPf6RecIYNP8JsW+974CREG1oAWGzCJym6dlWq/qu2zXdgApd6zV0Ym/DFdfqDecyjo5YZLEdKeDkjjTxfOySwRjBzlklt5SYHyNxsglh8MbqeW4K4LbzEy/QVJiU+PpwTdpuwJGIIF+6YuxOwuCjsZo0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iQwYRDqNaQri1wXQ+RpfNkqSztjuEwagK3PeTSCS0vc=; b=Sd8MwIbIkbc/sEIGn2M+4xuRtMHA2fYC8Q3YO/DbamidpiSxn+eUJmhaVMRZbsphNqy3a2uSgJ2PqD1KXb9nlzCfNhANDhAFXyX+DmT6B6fMr67ZzsToEwrcR9VKFTNPDDZFIexpLti5QEXYpgak/MXgLDhBpUThoPIc91bF55g= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB3875.eurprd05.prod.outlook.com (52.133.45.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.18; Sun, 15 Mar 2020 07:45:12 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::a564:a117:9022:1fee]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::a564:a117:9022:1fee%7]) with mapi id 15.20.2814.019; Sun, 15 Mar 2020 07:45:12 +0000 From: Matan Azrad To: Stephen Hemminger , "dev@dpdk.org" CC: "stable@dpdk.org" Thread-Topic: [PATCH 1/7] ethdev: add function to test port ownership Thread-Index: AQHV+JKYkQViMnwdNE+574nse9ln3KhJSYIw Date: Sun, 15 Mar 2020 07:45:12 +0000 Message-ID: References: <20200312172047.19973-1-stephen@networkplumber.org> <20200312172047.19973-2-stephen@networkplumber.org> In-Reply-To: <20200312172047.19973-2-stephen@networkplumber.org> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [77.125.85.240] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d10bdd6f-c000-4b15-1d52-08d7c8b4cb20 x-ms-traffictypediagnostic: AM0PR0502MB3875: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0343AC1D30 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(396003)(376002)(136003)(346002)(366004)(199004)(8936002)(7696005)(8676002)(316002)(4326008)(81156014)(81166006)(110136005)(6506007)(52536014)(478600001)(33656002)(55016002)(5660300002)(2906002)(9686003)(76116006)(66556008)(186003)(26005)(66946007)(66476007)(64756008)(86362001)(71200400001)(66446008); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3875; H:AM0PR0502MB4019.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gYkclyo72O/3AjjYgCOo6uZrNv6l+kl0ksi09T/AAUMrg4oRyUoQ42rM04McI6y3wLBI2SLEnnWi65ZfWJhcN5+VLLzEIGKgyVvYEWaYjuZEU1HntpOi5W3BDcIC3Z9K78Pi6crJIFUeJRZF1ekZ+uWm5Ms4l0CYQw9JKGvqaxlrN0oxjtxiPjL8fUOj4HcoMuYW28QzCVBiN3oXu7g7olXdzI/ZgM9DstT8DInClg5brKnvbKh4RK5SAjDXzHK0F314g1s5j5+hZeVUK+J+1swLmXmSZt6TKEaxDXRuAzwfMEd7aJcB8Xl5dDJImNrNqfLpZe2MG9OyajUafEM1vv30YH0UKFwKWwPfvKxauhaYca/47+zeBiwzGhG07JtOiv2WPrcSyKxaqjZmGB+SfUmNHvVzAb0V7ISqcPPEmh1XL6TI3HvZgcvvpjlu+uNV x-ms-exchange-antispam-messagedata: srniRVt8/APMfFEFhxayW2sK0oNpPzeXgE9tNrlqIczj8O67Rhad48LxK/SUvtQ2UmD2Nl6U/DZOvPWQMm0PdVGMs1Aa7CwkHbR/emK1AKb+qIIAsDgi9eW9J9ysEbr7JwANdw0iInOH02cTrkihTA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d10bdd6f-c000-4b15-1d52-08d7c8b4cb20 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2020 07:45:12.2942 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8YHGivaivx9SRhsHL46HVTXB0oX4cNv3Ws2CIHXvhEis4Jr+lIAc9U9jgXtHYlJrniJccNWm2C3iEr7IjPCPyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3875 Subject: Re: [dpdk-dev] [PATCH 1/7] ethdev: add function to test port ownership X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Hi Stephen From: Stephen Hemminger > Applications using a port mask need a method to be able to test for (and > reject) ethdev ports that are in use for other purposes. >=20 There is already function which is thread safe to get this information: rte_eth_dev_owner_get. I don't think we need one more. > Fixes: 5b7ba31148a8 ("ethdev: add port ownership") > Cc: matan@mellanox.com > Cc: stable@dpdk.org > Signed-off-by: Stephen Hemminger > --- > lib/librte_ethdev/rte_ethdev.c | 9 +++++++++ > lib/librte_ethdev/rte_ethdev.h | 15 +++++++++++++++ > lib/librte_ethdev/rte_ethdev_version.map | 3 +++ > 3 files changed, 27 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 774c721b3484..38f99f417dba 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -685,6 +685,15 @@ rte_eth_dev_owner_unset(const uint16_t port_id, > const uint64_t owner_id) > return ret; > } >=20 > +int > +rte_eth_dev_is_owned_by(uint16_t port_id, uint64_t owner_id) { > + if (!rte_eth_dev_is_valid_port(port_id)) > + return 0; > + > + return rte_eth_devices[port_id].data->owner.id =3D=3D owner_id; } > + > int > rte_eth_dev_owner_delete(const uint64_t owner_id) { diff --git > a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index > d1a593ad112a..91a8f9578282 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -1530,6 +1530,21 @@ uint64_t rte_eth_find_next_owned_by(uint16_t > port_id, > (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \ > p =3D rte_eth_find_next_owned_by(p + 1, o)) >=20 > +/** > + * Test if a port is owned > + * > + * @param port_id > + * The port identifier of the Ethernet device > + * @param owner_id > + * The owner identifier. > + * RTE_ETH_DEV_NO_OWNER means test if port is not owned. > + * @return > + * - 0 if port is out of range or not owned by owner_id > + * - 1 if device is associated with owner_id > + */ > +__rte_experimental > +int rte_eth_dev_is_owned_by(uint16_t port_id, uint64_t owner_id); > + > /** > * Iterates over valid ethdev ports. > * > diff --git a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index 3f32fdecf722..95231fe3410c 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -230,4 +230,7 @@ EXPERIMENTAL { >=20 > # added in 20.02 > rte_flow_dev_dump; > + > + # added in 20.05 > + rte_eth_dev_is_owned_by; > }; > -- > 2.20.1