From: Dmitry Fleytman <dmitry@daynix.com>
To: qemu-devel@nongnu.org
Cc: Gerhard Wiesinger <lists@wiesinger.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
Yan Vugenfirer <yan@daynix.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Dmitry Fleytman <dmitry@daynix.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH V14 2/5] net: iovec checksum calculator
Date: Sat, 9 Mar 2013 11:21:03 +0200 [thread overview]
Message-ID: <1362820866-23426-3-git-send-email-dmitry@daynix.com> (raw)
In-Reply-To: <1362820866-23426-1-git-send-email-dmitry@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
---
include/net/checksum.h | 12 ++++++++++++
net/checksum.c | 29 +++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 3e7b93d..80203fb 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -38,4 +38,16 @@ net_raw_checksum(uint8_t *data, int length)
return net_checksum_finish(net_checksum_add(length, data));
}
+/**
+ * net_checksum_add_iov: scatter-gather vector checksumming
+ *
+ * @iov: input scatter-gather array
+ * @iov_cnt: number of array elements
+ * @iov_off: starting iov offset for checksumming
+ * @size: length of data to be checksummed
+ */
+uint32_t net_checksum_add_iov(const struct iovec *iov,
+ const unsigned int iov_cnt,
+ uint32_t iov_off, uint32_t size);
+
#endif /* QEMU_NET_CHECKSUM_H */
diff --git a/net/checksum.c b/net/checksum.c
index 4fa5563..14c0855 100644
--- a/net/checksum.c
+++ b/net/checksum.c
@@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu-common.h"
#include "net/checksum.h"
#define PROTO_TCP 6
@@ -84,3 +85,31 @@ void net_checksum_calculate(uint8_t *data, int length)
data[14+hlen+csum_offset] = csum >> 8;
data[14+hlen+csum_offset+1] = csum & 0xff;
}
+
+uint32_t
+net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
+ uint32_t iov_off, uint32_t size)
+{
+ size_t iovec_off, buf_off;
+ unsigned int i;
+ uint32_t res = 0;
+ uint32_t seq = 0;
+
+ iovec_off = 0;
+ buf_off = 0;
+ for (i = 0; i < iov_cnt && size; i++) {
+ if (iov_off < (iovec_off + iov[i].iov_len)) {
+ size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);
+ void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off);
+
+ res += net_checksum_add_cont(len, chunk_buf, seq);
+ seq += len;
+
+ buf_off += len;
+ iov_off += len;
+ size -= len;
+ }
+ iovec_off += iov[i].iov_len;
+ }
+ return res;
+}
--
1.8.1.2
next prev parent reply other threads:[~2013-03-09 9:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 9:21 [Qemu-devel] [PATCH V14 0/5] VMXNET3 paravirtual NIC device implementation Dmitry Fleytman
2013-03-09 9:21 ` [Qemu-devel] [PATCH V14 1/5] Checksum-related utility functions Dmitry Fleytman
2013-03-09 9:21 ` Dmitry Fleytman [this message]
2013-03-09 9:21 ` [Qemu-devel] [PATCH V14 3/5] Common definitions for VMWARE devices Dmitry Fleytman
2013-03-09 9:21 ` [Qemu-devel] [PATCH V14 4/5] Packet abstraction for VMWARE network devices Dmitry Fleytman
2013-03-09 9:21 ` [Qemu-devel] [PATCH V14 5/5] VMXNET3 device implementation Dmitry Fleytman
2013-03-27 14:49 ` Alexander Graf
2013-03-27 15:46 ` Paolo Bonzini
2013-03-27 16:06 ` Alexander Graf
2013-03-27 16:36 ` Dmitry Fleytman
2013-03-28 9:09 ` Stefan Hajnoczi
2013-03-12 9:38 ` [Qemu-devel] [PATCH V14 0/5] VMXNET3 paravirtual NIC " Stefan Hajnoczi
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=1362820866-23426-3-git-send-email-dmitry@daynix.com \
--to=dmitry@daynix.com \
--cc=anthony@codemonkey.ws \
--cc=lists@wiesinger.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=yan@daynix.com \
/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).