From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0040.outbound.protection.outlook.com [104.47.0.40]) by dpdk.org (Postfix) with ESMTP id B2A797CD9 for ; Thu, 27 Sep 2018 10:24:46 +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=jILbDzO/36l7caDplfFEKAbiby5KIO5xkooheTrqoIM=; b=JEhCOzOtBgbqaX9EnWUy4YWVODWVLQ00tVJYxByfh1KuIM2XEKtF0A2ZX5738L0QG0S1SRjnJO6M7j1gbfvOLjJB/8P57lmgC0Bb5nSj67rbPrmPS47wk6dT5WCfj6CpHUUEgt1hKezm+1TPgO2yw+H++Z07cVgVPDDDvNcvdRg= Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com (52.134.8.154) by VI1PR0502MB2974.eurprd05.prod.outlook.com (10.175.21.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Thu, 27 Sep 2018 08:24:44 +0000 Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::c143:7ef1:6d6f:7aa2]) by VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::c143:7ef1:6d6f:7aa2%2]) with mapi id 15.20.1164.024; Thu, 27 Sep 2018 08:24:44 +0000 From: Ophir Munk To: Thomas Monjalon , "dev@dpdk.org" CC: "gaetan.rivet@6wind.com" , "qi.z.zhang@intel.com" , "ferruh.yigit@intel.com" , "ktraynor@redhat.com" , Shahaf Shuler , Olga Shern Thread-Topic: [PATCH v2 2/4] devargs: simplify parameters of removal function Thread-Index: AQHUVeKhCEWZPMlKgE2VkNQKObaDOKUDyZ+g Date: Thu, 27 Sep 2018 08:24:44 +0000 Message-ID: References: <20180907222727.20521-1-thomas@monjalon.net> <20180926214759.1856-1-thomas@monjalon.net> <20180926214759.1856-3-thomas@monjalon.net> In-Reply-To: <20180926214759.1856-3-thomas@monjalon.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0502MB2974; 6:bCfGhJO9g8Aq9tDGAA/csX/WaPVedrdpg9MRxYJLxpPHMgzw68AHpQ2YV9NSJwz1AjhqPFS76ilmd92O/g8SyfRoRozKxzNUFd5ByCPnr2NFeBO7fWz66mNhFx449NbZYD2/7whYnLZER5uvJyYC2CGDWE6Q6DwpQmZtUBoxDmNqJtPt9tWOl0NG39+bHyYm8PQk90q3MkKvtrZbylJpw7BdrjWem7tNX7UiwgtZsQCZKZGGYU8obXpXTS7zoRBHTLsU5E4kWwQp4LYf3tY6iULsALAJgP0QbXl+7eqo1Ae/e3QxB6IhoB14cL1vjwT464yL2NZ4aCZLZ5ewP4vGkBdDa2Vm2jKVD9b1ALSpyPvCtMBEhXeRAYmW8EBXFkJwbh0kPAi4PrBiY9et5NSx4lAR38wvZSLGcXuSFr0moij+z8/F63tjPNaKVMyM7u5kf4BOwt2g1o0fYlLalPq9fw==; 5:fDDWX8fylgXU4I4e2jIw5M2M2Y1BwhlggQGjnaW2eVw3QTCDEmaG7KbgMCwzWXf1E8En20iWgbqr98bDfR2Zr89s1oiT8bEmVpBSH17MN0m7pjmOPIs3h2XcgtJAS6HxpnqGTB54inpZCSZY58bBKSXr4TTff5Qh7hX0bcQPk+s=; 7:Stp6AIiY3zaiFJ4a723f++8oPaOAs7Ix+KttfgN8OF7pz7cmEbsFZygb3a/89cvxfbNz5AYnY44AapSguZ15tF6HFT9XLNoyVCMIREE0gbsCFjgJbNg5dGLKf5d34RLv4cM99e+0FKZNlv6l2b6bvwAeLk0XfQkTX5+NvWcuJnf5uxPC6xHrSVlEOmB80k1Z80qsaa1zs3Ls2DudNANURUl63/Id4Fl+r81fbbTdnJma6KcQN8LjnbS8sC7UwgUS x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 3e3dd86b-d462-4642-a9f7-08d62452ae1b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0502MB2974; x-ms-traffictypediagnostic: VI1PR0502MB2974: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051); SRVR:VI1PR0502MB2974; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB2974; x-forefront-prvs: 0808323E97 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(136003)(366004)(39860400002)(13464003)(189003)(199004)(2501003)(5250100002)(5660300001)(71200400001)(106356001)(105586002)(486006)(71190400001)(97736004)(229853002)(9686003)(55016002)(53936002)(66066001)(81166006)(2900100001)(81156014)(8936002)(8676002)(86362001)(6436002)(14454004)(33656002)(76176011)(2906002)(102836004)(54906003)(3846002)(6116002)(14444005)(256004)(478600001)(68736007)(110136005)(26005)(186003)(476003)(74316002)(11346002)(446003)(107886003)(316002)(99286004)(6246003)(7696005)(7736002)(25786009)(305945005)(6506007)(53546011)(34290500001)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB2974; H:VI1PR0502MB3743.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: MfDjVfEtseTqz7L8v5EYgu57+oTWT8aqOYJseexx31HpXpmNHAssxfBdvazgr+Jnu6sg8V7c4wpBOMA3r5H/lj+WLH1l6bfMp4nrNtdkJ+Wrb14h+AqAIRrak38Aq/1OHAjKxKq8sNGcqqDl+06mNXHSpQ5+EnhudGZjFYchTruj2Pfh5L2W3G4kkaCkaPs1vvOuqka6WBQFnHs8eBPk4awGkdAEx3Vfu1dIgHA793Q50Jy5wsrAtIFBEHWeTkJV5p7vT4SdHYh54L9iSnUy3gcgtI+H6SgSGpc5KhmY26zNgXfE6xFERO6QWGAJWZF8s+szZjAjDIoPKZR6MoGcJGqb7+hrumt3DChD1wmazF0= 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: 3e3dd86b-d462-4642-a9f7-08d62452ae1b X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2018 08:24:44.5064 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB2974 Subject: Re: [dpdk-dev] [PATCH v2 2/4] devargs: simplify parameters of removal function 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: Thu, 27 Sep 2018 08:24:47 -0000 > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Thursday, September 27, 2018 12:48 AM > To: dev@dpdk.org > Cc: gaetan.rivet@6wind.com; Ophir Munk ; > qi.z.zhang@intel.com; ferruh.yigit@intel.com; ktraynor@redhat.com > Subject: [PATCH v2 2/4] devargs: simplify parameters of removal function >=20 > The function rte_devargs_remove(), which is intended to be internal, can > take a devargs structure as argument. > The matching is still using string comparison of bus name and device name= . > It is simpler and may allow a different devargs matching in future. >=20 > Signed-off-by: Thomas Monjalon > --- > drivers/bus/ifpga/ifpga_bus.c | 5 +---- > drivers/bus/vdev/vdev.c | 8 ++------ > lib/librte_eal/common/eal_common_dev.c | 4 ++-- > lib/librte_eal/common/eal_common_devargs.c | 8 ++++---- > lib/librte_eal/common/include/rte_devargs.h | 10 +++------- > 5 files changed, 12 insertions(+), 23 deletions(-) >=20 > diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.= c > index b324872ee..0e17ea9a3 100644 > --- a/drivers/bus/ifpga/ifpga_bus.c > +++ b/drivers/bus/ifpga/ifpga_bus.c > @@ -363,7 +363,6 @@ static int > ifpga_unplug(struct rte_device *dev) > { > struct rte_afu_device *afu_dev =3D NULL; > - struct rte_devargs *devargs =3D NULL; > int ret; >=20 > if (dev =3D=3D NULL) > @@ -373,15 +372,13 @@ ifpga_unplug(struct rte_device *dev) > if (!afu_dev) > return -ENOENT; >=20 > - devargs =3D dev->devargs; > - > ret =3D ifpga_remove_driver(afu_dev); > if (ret) > return ret; >=20 > TAILQ_REMOVE(&ifpga_afu_dev_list, afu_dev, next); >=20 > - rte_devargs_remove(devargs->bus->name, devargs->name); > + rte_devargs_remove(dev->devargs); > free(afu_dev); > return 0; >=20 > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index > 69dee89a8..390c2ce70 100644 > --- a/drivers/bus/vdev/vdev.c > +++ b/drivers/bus/vdev/vdev.c > @@ -248,7 +248,6 @@ int > rte_vdev_init(const char *name, const char *args) { > struct rte_vdev_device *dev; > - struct rte_devargs *devargs; > int ret; >=20 > rte_spinlock_recursive_lock(&vdev_device_list_lock); > @@ -259,9 +258,8 @@ rte_vdev_init(const char *name, const char *args) > if (ret > 0) > VDEV_LOG(ERR, "no driver found for %s", > name); > /* If fails, remove it from vdev list */ > - devargs =3D dev->device.devargs; > TAILQ_REMOVE(&vdev_device_list, dev, next); > - rte_devargs_remove(devargs->bus->name, devargs- > >name); > + rte_devargs_remove(dev->device.devargs); > free(dev); > } > } > @@ -289,7 +287,6 @@ int > rte_vdev_uninit(const char *name) > { > struct rte_vdev_device *dev; > - struct rte_devargs *devargs; > int ret; >=20 > if (name =3D=3D NULL) > @@ -308,8 +305,7 @@ rte_vdev_uninit(const char *name) > goto unlock; >=20 > TAILQ_REMOVE(&vdev_device_list, dev, next); > - devargs =3D dev->device.devargs; > - rte_devargs_remove(devargs->bus->name, devargs->name); > + rte_devargs_remove(dev->device.devargs); > free(dev); >=20 > unlock: > diff --git a/lib/librte_eal/common/eal_common_dev.c > b/lib/librte_eal/common/eal_common_dev.c > index 678dbcac7..e81ff4258 100644 > --- a/lib/librte_eal/common/eal_common_dev.c > +++ b/lib/librte_eal/common/eal_common_dev.c > @@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const > char *busname, const char *devn > return 0; >=20 > err_devarg: > - if (rte_devargs_remove(busname, devname)) { > + if (rte_devargs_remove(da)) { Can you please explain why calling with 'da' parameter (which may have diff= erent internal fields of busname and devname than the explicit busname and = devname parameters) - is correct? > free(da->args); > free(da); > } > @@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, > const char *devname) > if (ret) > RTE_LOG(ERR, EAL, "Driver cannot detach the device > (%s)\n", > dev->name); > - rte_devargs_remove(busname, devname); > + rte_devargs_remove(dev->devargs); Can you please explain why calling with 'dev->devargs' parameter (which may= have different internal fields of busname and devname than the explicit bu= sname and devname parameters) - is correct? > return ret; > } >=20 > diff --git a/lib/librte_eal/common/eal_common_devargs.c > b/lib/librte_eal/common/eal_common_devargs.c > index f63d2c663..2f2bb4d90 100644 > --- a/lib/librte_eal/common/eal_common_devargs.c > +++ b/lib/librte_eal/common/eal_common_devargs.c > @@ -266,7 +266,7 @@ rte_devargs_insert(struct rte_devargs *da) { > int ret; >=20 > - ret =3D rte_devargs_remove(da->bus->name, da->name); > + ret =3D rte_devargs_remove(da); > if (ret < 0) > return ret; > TAILQ_INSERT_TAIL(&devargs_list, da, next); @@ -312,14 +312,14 > @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } >=20 > int __rte_experimental > -rte_devargs_remove(const char *busname, const char *devname) > +rte_devargs_remove(struct rte_devargs *devargs) > { > struct rte_devargs *d; > void *tmp; >=20 > TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { > - if (strcmp(d->bus->name, busname) =3D=3D 0 && > - strcmp(d->name, devname) =3D=3D 0) { > + if (strcmp(d->bus->name, devargs->bus->name) =3D=3D 0 && > + strcmp(d->name, devargs->name) =3D=3D 0) { > TAILQ_REMOVE(&devargs_list, d, next); > free(d->args); > free(d); > diff --git a/lib/librte_eal/common/include/rte_devargs.h > b/lib/librte_eal/common/include/rte_devargs.h > index 0eef6e9c4..b1f121f83 100644 > --- a/lib/librte_eal/common/include/rte_devargs.h > +++ b/lib/librte_eal/common/include/rte_devargs.h > @@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, > const char *devargs_str); > * Its resources are freed. > * If the devargs cannot be found, nothing happens. > * > - * @param busname > - * bus name of the devargs to remove. > - * > - * @param devname > - * device name of the devargs to remove. > + * @param devargs > + * The instance or a copy of devargs to remove. > * > * @return > * 0 on success. > @@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, > const char *devargs_str); > * >0 if the devargs was not within the user device list. > */ > __rte_experimental > -int rte_devargs_remove(const char *busname, > - const char *devname); > +int rte_devargs_remove(struct rte_devargs *devargs); >=20 > /** > * Count the number of user devices of a specified type > -- > 2.19.0