From patchwork Thu Jul 28 09:33:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12931185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A02FBC04A68 for ; Thu, 28 Jul 2022 12:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235249AbiG1MQC (ORCPT ); Thu, 28 Jul 2022 08:16:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237088AbiG1MQB (ORCPT ); Thu, 28 Jul 2022 08:16:01 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A79C66AD3 for ; Thu, 28 Jul 2022 05:15:59 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220728121558epoutp01d6a1e02b201bddd4d210226abcab602e~F-VANW9VB0846308463epoutp01S for ; Thu, 28 Jul 2022 12:15:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220728121558epoutp01d6a1e02b201bddd4d210226abcab602e~F-VANW9VB0846308463epoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659010558; bh=GaFMiezcC/Oe0p+cfmaYFu1JQYpckb58+h9LHvgAYKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trX2iSD0V3C7VtYS2JGs7yDuKHwQWfCw1FYGALoNGz8aLt3tbj/7l7KJkl+Hw7LQC Q87SaeFi3QThsvH/cHfExfkkKtrMZfyJnlHzQ8cD0FJea3tTwsG6t8AZVHL1uHlV2J nu0EGXn4HQNy6TiRMz3D9Ex/EA8aGLW91sVQeg1w= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220728121557epcas5p25b0e6c7ec2e0409b5d3a560f2d3000aa~F-U-56Hdl3150931509epcas5p2G; Thu, 28 Jul 2022 12:15:57 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4LtqP70Kznz4x9Pr; Thu, 28 Jul 2022 12:15:55 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6D.DC.09662.AFD72E26; Thu, 28 Jul 2022 21:15:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220728093904epcas5p4eed789c1eda441c223795dd026dc5d3f~F9MA32xkZ0692706927epcas5p4m; Thu, 28 Jul 2022 09:39:04 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220728093904epsmtrp1f23ab3ff929b8faa3dae461a2271690b~F9MA3SSh-1674116741epsmtrp1Z; Thu, 28 Jul 2022 09:39:04 +0000 (GMT) X-AuditID: b6c32a49-86fff700000025be-a1-62e27dfa0d19 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 19.56.08905.83952E26; Thu, 28 Jul 2022 18:39:04 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220728093903epsmtip14a85e1750395c4e45eac7527286242ef~F9L-yhx1c1234512345epsmtip1I; Thu, 28 Jul 2022 09:39:02 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v3 1/5] configure: check for nvme uring command support Date: Thu, 28 Jul 2022 15:03:23 +0530 Message-Id: <20220728093327.32580-2-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220728093327.32580-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmlu6v2kdJBjd+WFusufKb3WL13X42 i3et51gsjv5/y+bA4nH5bKlH35ZVjB6fN8kFMEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8eb mhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYALVNSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2Cql FqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGfsfzSftWAWV8WWhRYNjPs5uhg5OSQETCTe P1/O0sXIxSEksJtRouf0UmYI5xOjxMGePWwQzjdGiVmT1jLBtJyfuAGqZS+jxISzdxghnFYm iZkr17ODVLEJaEu8enuDGcQWERCW2N/RygJiMwtESax5dZYRxBYWCJI4e6cFrIZFQFXi0ekO sDivgI3E4i8X2SG2yUus3nAArIZTwFbi06MTYMskBOaxS5x/9ZMVoshFYs2prVC2sMSr41ug mqUkXva3QdnZEpse/oR6oUDiyIteZgjbXqL1VD+QzQF0nKbE+l36EGFZiamn1jFB3Mwn0fv7 CVQrr8SOeTC2qsTfe7dZIGxpiZvvrkLZHhIrX2+FhuMERommVbOYJzDKzUJYsYCRcRWjZGpB cW56arFpgWFeajk81pLzczcxghOUlucOxrsPPugdYmTiYDzEKMHBrCTCmxB9P0mINyWxsiq1 KD++qDQntfgQoykwACcyS4km5wNTZF5JvKGJpYGJmZmZiaWxmaGSOK/X1U1JQgLpiSWp2amp BalFMH1MHJxSDUzNl29GzoyMm3pxiSCT+XFNSyeFz7HKRsrpJ70OVczZmP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dG6xi2p Ad7fwsSvvF0vMjVaaif7na8ROx42sBYmsFbnK2zcMWfvkxNy22b+ue2q/u7HWofViyZaO1xn qX36s+0n92vh/u98hvVJN0O6q18Zn+hNN88L+KHjOWdf8+1zf5VYijMSDbWYi4oTAe3ZtpuN AgAA X-CMS-MailID: 20220728093904epcas5p4eed789c1eda441c223795dd026dc5d3f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220728093904epcas5p4eed789c1eda441c223795dd026dc5d3f References: <20220728093327.32580-1-ankit.kumar@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Modify configure to check availability of nvme_uring_cmd. The follow up patch will have uring passthrough tests. Signed-off-by: Ankit Kumar --- configure | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/configure b/configure index 43071dd..1b0cc50 100755 --- a/configure +++ b/configure @@ -367,6 +367,23 @@ if compile_prog "" "" "has_ucontext"; then fi print_config "has_ucontext" "$has_ucontext" +########################################## +# Check NVME_URING_CMD support +nvme_uring_cmd="no" +cat > $TMPC << EOF +#include +int main(void) +{ + struct nvme_uring_cmd *cmd; + + return sizeof(struct nvme_uring_cmd); +} +EOF +if compile_prog "" "" "nvme uring cmd"; then + nvme_uring_cmd="yes" +fi +print_config "NVMe uring command support" "$nvme_uring_cmd" + ############################################################################# if test "$liburing_nolibc" = "yes"; then output_sym "CONFIG_NOLIBC" @@ -402,6 +419,9 @@ fi if test "$array_bounds" = "yes"; then output_sym "CONFIG_HAVE_ARRAY_BOUNDS" fi +if test "$nvme_uring_cmd" = "yes"; then + output_sym "CONFIG_HAVE_NVME_URING" +fi echo "CC=$cc" >> $config_host_mak print_config "CC" "$cc" From patchwork Thu Jul 28 09:33:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12931264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9285FC3F6B0 for ; Thu, 28 Jul 2022 12:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236790AbiG1MwP (ORCPT ); Thu, 28 Jul 2022 08:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbiG1MwN (ORCPT ); Thu, 28 Jul 2022 08:52:13 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 240761025 for ; Thu, 28 Jul 2022 05:52:09 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220728125203epoutp02932a78c1ce4ed05b9d985c24ad02c150~F-0gjgXMu0683306833epoutp02h for ; Thu, 28 Jul 2022 12:52:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220728125203epoutp02932a78c1ce4ed05b9d985c24ad02c150~F-0gjgXMu0683306833epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659012723; bh=BbbSWEM1xsOG1dLNo8znd6zXYJk4jY/HHeirk2IeknA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDWDFIptYCTIgwCctt8/GOtAWPLgFZZc9sGHX9IOEMEgK2ON78//BYF/p+k4e5fBB +ke7UYujMy1Rv23LwGdxLHFiacrrOcjo3B30RnCdhA6ehfNvUM791/G7j+RM8twb30 R6G75mu6v+D6FjfxDSmFQvDN2Ilh+dh19NswG/Fk= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220728125201epcas5p400ddd320bb71973ba88aa64b5a3845f9~F-0fSrx880610606106epcas5p4z; Thu, 28 Jul 2022 12:52:01 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LtrBl13whz4x9Pr; Thu, 28 Jul 2022 12:51:59 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 1D.B1.09662.E6682E26; Thu, 28 Jul 2022 21:51:59 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220728093905epcas5p22963dd2dadb73bdabfaffc55cb2edef5~F9MCBS9LL0479104791epcas5p2y; Thu, 28 Jul 2022 09:39:05 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220728093905epsmtrp1ceeedb8ccc72254eddf632d252b0df3f~F9MCAqeTn1674116741epsmtrp1b; Thu, 28 Jul 2022 09:39:05 +0000 (GMT) X-AuditID: b6c32a49-86fff700000025be-de-62e2866e327e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D6.7B.08802.93952E26; Thu, 28 Jul 2022 18:39:05 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220728093904epsmtip127c37e59f1e1c68e8d0ce6e4676f72cd~F9MBLVjNg1442314423epsmtip1N; Thu, 28 Jul 2022 09:39:04 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v3 2/5] io_uring.h: sync sqe entry with 5.20 io_uring Date: Thu, 28 Jul 2022 15:03:24 +0530 Message-Id: <20220728093327.32580-3-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220728093327.32580-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKKsWRmVeSWpSXmKPExsWy7bCmhm5+26Mkg83zmSzWXPnNbrH6bj+b xbvWcywWR/+/ZXNg8bh8ttSjb8sqRo/Pm+QCmKOybTJSE1NSixRS85LzUzLz0m2VvIPjneNN zQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOAlikplCXmlAKFAhKLi5X07WyK8ktLUhUy8otLbJVS C1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjOm7zrFVNDBUXF70in2BsbJbF2MnBwSAiYS z9+eYOli5OIQEtjNKLH0wmtGCOcTo8TEy19YIZzPjBLzW2fCtcxecAeqZRejxNtdZ9kgnFYm iSVzXzCDVLEJaEu8ensDzBYREJbY39HKAmIzC0RJrHl1lhHEFhYIkOhZ+pcVxGYRUJX4Mv89 E4jNK2AjceTsISaIbfISqzccAJvDKWAr8enRCbD7JAQWsUs8mvIAqJkDyHGRaF+bCVEvLPHq +BZ2CFtK4mV/G5SdLbHp4U+omQUSR170MkPY9hKtp/qZQcYwC2hKrN+lDxGWlZh6ah0TxMl8 Er2/n0C18krsmAdjq0r8vXebBcKWlrj57iqU7SHRNm0C2HghgQmMEg8fCE5glJuFsGEBI+Mq RsnUguLc9NRi0wLDvNRyeKQl5+duYgSnJy3PHYx3H3zQO8TIxMF4iFGCg1lJhDch+n6SEG9K YmVValF+fFFpTmrxIUZTYPBNZJYSTc4HJsi8knhDE0sDEzMzMxNLYzNDJXFer6ubkoQE0hNL UrNTUwtSi2D6mDg4pRqYWqaf95C2ma6QnLZXeq+pPM+BTT9OzBUsEa94ZpuVe+WTc8vn91PW f2o3PF14pDWMd8vZCvu5pk7fJojovF7hI/iaze+HksBpJ6cV3h31Vb+WmmeXvtp+kmVSo/O9 +lLX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++8syp6627+XJ/uyK/MSnud33mXiazRWFUTpdgWP29yzzvJbUosxRmJhlrMRcWJAElw CHaPAgAA X-CMS-MailID: 20220728093905epcas5p22963dd2dadb73bdabfaffc55cb2edef5 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220728093905epcas5p22963dd2dadb73bdabfaffc55cb2edef5 References: <20220728093327.32580-1-ankit.kumar@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add a few missing fields which was added for uring command Signed-off-by: Ankit Kumar --- src/include/liburing/io_uring.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index 3953807..c923f5c 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -26,6 +26,10 @@ struct io_uring_sqe { union { __u64 off; /* offset into file */ __u64 addr2; + struct { + __u32 cmd_op; + __u32 __pad1; + }; }; union { __u64 addr; /* pointer to buffer or iovecs */ @@ -69,8 +73,17 @@ struct io_uring_sqe { __u16 addr_len; }; }; - __u64 addr3; - __u64 __pad2[1]; + union { + struct { + __u64 addr3; + __u64 __pad2[1]; + }; + /* + * If the ring is initialized with IORING_SETUP_SQE128, then + * this field is used for 80 bytes of arbitrary command data + */ + __u8 cmd[0]; + }; }; /* From patchwork Thu Jul 28 09:33:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12931186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EF55C04A68 for ; Thu, 28 Jul 2022 12:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237088AbiG1MQ3 (ORCPT ); Thu, 28 Jul 2022 08:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235640AbiG1MQ1 (ORCPT ); Thu, 28 Jul 2022 08:16:27 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F2EC52DFB for ; Thu, 28 Jul 2022 05:16:26 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220728121624epoutp04f352d7015e2eef8f38127c717a13b0ef~F-VYoAYjy2114421144epoutp04T for ; Thu, 28 Jul 2022 12:16:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220728121624epoutp04f352d7015e2eef8f38127c717a13b0ef~F-VYoAYjy2114421144epoutp04T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659010584; bh=ixo8XHXbvOE6FhFRDIheWX1l8RdvQY5+Z50btTxzHsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxA77ifoMiuxgZxL5J4IKT9JkrZZfG1Zs2j4pNX98qA43UOoGCt05Ji4AqNs9pYlk 3pECyvCOnNI1BVaM5KkSDnfk1VkUD7p66v/K/KaCMFOPg5REPF+KpVgV/na5kWdVgb 01aAnPMBfWjzv+yNOD951PcMBl6WG1Z0ovL3eHWY= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220728121623epcas5p4945b9794fb0cb1cce21255debe7f597e~F-VYDELR10551505515epcas5p4H; Thu, 28 Jul 2022 12:16:23 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LtqPb5f1bz4x9Pr; Thu, 28 Jul 2022 12:16:19 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.EC.09662.31E72E26; Thu, 28 Jul 2022 21:16:19 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220728093906epcas5p3fb607ddd16054ca7e6cbf26b53306062~F9MDC_j_E2634226342epcas5p3E; Thu, 28 Jul 2022 09:39:06 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220728093906epsmtrp2e7292a413294c57aa95f7db24c544326~F9MDCQhJG3160631606epsmtrp2H; Thu, 28 Jul 2022 09:39:06 +0000 (GMT) X-AuditID: b6c32a49-885ff700000025be-e6-62e27e13ec25 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 27.7B.08802.A3952E26; Thu, 28 Jul 2022 18:39:06 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220728093905epsmtip1e7defd0632d7fc0501cdc90b6f2dd8cf~F9MCOiMZE1284412844epsmtip1H; Thu, 28 Jul 2022 09:39:05 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v3 3/5] nvme: add nvme opcodes, structures and helper functions Date: Thu, 28 Jul 2022 15:03:25 +0530 Message-Id: <20220728093327.32580-4-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220728093327.32580-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCKsWRmVeSWpSXmKPExsWy7bCmuq5w3aM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d1p6zGJRWUFzt9W3/979YhFusdyvv7Wt c8qdTw2rZhtfPPQtboYSS3FGoqEWc1FxIgCUY9SP1wMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsWy7bCSnK5V5KMkg6WTRC3WXPnNbrH6bj+b xbvWcywWR/+/ZXNg8bh8ttSjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4Mja/7WUsuClbcXxj cAPjKbEuRk4OCQETia79O1i6GLk4hAR2MErM+7SXvYuRAyghLbFwfSJEjbDEyn/P2SFqmpkk HqydxAaSYBPQlnj19gYziC0CVLS/o5UFxGYWiJGYeuQwC8gcYYEIiZZtziBhFgFVicu/toKV 8ArYSFzYOIcFYr68xOoNB8DGcArYSnx6dIIRxBYCqnk9aTvTBEa+BYwMqxglUwuKc9Nziw0L jPJSy/WKE3OLS/PS9ZLzczcxgoNHS2sH455VH/QOMTJxMB5ilOBgVhLhTYi+nyTEm5JYWZVa lB9fVJqTWnyIUZqDRUmc90LXyXghgfTEktTs1NSC1CKYLBMHp1QD09Qf+++eXJ//V831xi3f yWZ/9qWZyV3fHZ0Ufi/n513zas6a9TwyZ27tquONvfB6+/95ry4sEpU3PvRQ8l+Ran3c56iU Gf4iVn9fbVl0o2pP063uNX48qcmvF57IzWh7/WHhgr1Lp70vna76se5PYs+ztv3zdz1ZwyF8 oXtZpPhevY9znwcKfjj517TK2C9ryhv3SIEqsbP7wzfNWLpk8rv5zJnXGwylHkad81zta39z ncxib1emiSfOarN89Lu13+KCj+lLr8V9AguNZq1wuLqgSpJNacLRQ36FbyeyKek899mfrTDd sezs/wPbo5h+KrXJzOTc8JpR81Ya43G9x4J2mVpNa03Pn9s0IZdT7uMHJZbijERDLeai4kQA mYJUO40CAAA= X-CMS-MailID: 20220728093906epcas5p3fb607ddd16054ca7e6cbf26b53306062 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220728093906epcas5p3fb607ddd16054ca7e6cbf26b53306062 References: <20220728093327.32580-1-ankit.kumar@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add bare minimum structures and helper functions required for io_uring passthrough commands. This will enable the follow up patch to add tests for nvme-ns generic character device. Signed-off-by: Ankit Kumar --- test/nvme.h | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 test/nvme.h diff --git a/test/nvme.h b/test/nvme.h new file mode 100644 index 0000000..14dc338 --- /dev/null +++ b/test/nvme.h @@ -0,0 +1,168 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: Helpers for NVMe uring passthrough commands + */ +#ifndef LIBURING_NVME_H +#define LIBURING_NVME_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * If the uapi headers installed on the system lacks nvme uring command + * support, use the local version to prevent compilation issues. + */ +#ifndef CONFIG_HAVE_NVME_URING +struct nvme_uring_cmd { + __u8 opcode; + __u8 flags; + __u16 rsvd1; + __u32 nsid; + __u32 cdw2; + __u32 cdw3; + __u64 metadata; + __u64 addr; + __u32 metadata_len; + __u32 data_len; + __u32 cdw10; + __u32 cdw11; + __u32 cdw12; + __u32 cdw13; + __u32 cdw14; + __u32 cdw15; + __u32 timeout_ms; + __u32 rsvd2; +}; + +#define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd) +#define NVME_URING_CMD_IO_VEC _IOWR('N', 0x81, struct nvme_uring_cmd) +#endif /* CONFIG_HAVE_NVME_URING */ + +#define NVME_DEFAULT_IOCTL_TIMEOUT 0 +#define NVME_IDENTIFY_DATA_SIZE 4096 +#define NVME_IDENTIFY_CSI_SHIFT 24 +#define NVME_IDENTIFY_CNS_NS 0 +#define NVME_CSI_NVM 0 + +enum nvme_admin_opcode { + nvme_admin_identify = 0x06, +}; + +enum nvme_io_opcode { + nvme_cmd_write = 0x01, + nvme_cmd_read = 0x02, +}; + +int nsid; +__u32 lba_shift; + +struct nvme_lbaf { + __le16 ms; + __u8 ds; + __u8 rp; +}; + +struct nvme_id_ns { + __le64 nsze; + __le64 ncap; + __le64 nuse; + __u8 nsfeat; + __u8 nlbaf; + __u8 flbas; + __u8 mc; + __u8 dpc; + __u8 dps; + __u8 nmic; + __u8 rescap; + __u8 fpi; + __u8 dlfeat; + __le16 nawun; + __le16 nawupf; + __le16 nacwu; + __le16 nabsn; + __le16 nabo; + __le16 nabspf; + __le16 noiob; + __u8 nvmcap[16]; + __le16 npwg; + __le16 npwa; + __le16 npdg; + __le16 npda; + __le16 nows; + __le16 mssrl; + __le32 mcl; + __u8 msrc; + __u8 rsvd81[11]; + __le32 anagrpid; + __u8 rsvd96[3]; + __u8 nsattr; + __le16 nvmsetid; + __le16 endgid; + __u8 nguid[16]; + __u8 eui64[8]; + struct nvme_lbaf lbaf[16]; + __u8 rsvd192[192]; + __u8 vs[3712]; +}; + +static inline int ilog2(uint32_t i) +{ + int log = -1; + + while (i) { + i >>= 1; + log++; + } + return log; +} + +int nvme_get_info(const char *file) +{ + struct nvme_id_ns ns; + int fd, err; + __u32 lba_size; + + fd = open(file, O_RDONLY); + if (fd < 0) { + perror("file open"); + return -errno; + } + + nsid = ioctl(fd, NVME_IOCTL_ID); + if (nsid < 0) { + close(fd); + return -errno; + } + + struct nvme_passthru_cmd cmd = { + .opcode = nvme_admin_identify, + .nsid = nsid, + .addr = (__u64)(uintptr_t)&ns, + .data_len = NVME_IDENTIFY_DATA_SIZE, + .cdw10 = NVME_IDENTIFY_CNS_NS, + .cdw11 = NVME_CSI_NVM << NVME_IDENTIFY_CSI_SHIFT, + .timeout_ms = NVME_DEFAULT_IOCTL_TIMEOUT, + }; + + err = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd); + if (err) { + close(fd); + return err; + } + + lba_size = 1 << ns.lbaf[(ns.flbas & 0x0f)].ds; + lba_shift = ilog2(lba_size); + + close(fd); + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Thu Jul 28 09:33:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12931199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80FD8C04A68 for ; Thu, 28 Jul 2022 12:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236128AbiG1MQn (ORCPT ); Thu, 28 Jul 2022 08:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235640AbiG1MQm (ORCPT ); Thu, 28 Jul 2022 08:16:42 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9D246DAC for ; Thu, 28 Jul 2022 05:16:38 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220728121636epoutp02f99eee71f2715ef3a43f51445a32b42f~F-Vkf9s3u1026010260epoutp02e for ; Thu, 28 Jul 2022 12:16:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220728121636epoutp02f99eee71f2715ef3a43f51445a32b42f~F-Vkf9s3u1026010260epoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659010597; bh=sE/z3xtqwZWTpBcIaTqpG/3Wq00FT35ZieEKsp9umsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ns9qDqCD5+LeuEzG5HVEjs8coS4URaOnPxwDCBxYWvXzDQF49CO1DWvkE4ASwrjqp dg37Hmf4G1reXa4kDuU7/g46rsHBINt9EJhA31uNlWzakjv59I2z4JaAS4SEDwGOsp PD420dD6OKZzBnSd9v8nST5yrfIFZI4Bs5FQ0e/k= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220728121635epcas5p49c218d5f2a7b74e3202f0ee476c15bed~F-VjatynS0689006890epcas5p4B; Thu, 28 Jul 2022 12:16:35 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4LtqPs3LKsz4x9Q0; Thu, 28 Jul 2022 12:16:33 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 41.7C.09639.F1E72E26; Thu, 28 Jul 2022 21:16:31 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220728093907epcas5p353489ffcc9bed6f3a5c64b4679ad11ee~F9MEbEZuD2636626366epcas5p3C; Thu, 28 Jul 2022 09:39:07 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220728093907epsmtrp175c56156546969e7fe08845060a8721b~F9MEaMIi51674116741epsmtrp1g; Thu, 28 Jul 2022 09:39:07 +0000 (GMT) X-AuditID: b6c32a4b-e83ff700000025a7-3e-62e27e1fd4c5 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CA.56.08905.B3952E26; Thu, 28 Jul 2022 18:39:07 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220728093906epsmtip18d4c3fe109d2677fe1c391386340963a~F9MDKPecr1442314423epsmtip1O; Thu, 28 Jul 2022 09:39:06 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v3 4/5] test: add io_uring passthrough test Date: Thu, 28 Jul 2022 15:03:26 +0530 Message-Id: <20220728093327.32580-5-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220728093327.32580-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmlq583aMkg8n/jS3WXPnNbrH6bj+b xbvWcywWR/+/ZXNg8bh8ttSjb8sqRo/Pm+QCmKOybTJSE1NSixRS85LzUzLz0m2VvIPjneNN zQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOAlikplCXmlAKFAhKLi5X07WyK8ktLUhUy8otLbJVS C1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjNO3t7AWrDRvuLqn2amBsY/+l2MHBwSAiYS Teecuhi5OIQEdjNKbFt7kwnC+cQo8fLiExYI5xujxLWDD4EcTrCOQ6tesEMk9jJKPOi9C+W0 Mkncuv0TrIpNQFvi1dsbzCC2iICwxP6OVrA4s0CUxJpXZxlBbGEBF4l/Lx6xgtgsAqoSfZN/ sIPYvAI2EssfvmKD2CYvsXrDAbA5nAK2Ep8enWAEWSYhsIhd4vzkD6wQRS4Slx4egjpPWOLV 8S3sELaUxMv+Nig7W2LTw59MEHaBxJEXvcwQtr1E66l+ZlBgMAtoSqzfpQ8RlpWYemodE8TN fBK9v59AtfJK7JgHY6tK/L13G2qttMTNd1ehbA+JnYfOsEECZQKjxIc7CxknMMrNQlixgJFx FaNkakFxbnpqsWmBcV5qOTzWkvNzNzGCE5SW9w7GRw8+6B1iZOJgPMQowcGsJMKbEH0/SYg3 JbGyKrUoP76oNCe1+BCjKTAAJzJLiSbnA1NkXkm8oYmlgYmZmZmJpbGZoZI4r9fVTUlCAumJ JanZqakFqUUwfUwcnFINTBo7u4VTzVlm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vCcJXNfx/XrBdeChLrVOe/M+yVb6mkg tPhGZcfExd0t3kvKakXPCvzrC3vCWs9psnOPd1HUjdMzBcOn5XxaEn9MqfBGu73w5ehVEkWH BILfvozQnWB8T3l7Xu4Hxdurymbudnt5xP3wI5k1c9ouHQv0nftWiaU4I9FQi7moOBEAqVqO X48CAAA= X-CMS-MailID: 20220728093907epcas5p353489ffcc9bed6f3a5c64b4679ad11ee X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220728093907epcas5p353489ffcc9bed6f3a5c64b4679ad11ee References: <20220728093327.32580-1-ankit.kumar@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add a way to test uring passthrough commands, which was added with 5.19 kernel. This requires nvme-ns character device (/dev/ngXnY) as filename argument. It runs a combination of read/write tests with sqthread poll, vectored and non-vectored commands, fixed I/O buffers. Tested-by: Kanchan Joshi Signed-off-by: Ankit Kumar --- test/Makefile | 1 + test/io_uring_passthrough.c | 314 ++++++++++++++++++++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 test/io_uring_passthrough.c diff --git a/test/Makefile b/test/Makefile index a36ddb3..418c11c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -90,6 +90,7 @@ test_srcs := \ io-cancel.c \ iopoll.c \ io_uring_enter.c \ + io_uring_passthrough.c \ io_uring_register.c \ io_uring_setup.c \ lfs-openat.c \ diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c new file mode 100644 index 0000000..03043b7 --- /dev/null +++ b/test/io_uring_passthrough.c @@ -0,0 +1,314 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: basic read/write tests for io_uring passthrough commands + */ +#include +#include +#include +#include +#include + +#include "helpers.h" +#include "liburing.h" +#include "nvme.h" + +#define FILE_SIZE (256 * 1024) +#define BS 8192 +#define BUFFERS (FILE_SIZE / BS) + +static struct iovec *vecs; + +/* + * Each offset in the file has the ((test_case / 2) * FILE_SIZE) + * + (offset / sizeof(int)) stored for every + * sizeof(int) address. + */ +static int verify_buf(int tc, void *buf, off_t off) +{ + int i, u_in_buf = BS / sizeof(unsigned int); + unsigned int *ptr; + + off /= sizeof(unsigned int); + off += (tc / 2) * FILE_SIZE; + ptr = buf; + for (i = 0; i < u_in_buf; i++) { + if (off != *ptr) { + fprintf(stderr, "Found %u, wanted %lu\n", *ptr, off); + return 1; + } + ptr++; + off++; + } + + return 0; +} + +static int fill_pattern(int tc) +{ + unsigned int val, *ptr; + int i, j; + int u_in_buf = BS / sizeof(val); + + val = (tc / 2) * FILE_SIZE; + for (i = 0; i < BUFFERS; i++) { + ptr = vecs[i].iov_base; + for (j = 0; j < u_in_buf; j++) { + *ptr = val; + val++; + ptr++; + } + } + + return 0; +} + +static int __test_io(const char *file, struct io_uring *ring, int tc, int read, + int sqthread, int fixed, int nonvec) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct nvme_uring_cmd *cmd; + int open_flags; + int do_fixed; + int i, ret, fd = -1; + off_t offset; + __u64 slba; + __u32 nlb; + +#ifdef VERBOSE + fprintf(stdout, "%s: start %d/%d/%d/%d: ", __FUNCTION__, read, + sqthread, fixed, + nonvec); +#endif + if (read) + open_flags = O_RDONLY; + else + open_flags = O_WRONLY; + + if (fixed) { + ret = t_register_buffers(ring, vecs, BUFFERS); + if (ret == T_SETUP_SKIP) + return 0; + if (ret != T_SETUP_OK) { + fprintf(stderr, "buffer reg failed: %d\n", ret); + goto err; + } + } + + fd = open(file, open_flags); + if (fd < 0) { + perror("file open"); + goto err; + } + + if (sqthread) { + ret = io_uring_register_files(ring, &fd, 1); + if (ret) { + fprintf(stderr, "file reg failed: %d\n", ret); + goto err; + } + } + + if (!read) + fill_pattern(tc); + + offset = 0; + for (i = 0; i < BUFFERS; i++) { + sqe = io_uring_get_sqe(ring); + if (!sqe) { + fprintf(stderr, "sqe get failed\n"); + goto err; + } + if (read) { + int use_fd = fd; + + do_fixed = fixed; + + if (sqthread) + use_fd = 0; + if (fixed && (i & 1)) + do_fixed = 0; + if (do_fixed) { + io_uring_prep_read_fixed(sqe, use_fd, vecs[i].iov_base, + vecs[i].iov_len, + offset, i); + sqe->cmd_op = NVME_URING_CMD_IO; + } else if (nonvec) { + io_uring_prep_read(sqe, use_fd, vecs[i].iov_base, + vecs[i].iov_len, offset); + sqe->cmd_op = NVME_URING_CMD_IO; + } else { + io_uring_prep_readv(sqe, use_fd, &vecs[i], 1, + offset); + sqe->cmd_op = NVME_URING_CMD_IO_VEC; + } + } else { + int use_fd = fd; + + do_fixed = fixed; + + if (sqthread) + use_fd = 0; + if (fixed && (i & 1)) + do_fixed = 0; + if (do_fixed) { + io_uring_prep_write_fixed(sqe, use_fd, vecs[i].iov_base, + vecs[i].iov_len, + offset, i); + sqe->cmd_op = NVME_URING_CMD_IO; + } else if (nonvec) { + io_uring_prep_write(sqe, use_fd, vecs[i].iov_base, + vecs[i].iov_len, offset); + sqe->cmd_op = NVME_URING_CMD_IO; + } else { + io_uring_prep_writev(sqe, use_fd, &vecs[i], 1, + offset); + sqe->cmd_op = NVME_URING_CMD_IO_VEC; + } + } + sqe->opcode = IORING_OP_URING_CMD; + sqe->user_data = ((uint64_t)offset << 32) | i; + if (sqthread) + sqe->flags |= IOSQE_FIXED_FILE; + + cmd = (struct nvme_uring_cmd *)sqe->cmd; + memset(cmd, 0, sizeof(struct nvme_uring_cmd)); + + cmd->opcode = read ? nvme_cmd_read : nvme_cmd_write; + + slba = offset >> lba_shift; + nlb = (BS >> lba_shift) - 1; + + /* cdw10 and cdw11 represent starting lba */ + cmd->cdw10 = slba & 0xffffffff; + cmd->cdw11 = slba >> 32; + /* cdw12 represent number of lba's for read/write */ + cmd->cdw12 = nlb; + if (do_fixed || nonvec) { + cmd->addr = (__u64)(uintptr_t)vecs[i].iov_base; + cmd->data_len = vecs[i].iov_len; + } else { + cmd->addr = (__u64)(uintptr_t)&vecs[i]; + cmd->data_len = 1; + } + cmd->nsid = nsid; + + offset += BS; + } + + ret = io_uring_submit(ring); + if (ret != BUFFERS) { + fprintf(stderr, "submit got %d, wanted %d\n", ret, BUFFERS); + goto err; + } + + for (i = 0; i < BUFFERS; i++) { + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "wait_cqe=%d\n", ret); + goto err; + } + if (cqe->res != 0) { + fprintf(stderr, "cqe res %d, wanted 0\n", cqe->res); + goto err; + } + io_uring_cqe_seen(ring, cqe); + if (read) { + int index = cqe->user_data & 0xffffffff; + void *buf = vecs[index].iov_base; + off_t voff = cqe->user_data >> 32; + + if (verify_buf(tc, buf, voff)) + goto err; + } + } + + if (fixed) { + ret = io_uring_unregister_buffers(ring); + if (ret) { + fprintf(stderr, "buffer unreg failed: %d\n", ret); + goto err; + } + } + if (sqthread) { + ret = io_uring_unregister_files(ring); + if (ret) { + fprintf(stderr, "file unreg failed: %d\n", ret); + goto err; + } + } + + close(fd); +#ifdef VERBOSE + fprintf(stdout, "PASS\n"); +#endif + return 0; +err: +#ifdef VERBOSE + fprintf(stderr, "FAILED\n"); +#endif + if (fd != -1) + close(fd); + return 1; +} + +static int test_io(const char *file, int tc, int read, int sqthread, + int fixed, int nonvec) +{ + struct io_uring ring; + int ret, ring_flags = 0; + + ring_flags |= IORING_SETUP_SQE128; + ring_flags |= IORING_SETUP_CQE32; + + if (sqthread) + ring_flags |= IORING_SETUP_SQPOLL; + + ret = t_create_ring(64, &ring, ring_flags); + if (ret == T_SETUP_SKIP) + return 0; + if (ret != T_SETUP_OK) { + fprintf(stderr, "ring create failed: %d\n", ret); + return 1; + } + + ret = __test_io(file, &ring, tc, read, sqthread, fixed, nonvec); + io_uring_queue_exit(&ring); + + return ret; +} + +int main(int argc, char *argv[]) +{ + int i, ret; + char *fname; + + if (argc < 2) + return T_EXIT_SKIP; + + fname = argv[1]; + ret = nvme_get_info(fname); + + if (ret) + return T_EXIT_SKIP; + + vecs = t_create_buffers(BUFFERS, BS); + + for (i = 0; i < 16; i++) { + int read = (i & 1) != 0; + int sqthread = (i & 2) != 0; + int fixed = (i & 4) != 0; + int nonvec = (i & 8) != 0; + + ret = test_io(fname, i, read, sqthread, fixed, nonvec); + if (ret) { + fprintf(stderr, "test_io failed %d/%d/%d/%d\n", + read, sqthread, fixed, nonvec); + goto err; + } + } + + return T_EXIT_PASS; +err: + return T_EXIT_FAIL; +} From patchwork Thu Jul 28 09:33:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12931200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1ECDC19F29 for ; Thu, 28 Jul 2022 12:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236416AbiG1MQx (ORCPT ); Thu, 28 Jul 2022 08:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237841AbiG1MQv (ORCPT ); Thu, 28 Jul 2022 08:16:51 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F51E65814 for ; Thu, 28 Jul 2022 05:16:50 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220728121648epoutp0133d9f03dd198db307ef4a523c5cc25c3~F-Vvi2-d90977209772epoutp01m for ; Thu, 28 Jul 2022 12:16:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220728121648epoutp0133d9f03dd198db307ef4a523c5cc25c3~F-Vvi2-d90977209772epoutp01m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659010608; bh=xItjwbmIKrRiHs1GBAuxCOnNwKcVUUkDgc8KDr5FcQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qj6ztXzFmbQpyv1aA3ZdVMT1kgPyB9uoEW3VDxekw7Klq5k/ucI7qBYh5kCe0PVEY wbozLSSP4/skCx2PyjmB9+8ebbOzTEc+g6pP7S69zq4S2eqJNCn1zFMy+R597b7hHK dcKDPYMD8YLk03aaPM6EshpsLu0gsGBm5h5hZ3zI= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220728121648epcas5p3bff19ffabd528a83b71233e7b2d71536~F-VvBQBRE2339023390epcas5p3q; Thu, 28 Jul 2022 12:16:48 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LtqQ53SPcz4x9Pr; Thu, 28 Jul 2022 12:16:45 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id FA.7C.09639.D2E72E26; Thu, 28 Jul 2022 21:16:45 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220728093908epcas5p4d6318b0f037f0ccf9e5422b6b63f217c~F9MFSI5VV0692706927epcas5p4o; Thu, 28 Jul 2022 09:39:08 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220728093908epsmtrp2818206cd9171c9162f83aeb2be0a6601~F9MFRe9DP3160531605epsmtrp2K; Thu, 28 Jul 2022 09:39:08 +0000 (GMT) X-AuditID: b6c32a4b-e6dff700000025a7-5f-62e27e2dcb63 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E7.7B.08802.C3952E26; Thu, 28 Jul 2022 18:39:08 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220728093908epsmtip11a075fc62b19405ef923983b659001b0~F9MEg2YBT1332713327epsmtip1t; Thu, 28 Jul 2022 09:39:07 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v3 5/5] test/io_uring_passthrough: add test case for poll IO Date: Thu, 28 Jul 2022 15:03:27 +0530 Message-Id: <20220728093327.32580-6-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220728093327.32580-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOKsWRmVeSWpSXmKPExsWy7bCmuq5u3aMkgwc9EhZrrvxmt1h9t5/N 4l3rORaLo//fsjmweFw+W+rRt2UVo8fnTXIBzFHZNhmpiSmpRQqpecn5KZl56bZK3sHxzvGm ZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAy5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqp BSk5BSYFesWJucWleel6eaklVoYGBkamQIUJ2Rmbe7axF6wTrZg1fw5TA+N7gS5GTg4JAROJ CQ1HGLsYuTiEBHYzSjx4epoNwvnEKDH5SDsLhPOZUWLplxVsMC3PJi5mhkjsYpTYMGU+E4TT yiSxfnEPE0gVm4C2xKu3N5hBbBEBYYn9Ha0sIDazQJTEmldnGUFsYYFwiQlNvWD1LAKqEr8O XQTbwCtgI3H9cicjxDZ5idUbDoDN4RSwlfj06ATYsRICi9glljY8Y4YocpFofnaEFcIWlnh1 fAs7hC0l8fndXqizsyU2PfzJBGEXSBx50QvVay/ReqofyOYAOk5TYv0ufYiwrMTUU+uYIG7m k+j9/QSqlVdixzwYW1Xi773bLBC2tM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djBcSSE8sSc1OTS1ILYLJMnFwSjUwKWdwmCWzr0k2X9haKyjo muo4o0/d5MqVH62pNpHuy8RD5k2WWbzDodP/3xW1s79vz+gu/nFl9n9P84Xqj9aIi3yTl5/O anp+dSev0ta1E1/POeExM2vBj2DdneJ+SbMNM396fJ6jlcO75FTv3fjrKzIsXFNdz0hcL0zt f3o3mMnxlvcHuxvyq6J2vnLb9jZANqjDcs31xxydyounn3XgeSzx7Zt/98kjzgmNTCeN+WSl LBb5O73uFS3NeeNUdF4ud+rFBVGGiU8vubzi+clq7bLubJxye36Yemqm2fEthpZFdzycFNwn SMktcnf6ELzwz9PFMkdvfdE1njOr1ZTP7+qq8J9iJqaSLCe6E84osRRnJBpqMRcVJwIApM3m vI8CAAA= X-CMS-MailID: 20220728093908epcas5p4d6318b0f037f0ccf9e5422b6b63f217c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220728093908epcas5p4d6318b0f037f0ccf9e5422b6b63f217c References: <20220728093327.32580-1-ankit.kumar@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org For uring passthrough add test case for poll IO completion. If poll IO is not supported return success. Tested-by: Kanchan Joshi Signed-off-by: Ankit Kumar --- test/io_uring_passthrough.c | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c index 03043b7..d4a2169 100644 --- a/test/io_uring_passthrough.c +++ b/test/io_uring_passthrough.c @@ -10,6 +10,7 @@ #include "helpers.h" #include "liburing.h" +#include "../src/syscall.h" #include "nvme.h" #define FILE_SIZE (256 * 1024) @@ -278,6 +279,75 @@ static int test_io(const char *file, int tc, int read, int sqthread, return ret; } +extern int __io_uring_flush_sq(struct io_uring *ring); + +/* + * if we are polling io_uring_submit needs to always enter the + * kernel to fetch events + */ +static int test_io_uring_submit_enters(const char *file) +{ + struct io_uring ring; + int fd, i, ret, ring_flags, open_flags; + unsigned head; + struct io_uring_cqe *cqe; + + ring_flags = IORING_SETUP_IOPOLL; + ring_flags |= IORING_SETUP_SQE128; + ring_flags |= IORING_SETUP_CQE32; + + ret = io_uring_queue_init(64, &ring, ring_flags); + if (ret) { + fprintf(stderr, "ring create failed: %d\n", ret); + return 1; + } + + open_flags = O_WRONLY; + fd = open(file, open_flags); + if (fd < 0) { + perror("file open"); + goto err; + } + + for (i = 0; i < BUFFERS; i++) { + struct io_uring_sqe *sqe; + off_t offset = BS * (rand() % BUFFERS); + + sqe = io_uring_get_sqe(&ring); + io_uring_prep_writev(sqe, fd, &vecs[i], 1, offset); + sqe->user_data = 1; + } + + /* submit manually to avoid adding IORING_ENTER_GETEVENTS */ + ret = __sys_io_uring_enter(ring.ring_fd, __io_uring_flush_sq(&ring), 0, + 0, NULL); + if (ret < 0) + goto err; + + for (i = 0; i < 500; i++) { + ret = io_uring_submit(&ring); + if (ret != 0) { + fprintf(stderr, "still had %d sqes to submit, this is unexpected", ret); + goto err; + } + + io_uring_for_each_cqe(&ring, head, cqe) { + if (cqe->res == -EOPNOTSUPP) + fprintf(stdout, "Device doesn't support polled IO\n"); + goto ok; + } + usleep(10000); + } +err: + ret = 1; + if (fd != -1) + close(fd); + +ok: + io_uring_queue_exit(&ring); + return ret; +} + int main(int argc, char *argv[]) { int i, ret; @@ -308,6 +378,12 @@ int main(int argc, char *argv[]) } } + ret = test_io_uring_submit_enters(fname); + if (ret) { + fprintf(stderr, "test_io_uring_submit_enters failed\n"); + goto err; + } + return T_EXIT_PASS; err: return T_EXIT_FAIL;