From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0072.outbound.protection.outlook.com [104.47.2.72]) by dpdk.org (Postfix) with ESMTP id D60E72C55 for ; Tue, 14 Aug 2018 07:52:21 +0200 (CEST) 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=gPhbKpz0FfPzMUMKRLInrDY2UW1MZ2gZUH3oc+7ukXo=; b=nCnQ3vYEnAU91+2R/IKRardS1PM7dXFBE/EoY3NE4miKp4GVtxDOcJYaS+LC6mvvrRr/0zbokapkKIAMQGAOfVFDEVqWQhnS9JLnISaQsz3QxFe1ESgHQ9U2nGU8pPWUrvab1u6YLUAPOqJA+CsXoFyPVBdxkOCzx5yxrQlV29c= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.41.11) by AM0PR0502MB3811.eurprd05.prod.outlook.com (52.133.47.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.18; Tue, 14 Aug 2018 05:52:21 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::9d98:d47f:5b50:1f49]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::9d98:d47f:5b50:1f49%2]) with mapi id 15.20.1017.022; Tue, 14 Aug 2018 05:52:21 +0000 From: Matan Azrad To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset Thread-Index: AQHUM2R/ErHsTWQ+B0y/m9FWquxXq6S+vdUQ Date: Tue, 14 Aug 2018 05:52:20 +0000 Message-ID: References: <20180814001926.19630-1-stephen@networkplumber.org> In-Reply-To: <20180814001926.19630-1-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: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR0502MB3811; 6:UeAOiPG55AqiWCszbLCV90wOPkciRHRce4Jdp+qsnWUXv4NzN7SLvwYgS+jXrXMqgYsImNZK/2W4OW34YE6khzGqacjZRovq3nu9CMc75Z3qsv7Rr5l3PiRRkehczTCz0CJqhM4sjRSIvnA39F+aZ/eCobCMHCYsa0wIEhrraiDxwhCilp1SgASHBs1W9UNFHXFKGCw0Cums0uHwXD8UrOTel4OxsGL/te/+BRxc0Hz6dzJOrNU44hPIGN+Tn1MD/zVAfjooDa9hUwEDMXnFwh9quhGUgY0Q+NI8MpZyWpVepLlToI8l8jB0qABl5FbSSxgST++Luhfiqd2SkSaepMyhGDUgX6UyI33TGSYDW7qwxueF9imOcUVhbNSdrfqx9M5uNUFm77xDwR4eXe9J5FLtuESbiWiwRCUB/O31maX2Rukj1GwIabr0trDUCpeDA5L7MTM7L8Pn4FRZ6aZSXw==; 5:598RSFBqqxUPSnDBJ8X/L+c/ODjGspxqxxYefi65JzSRrdOxBSjXu97J9Rj6ogRkzsdkuU6LKyBSJICH0ehw2dLwrVvfqlo3VYDUCkbgG7+3+72wPrfsUgSkl8n2BFYUIu5b0mhiOaVKg1tTQNqR728Z5sYRMZQkV7CPM5yKnmE=; 7:Eas4tqqa1IoQsLSyrvjJa9nKRoEJdgv0DY5FfTkcRwG0jlUpSpMa6qaBZTaTU5HDzkhgWbyE+novD3c/u1Stj/QKt3rdH/VqUUYkx2RkJ7xyAGLpsQ9Nzi9nHDylcytd6WMJuLdG87pcIcJbGP5dlxdJEJw9N/hVeHDO9asrJ5KDrI9BN8tNmsCvn4gKPBrO2kkvNuWkqOrEefT47ObkPxYCx9N0Lvx6FTOtTIxnI1ULsmL0bZGw0SPJlfMV7NY5 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: b8753c0d-0926-4d33-4e57-08d601aa19e9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM0PR0502MB3811; x-ms-traffictypediagnostic: AM0PR0502MB3811: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(60795455431006); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM0PR0502MB3811; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0502MB3811; x-forefront-prvs: 0764C4A8CD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(376002)(39860400002)(346002)(366004)(199004)(189003)(76176011)(7696005)(33656002)(97736004)(5660300001)(7736002)(26005)(74316002)(2906002)(102836004)(256004)(186003)(8936002)(14444005)(6506007)(305945005)(14454004)(105586002)(106356001)(25786009)(66066001)(6246003)(99286004)(5250100002)(3846002)(478600001)(316002)(11346002)(6116002)(55016002)(110136005)(229853002)(68736007)(53936002)(9686003)(86362001)(476003)(486006)(446003)(81166006)(6436002)(8676002)(81156014)(2501003)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3811; H:AM0PR0502MB4019.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 65Jr93tgVsRI2k9lr/Dhwi9mmV2soVXjXai3iEZ+owRc70g+doPyeXHwn2jA3iWRVsyb8OHJAqY/U7yV8NYVk0XxV2jLtR7lwKZGSghfi49IiU82bbJz9XcljebKGUUp2qzro1NlDNANj3lXX9Gvx12TmhoOxNdvP0NMsybGWFnAHQI1oQ+dZkWSkyxwDK2ZM9yXgDNj1M5veBEy7chrTqOdA+eX1bbvtQYW/TuNoSBtyJ17Q0S7X+PFmyCbdI/owcPNBJ5iJK/L0Qxx7u8mWn/eB0f0IWb1h2gRHEmsith+Viqwndx8uKrsGW4Dk9aM70MpcJinU9Dr+RLrWwMw3ykJ3ZRMjvzK7oP7mjo/g2I= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: b8753c0d-0926-4d33-4e57-08d601aa19e9 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Aug 2018 05:52:20.9471 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3811 Subject: Re: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset 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: , X-List-Received-Date: Tue, 14 Aug 2018 05:52:22 -0000 Hi Stephen From: Stephen Hemminger > The rte_eth_dev_owner_unset function is unusable because it always > returns -EINVAL. This is because the magic (unowned) value is flagged as = not > valid. >=20 It's OK to raise an error when you do unset for unowned device. It means that unset owner should be called for owned device. > Move the validation of owner into set and unset as separate calls. >=20 > Fixes: 5b7ba31148a8 ("ethdev: add port ownership") > Signed-off-by: Stephen Hemminger > --- > lib/librte_ethdev/rte_ethdev.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 4c320250589a..9398550a1189 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -443,10 +443,6 @@ _rte_eth_dev_owner_set(const uint16_t port_id, > const uint64_t old_owner_id, > return -ENODEV; > } >=20 > - if (!rte_eth_is_valid_owner_id(new_owner->id) && > - !rte_eth_is_valid_owner_id(old_owner_id)) > - return -EINVAL; > - > port_owner =3D &rte_eth_devices[port_id].data->owner; > if (port_owner->id !=3D old_owner_id) { > RTE_ETHDEV_LOG(ERR, > @@ -475,6 +471,9 @@ rte_eth_dev_owner_set(const uint16_t port_id, { > int ret; >=20 > + if (!rte_eth_is_valid_owner_id(owner->id)) > + return -EINVAL; > + > rte_eth_dev_shared_data_prepare(); >=20 > rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); > @@ -492,6 +491,9 @@ rte_eth_dev_owner_unset(const uint16_t port_id, > const uint64_t owner_id) > {.id =3D RTE_ETH_DEV_NO_OWNER, .name =3D ""}; > int ret; >=20 > + if (!rte_eth_is_valid_owner_id(owner_id)) > + return -EINVAL; > + > rte_eth_dev_shared_data_prepare(); >=20 > rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); > -- > 2.18.0