diff options
author | Ilya Maximets <i.maximets@samsung.com> | 2018-12-10 20:17:53 +0300 |
---|---|---|
committer | Ian Stokes <ian.stokes@intel.com> | 2018-12-11 20:18:26 +0000 |
commit | 1270b6e52c75484fd3ad74bdf639a21939c08e63 (patch) | |
tree | 99dfa9282a0899e83f3c24315cfffd25b7997ec3 /lib | |
parent | f9162628325cef86a0666f422d148f592d06c39d (diff) | |
download | openvswitch-1270b6e52c75484fd3ad74bdf639a21939c08e63.tar.gz |
treewide: Wider use of packet batch APIs.
This patch replaces most of direct accesses to the dp_packet_batch
internal components by appropriate APIs.
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpif.c | 2 | ||||
-rw-r--r-- | lib/netdev-bsd.c | 11 | ||||
-rw-r--r-- | lib/netdev-dummy.c | 5 | ||||
-rw-r--r-- | lib/odp-execute.c | 2 |
4 files changed, 9 insertions, 11 deletions
diff --git a/lib/dpif.c b/lib/dpif.c index 59aa1dc7c..e35f11147 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -1166,7 +1166,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_, int type = nl_attr_type(action); struct dp_packet *packet = packets_->packets[0]; - ovs_assert(packets_->count == 1); + ovs_assert(dp_packet_batch_size(packets_) == 1); switch ((enum ovs_action_attr)type) { case OVS_ACTION_ATTR_METER: diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index 99d4f4842..46698d547 100644 --- a/lib/netdev-bsd.c +++ b/lib/netdev-bsd.c @@ -640,8 +640,7 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch, if (retval) { dp_packet_delete(packet); } else { - batch->packets[0] = packet; - batch->count = 1; + dp_packet_batch_init_packet(batch, packet); } if (qfill) { @@ -690,8 +689,8 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED, { struct netdev_bsd *dev = netdev_bsd_cast(netdev_); const char *name = netdev_get_name(netdev_); + struct dp_packet *packet; int error; - int i; ovs_mutex_lock(&dev->mutex); if (dev->tap_fd < 0 && !dev->pcap) { @@ -700,9 +699,9 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED, error = 0; } - 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]); + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + const void *data = dp_packet_data(packet); + size_t size = dp_packet_size(packet); while (!error) { ssize_t retval; diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 23817d121..72b4f7adc 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1036,8 +1036,7 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch, netdev->custom_stats[1].value++; ovs_mutex_unlock(&netdev->mutex); - batch->packets[0] = packet; - batch->count = 1; + dp_packet_batch_init_packet(batch, packet); if (qfill) { *qfill = -ENOTSUP; @@ -1091,7 +1090,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED, const void *buffer = dp_packet_data(packet); size_t size = dp_packet_size(packet); - if (batch->packets[i]->packet_type != htonl(PT_ETH)) { + if (packet->packet_type != htonl(PT_ETH)) { error = EPFNOSUPPORT; break; } diff --git a/lib/odp-execute.c b/lib/odp-execute.c index 5831d1fdb..3b6890e95 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -717,7 +717,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, dp_execute_action(dp, batch, a, should_steal); - if (last_action || batch->count == 0) { + if (last_action || dp_packet_batch_is_empty(batch)) { /* We do not need to free the packets. * Either dp_execute_actions() has stolen them * or the batch is freed due to errors. In either |