Changeset View
Changeset View
Standalone View
Standalone View
sys/net/mp_ring.c
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | drain_ring_locked(struct ifmp_ring *r, union ring_state os, uint16_t prev, int budget) | ||||
if (prev == IDLE) | if (prev == IDLE) | ||||
counter_u64_add(r->starts, 1); | counter_u64_add(r->starts, 1); | ||||
pending = 0; | pending = 0; | ||||
total = 0; | total = 0; | ||||
while (cidx != pidx) { | while (cidx != pidx) { | ||||
/* Items from cidx to pidx are available for consumption. */ | /* Items from cidx to pidx are available for consumption. */ | ||||
n = r->drain(r, cidx, pidx); | n = r->drain(r, (void **)r->items, cidx, pidx); | ||||
if (n == 0) { | if (n == 0) { | ||||
os.state = ns.state = r->state; | os.state = ns.state = r->state; | ||||
ns.cidx = cidx; | ns.cidx = cidx; | ||||
ns.flags = STALLED; | ns.flags = STALLED; | ||||
r->state = ns.state; | r->state = ns.state; | ||||
if (prev != STALLED) | if (prev != STALLED) | ||||
counter_u64_add(r->stalls, 1); | counter_u64_add(r->stalls, 1); | ||||
else if (total > 0) { | else if (total > 0) { | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | drain_ring_lockless(struct ifmp_ring *r, union ring_state os, uint16_t prev, int budget) | ||||
if (prev == IDLE) | if (prev == IDLE) | ||||
counter_u64_add(r->starts, 1); | counter_u64_add(r->starts, 1); | ||||
pending = 0; | pending = 0; | ||||
total = 0; | total = 0; | ||||
while (cidx != pidx) { | while (cidx != pidx) { | ||||
/* Items from cidx to pidx are available for consumption. */ | /* Items from cidx to pidx are available for consumption. */ | ||||
n = r->drain(r, cidx, pidx); | n = r->drain(r, r->items, cidx, pidx); | ||||
if (n == 0) { | if (n == 0) { | ||||
critical_enter(); | critical_enter(); | ||||
os.state = r->state; | os.state = r->state; | ||||
do { | do { | ||||
ns.state = os.state; | ns.state = os.state; | ||||
ns.cidx = cidx; | ns.cidx = cidx; | ||||
ns.flags = STALLED; | ns.flags = STALLED; | ||||
} while (atomic_fcmpset_64(&r->state, &os.state, | } while (atomic_fcmpset_64(&r->state, &os.state, | ||||
▲ Show 20 Lines • Show All 355 Lines • Show Last 20 Lines |