From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0086.outbound.protection.outlook.com [104.47.32.86]) by dpdk.org (Postfix) with ESMTP id 13BDF1B363 for ; Tue, 30 Jan 2018 16:24:50 +0100 (CET) Received: from BLUPR0301CA0021.namprd03.prod.outlook.com (2a01:111:e400:5259::31) by DM2PR03MB477.namprd03.prod.outlook.com (2a01:111:e400:2420::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Tue, 30 Jan 2018 15:24:48 +0000 Received: from BY2FFO11FD038.protection.gbl (2a01:111:f400:7c0c::153) by BLUPR0301CA0021.outlook.office365.com (2a01:111:e400:5259::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.444.14 via Frontend Transport; Tue, 30 Jan 2018 15:24:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 BY2FFO11FD038.mail.protection.outlook.com (10.1.14.223) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.444.13 via Frontend Transport; Tue, 30 Jan 2018 15:24:46 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.39]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0UEh7sf023996; Tue, 30 Jan 2018 07:43:16 -0700 From: Shreyansh Jain To: CC: , , , , Shreyansh Jain Date: Tue, 30 Jan 2018 20:27:01 +0530 Message-ID: <20180130145710.24757-3-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180130145710.24757-1-shreyansh.jain@nxp.com> References: <20180123135910.10755-1-shreyansh.jain@nxp.com> <20180130145710.24757-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131617994878534831; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(346002)(39860400002)(396003)(39380400002)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(8936002)(6666003)(2906002)(50226002)(105606002)(2351001)(5660300001)(81156014)(104016004)(81166006)(106466001)(2950100002)(36756003)(8676002)(76176011)(51416003)(498600001)(77096007)(47776003)(26005)(53936002)(54906003)(48376002)(85426001)(50466002)(336011)(59450400001)(97736004)(1076002)(356003)(4326008)(68736007)(305945005)(6862004)(16586007)(86362001)(316002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB477; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD038; 1:dx2yAcuOkbp8zu0lY4yPu+ZwZGyFjEuaLrQBbGmuS1mzeDs6y996A74Gko1Fb/TGBxKIqvOdZkLUqo7dbh+MpoiCSYk3z2X2ZLCc4tRJamzG6GuuFAV1+C1X0nqfvhfq MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15687642-fd97-465d-b9a7-08d567f5992c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:DM2PR03MB477; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB477; 3:rVI7sQITJbotv181QfshZmR8vTd4engVgTiEMTayHESsCVFKgmFOu6fCjJvQX3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1PHAbkFgRCpu9wAsc9ZwMnHg4F9AxsoulL7H81HtBC8bsgNkfAyarSFLqUJe1Sy9XcwrNi48KXMk/ra+0dFtp6D2v5s/QGaAIXwMZLJgYPrUQ2oFDWCJDXaSlgM6ZV3e/lVC8RkGvJrv7Q26FOOYeSoe/pHiyku07L1xQeBxudUv0h/6lzlMWTfWe69c8OKfMoC1osxdQ5xuOwU0XN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231101)(944501161)(10201501046)(6055026)(6096035)(20161123565025)(20161123563025)(20161123559100)(201703131430075)(201703131448075)(201703131433075)(201703151042153)(20161123561025)(20161123556025)(201708071742011); SRVR:DM2PR03MB477; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR03MB477; X-Forefront-PRVS: 0568F32D91 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR03MB477; 23:XWMrxIKjFEHx8aqtlAGOXOE99vjUgKCM1K2IwhJnWf?= =?us-ascii?Q?lIsdSoKR0EMDlBIoQk8OneB6zesIv9VZ7R2OjurEQfEX9TX96YwXHBh6R9kj?= =?us-ascii?Q?VL7SJeH9K1KvJohmQsNZeaVcUciG4kMVQjwkCU8TTTYKB/knQODCTYxswHXX?= =?us-ascii?Q?EPJXajmKZ55pGzsqX+P1pW/4TnFpsmS+wmRe6XXG/7rovuw6BY4avF3LsKCe?= =?us-ascii?Q?MSh1rP4v8xwD1SelYXBGfySG3Ot2dm5QlU9LWANjg7EqxHknI+YTVxQvJCcc?= =?us-ascii?Q?s3bqjGt/tiq8I96BNQej7UXJ/uKIJqSYTMIc8JkYfXMVeTtrnwhxo2mCGrZH?= =?us-ascii?Q?PWCtZ49JtrLe50dwrZnZB/FI03oTNZ0xxW1og+hQ5as84inMUFmrCDagZ20d?= =?us-ascii?Q?3mX3spkkbW1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hzbRg8yHON0CTOxxWE7F3PBkPz/Cxz1+cBWyDwW8BpGHdXRkkg+K5t+ct34lNmXqT6VJ2eKtqFZJjfhFCk49DSh4lcMJ52t/v9wr/bpo3uDRue+hmCxo8nPYDzHPbKC0dz4CJv7+k7MhfZhNzoC1Voc4SR9eX7Dg6koyW1GNJSYAJ6KdN4q9cJRhAHdrMUKadhV782G4KdKQR/BMU8UarzVFTkUDG8yJMZ1K/gE3wbaWVFnpmT4dAc3UA7hpKJB5ETrXdmYaGOVruBIgQUZdbqCOqPU9EabnTQUcR9U8dR4/9xhRzr1tdBODo7Y1dyqt+mOasFCgpxWVBwmLlv8JBTwF62mg=; 5:kwpK8yOG5tUnvetplFqjQJ8QNuVzOmqQ5VmMlh4DlF50QFk1/5fBTNX2KpLmbOfkJNhxqwxCSKDiRuujRxoqd7lNNRlNM0S0J7tuu5NQR/aNHEpqGwNLjFwBxWjesyIAp90QiqwodyiCob8Zl3zWQjhVzcGXA1fGosS/MFiVH50=; 24:8Nl2g/6mci5DDM+6XvcILPyqIVJkgjnh1B9UzRNqnRcxBwfgiXQROlx+OyyvXtCyQqmXgKEeLUBvCNMWkosWiFCgobj2D/aKhoDbIc2s2oQ=; 7:4Q1/+pztY5AiSswZLAxkC8vp+7zB/OEt8EHeYteaxnbNfyb1PKzONHNz81C3hEsa0Rd9dSGq/h5/4d5R+YI85cdp7BAKz0MEypRIvFL+rY2vf1rraDfGo/HWPZkz596+sd3Hu/W0eY4hcPx/i1gVS4xlzmg42CJ1NlEfOCE3hB/dEPPaCLHLDls1M/OfzHZgNgvdXaujfMtAMpDkIHCpfccNvvFItr6xeddGW4s01vkzNmtAhHyG+vmuP0BPHUXl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2018 15:24:46.5742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15687642-fd97-465d-b9a7-08d567f5992c 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: DM2PR03MB477 Subject: [dpdk-dev] [PATCH v3 02/11] rawdev: add attribute get and set support 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, 30 Jan 2018 15:24:50 -0000 A rawdevice can have various attributes. This patch introduce support for transparently setting attribute value or getting current attribute state. This is done by allowing an opaque set of key and value to be passed through rawdev library. Signed-off-by: Shreyansh Jain --- lib/librte_rawdev/rte_rawdev.c | 28 +++++++++++++++++++++ lib/librte_rawdev/rte_rawdev.h | 43 ++++++++++++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_pmd.h | 42 +++++++++++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_version.map | 2 ++ 4 files changed, 115 insertions(+) diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index 46353a4eb..08dd982a4 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -175,6 +175,34 @@ rte_rawdev_queue_release(uint16_t dev_id, uint16_t queue_id) return (*dev->dev_ops->queue_release)(dev, queue_id); } +int __rte_experimental +rte_rawdev_get_attr(uint16_t dev_id, + const char *attr_name, + uint64_t *attr_value) +{ + struct rte_rawdev *dev; + + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->attr_get, -ENOTSUP); + return (*dev->dev_ops->attr_get)(dev, attr_name, attr_value); +} + +int __rte_experimental +rte_rawdev_set_attr(uint16_t dev_id, + const char *attr_name, + const uint64_t attr_value) +{ + struct rte_rawdev *dev; + + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->attr_set, -ENOTSUP); + return (*dev->dev_ops->attr_set)(dev, attr_name, attr_value); +} + int __rte_experimental rte_rawdev_dump(uint16_t dev_id, FILE *f) { diff --git a/lib/librte_rawdev/rte_rawdev.h b/lib/librte_rawdev/rte_rawdev.h index e13b11400..bfcbe1270 100644 --- a/lib/librte_rawdev/rte_rawdev.h +++ b/lib/librte_rawdev/rte_rawdev.h @@ -307,6 +307,49 @@ struct rte_rawdev_buf { int __rte_experimental rte_rawdev_dump(uint16_t dev_id, FILE *f); +/** + * Get an attribute value from implementation. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * Implementations are expected to maintain an array of attribute-value pairs + * based on application calls. Memory management for this structure is + * shared responsibility of implementation and application. + * + * @param dev_id + * The identifier of the device to configure. + * @attr_name + * Opaque object representing an attribute in implementation. + * @attr_value [out] + * Opaque response to the attribute value. In case of error, this remains + * untouched. This is double pointer of void type. + * @return + * 0 for success + * !0 Error; attr_value remains untouched in case of error. + */ +int __rte_experimental +rte_rawdev_get_attr(uint16_t dev_id, + const char *attr_name, + uint64_t *attr_value); + +/** + * Set an attribute value. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * @param dev_id + * The identifier of the device to configure. + * @attr_name + * Opaque object representing an attribute in implementation. + * @attr_value + * Value of the attribute represented by attr_name + * @return + * 0 for success + * !0 Error + */ +int __rte_experimental +rte_rawdev_set_attr(uint16_t dev_id, + const char *attr_name, + const uint64_t attr_value); + #ifdef __cplusplus } #endif diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h index ca6e6a1c8..aa67c4f39 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -262,6 +262,43 @@ typedef int (*rawdev_queue_release_t)(struct rte_rawdev *dev, */ typedef int (*rawdev_dump_t)(struct rte_rawdev *dev, FILE *f); +/** + * Get an attribute value from implementation. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * @param dev + * Raw device pointer + * @attr_name + * Opaque object representing an attribute in implementation. + * @attr_value [out] + * Opaque response to the attribute value. In case of error, this remains + * untouched. This is double pointer of void type. + * @return + * 0 for success + * !0 Error; attr_value remains untouched in case of error. + */ +typedef int (*rawdev_get_attr_t)(struct rte_rawdev *dev, + const char *attr_name, + uint64_t *attr_value); + +/** + * Set an attribute value. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * @param dev + * Raw device pointer + * @attr_name + * Opaque object representing an attribute in implementation. + * @attr_value + * Value of the attribute represented by attr_name + * @return + * 0 for success + * !0 Error + */ +typedef int (*rawdev_set_attr_t)(struct rte_rawdev *dev, + const char *attr_name, + const uint64_t attr_value); + /** Rawdevice operations function pointer table */ struct rte_rawdev_ops { /**< Get device info. */ @@ -286,6 +323,11 @@ struct rte_rawdev_ops { /* Dump internal information */ rawdev_dump_t dump; + + /**< Get an attribute managed by the implementation */ + rawdev_get_attr_t attr_get; + /**< Set an attribute managed by the implementation */ + rawdev_set_attr_t attr_set; }; /** diff --git a/lib/librte_rawdev/rte_rawdev_version.map b/lib/librte_rawdev/rte_rawdev_version.map index 64e60d945..d63476e47 100644 --- a/lib/librte_rawdev/rte_rawdev_version.map +++ b/lib/librte_rawdev/rte_rawdev_version.map @@ -4,6 +4,7 @@ EXPERIMENTAL { rte_rawdev_close; rte_rawdev_configure; rte_rawdev_count; + rte_rawdev_get_attr; rte_rawdev_get_dev_id; rte_rawdev_info_get; rte_rawdev_pmd_allocate; @@ -12,6 +13,7 @@ EXPERIMENTAL { rte_rawdev_queue_setup; rte_rawdev_queue_release; rte_rawdev_reset; + rte_rawdev_set_attr; rte_rawdev_socket_id; rte_rawdev_start; rte_rawdev_stop; -- 2.14.1