From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0085.outbound.protection.outlook.com [104.47.1.85]) by dpdk.org (Postfix) with ESMTP id 17BF61B732 for ; Wed, 31 Jan 2018 09:58:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0GI1HfiSn0oG4c6Tn4ORt2dmugXxqCNbAiwaFQzG8x4=; b=wWVvaggFwnV2hY/WinrYG8nES4sxiLkVDlcdiW4fD2xHOTutvXOgzTEYcxVqI/TT592zJyDwsxGI6qH33OSizNBcvR16zXqHl5RZ5UeUsRGlrjcdpoZL8hr0dK4zGXCrBDsSsmMxVK+33OpF8BspNQ4SCY1phOwnySvUyD1xe8w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (192.88.169.1) by VI1PR0401MB2462.eurprd04.prod.outlook.com (2603:10a6:800:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Wed, 31 Jan 2018 08:58:49 +0000 From: Shreyansh Jain To: thomas@monjalon.net Cc: dev@dpdk.org, hemant.agrawal@nxp.com, fiona.trahe@intel.com, rosen.xu@intel.com, Shreyansh Jain Date: Wed, 31 Jan 2018 14:43:10 +0530 Message-Id: <20180131091318.7894-3-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180131091318.7894-1-shreyansh.jain@nxp.com> References: <20180130145710.24757-1-shreyansh.jain@nxp.com> <20180131091318.7894-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.169.1] X-ClientProxiedBy: HK2PR02CA0168.apcprd02.prod.outlook.com (2603:1096:201:1f::28) To VI1PR0401MB2462.eurprd04.prod.outlook.com (2603:10a6:800:55::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d1b67a7e-c768-4f61-e000-08d56888da04 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0401MB2462; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2462; 3:b1Fxc7Fu5Yl1shoetu/p2oSxvVigDXN5Yy+msDMTDDw+oqKZxpz71dVvNxVyxFWnABT69Q58oytDhQjNjX+i0ns+07vyH98+pAfiJox7U+ZukPVfmTwtPL+OPEliE4jF6zy8361viY9Ai6wfiOTUctUAMPM0tDk3CE+GSHO2yF/txuB2a+s1rXu3eJ/ptJiXYcCPEUzf/iKVBDDz4C0rBaMo87p7tlqRMyDlcVErA5cthuBbkw1Nfxvx1sR01/6y; 25:1blfRKMD+KXAqsgon2kR/aq01SUkjrQv+h9ShSf/M6BthPdFLcLpC0Nh4z5LkFkl1nLwu2se+Iw/ClHF3MCoRwCQ49ccL7VT2yDZVrtuMCrjzqFTDEiftA8UCjg5jmhCGwXSFRBKvlwyEdpurYsv5kAMuqFsBkUmInWSeS7Ga9XxlqiAMXgAg/EKxmzE17xk3PGX7SHbmMuf5mBFVUb9RH+3iv0BB9Xve+eqUyrAbW/0Oy6Xa2UAwdUlz+2xSK1QRhCR+YfcysGiTFAeQbj7H/TFPmtmafnX2nn7nEpT/8YP5I1Vy/8MuvwPTD6yW7kVrihgT+mDb1z8z1SYrFSThw==; 31:DwGrCXWcs7rUCcpnvFM/HNEFIeYMJiE8gVAY6v9HTqx2MtD3b9AiAXY/eanX766MtEfaLxUsqQrJwJg/wV8++BlBmc6RszHK31GBb986Q7ioS0I4uvDAP7s1QCE1cAGD2hLVbInRLiVCkpCQhnWDYhctdZ3f7QP6Cl0HxTClu5G/DMiSZHuF4iLeB2OWpSH8Yx2ll2dNxybeV/jtkMj5u8NDE4W25O9WH9rMafReiV8= X-MS-TrafficTypeDiagnostic: VI1PR0401MB2462: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2462; 20:42vsBb/JVy744MLx7mrOmmt3vWpr3XWq9HzDMPQwminvEGc8dBDyjQ1AkVUamuu7PtE0zZJFKQcnfjVrwtFU2sY8kEarRx3vgYGR++XIHCNCeStGe5rwFxv81rr12DlaxK9gjQABk/c5Jwd+wb9OIgq2TbU8+gzBR7XUfC3wHgVosXCHH9V2lwXSIf7ols8D8r/nYRg/MsheSBylnOTQ2p3W7z/zBF2VRanBceyT0Z3Ui/eR6v69KbRvF5QHhvIH73mwNQfptTzuU4Ldajk359Pm+IJ/GuBMjPu1Id/08qWvMu22pZVfJbjj7xFmhp71wXLtKN3EiJ2LCtDnovLDxmyJiU4NThQXd3LsnSckSIynpGD69GZIgzF4DKtN39ptpiso11jKOWdj9oxftQC0CDbky44IQxopqmJGkbXHUd6ip9P1WjsnmPKGxrxWtasaqWE2HNrj17D+hiqmjaGxboqT82ccB2P4J138je0ywZGM2XackZLLIZL5lxGiWHWU; 4:EAFUUEM8xCczV1sSMBv4AT5udKv0Ng+pYohIWp9AtXZmA4drV+SOfpEAi22ccQDlaIBJAUp4fCgXECfBR+lNZ2GpPpeG9H2CSrHscY4yaUoEB8mdQL11oMBw82tHo3ocJBj6A/DuZtBfOwC3A/Opf2nodbX06atnHAIBxfdUT8Q5Jmr5yPfgOXDvAK9VBcp5qZOQLHLBxN7rsDTI0ushTxshFj9UPs9LhPcTvoYXQJIaS33sL0S33epUv868FBNHD/TxRmnNAXjhIwJmcakJQZxcjdqjh5eQZ8f0ZgJKBBHr4GgjlfjE9XJDwQ4/WF00 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR0401MB2462; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2462; X-Forefront-PRVS: 056929CBB8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(376002)(366004)(346002)(39860400002)(199004)(189003)(6486002)(6512007)(50226002)(8676002)(48376002)(4326008)(81156014)(316002)(8936002)(66066001)(6666003)(2950100002)(81166006)(6916009)(53936002)(16526019)(5660300001)(47776003)(186003)(26005)(106356001)(2361001)(97736004)(16586007)(305945005)(478600001)(51416003)(386003)(36756003)(86362001)(105586002)(68736007)(2351001)(76176011)(1076002)(52116002)(2906002)(6506007)(25786009)(3846002)(6116002)(50466002)(59450400001)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2462; H:Tophie.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB2462; 23:7aNcyRE/jt+bMmTplC4ngXuJnkUFcyrDWjOWQLC?= =?us-ascii?Q?ftGNn2y9kodyclgOh/rk2wvEr0/gBkEo5/lRWtA1e5dODfwApyy1xuw1bg0I?= =?us-ascii?Q?BI62Ijjb9Xj1b4MQEbQC3WkLzGfYsy6RafUJV5XeH0F12xN7YLGih4IUOWWH?= =?us-ascii?Q?UEE6z0hyHNInpw+xNig38XGPkCeE+guREuksoliiRdc2apyoijThSjf6LIqe?= =?us-ascii?Q?8fTVILMN4+b4coIDdY1kzNdpAS0qYRKmN0Qy085N5lNOiNSlOr7L2sIDF3go?= =?us-ascii?Q?f4UCg5WcFDIJr1r43AOWsqAOqBTZf6M+77J+wMnC62jC7q9Kva2wjFg1/hIk?= =?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ange-Diagnostics: 1; VI1PR0401MB2462; 6:swVDusNYvtzCRi5hzWl1PtBFU47Yixq7rA8sTInnepU1XoKIoDCKQIpomEmAhdiRTtrGdObKTxOtDRo8nUzP0OVGD/EAP8zOy1k1pnbiBook+W+2xKoagp2btkxzmWJ0jSt0olcI+2dNNWgzAlB8ihRgPkHMZiFLlwfYBkbRi187lZpTeAu8AKmO82k78dtYcbNJ7NmH0WhD2oHzu2shTSbrMcu+4UJVqUHAukHcoUaDgIOHcHNOgXicAhyzJcpTYsPGqxScCKHk+rw7jYUGKCZDDwjpXuyQs7q1s/AZQEyLqa8E4Zn8KAweHqsK6HKXCVWJbRDJlj4RVQclmhdrT2FoTlPvJUBsa8SFWRMN82M=; 5:eyGHXw7GdhmgMfyQSk3LmXlfvoi0K+mv8z+gzLIZIJUUPfEIlrPkPLm8+vajHcfIpY46oLTSgODmUX7yS3/LHz7OCr28c7TMNetL9JnA6SsDRBrazLGLnhxg4QZ/sOcFPAV6NbaUJTz9EbhrCTgVhFc313RS7BKC2VLkUDwTpcw=; 24:Q4OdBKco3fBKYlupMUKhWDFYoX8G7ruSztn1O0f1UCCGBMFSYd3V176va7umszXH5OnE3ffrC0sbajyzBfkwl7fI1KegaAWFCCXEvsWb3/A=; 7:r9J9T+TIvjCW5E8j28zrYV/ObLFvnCqXC70ZQMc1r0TLv9/jYX3DowbQPdrb9L+Khg39EpPima/tWmVcTRRkE8flHXGWrm14IL9Dug09nl2BWcEltIg86Qy8i8a1ckGHnh/otFqg7H5BWEW770FeLb4HApi4ZL3j1e+9UwB8WO/0S7c9HkpCHP3Y9uzGs0QvxcpAsRzptoDtNfslmn2/d8qjaghHPg0i8QGA4564PQb4DWT27qOTc1+jixmyoPHd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2018 08:58:49.2105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1b67a7e-c768-4f61-e000-08d56888da04 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2462 Subject: [dpdk-dev] [PATCH v4 02/10] 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: Wed, 31 Jan 2018 08:58:57 -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 76a533e06..a58abc3ca 100644 --- a/lib/librte_rawdev/rte_rawdev.h +++ b/lib/librte_rawdev/rte_rawdev.h @@ -319,6 +319,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. + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param 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. + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param 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 aeb371152..3e643691d 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -264,6 +264,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 + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param 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 + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param 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. */ @@ -288,6 +325,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