2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev-provider: Apply batch object to netdev provider.

Commit 1895cc8dbb ("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>
This commit is contained in:
William Tu
2016-07-18 17:05:35 -07:00
committed by Daniele Di Proietto
parent b52388e6c4
commit 64839cf432
6 changed files with 106 additions and 130 deletions

View File

@@ -1091,8 +1091,7 @@ netdev_linux_rxq_recv_tap(int fd, struct dp_packet *buffer)
}
static int
netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
int *c)
netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch)
{
struct netdev_rxq_linux *rx = netdev_rxq_linux_cast(rxq_);
struct netdev *netdev = rx->up.netdev;
@@ -1118,8 +1117,8 @@ netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
dp_packet_delete(buffer);
} else {
dp_packet_pad(buffer);
packets[0] = buffer;
*c = 1;
batch->packets[0] = buffer;
batch->count = 1;
}
return retval;
@@ -1161,19 +1160,19 @@ netdev_linux_rxq_drain(struct netdev_rxq *rxq_)
* expected to do additional queuing of packets. */
static int
netdev_linux_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)
{
int i;
int error = 0;
/* 'i' is incremented only if there's no error */
for (i = 0; i < cnt;) {
const void *data = dp_packet_data(pkts[i]);
size_t size = dp_packet_size(pkts[i]);
for (i = 0; i < batch->count;) {
const void *data = dp_packet_data(batch->packets[i]);
size_t size = dp_packet_size(batch->packets[i]);
ssize_t retval;
/* Truncate the packet if it is configured. */
size -= dp_packet_get_cutlen(pkts[i]);
size -= dp_packet_get_cutlen(batch->packets[i]);
if (!is_tap_netdev(netdev_)) {
/* Use our AF_PACKET socket to send to this device. */
@@ -1249,11 +1248,7 @@ netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
i++;
}
if (may_steal) {
for (i = 0; i < cnt; i++) {
dp_packet_delete(pkts[i]);
}
}
dp_packet_delete_batch(batch, may_steal);
if (error && error != EAGAIN) {
VLOG_WARN_RL(&rl, "error sending Ethernet packet on %s: %s",