From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0064.outbound.protection.outlook.com [104.47.33.64]) by dpdk.org (Postfix) with ESMTP id 53FB84A65 for ; Fri, 15 Jul 2016 11:39:25 +0200 (CEST) Received: from BY2PR03CA074.namprd03.prod.outlook.com (10.141.249.47) by SN2PR03MB2414.namprd03.prod.outlook.com (10.166.211.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Fri, 15 Jul 2016 09:39:24 +0000 Received: from BY2FFO11FD010.protection.gbl (2a01:111:f400:7c0c::114) by BY2PR03CA074.outlook.office365.com (2a01:111:e400:2c5d::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Fri, 15 Jul 2016 09:39:24 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; rehivetech.com; dkim=none (message not signed) header.d=none;rehivetech.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD010.mail.protection.outlook.com (10.1.14.74) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Fri, 15 Jul 2016 09:39:23 +0000 Received: from [10.232.14.199] (Tophie.ap.freescale.net [10.232.14.199]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u6F9dKKb027269; Fri, 15 Jul 2016 02:39:21 -0700 To: Jan Viktorin References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-13-git-send-email-shreyansh.jain@nxp.com> <20160714185546.6e483b40@jvn> CC: , , From: Shreyansh jain Message-ID: <5788AF6E.9080203@nxp.com> Date: Fri, 15 Jul 2016 15:09:58 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20160714185546.6e483b40@jvn> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-Matching-Connectors: 131130491638425857; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(377454003)(24454002)(199003)(189002)(2906002)(80316001)(93886004)(11100500001)(4326007)(586003)(19580405001)(19580395003)(356003)(65956001)(105606002)(110136002)(68736007)(92566002)(47776003)(230700001)(104016004)(86362001)(85426001)(50986999)(189998001)(64126003)(36756003)(8676002)(54356999)(4001350100001)(83506001)(97736004)(65816999)(76176999)(81156014)(81166006)(87266999)(65806001)(7846002)(59896002)(23746002)(77096005)(87936001)(6806005)(305945005)(2950100001)(106466001)(33656002)(50466002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2414; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD010; 1:sj11Js6HQCbM6F6bWoPZuuAwcUPh7OaVeQsIFXet/cbSDqcko3QMTAb71GoUs4Fdjh+9KPlMea58EmOnXdbIsM27gO0XKK+++9zvXYdffhAIrCEF9pw1xQGgp6E2jTmuvM8F1Lcpy+BBrnlRQjreSX1PuOD4wcMYfayfTOtrhPucCkArmYsXFZJqEQSZFoC6XJRMzNv1vhO1SH0vdBRqj/5SEY3Oj+2w4kwItTBXrhaYbkbOKbseAb6T3cTacJZZpw3t8w+/u6ugo52g66Bw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NH7DU0khYcV9jpUKtBw+9SojbhKYUrb7WAV5AgDcz6xg9tRdXi3eZl2pZVADVQhbcVkRcwaGJiMrJXRfbETwSHuulyBCPej+9bbx6Wo6jGP318N4TV5kSOIHXRr5+ewwEK7jZspBzJ186YndY7uRLcj4HuMUesaSmGQjH8gDWf3P8viMXBb4vCJzzrqqdNIfi5KqdMxgE3UI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB2414; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2414; 31:/gRzY6Nj9zXVTlFfMb/GxbDlYVQqVQnqmr7reHOqgPBGLshF2t3p7h7tCmK1EIcFemvC1m1VgKyqDiOhA4WEd4Tphl3OetKvKOEUzlTO8t1IQdiquIdPkI89KyBi534AzU7b1jT9d0ziCX79gGEgzkCg7BIhL0EAylFPQOIJFlCHD2Su969V97qC8IZfI5chqGF3rlTin4g3DLmTHRVm8w==; 4:OPc6OgupjlYCjOxRmnkkn1NIhsZvXsUt7z5trogvIRK2309ei8shuH2MLifG2znBGe+6ZlPlPBlbW9wurspRgKYgmX8GvfRWeEqSVntzYBwNwnbC4zPW0Mg0PQDRIpAYp3yDaqXqkmBLGZTbfgACfCjKu37XYVrlLFglgAgjmb98AOMCrBjnZhKV3rShbImkUyYe8spZnTFt67iLbWfsOX3NEwTIORQyuYiX+qGcYxNQLYM2KK+n8mUDPDCktEYvdd7hWzX/UU18dcOhX+45OqaoXR5JmSRgkY4L+zUKRWpxMpyooXAy/wJ0+wfP+5O8pXobWit0aiVu2psVoyTHAbQaIm38+LhlKEtfQQOwj2SDZy1jbeGkwUpxX5NK2AppqdLMbuTxiFrfBsaiAcv9yaWVnCEeUbhtJazW8FRRh4QWpwXhfn0OVhMY0U4tgBYpCywHRz08mY0Hb3kdHsgbU3W4p2TpxboDTqcppDmqByjVf6vQEx3nsdPwutNMT3w/M5sd15Sws0Y5lvTOJHrNdg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(8121501046)(5005006)(13023025)(13018025)(13024025)(13017025)(3002001)(10201501046)(6055026); SRVR:SN2PR03MB2414; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB2414; X-Forefront-PRVS: 00046D390F X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; SN2PR03MB2414; 23:0ZQGCWsBL49ocChRvwN5IyJLlpfvlMJW5wVFp?= =?Windows-1252?Q?Hvw7zNZuF0dTIimGHwnviXd5VSgvrQ6OiHPDypCWY5LVvmO7tfKb+kiv?= =?Windows-1252?Q?MSMZ4VhF4ZO2HkfX0AkGBvnDVLufhzQy7JiX2lqRdz5qPhz6Rl/u6eEU?= =?Windows-1252?Q?CuJEMjs5j5dvXhRXYtgXl2TFdvpF5h0ahmN8Op/mYpEP8kLwx/Yt5D1o?= =?Windows-1252?Q?S91zHu5/2uf/S+xPlhdH/Xz8hAlNRfehMlWrS3Tf0oXCBm53mrK1C6dm?= =?Windows-1252?Q?kKDiWNaP6ylLrckh7ehn/VHbrGY4KTXOKjVh9VnNmPZAcCFAYTZiY71b?= =?Windows-1252?Q?lUuLKNRQQjdcMEV7vWo1g+yhUv7gBMu7RSlQUpU7ARWLHfP6mjgb4Bch?= =?Windows-1252?Q?O8CmWqEzolwTgxzJcrg+/YhpipqfWTz59WXf75E4qFi+Go+BLlrWc8uZ?= =?Windows-1252?Q?efcuw2+ykbJX7hJTbxf3eer3qGEmkKPR5qUy3dUrmwPTg06JpWhtw7GX?= =?Windows-1252?Q?jGIFoQGsg6HjRxSKoNZLrbI6UC7Eweg/p7DVM6ObnZH6eQAh+Z4cbb99?= =?Windows-1252?Q?NyikqIlznAJ2IP6CuLq/2nq3vKHkSLZW5WW+qvIxPkpAhyXktQrUDKzg?= =?Windows-1252?Q?6rBq7kGKaaG7hpoRu03aUoyIJXSIs2LJtki/PAwhVf4Q8KeGu5ZWHC+h?= =?Windows-1252?Q?ZHykehM8utThzkY9qdaHpu6uLbC9n6CPPo+pwQCdxBsosoeHD8P/Szrd?= =?Windows-1252?Q?dMJC81M10DUFQuybIHBtdyvBm6ZrF/F7my7rM0PSBA82fULsR2fYxDRr?= =?Windows-1252?Q?ft+8lD6h6AY0LF8pz7RZe3Tdy06Uza/dy6UqolcgOVdpJynqC7VCoYLl?= =?Windows-1252?Q?AikHlxCw6BKTKG/YOo6ynJUk4X9eaphaj1MFHUyYsx8cwknS3hgg3m5h?= =?Windows-1252?Q?0LcJByS9ZqZTEfRmkHuGFDdm50mqndeFadgCSaxW5GBANU7Ky+V4tOEm?= =?Windows-1252?Q?sA8bzw93WNIDkC29lmcgxFKM9sRvRZvuDdL9lez7o/sBCcdl1KX4ZAfg?= =?Windows-1252?Q?DeDTGFeuaDgduEPEUXJ0mSAMzLSycnceECtRF850kzPMqrQkBAU5BFiP?= =?Windows-1252?Q?Hlpdn98iiyeXy7KRKMPQ9SyfVaRTnx7eD6kd/xTOUTYJaXL+EyP99CSL?= =?Windows-1252?Q?cgmTVLXzH5/eyi2PuthdQO6kDGyGdfwA72YgaFzZagawsUC7XP58vq4L?= =?Windows-1252?Q?g924IH/DsMPClnnSsOBjwNJZh9v+z0D7+bOcFRENEkFCWeOCz9mLDoWX?= =?Windows-1252?Q?9jMTn++3b/xL7YLjyGrV6J7uhI5ueJEgjgcuN7NwqxRzBWeO21RCn07C?= =?Windows-1252?Q?ZmxheYjJNg0Af6Thg7jELm24C7PDRujSO514JCJ9PkN6SXYgjWx7c3xT?= =?Windows-1252?Q?5NyRfCn65RYDep3UejV?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2414; 6:tHyc1ORS5qcyfCHMY+nMX1n1ALFWRCUyMOvY8LWlc5AmRC4a6BA6OX6OCLyUvNBYEgMx3FU7GCJ2mAda+Dd8CvLHerpsNGKs1UjoWkM6L5PcJF1drkhiJ8QjJ6w5h5MryV4isBsfYnARR3KLJTLMvfD64HD+IXBxMUtb3kiT8xJGPVV9j+TisK0VflAWyqBUNQt975p+5Qg6xZK/CuJCKZrIn6qarPK2FtFMIxYifWw+VqOFdeSHvUJPUylAj143VuUkbynE/9mDDk9D6dsWY4uWzZoCzMsgBqHH9gxnOM0=; 5:gVMEX2nCyGryr2IDhdHkbaKCA0yXcF71TDTg8GtLyvwF8sniUue8lbp2zNY0MNitTCjPc0L9iuf5jngBGTF/O5G9m5TexqhaNcK22SsfKRnGsZ/0UddSlUoALzX4CUyj2fCSvGJO3m4tMLl3yQ22KXuzvtYrn3cmXZFepARZ9fc=; 24:XLNsCJf5mbsfzKHSIEoSrmdYbm7Q5knI7/FKWSg0eOXQ/zpplXhtCznjeDfbDvg349xWzcrBB0BJpoXa3N5UqF5vnrqsayBsyvPcVXe37HE=; 7:HWePRBsj2kbRuQYzHdUA+8JRfX1BsyhkoZZ3+yBqAkXV3XNW82k6H9nJYrgJR8yF1qdJg03JYmYUN+JMUnIUgN6G0yBfPV9wK8oVpuIZAHC++FzKh++zQDmuJ+/NchhGWIi8z8ZJD32e7+M57qt2STawJmV51/p27sP7piRxGdhfgYUK/myjK9/ER3Z6Ecaqdyu9VYxMfT/kobyEnJag30PEW0ltC54/ArdoRwTGC6F5BrIf6m1AKvEZ/Z2Zv3+H SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2016 09:39:23.5149 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2414 Subject: Re: [dpdk-dev] [PATCH v6 12/17] pci: add a helper for device name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2016 09:39:25 -0000 On Thursday 14 July 2016 10:25 PM, Jan Viktorin wrote: > On Tue, 12 Jul 2016 11:31:17 +0530 > Shreyansh Jain wrote: > >> eal is a better place than crypto / ethdev for naming resources. > > s/for naming/to name/ OK. > > What is meant by "resources" here? This has historic context (from earlier version of this patch). But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device. > >> Add a helper in eal and make use of it in crypto / ethdev. >> >> Signed-off-by: David Marchand >> Signed-off-by: Shreyansh Jain >> --- >> lib/librte_cryptodev/rte_cryptodev.c | 27 ++++----------------------- >> lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++ >> lib/librte_ether/rte_ethdev.c | 24 ++++-------------------- >> 3 files changed, 33 insertions(+), 43 deletions(-) >> >> diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c >> index d7be111..60c6384 100644 >> --- a/lib/librte_cryptodev/rte_cryptodev.c >> +++ b/lib/librte_cryptodev/rte_cryptodev.c >> @@ -367,23 +367,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id) >> return cryptodev; >> } >> >> -static inline int >> -rte_cryptodev_create_unique_device_name(char *name, size_t size, >> - struct rte_pci_device *pci_dev) >> -{ >> - int ret; >> - >> - if ((name == NULL) || (pci_dev == NULL)) >> - return -EINVAL; >> - >> - ret = snprintf(name, size, "%d:%d.%d", >> - pci_dev->addr.bus, pci_dev->addr.devid, >> - pci_dev->addr.function); >> - if (ret < 0) >> - return ret; >> - return 0; >> -} >> - >> int >> rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev) >> { >> @@ -446,9 +429,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv, >> if (cryptodrv == NULL) >> return -ENODEV; >> >> - /* Create unique Crypto device name using PCI address */ >> - rte_cryptodev_create_unique_device_name(cryptodev_name, >> - sizeof(cryptodev_name), pci_dev); >> + rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name, >> + sizeof(cryptodev_name)); >> >> cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id()); >> if (cryptodev == NULL) >> @@ -503,9 +485,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev) >> if (pci_dev == NULL) >> return -EINVAL; >> >> - /* Create unique device name using PCI address */ >> - rte_cryptodev_create_unique_device_name(cryptodev_name, >> - sizeof(cryptodev_name), pci_dev); >> + rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name, >> + sizeof(cryptodev_name)); >> >> cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name); >> if (cryptodev == NULL) >> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h >> index 3027adf..06508fa 100644 >> --- a/lib/librte_eal/common/include/rte_pci.h >> +++ b/lib/librte_eal/common/include/rte_pci.h >> @@ -82,6 +82,7 @@ extern "C" { >> #include >> #include >> >> +#include >> #include >> >> TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */ >> @@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void); >> >> /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ >> #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 >> +#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X") >> >> /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */ >> #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 >> @@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) >> } >> #undef GET_PCIADDR_FIELD >> >> +/** >> + * Utility function to write a pci device name, this device name can later be >> + * used to retrieve the corresponding rte_pci_addr using above functions. > > What about saying "using functions eal_parse_pci_*BDF"? The > specification "above" is quite uncertain... Agree that 'above' is positional word and should be avoided. I will change that to "... using eal_parse_pci_* BDF helpers". OK? > >> + * >> + * @param addr >> + * The PCI Bus-Device-Function address >> + * @param output >> + * The output buffer string >> + * @param size >> + * The output buffer size >> + * @return >> + * 0 on success, negative on error. >> + */ >> +static inline void >> +rte_eal_pci_device_name(const struct rte_pci_addr *addr, >> + char *output, size_t size) >> +{ >> + RTE_VERIFY(size >= PCI_PRI_STR_SIZE); >> + RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT, >> + addr->domain, addr->bus, >> + addr->devid, addr->function) >= 0); >> +} >> + >> /* Compare two PCI device addresses. */ >> /** > > [...] > >