From: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Alex Fishman <alex.fishman@ravellosystems.com>,
Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>,
yvugenfi@redhat.com, Izik Eidus <izik.eidus@ravellosystems.com>,
Yan Vugenfirer <yan@daynix.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Dmitry Fleytman <dmitry@daynix.com>
Subject: [Qemu-devel] [PATCH v4 3/9] Adding utility function iov_net_csum_add() for iovec checksum calculation
Date: Thu, 15 Mar 2012 23:09:02 +0200 [thread overview]
Message-ID: <1331845748-6026-4-git-send-email-dmitry.fleytman@ravellosystems.com> (raw)
In-Reply-To: <1331845748-6026-1-git-send-email-dmitry.fleytman@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
---
iov.c | 29 +++++++++++++++++++++++++++++
iov.h | 3 +++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/iov.c b/iov.c
index 0f96493..5d4f94c 100644
--- a/iov.c
+++ b/iov.c
@@ -16,6 +16,7 @@
*/
#include "iov.h"
+#include "net/checksum.h"
size_t iov_from_buf(struct iovec *iov, unsigned int iov_cnt,
const void *buf, size_t iov_off, size_t size)
@@ -130,3 +131,31 @@ void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt,
fprintf(fp, "\n");
}
}
+
+uint32_t
+iov_net_csum_add(const struct iovec *iov, const unsigned int iov_cnt,
+ size_t iov_off, size_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;
+}
diff --git a/iov.h b/iov.h
index 94d2f78..ba385f5 100644
--- a/iov.h
+++ b/iov.h
@@ -21,3 +21,6 @@ size_t iov_clear(const struct iovec *iov, const unsigned int iov_cnt,
size_t iov_off, size_t size);
void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt,
FILE *fp, const char *prefix, size_t limit);
+uint32_t
+iov_net_csum_add(const struct iovec *iov, const unsigned int iov_cnt,
+ size_t iov_off, size_t size);
--
1.7.7.6
next prev parent reply other threads:[~2012-03-15 21:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 21:08 [Qemu-devel] [PATCH v4 0/9] VMXNET3 paravirtual NIC device implementation Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 1/9] Adding missing flag VIRTIO_NET_HDR_F_DATA_VALID from Linux kernel source tre Reformatting comments according to checkpatch.pl requirements Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 2/9] Adding utility function net_checksum_add_cont() that allows checksum calculation of scattered data with odd chunk sizes Dmitry Fleytman
2012-03-15 21:09 ` Dmitry Fleytman [this message]
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 4/9] MSI-X state save/load invocations moved to PCI Device save/load callbacks to avoid code duplication in MSI-X-enabled devices that support live migration Dmitry Fleytman
2012-03-15 23:00 ` Michael S. Tsirkin
2012-03-16 9:18 ` Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 5/9] Header with various utility functions shared by VMWARE SCSI and network devi Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 6/9] Various utility functions used by VMWARE network devices Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 7/9] Packet abstraction " Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 8/9] VMXNET3 paravirtual device implementation Dmitry Fleytman
2012-03-15 21:09 ` [Qemu-devel] [PATCH v4 9/9] VMXNET3 paravirtualized device integration. Interface type "vmxnet3" added Dmitry Fleytman
2012-03-16 11:35 ` Paolo Bonzini
2012-03-18 9:26 ` Dmitry Fleytman
2012-03-18 8:29 ` [Qemu-devel] [PATCH v4 0/9] VMXNET3 paravirtual NIC device implementation Gerhard Wiesinger
2012-03-18 15:30 ` Dmitry Fleytman
2012-03-19 19:24 ` Gerhard Wiesinger
2012-03-20 8:00 ` Dmitry Fleytman
2012-03-21 6:59 ` Gerhard Wiesinger
2012-03-25 6:39 ` Gerhard Wiesinger
2012-03-18 8:32 ` Gerhard Wiesinger
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=1331845748-6026-4-git-send-email-dmitry.fleytman@ravellosystems.com \
--to=dmitry.fleytman@ravellosystems.com \
--cc=alex.fishman@ravellosystems.com \
--cc=aliguori@us.ibm.com \
--cc=dmitry@daynix.com \
--cc=izik.eidus@ravellosystems.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.com \
--cc=yvugenfi@redhat.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).