From patchwork Tue Jul 26 10:52: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: 12929176 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 F3D9FC43334 for ; Tue, 26 Jul 2022 11:50:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237582AbiGZLux (ORCPT ); Tue, 26 Jul 2022 07:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbiGZLux (ORCPT ); Tue, 26 Jul 2022 07:50:53 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 327B432DBF for ; Tue, 26 Jul 2022 04:50:51 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220726115046epoutp014b2f6636d69cf43a1af995c282d66cb8~FXsboFI1u0603106031epoutp01O for ; Tue, 26 Jul 2022 11:50:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220726115046epoutp014b2f6636d69cf43a1af995c282d66cb8~FXsboFI1u0603106031epoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658836246; bh=GaFMiezcC/Oe0p+cfmaYFu1JQYpckb58+h9LHvgAYKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G6rUCRvfTA1fYpWtRxvaijkqu/bXQC3B55c5QrHwPfjrsY7rOKQD5jYeydaIsrFMS hNzxV1UXIu4F61pLjAFgluMwCMqoSCSqtFp/mcnO+zIV9xU0720gGYTN73gTW3ca75 P32CW96InC2+tnE7DJUWAv9wWZBI0ZXgW4JacQWk= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220726115045epcas5p2fb1d6de1f996d5244130cc99b07089b7~FXsbaCMTq0568605686epcas5p25; Tue, 26 Jul 2022 11:50:45 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4LsZwz109mz4x9Pv; Tue, 26 Jul 2022 11:50:43 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BB.CE.09662.F05DFD26; Tue, 26 Jul 2022 20:50:39 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220726105813epcas5p44c4058c9d3e9332ef939dbbb9a052738~FW_jeho7f2203422034epcas5p46; Tue, 26 Jul 2022 10:58:13 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220726105813epsmtrp2e1739a33789c0046949f0b5502880d15~FW_jd6JxZ3043430434epsmtrp2W; Tue, 26 Jul 2022 10:58:13 +0000 (GMT) X-AuditID: b6c32a49-86fff700000025be-1c-62dfd50fd88f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FF.D9.08905.5C8CFD26; Tue, 26 Jul 2022 19:58:13 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220726105812epsmtip1baa3c7077a243fdeae17fea01d54b1e5~FW_isxgU-1956619566epsmtip1C; Tue, 26 Jul 2022 10:58:12 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v2 1/5] configure: check for nvme uring command support Date: Tue, 26 Jul 2022 16:22:26 +0530 Message-Id: <20220726105230.12025-2-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220726105230.12025-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCKsWRmVeSWpSXmKPExsWy7bCmhi7/1ftJBnOmWlisufKb3WL13X42 i3et51gsjv5/y+bA4nH5bKlH35ZVjB6fN8kFMEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8eb mhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYALVNSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2Cql FqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGfsfzSftWAWV8WWhRYNjPs5uhg5OCQETCQW LrHsYuTiEBLYzSjx9OZMFgjnE6PEoenP2LsYOYGcb4wSm9f5gNggDS+n3mOGKNrLKNH7/BEj hNPKJLFuZg8LSBWbgLbEq7c3mEFsEQFhif0drWBxZoEoiTWvzjKC2MICQRJ3LywG28AioCox v3E9K4jNK2Aj8bb9FBvENnmJ1RsOgM3hFLCVaHo5hRVkmYTAInaJ+W2nWSGKXCQOTnvEAmEL S7w6voUdwpaS+PxuL9SgbIlND38yQdgFEkde9DJD2PYSraf6mUFhwSygKbF+lz5EWFZi6ql1 TBA380n0/n4C1corsWMejK0q8ffebai10hI3312Fsj0kGj+9ggbjBEaJPQemsExglJuFsGIB I+MqRsnUguLc9NRi0wLDvNRyeJwl5+duYgQnJy3PHYx3H3zQO8TIxMF4iFGCg1lJhDch+n6S EG9KYmVValF+fFFpTmrxIUZTYABOZJYSTc4Hpse8knhDE0sDEzMzMxNLYzNDJXFer6ubkoQE 0hNLUrNTUwtSi2D6mDg4pRqY5r486mkRtmSvRWHyB76ApvUzcmPOrLmayX0icdsTw1mLm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wklnnq3umMyUl1f5hmVtqvOp+Tpcq+eJzGO5dve425Tdmx6rRrEH54WVOTg/2tSe 31OtdVjD/B1vgcTP+Veywk4/ZjCKcby4fknEsW32Oq98WZqKJsopsRRnJBpqMRcVJwIAEbs4 xI4CAAA= X-CMS-MailID: 20220726105813epcas5p44c4058c9d3e9332ef939dbbb9a052738 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220726105813epcas5p44c4058c9d3e9332ef939dbbb9a052738 References: <20220726105230.12025-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 Tue Jul 26 10:52: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: 12929177 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 4E576C43334 for ; Tue, 26 Jul 2022 11:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbiGZLvF (ORCPT ); Tue, 26 Jul 2022 07:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiGZLvE (ORCPT ); Tue, 26 Jul 2022 07:51:04 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EBEE32EC3 for ; Tue, 26 Jul 2022 04:50:58 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220726115055epoutp02f1ad338b3a6d8cd1c388bf0077c6c609~FXskclHID1333813338epoutp02P for ; Tue, 26 Jul 2022 11:50:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220726115055epoutp02f1ad338b3a6d8cd1c388bf0077c6c609~FXskclHID1333813338epoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658836255; bh=BbbSWEM1xsOG1dLNo8znd6zXYJk4jY/HHeirk2IeknA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MM3leesZpAyOXUuyL4aoFvOWs26VQUw792EEZGo27o941QpSzIhdD93C/Pi9e5qDV OXW47ydOrpRNovnrvi1JxBfGrTsJdwp7W6iZAuGA3De66kt1eoG3ESNWyHhLMz0O73 FF5UhlHIMCxwuSCuWiGdAv2cf8sy+5xUQDPzp/6c= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220726115055epcas5p1683dafeac76e0faefc591bfd66392d4d~FXskKY1tS2883728837epcas5p1I; Tue, 26 Jul 2022 11:50:55 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4LsZx82lDPz4x9Q9; Tue, 26 Jul 2022 11:50:52 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id D6.D9.09639.715DFD26; Tue, 26 Jul 2022 20:50:47 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220726105814epcas5p4b454a04c6f7befa23788b5a6bf3031c3~FW_kf06oc1109211092epcas5p4B; Tue, 26 Jul 2022 10:58:14 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220726105814epsmtrp202dbfe63d8a56e1d3669a898fa36c6ae~FW_kea03G3043430434epsmtrp2X; Tue, 26 Jul 2022 10:58:14 +0000 (GMT) X-AuditID: b6c32a4b-e6dff700000025a7-cb-62dfd517b511 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 31.6E.08802.6C8CFD26; Tue, 26 Jul 2022 19:58:14 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220726105813epsmtip14c47e17146478e3c5d65bcf811ede824~FW_jydzvg1956919569epsmtip10; Tue, 26 Jul 2022 10:58:13 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v2 2/5] io_uring.h: sync sqe entry with 5.20 io_uring Date: Tue, 26 Jul 2022 16:22:27 +0530 Message-Id: <20220726105230.12025-3-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220726105230.12025-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmuq741ftJBgc/SVusufKb3WL13X42 i3et51gsjv5/y+bA4nH5bKlH35ZVjB6fN8kFMEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8eb mhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYALVNSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2Cql FqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGdM33WKqaCDo+L2pFPsDYyT2boYOTkkBEwk NjVdYgWxhQR2M0r8OBDWxcgFZH9ilOjft5IRwvnMKDF1YQMLTMeq9plsEIldjBJXHu5khXBa mSTaZ95hAqliE9CWePX2BjOILSIgLLG/oxWsm1kgSmLNq7OMILawQIDExXtHwGpYBFQlft1c DHYTr4CNxNRLrVD3yUus3nAArIZTwFai6eUUsGUSAvPYJW4+WMAOUeQi8fbMeqgGYYlXx7dA xaUkPr/bCxXPltj08CcThF0gceRFLzOEbS/ReqofyOYAOk5TYv0ufYiwrMTUU+uYIG7mk+j9 /QSqlVdixzwYW1Xi773b0FCRlrj57iqU7SHRNWclNFAmMEr0dfewTmCUm4WwYgEj4ypGydSC 4tz01GLTAuO81HJ4rCXn525iBCcoLe8djI8efNA7xMjEwXiIUYKDWUmENyH6fpIQb0piZVVq UX58UWlOavEhRlNgAE5klhJNzgemyLySeEMTSwMTMzMzE0tjM0MlcV6vq5uShATSE0tSs1NT C1KLYPqYODilGpgOnY5J37qkMGpFNIdQwxfreS2r9WtKZa+IT3v04fzFnfNKEyIqj+9uXfrn +7GOv0vPhnHsvHj9/py23kQtm4YlnsnCG7LuveN6uurdmr0Gyg/7n+VN+b/EtOdAso2XKoOZ 3tuPObPS0r5wRbe/ZD3Y8K43bMnj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QiaU4I9FQi7moOBEAbVBA8I4C AAA= X-CMS-MailID: 20220726105814epcas5p4b454a04c6f7befa23788b5a6bf3031c3 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220726105814epcas5p4b454a04c6f7befa23788b5a6bf3031c3 References: <20220726105230.12025-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 Tue Jul 26 10:52:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12929178 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 79990C43334 for ; Tue, 26 Jul 2022 11:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232759AbiGZLvL (ORCPT ); Tue, 26 Jul 2022 07:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238919AbiGZLvK (ORCPT ); Tue, 26 Jul 2022 07:51:10 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AE432ED9 for ; Tue, 26 Jul 2022 04:51:09 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220726115106epoutp0448a61d55bb96f7445c68f75a82606d1f~FXsurH1Dx0128801288epoutp047 for ; Tue, 26 Jul 2022 11:51:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220726115106epoutp0448a61d55bb96f7445c68f75a82606d1f~FXsurH1Dx0128801288epoutp047 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658836266; bh=8ZRJ2yAa5YlNjP+lRsTxBfnnFz5zvSEZd11Xx72zjSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPpNidHOaAR/KUb6hETdBwDHLfU2xN5LYbT0jy+fT079pl3H+aXGzNz0EkQmhlQlB ZOXF7krU7gETdpIAyDqGdz/vkl7IXtXxfkBN32nNUxL58cqRqgREHEPNLiCONUfi1i Q9kp8F7WgfZ77IJrbFjrABihAhjbA0Jfy1o/LQxE= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220726115105epcas5p1af17983335de3e7e3cc779ca7dd6b58e~FXsuDksnq2881828818epcas5p1h; Tue, 26 Jul 2022 11:51:05 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.175]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4LsZxM2w4fz4x9Pt; Tue, 26 Jul 2022 11:51:03 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 92.58.09566.525DFD26; Tue, 26 Jul 2022 20:51:01 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220726105815epcas5p2e19ff2fe748cfeb69517124370de3b7f~FW_lu3TMZ3232132321epcas5p20; Tue, 26 Jul 2022 10:58:15 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220726105815epsmtrp11363e7f0314d62473ab7076b6c87a3e5~FW_luTVcI0116501165epsmtrp1Z; Tue, 26 Jul 2022 10:58:15 +0000 (GMT) X-AuditID: b6c32a4a-ba3ff7000000255e-3a-62dfd52518b5 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 90.E9.08905.7C8CFD26; Tue, 26 Jul 2022 19:58:15 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220726105815epsmtip1cfe10782a0c3effe98f87a22e2d7d254~FW_lAQ16b1956519565epsmtip1G; Tue, 26 Jul 2022 10:58:14 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v2 3/5] nvme: add nvme opcodes, structures and helper functions Date: Tue, 26 Jul 2022 16:22:28 +0530 Message-Id: <20220726105230.12025-4-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220726105230.12025-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmuq7q1ftJBocbpS3WXPnNbrH6bj+b xbvWcywWR/+/ZXNg8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bijERDLeai4kQAuUnJzdkDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDJMWRmVeSWpSXmKPExsWy7bCSnO7xE/eTDD6+NbZYc+U3u8Xqu/1s Fu9az7FYHP3/ls2BxePy2VKPvi2rGD0+b5ILYI7isklJzcksSy3St0vgyljz8iVjwUa5ilnb DrE2MM4S72Lk5JAQMJF4vP8qexcjF4eQwG5GiY0nJgA5HEAJaYmF6xMhaoQlVv57DlXTzCTx 8fojZpAEm4C2xKu3N8BsEaCi/R2tLCA2s0CMxNQjh8FsYYEIiRnr3jKC2CwCqhJ/b5xnB7F5 BWwkrrzcyAaxQF5i9YYDYHM4BWwlml5OYQWxhYBq/h46xjaBkW8BI8MqRsnUguLc9NxiwwLD vNRyveLE3OLSvHS95PzcTYzgANLS3MG4fdUHvUOMTByMhxglOJiVRHgTou8nCfGmJFZWpRbl xxeV5qQWH2KU5mBREue90HUyXkggPbEkNTs1tSC1CCbLxMEp1cDEniH5MapMtlVXa9v+nH9M 5hHbN+/If+qT1JT56b+YybuUR9wHClmYbGc86N1Z6b9lYfjOJWXnS70Orssv/TlBR7jPIOt9 UvSyNZ9FBa5n8Uos6Ci+zF71Jnleee9yPoHCUP7kS2ayUfO/3+k9ITtzY/TjjMLD03c/uzF3 le76imiDPyHVb5LXrxYxr/Yy+FIddP/aZY5m+fP2+6XDzn+ylXn89MGj017dHz8wsfJU5Yqc Tz4V1Pmv9Jfxc9a2cz6bfh51CfePvfuw9UmSePOvKd2pE7fU3V0wK2C+8qmnKt0yN8K28e/L bA09ZuXr5vPo1veTAvxzmQXWTingdi6ez9o3o3DNK62ym948Sw2UWIozEg21mIuKEwEyvMj3 jwIAAA== X-CMS-MailID: 20220726105815epcas5p2e19ff2fe748cfeb69517124370de3b7f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220726105815epcas5p2e19ff2fe748cfeb69517124370de3b7f References: <20220726105230.12025-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..866a7e6 --- /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 fio_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) + return -errno; + + nsid = ioctl(fd, NVME_IOCTL_ID); + if (nsid < 0) { + fprintf(stderr, "failed to fetch namespace-id\n"); + 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) { + fprintf(stderr, "failed to fetch identify namespace\n"); + 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 Tue Jul 26 10:52:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12929179 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 29740C43334 for ; Tue, 26 Jul 2022 11:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231473AbiGZLvZ (ORCPT ); Tue, 26 Jul 2022 07:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbiGZLvY (ORCPT ); Tue, 26 Jul 2022 07:51:24 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95A0932ED1 for ; Tue, 26 Jul 2022 04:51:21 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220726115120epoutp04f2bd0dc85582b2df4a084879497d7f2b~FXs7QGTf83212932129epoutp04i for ; Tue, 26 Jul 2022 11:51:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220726115120epoutp04f2bd0dc85582b2df4a084879497d7f2b~FXs7QGTf83212932129epoutp04i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658836280; bh=kx85pLS45GqWj2EfzdAuR6iDYDiGVWfmEvcTBt7REaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vu+HWC+09Dj3TkiN3NGENw0e4gZOP2TSkMVE6xIfOTs3iPgOTDnAWZ4pMqP22rO6g 5INYvj2hA/dLleyZbX/4b5PtrpRXQeEETrj3Qtd7xn5Ib9Y9zprPySzSVTzeZX3Fua CJp1GWZy98RhIawJzQ17tt0/3axmV0rnK6nViJ8g= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220726115119epcas5p38a9a9c61c64c78d4121cf8c0d8281583~FXs6phRkW3057330573epcas5p31; Tue, 26 Jul 2022 11:51:19 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4LsZxc4HkKz4x9Q0; Tue, 26 Jul 2022 11:51:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8F.E9.09639.135DFD26; Tue, 26 Jul 2022 20:51:13 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220726105816epcas5p3365fed54f9ba20518dd8019a50c6c27c~FW_ml1qfp2226722267epcas5p3W; Tue, 26 Jul 2022 10:58:16 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220726105816epsmtrp271e819bf9253d5cf0c708b35dd8b50f7~FW_mkvMI93043430434epsmtrp2a; Tue, 26 Jul 2022 10:58:16 +0000 (GMT) X-AuditID: b6c32a4b-e83ff700000025a7-26-62dfd531dfb1 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E2.6E.08802.8C8CFD26; Tue, 26 Jul 2022 19:58:16 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220726105816epsmtip157fcf9dbb6646880d7ab204b8b580bbb~FW_l1Cbdh2376423764epsmtip1E; Tue, 26 Jul 2022 10:58:15 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v2 4/5] test: add io_uring passthrough test Date: Tue, 26 Jul 2022 16:22:29 +0530 Message-Id: <20220726105230.12025-5-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220726105230.12025-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmlq7h1ftJBge/q1isufKb3WL13X42 i3et51gsjv5/y+bA4nH5bKlH35ZVjB6fN8kFMEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8eb mhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYALVNSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2Cql FqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGf8nN3OUrDboeLT9E62BsbHBl2MnBwSAiYS J0+2MHYxcnEICexmlNjReo4JwvnEKNE0czUrhPOZUWJ932RWmJa9F/uYIRK7GCXaFp9iB0kI CbQySTz5BjaXTUBb4tXbG8wgtoiAsMT+jlYWEJtZIEpizauzjCC2sICLRMPSZWwgNouAqsSp Y1vA4rwCNhKfenZALZOXWL3hANgcTgFbiaaXU8AukhBYxC7x8OcOJogiF4kZk46zQdjCEq+O b2GHsKUkPr/bCxXPltj08CdUfYHEkRe9zBC2vUTrqX4gmwPoOE2J9bv0IcKyElNPrWOCuJlP ovf3E6hWXokd82BsVYm/926zQNjSEjffXYWyPSTObjsEDcYJjBIH7yxmmcAoNwthxQJGxlWM kqkFxbnpqcWmBcZ5qeXwWEvOz93ECE5QWt47GB89+KB3iJGJg/EQowQHs5IIb0L0/SQh3pTE yqrUovz4otKc1OJDjKbAAJzILCWanA9MkXkl8YYmlgYmZmZmJpbGZoZK4rxeVzclCQmkJ5ak ZqemFqQWwfQxcXBKNTBxiP/Nmuu8YtMbF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nJZ6MmOnza+n8u96H0LbIu0yQrlJeeeRuV +DzVc3dbcsCNhft/MXM7n/HOjrztUprmdt9vzfSKCdMZK3xc6wI/Knbes576Ry1Bl+3r3HXf vB3D0t8xih56m9rRrtp+aEnhV3bORcqn/l+q2vD/6PKb60RiJj1WYinOSDTUYi4qTgQAK9P7 Vo8CAAA= X-CMS-MailID: 20220726105816epcas5p3365fed54f9ba20518dd8019a50c6c27c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220726105816epcas5p3365fed54f9ba20518dd8019a50c6c27c References: <20220726105230.12025-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. Signed-off-by: Ankit Kumar Reviewed-by: Kanchan Joshi --- test/Makefile | 1 + test/io_uring_passthrough.c | 319 ++++++++++++++++++++++++++++++++++++ 2 files changed, 320 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..2e2b806 --- /dev/null +++ b/test/io_uring_passthrough.c @@ -0,0 +1,319 @@ +/* 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; + + /* 80 bytes for NVMe uring passthrough command */ + 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) { + printf("%s: requires NVMe character device\n", argv[0]); + return T_EXIT_SKIP; + } + + fname = argv[1]; + ret = fio_nvme_get_info(fname); + + if (ret) { + fprintf(stderr, "failed to fetch device info: %d\n", ret); + goto err; + } + + 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 Tue Jul 26 10:52:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Kumar X-Patchwork-Id: 12929180 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 143A1C433EF for ; Tue, 26 Jul 2022 11:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232850AbiGZLvt (ORCPT ); Tue, 26 Jul 2022 07:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiGZLvr (ORCPT ); Tue, 26 Jul 2022 07:51:47 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A14532EEF for ; Tue, 26 Jul 2022 04:51:43 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220726115142epoutp02ac0e94c2bd0f0268865cc200390157b5~FXtP-r47_1280612806epoutp02u for ; Tue, 26 Jul 2022 11:51:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220726115142epoutp02ac0e94c2bd0f0268865cc200390157b5~FXtP-r47_1280612806epoutp02u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658836302; bh=V6kCFEnNmUA65C9BXm3wlYHngtC9W67zIvUb4TG3zS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRpOYrmzCMF+2nHVHESDU0xuWecG9O56eUzXLC4GIZz90nAm5RrkO8bZymB9K+7WC rgdGvFRwWBLGVLejgVRNCbALNcpMrJXYZz1P/erFtjb/DkjeeWWwmvw1AfUGAlSrla Te28YirEHKmfcWsvCl01g4P3xCDAVGemH4vGch0w= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220726115141epcas5p4d09348f5b00833c217e671a2b47753c7~FXtPBZj211440814408epcas5p4z; Tue, 26 Jul 2022 11:51:41 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4LsZy1691yz4x9Pp; Tue, 26 Jul 2022 11:51:37 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 9C.F9.09639.345DFD26; Tue, 26 Jul 2022 20:51:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220726105817epcas5p450a87008879689894b187924a854d513~FW_nbIhiy2203422034epcas5p4F; Tue, 26 Jul 2022 10:58:17 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220726105817epsmtrp26072304396871fa51dfcf96784e98af1~FW_naho-E3043430434epsmtrp2c; Tue, 26 Jul 2022 10:58:17 +0000 (GMT) X-AuditID: b6c32a4b-e6dff700000025a7-68-62dfd5435238 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 53.6E.08802.9C8CFD26; Tue, 26 Jul 2022 19:58:17 +0900 (KST) Received: from test-zns.sa.corp.samsungelectronics.net (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220726105816epsmtip12f38265ec35e873037f5e1e7b71e91cb~FW_mqkNgA1956919569epsmtip11; Tue, 26 Jul 2022 10:58:16 +0000 (GMT) From: Ankit Kumar To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, joshi.k@samsung.com, Ankit Kumar Subject: [PATCH liburing v2 5/5] test/io_uring_passthrough: add test case for poll IO Date: Tue, 26 Jul 2022 16:22:30 +0530 Message-Id: <20220726105230.12025-6-ankit.kumar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220726105230.12025-1-ankit.kumar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOKsWRmVeSWpSXmKPExsWy7bCmpq7z1ftJBtdaxC3WXPnNbrH6bj+b xbvWcywWR/+/ZXNg8bh8ttSjb8sqRo/Pm+QCmKOybTJSE1NSixRS85LzUzLz0m2VvIPjneNN zQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOAlikplCXmlAKFAhKLi5X07WyK8ktLUhUy8otLbJVS C1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjOeH97NXPBdpOLZiQXsDYz7BLoYOTkkBEwk ejccYe9i5OIQEtjNKNF1ewoLhPOJUWLOuwYmCOczo8TVCXfYYFqOfz7JDJHYxSjxfMJ6Rgin lUli4tbn7CBVbALaEq/e3mAGsUUEhCX2d7SygNjMAlESa16dZQSxhQXCJX7cWsUEYrMIqEq8 eb+QFcTmFbCRWHinH2qbvMTqDQfA5nAK2Eo0vZzCCrJMQmARu8TPuceZIIpcJI69+s0MYQtL vDq+hR3ClpL4/G4v1KBsiU0Pf0LVF0gcedELVW8v0XqqH8jmADpO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ZlVqU H19UmpNafIhRmoNFSZz3QtfJeCGB9MSS1OzU1ILUIpgsEwenVANTt8H6heVs7rN8tF67Mj4t 8Ttn1j03QyV+SZ3RlNYXcyef3idiXyJ16RiXlVTwTYub02wnTDV71bLzS2qg+r6mVxuuBeh/ Cw7pv/lLSyJUz/CP+6/lZrGv5lyYt/RdNI/mu37fL+ltrGWMF/ffV1lwVHT1BIH0f4qOyx7M ue6SMc09zOumn8R6XlsL3/fH3tYcznX4Mv3QmeLjcYdWWKv9vJuxRy0i9tG8yd6LVzPkCIrH yBUU5cvdzfQ9Y2//O5XRJunlXq+Fez/5K85yFpn/O0nDnMV17emE+Mn71knb3pzRY2ircLeH RSR57po53coR0s1qCpqHRGU25f6YO/9g6pfdTTfWFuzzemZ57TGjEktxRqKhFnNRcSIAih8W r48CAAA= X-CMS-MailID: 20220726105817epcas5p450a87008879689894b187924a854d513 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220726105817epcas5p450a87008879689894b187924a854d513 References: <20220726105230.12025-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. 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 2e2b806..acb57f8 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) @@ -279,6 +280,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, "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; @@ -313,6 +383,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;