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

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>
This commit is contained in:
Ilya Maximets
2018-12-10 20:17:53 +03:00
committed by Ian Stokes
parent f916262832
commit 1270b6e52c
5 changed files with 11 additions and 13 deletions

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -177,7 +177,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct_,
NULL, NULL, 0, 0, NULL, NULL, now);
dp_packet_batch_init(&new_batch);
}
new_batch.packets[new_batch.count++] = packet;;
dp_packet_batch_add(&new_batch, packet);
}
if (!dp_packet_batch_is_empty(&new_batch)) {
@@ -226,7 +226,7 @@ test_pcap(struct ovs_cmdl_context *ctx)
}
dp_packet_batch_add(batch, packet);
}
if (!batch->count) {
if (dp_packet_batch_is_empty(batch)) {
break;
}
pcap_batch_execute_conntrack(&ct, batch);