From patchwork Tue Jan 23 13:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 34347 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 777121B16D; Tue, 23 Jan 2018 15:25:00 +0100 (CET) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0069.outbound.protection.outlook.com [104.47.37.69]) by dpdk.org (Postfix) with ESMTP id 40A697CEF for ; Tue, 23 Jan 2018 15:24:54 +0100 (CET) Received: from MWHPR03CA0022.namprd03.prod.outlook.com (2603:10b6:300:117::32) by BL2PR03MB468.namprd03.prod.outlook.com (2a01:111:e400:c27::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Tue, 23 Jan 2018 14:24:52 +0000 Received: from BY2FFO11FD011.protection.gbl (2a01:111:f400:7c0c::134) by MWHPR03CA0022.outlook.office365.com (2603:10b6:300:117::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Tue, 23 Jan 2018 14:24:52 +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 BY2FFO11FD011.mail.protection.outlook.com (10.1.14.129) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.428.12 via Frontend Transport; Tue, 23 Jan 2018 14:24:50 +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 w0NDj5Rd022838; Tue, 23 Jan 2018 06:45:15 -0700 From: Shreyansh Jain To: , CC: , , , Shreyansh Jain Date: Tue, 23 Jan 2018 19:29:02 +0530 Message-ID: <20180123135910.10755-3-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180123135910.10755-1-shreyansh.jain@nxp.com> References: <20180102125749.2379-1-shreyansh.jain@nxp.com> <20180123135910.10755-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131611910919009081; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(376002)(39860400002)(396003)(346002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(8936002)(86362001)(81166006)(51416003)(50226002)(356003)(8676002)(498600001)(81156014)(76176011)(2906002)(26005)(68736007)(47776003)(105606002)(59450400001)(305945005)(77096007)(4326008)(48376002)(104016004)(5660300001)(2950100002)(6666003)(54906003)(16586007)(336011)(110136005)(36756003)(53936002)(106466001)(1076002)(50466002)(85426001)(316002)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB468; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD011; 1:Dz0LjrdLuP18619iGmk1PzfqgmJn6Il3yBMJ5CNbWL1g6s0lOyiXkWO0+KRAercJ5pEy3wehLENR+UEf3RWop4rC6tO+gW+TTT01D3TDCN1Ox6qnQ1RSHj9g9SKHnKWr MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ce15738-80aa-4db3-46d0-08d5626d10eb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BL2PR03MB468; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB468; 3:aPmRhtwyw7qVTOC9KuFid2w8MQ3l/baR05WMkl7SvRConLT178zhUOZZKvyTZ7GDlYIlE1Jd0yWx9KArUAZwp4ogwga/yid8fVMYH0n2lVXZ7iyiMU8tFT4UkJUBJsRFQvZfxr5f8afZbCubDkF33g9hCJdu2x/VT3U+mRkqhr46mitU1pFIhTv/Ofqrg/CedGQwCoGwSrIuWyD0+rdgkig8INGsN1eXbrGGHpPwRXdrGmUoYE2uNFOKYnMwwdO8K/3L/LDw/Zf137dKZX7McGfFwGtPz5NnaBw0Zim/a17RIUj2njzyDSLBB12p+TREzmqdVelUY+TSiU0qOJv4jVWq1cqM4PZ6GsoWcGCLtDA=; 25:TZLt0/cvwvOUch1Yw7WdUx/Ba9p3w1R9Kgavp9ZPp7ZjRQDsTmYLZZqoZuZF+RJcG5Zu3EbA9/QjCbopGSQxklFuM+tLcY/tDVU+p/+JCegL8fF0mzsKu5IHraZyLtio1DmHj8dBszExXyyky/ZDhXnZApf3hdSEYsZ7/inqUoQfjwbdPQWRLfhrkoI7mZgTZ7K7FIwC6rKQS59JjJyFGnoBidS3yyUc1L5ECzaoDg2Ohox3IH+FSnbNwUN8FWCjlTuUkST2KUJui+D7ggxQ3a2Lhy0e4uOh+5F6svKDKQek3clZLWGKn5eDxW4nXNZ0NlrxyYLWy2/2HHEgQAdIsg== X-MS-TrafficTypeDiagnostic: BL2PR03MB468: X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB468; 31:gzZmpU1XhpHWJpg2yAc2ezmG8DlGE81OwxFc3UnYzDUtXbmB2wFFutsmJrNjV+nD5AbcQMda5o5CkSzr7+tAWDubYCwXNf81ZycTNAMARQdxwlTRdEwiBTMV9+pX1R4DrNY49TjMbPxKfECogfZ9p0Iq2qu/AfRn7q7JHbCCZ4hfk1WcmOI7OWgJHfauOnINLFNESGsMaJ3NSai7WrG/z7F3zXUCoPAFhrtsqQPLL8s=; 4:FHx3Ntrpi5UkTtachG7h2VVc6LXdpikQHGMSmvzZtlQ20zvBWvME7HIwXlKxiBqlSlLDEhx0nA6TtOkWNVLkuosjI8RcRQ2iga2P71aGPmtj2rcbeI5DUd4SkqmsZ3c74cxZKPwxfphU4GuOut47q+u6Ovs8h9Es1UGIkzWtXK4vRfIs0zs8mKLUM7Gi4XQNEHDC4ZbhdkGTBXduAuNb+RurRnZdpXkQgtQN92l1IVNcLkt/QkQFv+9nhHTUou2PQQpDG5Lwpk/XZxx1ruen75ndN7A4xU6ECdS4SpOSJrMBWy8H0NHI5H0nHzRaCetY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(10201501046)(3231023)(2400081)(944501161)(93006095)(93001095)(3002001)(6055026)(6096035)(20161123565025)(20161123561025)(20161123559100)(201703131430075)(201703131433075)(201703131448075)(201703151042153)(20161123563025)(20161123556025)(201708071742011); SRVR:BL2PR03MB468; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BL2PR03MB468; X-Forefront-PRVS: 05610E64EE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB468; 23:6U8Y/n9zexLELz7ud6dFhBErpe2kktDQfttrJ+Ea3R?= L+PMDUTkMvzRY1KO5lPnus0JscBRjyxymViQ4QdHrbN99drIDYQtWT3GMIx50KT+hgdVBc93mCwM9tuNC8sV5kmbhhu+zhxkDe/i7oFKwuVpaka3tN/uGUhBZkCptfZScTIxz//EzqNX/l+S2jqkVjm0+UiQsruPujPrcEQxgSTkv015zppZzw8pLbB7pQnTZD8anw4mC8PdjIThiWqdAqO9di5p14QTlQeVJeXxgBZiQpqO3IrXQO8axHM/8F8/ZPdEQGksMe/1iM3lI89Tn1myP9Azm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PEEVUFDXu425fQ9sYfPnTcfxxCc9NHsd7kf0BqtVmX5HiMCBDki6TwyeTyb9Vd2P27zQAdQyjcyGhBJn8NwxVl+ZxUNtplSEiPCkgUWf4=; 5:hxsfEfPCqe8jltfB2mLRT6+aiwRGAc+RfX0iZOuJX0aiPFVfiGpO8z60dFsOdWc3+T88+9MgtWk0pPktUKjEFYSWEhNugamdQYgW6uANuN5cFewrwRIxNpkO6ACjrM+EXKwC3Hysm1CSBihN9p1lgpk8XLZpsiy1Be2YJWi8lPo=; 24:1ThAwwvYqTrEWk3jeGhnc+qH32dKK2LbNNz8H8S0/iBFvzodRY0VC3vvI4TpiYx+u6rr+58RHmSDyZhwoU5xG1qd/ublHxIdfwQxYYf86y8=; 7:7QHhRWcQhfTKx5YbJEr4QWi8xp+qtKHZ+yTIcgPpKSYjYLIfpQZCFYopXwNFMsk86BKNhoyhqBIdvVHMv6OC4K7OcyatZrUVZueolBpGPcD+A4Zfku1Q26OP5gl6Qa2dB6rPBcN0slPGvtOTh1JEyboDIlVGl/Z2zfkfhr0gvogOtM8w0mhAepWVE5+/1jZlFvTuKZh/WugY/0Z+Tromp6ZeaiO/+nqDDirYNjBvkvpJVmT9xXfzaWv62yUPg7g+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 14:24:50.0600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce15738-80aa-4db3-46d0-08d5626d10eb 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: BL2PR03MB468 Subject: [dpdk-dev] [PATCH v2 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 4b89bf07d..427c8a664 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_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_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_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 ef66006f9..44a87c01d 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_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_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_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 a5789cf43..0925d5877 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;