From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70045.outbound.protection.outlook.com [40.107.7.45]) by dpdk.org (Postfix) with ESMTP id 553A54CBD for ; Tue, 14 Aug 2018 21:46:15 +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=Q5FWZDj3nUsBXgCq5M+nClChQuYpkAfrVcsW/3WwrxA=; b=xj+QmdlGj/gD8hPENeJw9UvjSDJliC4ULcNMhG7qf/pst5KR58Psv1UqvuhvX3L+js5Ld3ghM+YFrcCOU4WRfxKvfzorQAaq/r9me1YtAIb4lWRRxHlU0u2PauJQuYIz6tearankInBYKwyO4X1NGN1YWBaAFKrpGFqXY2Yj8sI= Received: from DB3PR0502MB4028.eurprd05.prod.outlook.com (52.134.72.145) by DB3PR0502MB3994.eurprd05.prod.outlook.com (52.134.72.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.25; Tue, 14 Aug 2018 19:46:13 +0000 Received: from DB3PR0502MB4028.eurprd05.prod.outlook.com ([fe80::2552:6f91:4d84:b7db]) by DB3PR0502MB4028.eurprd05.prod.outlook.com ([fe80::2552:6f91:4d84:b7db%3]) with mapi id 15.20.1038.025; Tue, 14 Aug 2018 19:46:13 +0000 From: Matan Azrad To: Stephen Hemminger CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset Thread-Index: AQHUM2R/ErHsTWQ+B0y/m9FWquxXq6S+vdUQgAC6joCAAC1P4A== Date: Tue, 14 Aug 2018 19:46:13 +0000 Message-ID: References: <20180814001926.19630-1-stephen@networkplumber.org> <20180814095521.492e575a@xeon-e3> In-Reply-To: <20180814095521.492e575a@xeon-e3> 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: [85.64.136.190] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3994; 6:ZMP6PzJvr3/FbBf9FEoGItksuthW77vHar4ZnncUfrwC+zvW2nF5+MJw29tc1NSAlA20yDH/pgXaJYMIIDy7pe8/L+XWeuqL2refu3YNAIqWYVcPKKSU+WL4X5E0LXhVFv0reULs0gLZpfL/2SYAKKmdwmODWlJqb7gtSkSSKy+IJOCjE3dI53OFdqqFLIAdVkbYRYHXa2T5hqqXSf0yHeB0ddclyfgoQW2U3pGH6ZqcHwpt1ypLN4zFobTt5Guaa9N04PHzyR8FCnt5o12tk+LuvXti48N+d9qp3M00ZtGEQRhLTt/zYbylBexyeitlw3wBSrdPf9vpqeNVkXyqQjvNN3PIrwLeXghKD2LsIJdHUlf7JxneDYWq02ZZ1JQVhOdC5aXmq/j+CGUlDKCB+3ST+6DdDaBIK7D6sEWz3bXfTgO3J4WDoE7q92ivp4X9n1IvP35kagaDY4iZJ7qNuQ==; 5:lRzeSkfOWUc/vLM6ifF1prmlVVn9gzhJQGkZ4z/tiie0KcJf1ckWMF0w6eu/T90t8gx1Yc33aieBgDSCazzaTEDkuMdZ3oEFmMIuXw8r0l+3jRh1T4hIoR2cHpiPfVsFU23SfIuSys3EdeQ4Kpv7MUAD2vVZ0iOZZ83F5qmATQU=; 7:sKCW6wTE6Vdwtzp5dcDJ6bm09pVbExXIF+o83YAc5i/YlYuGcR1qDiAnIH13El2iNXENMGJUjrSaSZESzjKHhRwr+cV6GiFZP2gpHMdI1WZxVOKKlkiunQghhUgHrjFOhXHZD2u8Q7wRqU21AOJpHUsh/uwHCSx54mHQRgvg0Kx3xj2N8vkz2tCT0I5Uwb6kFADK287weLu0WUsiTtbLBsZg0myerkKsZ4UEge0DYxeu7uZC365mBl/hHyJP3R0K x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: d6e53566-6cd5-479c-64ee-08d6021e97cd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3994; x-ms-traffictypediagnostic: DB3PR0502MB3994: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DB3PR0502MB3994; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3994; x-forefront-prvs: 0764C4A8CD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(316002)(6436002)(68736007)(105586002)(229853002)(81156014)(81166006)(8676002)(486006)(86362001)(106356001)(11346002)(9686003)(99286004)(53936002)(476003)(76176011)(33656002)(8936002)(55016002)(446003)(256004)(7696005)(186003)(102836004)(6246003)(97736004)(2900100001)(7736002)(5250100002)(26005)(6116002)(3846002)(66066001)(25786009)(14454004)(305945005)(4326008)(478600001)(6506007)(6916009)(2906002)(5660300001)(74316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3994; H:DB3PR0502MB4028.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: k6pN/fI3RPeIda6hINOEGX0u7US1PaOHhstVSH59mcx9TX99Jua0rMmz+LC3R3pfkwsNRQP3RKUzp9RmPxt3gbE8Y6uG8GFf7bjrVlX5jMeHBjjS0o2uSDz2OPFb8AbCNBK2iwbFLU9cbj3r/b+RaKVdesyEKUIeJ6ms0jvwJAmwEacvO65pKKZe6xz2KA5ETSaMiX3rkNGk1iMi9blAKBNaGGDNJXF7xhNSktMbtlLYpRneA0qDOnay2uVWLUKf6hHos4b8VRAUFd6MghYhNlzO1AFJrzLx1MIpfu65SCj3to95vbmXqMq+9pgaF9PTuW2+EsmhA7OIx+ged8VPER/ppImPZ3LXervp84+ekEo= 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: d6e53566-6cd5-479c-64ee-08d6021e97cd X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Aug 2018 19:46:13.8129 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3994 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 19:46:16 -0000 Hi Stephen From: Stephen Hemminger > On Tue, 14 Aug 2018 05:52:20 +0000 > Matan Azrad wrote: >=20 > > 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. > > > > > > > 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. > > >=20 > Original code was broken. The following would always fail. >=20 > rte_eth_dev_owner_new(&owner.id); > sprintf(owner.name, "example"); > rte_eth_dev_owner_set(port_id, &owner); > rte_eth_dev_owner_unset(port_id, owner.id); >=20 > That is because of: > rte_eth_dev_owner_unset(port_id, owner_id) > _rte_eth_dev_owner_set(port_id, owner_id, &new_owner) > << new_owner.id =3D=3D RTE_ETH_DEV_NO_OWNER (0) >=20 >=20 > if (!rte_eth_is_valid_owner_id(new_owner->id) && << > new_owner->id =3D=3D RTE_ETH_DEV_NO_OWNER (which is flagged as invalid) > !rte_eth_is_valid_owner_id(old_owner_id)) > return -EINVAL; >=20 But both should be invalid the new owner and the old owner(&&) to raise an = EINVAL error. In the aforementioned check above the old owner should be valid. > The failsafe driver never checks the return value, and therefore doesn't = see > that it never clears ownership.