2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

ofproto-dpif: Add 'meter_ids' to backer

Add 'meter_ids', an id-pool object to manage datapath meter id, i.e.
provider_meter_id.

Currently, only userspace datapath supports meter, and it implements
the provider_meter_id management. Moving this function to 'backer'
allows other datapath implementation to share the same logic.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
This commit is contained in:
Andy Zhou
2017-03-30 17:03:08 -07:00
parent ba8cff36bb
commit 333ad77dbd
3 changed files with 51 additions and 26 deletions

View File

@@ -260,7 +260,6 @@ struct dp_netdev {
/* Meters. */
struct ovs_mutex meter_locks[N_METER_LOCKS];
struct dp_meter *meters[MAX_METERS]; /* Meter bands. */
uint32_t meter_free; /* Next free meter. */
/* Protects access to ofproto-dpif-upcall interface during revalidator
* thread synchronization. */
@@ -3896,9 +3895,6 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id *meter_id,
struct dp_meter *meter;
int i;
if (mid == UINT32_MAX) {
mid = dp->meter_free;
}
if (mid >= MAX_METERS) {
return EFBIG; /* Meter_id out of range. */
}
@@ -3958,21 +3954,6 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id *meter_id,
dp->meters[mid] = meter;
meter_unlock(dp, mid);
meter_id->uint32 = mid; /* Store on success. */
/* Find next free meter */
if (dp->meter_free == mid) { /* Now taken. */
do {
if (++mid >= MAX_METERS) { /* Wrap around */
mid = 0;
}
if (mid == dp->meter_free) { /* Full circle */
mid = MAX_METERS;
break;
}
} while (dp->meters[mid]);
dp->meter_free = mid; /* Next free meter or MAX_METERS */
}
return 0;
}
return ENOMEM;
@@ -4027,11 +4008,6 @@ dpif_netdev_meter_del(struct dpif *dpif,
meter_lock(dp, meter_id);
dp_delete_meter(dp, meter_id);
meter_unlock(dp, meter_id);
/* Keep free meter index as low as possible */
if (meter_id < dp->meter_free) {
dp->meter_free = meter_id;
}
}
return error;
}