linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org
Cc: linux-block@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Keith Busch <keith.busch@intel.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH v5 06/13] datagram: introduce skb_copy_and_hash_datagram_iter helper
Date: Mon,  3 Dec 2018 17:52:10 -0800	[thread overview]
Message-ID: <20181204015217.16613-7-sagi@grimberg.me> (raw)
In-Reply-To: <20181204015217.16613-1-sagi@grimberg.me>

From: Sagi Grimberg <sagi@lightbitslabs.com>

Introduce a helper to copy datagram into an iovec iterator
but also update a predefined hash. This is useful for
consumers of skb_copy_datagram_iter to also support inflight
data digest without having to finish to copy and only then
traverse the iovec and calculate the digest hash.

Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sagi Grimberg <sagi@lightbitslabs.com>
---
 include/linux/skbuff.h |  3 +++
 net/core/datagram.c    | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0ba687454267..b0b8d5653f0d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3309,6 +3309,9 @@ static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
 }
 int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
 				   struct msghdr *msg);
+int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
+			   struct iov_iter *to, int len,
+			   struct ahash_request *hash);
 int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 				 struct iov_iter *from, int len);
 int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 382543302ae5..ef262282c8be 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -465,7 +465,7 @@ int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 			if (copy > len)
 				copy = len;
 			if (__skb_datagram_iter(frag_iter, offset - start,
-						to, copy, short_copy, cb, data))
+						to, copy, fault_short, cb, data))
 				goto fault;
 			if ((len -= copy) == 0)
 				return 0;
@@ -492,6 +492,24 @@ int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 	return 0;
 }
 
+/**
+ *	skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator
+ *          and update a hash.
+ *	@skb: buffer to copy
+ *	@offset: offset in the buffer to start copying from
+ *	@to: iovec iterator to copy to
+ *	@len: amount of data to copy from buffer to iovec
+ *      @hash: hash request to update
+ */
+int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
+			   struct iov_iter *to, int len,
+			   struct ahash_request *hash)
+{
+	return __skb_datagram_iter(skb, offset, to, len, true,
+			hash_and_copy_to_iter, hash);
+}
+EXPORT_SYMBOL(skb_copy_and_hash_datagram_iter);
+
 static size_t simple_copy_to_iter(const void *addr, size_t bytes,
 		void *data __always_unused, struct iov_iter *i)
 {
-- 
2.17.1


  parent reply	other threads:[~2018-12-04  1:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04  1:52 [PATCH v5 00/13] TCP transport binding for NVMe over Fabrics Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 01/13] ath6kl: add ath6kl_ prefix to crypto_type Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 02/13] datagram: open-code copy_page_to_iter Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 03/13] iov_iter: pass void csum pointer to csum_and_copy_to_iter Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 04/13] datagram: consolidate datagram copy to iter helpers Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 05/13] iov_iter: introduce hash_and_copy_to_iter helper Sagi Grimberg
2018-12-04  1:52 ` Sagi Grimberg [this message]
2018-12-04  1:52 ` [PATCH v5 07/13] nvmet: Add install_queue callout Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 08/13] nvme-fabrics: allow user passing header digest Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 09/13] nvme-fabrics: allow user passing data digest Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 10/13] nvme-tcp: Add protocol header Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 11/13] nvmet-tcp: add NVMe over TCP target driver Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 12/13] nvmet: allow configfs tcp trtype configuration Sagi Grimberg
2018-12-04  1:52 ` [PATCH v5 13/13] nvme-tcp: add NVMe over TCP host driver Sagi Grimberg
2018-12-08 17:00 ` [PATCH v5 00/13] TCP transport binding for NVMe over Fabrics Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181204015217.16613-7-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=davem@davemloft.net \
    --cc=hch@lst.de \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).