From patchwork Wed Sep 28 11:02:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12992154 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 85A19C04A95 for ; Wed, 28 Sep 2022 11:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234039AbiI1LHi (ORCPT ); Wed, 28 Sep 2022 07:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234027AbiI1LHB (ORCPT ); Wed, 28 Sep 2022 07:07:01 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1874CFFA48 for ; Wed, 28 Sep 2022 04:04:06 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id x18so19205187wrm.7 for ; Wed, 28 Sep 2022 04:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=D6FZLh4CObYRBQVaOo1yXaxqOpUAqdHJB/+HnubEIVw=; b=n5L1GeyH+Msn+h4uU71vAN+W8jDNVKMdL73n3W287ezwC2dRkHRhln2S5iA8XaUERo f8suskn81JpSa7atuxK6gJ3hS+j9U6vxnO9LfVR8cmlBjyFjW6QlYG5UgAfc2i7bzW3S tvMWKiUNRKMqfmh49bTNO5HE/IgUwspVcC//w7MHpo/kzdt0tvm1lOpiU+/rn8+D64FC UGXbP7bA4rNNtJdyukfiAaT/wbWE3uVBtFgYw6xpR74zYcne5Pef3A9hIb346he1oFDb /xUxTcHDj5tDYNhTddUV7jmIwrFJjvguKR6WahsqLuYD4iWNUnkdl9PTQKZ/Ff1+z3vh HR4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=D6FZLh4CObYRBQVaOo1yXaxqOpUAqdHJB/+HnubEIVw=; b=xas41Yp+DhUWVXgL4N385vy5eiukq0d9pts3A3JgvPeiwFuBRQOyVMzYA/9qUmNn2s fULZfB5r/qiCzRz+npgds5W80OfXopHHtnZPU9fUeBG4b2mmhcfF5LxVsF/Q7tneBcsg 4rK3pFmY8QvrwjGR5f/MfnWZay0LEq4n8SniwikFnWRDiHV2y8cSU2Kc6HlR4kNV0FVF NXf2D08Ry1BOYqtuYrGnaB4+Zy47O8EzdtnTYCKQpQMjjvqt3w553DN8EPPjjcvOHesN alJOkaUub5Spcu3CRwdnCRLphhTcO2lrbXog6MvepzdwbXrzQq/2YZ8vgoBBGiomg8Tn ELGA== X-Gm-Message-State: ACrzQf1+bfo5tb+2q6OQZdRWLeltfPkHvjnQBNvhUtMscoEFOCZ/7CVy EkK/YagtoAJ9szVLnbyxbFKNS4MggRU= X-Google-Smtp-Source: AMsMyM4fwF6ziEbxzdwv7Ccg9d6uu1cLPDAq/U1R/76S0tJkgTrndqFhEUbLC5Q9KHamFz5mZXPhkA== X-Received: by 2002:adf:bc13:0:b0:228:6d28:d489 with SMTP id s19-20020adfbc13000000b002286d28d489mr19153120wrg.668.1664363043142; Wed, 28 Sep 2022 04:04:03 -0700 (PDT) Received: from 127.0.0.1localhost (94.196.228.157.threembb.co.uk. [94.196.228.157]) by smtp.gmail.com with ESMTPSA id t15-20020a5d42cf000000b00228c483128dsm4654460wrr.90.2022.09.28.04.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 04:04:02 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/1] liburing: add more zc helpers Date: Wed, 28 Sep 2022 12:02:58 +0100 Message-Id: <25a5e4ff7c480cf5c68be2e223a2fa9787ee6283.1664361932.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add a helper for zc sendmsg and also for zc send with registered buffers (aka fixed). Signed-off-by: Pavel Begunkov --- src/include/liburing.h | 19 +++++++++++++++++++ test/send-zerocopy.c | 3 +-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index 902f26a..1d04923 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -746,6 +746,25 @@ static inline void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd, sqe->ioprio = zc_flags; } +static inline void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe, + int sockfd, const void *buf, + size_t len, int flags, + unsigned zc_flags, + unsigned buf_index) +{ + io_uring_prep_send_zc(sqe, sockfd, buf, len, flags, zc_flags); + sqe->ioprio |= IORING_RECVSEND_FIXED_BUF; + sqe->buf_index = buf_index; +} + +static inline void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd, + const struct msghdr *msg, + unsigned flags) +{ + io_uring_prep_sendmsg(sqe, fd, msg, flags); + sqe->opcode = IORING_OP_SENDMSG_ZC; +} + static inline void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe, const struct sockaddr *dest_addr, __u16 addr_len) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 88578e0..31d66e3 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -301,8 +301,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)addr, addr_len); } else { - io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags); - sqe->opcode = IORING_OP_SENDMSG_ZC; + io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags); memset(&msghdr[i], 0, sizeof(msghdr[i])); iov[i].iov_len = cur_size;