diff options
author | William Tu <u9012063@gmail.com> | 2016-07-18 17:05:35 -0700 |
---|---|---|
committer | Daniele Di Proietto <diproiettod@vmware.com> | 2016-07-21 16:46:32 -0700 |
commit | 64839cf4325198e6ba845de72efd7c7a726c62a1 (patch) | |
tree | d23341a59d84f2d59bad4aa0b986ee81ed800b34 /lib/netdev-bsd.c | |
parent | b52388e6c49702c4245f2254b11d669d7f7c9a83 (diff) | |
download | openvswitch-64839cf4325198e6ba845de72efd7c7a726c62a1.tar.gz |
netdev-provider: Apply batch object to netdev provider.
Commit 1895cc8dbb64 ("dpif-netdev: create batch object") introduces
batch process functions and 'struct dp_packet_batch' to associate with
batch-level metadata. This patch applies the packet batch object to
the netdev provider interface (dummy, Linux, BSD, and DPDK) so that
batch APIs can be used in providers. With batch metadata visible in
providers, optimizations can be introduced at per-batch level instead
of per-packet.
Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/145694197
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Diffstat (limited to 'lib/netdev-bsd.c')
-rw-r--r-- | lib/netdev-bsd.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index 2e92d9768..869d54d35 100644 --- a/lib/netdev-bsd.c +++ b/lib/netdev-bsd.c @@ -618,8 +618,7 @@ netdev_rxq_bsd_recv_tap(struct netdev_rxq_bsd *rxq, struct dp_packet *buffer) } static int -netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets, - int *c) +netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch) { struct netdev_rxq_bsd *rxq = netdev_rxq_bsd_cast(rxq_); struct netdev *netdev = rxq->up.netdev; @@ -641,8 +640,8 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets, dp_packet_delete(packet); } else { dp_packet_pad(packet); - packets[0] = packet; - *c = 1; + batch->packets[0] = packet; + batch->count = 1; } return retval; } @@ -681,7 +680,7 @@ netdev_bsd_rxq_drain(struct netdev_rxq *rxq_) */ static int netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED, - struct dp_packet **pkts, int cnt, bool may_steal) + struct dp_packet_batch *batch, bool may_steal) { struct netdev_bsd *dev = netdev_bsd_cast(netdev_); const char *name = netdev_get_name(netdev_); @@ -695,12 +694,12 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED, error = 0; } - for (i = 0; i < cnt; i++) { - const void *data = dp_packet_data(pkts[i]); - size_t size = dp_packet_size(pkts[i]); + for (i = 0; i < batch->count; i++) { + const void *data = dp_packet_data(batch->packets[i]); + size_t size = dp_packet_size(batch->packets[i]); /* Truncate the packet if it is configured. */ - size -= dp_packet_get_cutlen(pkts[i]); + size -= dp_packet_get_cutlen(batch->packets[i]); while (!error) { ssize_t retval; @@ -731,11 +730,7 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED, } ovs_mutex_unlock(&dev->mutex); - if (may_steal) { - for (i = 0; i < cnt; i++) { - dp_packet_delete(pkts[i]); - } - } + dp_packet_delete_batch(batch, may_steal); return error; } |