@@ -1312,7 +1312,7 @@ conntrack_execute(struct conntrack *ct, struct dp_packet_batch *pkt_batch,
struct dp_packet *packet;
struct conn_lookup_ctx ctx;
- DP_PACKET_BATCH_FOR_EACH (packet, pkt_batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, pkt_batch) {
if (!conn_key_extract(ct, packet, dl_type, &ctx, zone)) {
packet->md.ct_state = CS_INVALID;
write_ct_md(packet, zone, NULL, NULL, NULL);
@@ -759,9 +759,9 @@ dp_packet_batch_is_empty(const struct dp_packet_batch *batch)
return !dp_packet_batch_size(batch);
}
-#define DP_PACKET_BATCH_FOR_EACH(PACKET, BATCH) \
- for (size_t i = 0; i < dp_packet_batch_size(BATCH); i++) \
- if (PACKET = BATCH->packets[i], true)
+#define DP_PACKET_BATCH_FOR_EACH(IDX, PACKET, BATCH) \
+ for (size_t IDX = 0; IDX < dp_packet_batch_size(BATCH); IDX++) \
+ if (PACKET = BATCH->packets[IDX], true)
/* Use this macro for cases where some packets in the 'BATCH' may be
* dropped after going through each packet in the 'BATCH'.
@@ -785,7 +785,7 @@ dp_packet_batch_clone(struct dp_packet_batch *dst,
struct dp_packet *packet;
dp_packet_batch_init(dst);
- DP_PACKET_BATCH_FOR_EACH (packet, src) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, src) {
dp_packet_batch_add(dst, dp_packet_clone(packet));
}
dst->trunc = src->trunc;
@@ -797,7 +797,7 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, bool may_steal)
if (may_steal) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_delete(packet);
}
dp_packet_batch_init(batch);
@@ -809,7 +809,7 @@ dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
{
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_reset_cutlen(packet);
packet->packet_type = htonl(PT_ETH);
}
@@ -821,7 +821,7 @@ dp_packet_batch_apply_cutlen(struct dp_packet_batch *batch)
if (batch->trunc) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_set_size(packet, dp_packet_get_send_len(packet));
dp_packet_reset_cutlen(packet);
}
@@ -835,7 +835,7 @@ dp_packet_batch_reset_cutlen(struct dp_packet_batch *batch)
if (batch->trunc) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_reset_cutlen(packet);
}
batch->trunc = false;
@@ -4223,7 +4223,6 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
struct dp_packet *packet;
long long int long_delta_t; /* msec */
uint32_t delta_t; /* msec */
- int i;
const size_t cnt = dp_packet_batch_size(packets_);
uint32_t bytes, volume;
int exceeded_band[NETDEV_MAX_BURST];
@@ -4257,7 +4256,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
meter->used = now;
meter->packet_count += cnt;
bytes = 0;
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
bytes += dp_packet_size(packet);
}
meter->byte_count += bytes;
@@ -4299,7 +4298,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
/* Update the exceeding band for each exceeding packet.
* (Only one band will be fired by a packet, and that
* can be different for each packet.) */
- for (i = band_exceeded_pkt; i < cnt; i++) {
+ for (int i = band_exceeded_pkt; i < cnt; i++) {
if (band->up.rate > exceeded_rate[i]) {
exceeded_rate[i] = band->up.rate;
exceeded_band[i] = m;
@@ -4308,7 +4307,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
} else {
/* Packet sizes differ, must process one-by-one. */
band_exceeded_pkt = cnt;
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
uint32_t bits = dp_packet_size(packet) * 8;
if (band->bucket >= bits) {
@@ -5147,9 +5146,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
int upcall_ok_cnt = 0, upcall_fail_cnt = 0;
int lookup_cnt = 0, add_lookup_cnt;
bool any_miss;
- size_t i;
- for (i = 0; i < cnt; i++) {
+ for (size_t i = 0; i < cnt; i++) {
/* Key length is needed in all the cases, hash computed on demand. */
keys[i].len = netdev_flow_key_size(miniflow_n_values(&keys[i].mf));
}
@@ -5168,7 +5166,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
ofpbuf_use_stub(&actions, actions_stub, sizeof actions_stub);
ofpbuf_use_stub(&put_actions, slow_stub, sizeof slow_stub);
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
struct dp_netdev_flow *netdev_flow;
if (OVS_LIKELY(rules[i])) {
@@ -5200,7 +5198,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
ofpbuf_uninit(&put_actions);
fat_rwlock_unlock(&dp->upcall_rwlock);
} else if (OVS_UNLIKELY(any_miss)) {
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
if (OVS_UNLIKELY(!rules[i])) {
dp_packet_delete(packet);
upcall_fail_cnt++;
@@ -5208,7 +5206,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
}
}
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
struct dp_netdev_flow *flow;
if (OVS_UNLIKELY(!rules[i])) {
@@ -5495,7 +5493,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
pmd->n_output_batches++;
}
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
p->output_pkts_rxqs[dp_packet_batch_size(&p->output_pkts)] =
pmd->ctx.last_rxq;
dp_packet_batch_add(&p->output_pkts, packet);
@@ -5535,7 +5533,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
}
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
packet->md.in_port.odp_port = portno;
}
@@ -5572,7 +5570,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
}
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
flow_extract(packet, &flow);
dpif_flow_hash(dp->dpif, &flow, sizeof flow, &ufid);
dp_execute_userspace_action(pmd, packet, may_steal, &flow,
@@ -5600,7 +5598,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
}
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, packets_) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
packet->md.recirc_id = nl_attr_get_u32(a);
}
@@ -3297,7 +3297,7 @@ netdev_dpdk_ring_send(struct netdev *netdev, int qid,
* the rss hash field is clear. This is because the same mbuf may be
* modified by the consumer of the ring and return into the datapath
* without recalculating the RSS hash. */
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_mbuf_rss_flag_reset(packet);
}
@@ -1081,7 +1081,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED,
int error = 0;
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH(packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH(i, packet, batch) {
const void *buffer = dp_packet_data(packet);
size_t size = dp_packet_size(packet);
@@ -1203,7 +1203,7 @@ netdev_linux_sock_batch_send(int sock, int ifindex,
struct iovec *iov = xmalloc(sizeof(*iov) * size);
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
iov[i].iov_base = dp_packet_data(packet);
iov[i].iov_len = dp_packet_size(packet);
mmsg[i].msg_hdr = (struct msghdr) { .msg_name = &sll,
@@ -1252,7 +1252,7 @@ netdev_linux_tap_batch_send(struct netdev *netdev_,
return 0;
}
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
size_t size = dp_packet_size(packet);
ssize_t retval;
int error;
@@ -854,7 +854,7 @@ netdev_push_header(const struct netdev *netdev,
const struct ovs_action_push_tnl *data)
{
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
netdev->netdev_class->push_header(packet, data);
pkt_metadata_init(&packet->md, data->out_port);
}
@@ -737,7 +737,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
struct flow flow;
uint32_t hash;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
/* RSS hash can be used here instead of 5tuple for
* performance reasons. */
if (dp_packet_rss_valid(packet)) {
@@ -759,14 +759,14 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
case OVS_ACTION_ATTR_PUSH_VLAN: {
const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
eth_push_vlan(packet, vlan->vlan_tpid, vlan->vlan_tci);
}
break;
}
case OVS_ACTION_ATTR_POP_VLAN:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
eth_pop_vlan(packet);
}
break;
@@ -774,32 +774,32 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
case OVS_ACTION_ATTR_PUSH_MPLS: {
const struct ovs_action_push_mpls *mpls = nl_attr_get(a);
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
push_mpls(packet, mpls->mpls_ethertype, mpls->mpls_lse);
}
break;
}
case OVS_ACTION_ATTR_POP_MPLS:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
pop_mpls(packet, nl_attr_get_be16(a));
}
break;
case OVS_ACTION_ATTR_SET:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
odp_execute_set_action(packet, nl_attr_get(a));
}
break;
case OVS_ACTION_ATTR_SET_MASKED:
- DP_PACKET_BATCH_FOR_EACH(packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH(i, packet, batch) {
odp_execute_masked_set_action(packet, nl_attr_get(a));
}
break;
case OVS_ACTION_ATTR_SAMPLE:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
odp_execute_sample(dp, packet, steal && last_action, a,
dp_execute_action);
}
@@ -816,7 +816,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
nl_attr_get_unspec(a, sizeof *trunc);
batch->trunc = true;
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
dp_packet_set_cutlen(packet, trunc->max_len);
}
break;
@@ -837,7 +837,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
case OVS_ACTION_ATTR_PUSH_ETH: {
const struct ovs_action_push_eth *eth = nl_attr_get(a);
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
push_eth(packet, ð->addresses.eth_dst,
ð->addresses.eth_src);
}
@@ -845,7 +845,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
}
case OVS_ACTION_ATTR_POP_ETH:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
pop_eth(packet);
}
break;
@@ -855,7 +855,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
struct nsh_hdr *nsh_hdr = ALIGNED_CAST(struct nsh_hdr *, buffer);
nsh_reset_ver_flags_ttl_len(nsh_hdr);
odp_nsh_hdr_from_attr(nl_attr_get(a), nsh_hdr, NSH_HDR_MAX_LEN);
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
push_nsh(packet, nsh_hdr);
}
break;
@@ -874,7 +874,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
break;
}
case OVS_ACTION_ATTR_CT_CLEAR:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
conntrack_clear(packet);
}
break;
@@ -162,7 +162,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct,
/* pkt_batch contains packets with different 'dl_type'. We have to
* call conntrack_execute() on packets with the same 'dl_type'. */
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (packet, pkt_batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, pkt_batch) {
struct flow flow;
/* This also initializes the l3 and l4 pointers. */
@@ -231,7 +231,7 @@ test_pcap(struct ovs_cmdl_context *ctx)
}
pcap_batch_execute_conntrack(&ct, batch);
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
struct ds ds = DS_EMPTY_INITIALIZER;
total_count++;
Signed-off-by: Justin Pettit <jpettit@ovn.org> --- lib/conntrack.c | 2 +- lib/dp-packet.h | 16 ++++++++-------- lib/dpif-netdev.c | 24 +++++++++++------------- lib/netdev-dpdk.c | 2 +- lib/netdev-dummy.c | 2 +- lib/netdev-linux.c | 4 ++-- lib/netdev.c | 2 +- lib/odp-execute.c | 26 +++++++++++++------------- tests/test-conntrack.c | 4 ++-- 9 files changed, 40 insertions(+), 42 deletions(-)