From patchwork Tue Jan 23 13:59:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 34349 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 1467D1B16C; Tue, 23 Jan 2018 15:25:41 +0100 (CET) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0062.outbound.protection.outlook.com [104.47.37.62]) by dpdk.org (Postfix) with ESMTP id 818DE1200A for ; Tue, 23 Jan 2018 15:24:54 +0100 (CET) Received: from MWHPR03CA0012.namprd03.prod.outlook.com (10.175.133.150) by BLUPR03MB1409.namprd03.prod.outlook.com (10.163.81.143) 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 BN1BFFO11FD026.protection.gbl (2a01:111:f400:7c10::1:155) by MWHPR03CA0012.outlook.office365.com (2603:10b6:300:117::22) 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, 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 BN1BFFO11FD026.mail.protection.outlook.com (10.58.144.89) 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:49 +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 w0NDj5Re022838; Tue, 23 Jan 2018 06:45:18 -0700 From: Shreyansh Jain To: , CC: , , , Shreyansh Jain Date: Tue, 23 Jan 2018 19:29:03 +0530 Message-ID: <20180123135910.10755-4-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: 131611910917975953; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(39380400002)(396003)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(336011)(36756003)(8936002)(68736007)(50226002)(26005)(356003)(4326008)(105606002)(50466002)(48376002)(86362001)(106466001)(97736004)(5660300001)(81156014)(77096007)(8676002)(81166006)(2950100002)(53936002)(51416003)(104016004)(76176011)(85426001)(59450400001)(305945005)(1076002)(16586007)(54906003)(110136005)(6666003)(316002)(498600001)(2906002)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB1409; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD026; 1:fZkCQHd/cTRHr8r/5wurjSmYEDwnimKY4rdsM1dIEJ8L3rp34YLEck5n1unTr+Nl8dSsmYGlAm8rMUNTRH5fSck80Rz7rTuJ0YScBz0oILqgjGWJvbua3WxUypt7RZ6N MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89ad067d-cbab-4dfd-ef91-08d5626d10f0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BLUPR03MB1409; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1409; 3:/xXK3+gLQzJ8iCbbn6VTsGTlH9FkruXJNJY+neAe/ZTDNz3ViW0GkWbZwkh5Xqpxt8zNSo9RCgyN/Lv9KOWxg/11z5w1qFJ43hcwxlyz+acIi2A4T+IbWRvB/UrHX55phU8kwIKaTskaQRKgPkISH2FLMhbmMvnVIjEg3zqEmekyU3AdEGj0yDOxuc6AdwhItN1Ga5E65Qg4tw4KE79r90TjbetAHwzkUBXlwJonbZc391UXtcM65/MoM3OtBCnv3HvU69sGVCWrl3uPbpxn74LbtVzL6aAQkpj36GSL5uFk/BzdRyQCeuiBJAHObK9du5dawVsjhwCUcFcwJT5P4vHioXHqfvw8K0N5caYSssU=; 25:dfe635MA5tdrJgaUG+2ZdAMpH1aiBRgFWns8ict7JAuY5oNk1WQLCNEDo3OpU0y8xrBMY2UQK8+G3ABB01npGlrmpmqw1Eja4ECAWb2Geu3r/Hbo5KqFoUNQcmEmACVOy+2+908443bWNJqVhBd6wrFD8Gikf5DWsWS1t0nt/Oj18sUgVDkG2y/PywNPjkUHeZa7UOw60ATbLEEjCjtEwghC3K3HFh8BEQkNIpl2iaad9YKTqVcg8O3KTPc9xWhPgmgN+sz8SS24PZ6J8eiPZBmXDLFXmTexSRuK01WFFVkrzEZRyyw60rouTZThrg3gfoJEOyN8jKpkWLM/bpWpbg== X-MS-TrafficTypeDiagnostic: BLUPR03MB1409: X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1409; 31:acnyTsdOcumJYBbVWVQih3LeqNxZyML2dn0YX4jAFvsEJ1UUhgkTWWID9mPErIicDupzOKVuK8Uf/x79fSf1Ow41wlxWRM/iVPxAvIV/G83uJ6nL7IEx0AOdSoLeP124FTbewhSKGqgdGj6c9LCUY0A7qHRnErTLoHH7JUjhica4d4oOzyjy4SUSegy73fuzFDGPKWrm8lPCCHY3yc8cw2IBHBT19ZzBnQ64D1q1ALY=; 4:W35+KzP762Sc1xQqHHgnmFxAenuILRUUOj57TqiOvSPXF5WLKX2j6x4KHz+25O/DcSQwzT2KD2mdpeIkA8Z8jsfkIAt4w0d6ex2Oa0s0X+uHkBrpf+PF9CgtqsUEA5h1kynrxgJ9fEoIga/NtyPH1qnm+KoLOr5NVK/SRoC3aS3geNIcOKWSHxohpvaUAMHbES25uIDrex2+/k+/yLZx/btpPfSnGV0axwG71p0wXyHb9ovUvg/xMnLMtsUZ1Xt7DxKjNWftX48So+/VBnjE8/7w31kluMjBrxT1fNFdHA509zeTcu0+m06r11h9ryUK 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)(93006095)(93001095)(3002001)(10201501046)(3231023)(2400081)(944501161)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(20161123559100)(20161123556025)(201703131430075)(201703131433075)(201703131448075)(201703151042153)(201708071742011); SRVR:BLUPR03MB1409; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BLUPR03MB1409; X-Forefront-PRVS: 05610E64EE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB1409; 23:dDxKrBEj3s2gdsVr4OoY4KL/urSXR8C2lAFH/dtXQ?= C0El+Dv17g2mEFexAxY6VSiwlX+Xw03c5uDZaiTTBSnrBGTYVXO2KSXr7xWv5lPpvVju8egi1LXLMZekIxflTb9FNkNBAjzQMcwnWL4Gzi3yJP8q2JiCNyqHU3deArxxaAVtFFJE49Urs0u9yGv8xba8trCcxthyfIiKBbngycH0qthuD4Gso/HMC0yd0GMoVjts+GAvjEAGF1EE3TFyJt9olUQW/ywiGiOUkMsl7lx1PPs90GpboS3ncYDlnPTA7fzerQ94EjoR5qBEGVbiVgEBUjnQPVsWKYjSMIgN7U8xzITW7zW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nkRCwSmSJ/eJss8ris1Fuftfy4AvOxIzWwj+s2wumMEy1RAuM2LPCjB00NyuuH/P31vn0OFckv2TXV8hPLO+Y7QZhJOAo=; 5:UeQyouxoQLKx6AWPvQUm1NA3nD3ycE7EFRWl5mWWY61jQ2r62IyqK7NCSVrlyn/E/VYnHbp/neCGqGJryCbhhvy0sD3aVLdGuzQk7I+TwptRmKpQWxPEDamMM1ULZO1IzkfAcaBDDEa3VQl/u/QAJlXN/7xDOJV+pUX8xcruoZ0=; 24:ww5OOU6xIARYoE8uY/AgUHKK8e0gRi6ck15+R77iJ5JFQOlFe8znETcA3wmHaM/lsiUh7OcSyK73rz7m9jUd12iqLspdpUYjSh31llT2vGI=; 7:aRnrHr6/ZY1+jQYUS4J8l1GCqNpfytNOkGifUOANlPZ5yW0zLwOif+MeWqsPC4xMc0EnGbF6E/YVUK7vJPasIMJjLxe+sjMf6AZ9U8I63t8kNoWr5Qvre8hjKAp+l89UdbuLAPx/KNdM+kSDhKMFMZ5IopJYBs0/Ie8GkdFAOYlHilZ8VemSV3GtZIIN5N0W60aWFcpRDv+fqh3DNdqAXSebR9RhDmPbX5Xn+tv1lkTiXo+1TK4aOiyw1mujyc+W SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 14:24:49.9882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89ad067d-cbab-4dfd-ef91-08d5626d10f0 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: BLUPR03MB1409 Subject: [dpdk-dev] [PATCH v2 03/10] rawdev: add buffer stream IO 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" Introduce handlers for raw buffer enqueue and dequeue. A raw buffer is essentially a void object which is transparently passed via the library onto the driver. Using a context field as argument, any arbitrary meta information can be passed by application to the driver/implementation. This can be any data on which driver needs to define the operation semantics. For example, passing along a queue identifier can suggest the driver the queue context to perform I/O on. Signed-off-by: Shreyansh Jain --- lib/librte_rawdev/rte_rawdev.c | 30 +++++++++++++++++ lib/librte_rawdev/rte_rawdev.h | 58 ++++++++++++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_pmd.h | 58 ++++++++++++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_version.map | 2 ++ 4 files changed, 148 insertions(+) diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index 427c8a664..0c5204f51 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -203,6 +203,36 @@ rte_rawdev_set_attr(uint16_t dev_id, return (*dev->dev_ops->attr_set)(dev, attr_name, attr_value); } +int +rte_rawdev_enqueue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context) +{ + 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->enqueue_bufs, -ENOTSUP); + return (*dev->dev_ops->enqueue_bufs)(dev, buffers, count, context); +} + +int +rte_rawdev_dequeue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context) +{ + 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->dequeue_bufs, -ENOTSUP); + return (*dev->dev_ops->dequeue_bufs)(dev, buffers, count, context); +} + 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 44a87c01d..22f055a40 100644 --- a/lib/librte_rawdev/rte_rawdev.h +++ b/lib/librte_rawdev/rte_rawdev.h @@ -350,6 +350,64 @@ rte_rawdev_set_attr(uint16_t dev_id, const char *attr_name, const uint64_t attr_value); +/** + * Enqueue a stream of buffers to the device. + * + * Rather than specifying a queue, this API passes along an opaque object + * to the driver implementation. That object can be a queue or any other + * contextual information necessary for the device to enqueue buffers. + * + * @param dev_id + * The identifier of the device to configure. + * @param bufs + * Collection of buffers for enqueueing + * @param count + * Count of buffers to enqueue + * @param context + * Opaque context information. + * @return + * >=0 for buffers enqueued + * !0 for failure. + * Whether partial enqueue is failure or success is defined between app + * and driver implementation. + */ +int +rte_rawdev_enqueue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + +/** + * Dequeue a stream of buffers from the device. + * + * Rather than specifying a queue, this API passes along an opaque object + * to the driver implementation. That object can be a queue or any other + * contextual information necessary for the device to dequeue buffers. + * + * Application should have allocated enough space to store `count` response + * buffers. + * Releasing buffers dequeued is responsibility of the application. + * + * @param dev_id + * The identifier of the device to configure. + * @param bufs + * Collection of buffers dequeued + * @param count + * Max buffers expected to be dequeued + * @param context + * Opaque context information. + * @return + * >=0 for buffers dequeued + * !0 for failure. + * Whether partial enqueue is failure or success is defined between app + * and driver implementation. + */ +int +rte_rawdev_dequeue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + #ifdef __cplusplus } #endif diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h index 0925d5877..300693f41 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -248,6 +248,58 @@ typedef int (*rawdev_queue_setup_t)(struct rte_rawdev *dev, typedef int (*rawdev_queue_release_t)(struct rte_rawdev *dev, uint16_t queue_id); +/** + * Enqueue an array of raw buffers to the device. + * + * Buffer being used is opaque - it can be obtained from mempool or from + * any other source. Interpretation of buffer is responsibility of driver. + * + * @param dev + * Raw device pointer + * @param bufs + * array of buffers + * @param count + * number of buffers passed + * @context + * an opaque object representing context of the call; for example, an + * application can pass information about the queues on which enqueue needs + * to be done. Or, the enqueue operation might be passed reference to an + * object containing a callback (agreed upon between applicatio and driver). + * + * @return + * >=0 Count of buffers successfully enqueued (0: no buffers enqueued) + * <0 Error count in case of error + */ +typedef int (*rawdev_enqueue_bufs_t)(struct rte_rawdev *dev, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + +/** + * Dequeue an array of raw buffers from the device. + * + * @param dev + * Raw device pointer + * @param bufs + * array of buffers + * @param count + * Max buffers expected to be dequeued + * @context + * an opaque object representing context of the call. Based on this object, + * the application and driver can coordinate for dequeue operation involving + * agreed upon semantics. For example, queue information/id on which Dequeue + * needs to be performed. + * @return + * >0, ~0: Count of buffers returned + * <0: Error + * Whether short dequeue is success or failure is decided between app and + * driver. + */ +typedef int (*rawdev_dequeue_bufs_t)(struct rte_rawdev *dev, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + /** * Dump internal information * @@ -321,6 +373,12 @@ struct rte_rawdev_ops { /**< Release an raw queue. */ rawdev_queue_release_t queue_release; + /**< Enqueue an array of raw buffers to device. */ + rawdev_enqueue_bufs_t enqueue_bufs; + /**< Dequeue an array of raw buffers from device. */ + /** TODO: Callback based enqueue and dequeue support */ + rawdev_dequeue_bufs_t dequeue_bufs; + /* Dump internal information */ rawdev_dump_t dump; diff --git a/lib/librte_rawdev/rte_rawdev_version.map b/lib/librte_rawdev/rte_rawdev_version.map index d63476e47..bafe2c5de 100644 --- a/lib/librte_rawdev/rte_rawdev_version.map +++ b/lib/librte_rawdev/rte_rawdev_version.map @@ -4,6 +4,8 @@ EXPERIMENTAL { rte_rawdev_close; rte_rawdev_configure; rte_rawdev_count; + rte_rawdev_dequeue_buffers; + rte_rawdev_enqueue_buffers; rte_rawdev_get_attr; rte_rawdev_get_dev_id; rte_rawdev_info_get;