mirror of
https://github.com/openvswitch/ovs
synced 2025-09-02 15:25:22 +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:
committed by
Ian Stokes
parent
f916262832
commit
1270b6e52c
@@ -1166,7 +1166,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
|||||||
int type = nl_attr_type(action);
|
int type = nl_attr_type(action);
|
||||||
struct dp_packet *packet = packets_->packets[0];
|
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) {
|
switch ((enum ovs_action_attr)type) {
|
||||||
case OVS_ACTION_ATTR_METER:
|
case OVS_ACTION_ATTR_METER:
|
||||||
|
@@ -640,8 +640,7 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch,
|
|||||||
if (retval) {
|
if (retval) {
|
||||||
dp_packet_delete(packet);
|
dp_packet_delete(packet);
|
||||||
} else {
|
} else {
|
||||||
batch->packets[0] = packet;
|
dp_packet_batch_init_packet(batch, packet);
|
||||||
batch->count = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qfill) {
|
if (qfill) {
|
||||||
@@ -690,8 +689,8 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
|
|||||||
{
|
{
|
||||||
struct netdev_bsd *dev = netdev_bsd_cast(netdev_);
|
struct netdev_bsd *dev = netdev_bsd_cast(netdev_);
|
||||||
const char *name = netdev_get_name(netdev_);
|
const char *name = netdev_get_name(netdev_);
|
||||||
|
struct dp_packet *packet;
|
||||||
int error;
|
int error;
|
||||||
int i;
|
|
||||||
|
|
||||||
ovs_mutex_lock(&dev->mutex);
|
ovs_mutex_lock(&dev->mutex);
|
||||||
if (dev->tap_fd < 0 && !dev->pcap) {
|
if (dev->tap_fd < 0 && !dev->pcap) {
|
||||||
@@ -700,9 +699,9 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
|
|||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < batch->count; i++) {
|
DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
|
||||||
const void *data = dp_packet_data(batch->packets[i]);
|
const void *data = dp_packet_data(packet);
|
||||||
size_t size = dp_packet_size(batch->packets[i]);
|
size_t size = dp_packet_size(packet);
|
||||||
|
|
||||||
while (!error) {
|
while (!error) {
|
||||||
ssize_t retval;
|
ssize_t retval;
|
||||||
|
@@ -1036,8 +1036,7 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch,
|
|||||||
netdev->custom_stats[1].value++;
|
netdev->custom_stats[1].value++;
|
||||||
ovs_mutex_unlock(&netdev->mutex);
|
ovs_mutex_unlock(&netdev->mutex);
|
||||||
|
|
||||||
batch->packets[0] = packet;
|
dp_packet_batch_init_packet(batch, packet);
|
||||||
batch->count = 1;
|
|
||||||
|
|
||||||
if (qfill) {
|
if (qfill) {
|
||||||
*qfill = -ENOTSUP;
|
*qfill = -ENOTSUP;
|
||||||
@@ -1091,7 +1090,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED,
|
|||||||
const void *buffer = dp_packet_data(packet);
|
const void *buffer = dp_packet_data(packet);
|
||||||
size_t size = dp_packet_size(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;
|
error = EPFNOSUPPORT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -717,7 +717,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
|
|||||||
|
|
||||||
dp_execute_action(dp, batch, a, should_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.
|
/* We do not need to free the packets.
|
||||||
* Either dp_execute_actions() has stolen them
|
* Either dp_execute_actions() has stolen them
|
||||||
* or the batch is freed due to errors. In either
|
* or the batch is freed due to errors. In either
|
||||||
|
@@ -177,7 +177,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct_,
|
|||||||
NULL, NULL, 0, 0, NULL, NULL, now);
|
NULL, NULL, 0, 0, NULL, NULL, now);
|
||||||
dp_packet_batch_init(&new_batch);
|
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)) {
|
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);
|
dp_packet_batch_add(batch, packet);
|
||||||
}
|
}
|
||||||
if (!batch->count) {
|
if (dp_packet_batch_is_empty(batch)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pcap_batch_execute_conntrack(&ct, batch);
|
pcap_batch_execute_conntrack(&ct, batch);
|
||||||
|
Reference in New Issue
Block a user