Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_dn_io.c
Context not available. | |||||
* in milliseconds so we need to divide by 1000. | * in milliseconds so we need to divide by 1000. | ||||
*/ | */ | ||||
static uint64_t | static uint64_t | ||||
extra_bits(struct mbuf *m, struct dn_schk *s) | extra_bits(struct mbuf *m, struct dn_schk *s, uint32_t pkt_len) | ||||
{ | { | ||||
int index; | int index; | ||||
uint64_t bits; | uint64_t bits; | ||||
Context not available. | |||||
if (!pf || pf->samples_no == 0) | if (!pf || pf->samples_no == 0) | ||||
return 0; | return 0; | ||||
index = random() % pf->samples_no; | if (pf->bytes_used == 0) { | ||||
bits = div64((uint64_t)pf->samples[index] * s->link.bandwidth, 1000); | index = random() % pf->samples_no; | ||||
if (index >= pf->loss_level) { | bits = div64((uint64_t)pf->samples[index] * s->link.bandwidth, 1000); | ||||
struct dn_pkt_tag *dt = dn_tag_get(m); | if (index >= pf->loss_level) { | ||||
if (dt) | struct dn_pkt_tag *dt = dn_tag_get(m); | ||||
dt->dn_dir = DIR_DROP; | if (dt) | ||||
dt->dn_dir = DIR_DROP; | |||||
} | |||||
} else | |||||
bits = 0; | |||||
if (pf->channel_bytes) { | |||||
pf->bytes_used += pkt_len; | |||||
if (pf->bytes_used >= pf->channel_bytes) | |||||
pf->bytes_used = 0; | |||||
} | } | ||||
return bits; | return bits; | ||||
} | } | ||||
Context not available. | |||||
done++; | done++; | ||||
len_scaled = (bw == 0) ? 0 : hz * | len_scaled = (bw == 0) ? 0 : hz * | ||||
(m->m_pkthdr.len * 8 + extra_bits(m, s)); | (m->m_pkthdr.len * 8 + extra_bits(m, s, m->m_pkthdr.len)); | ||||
si->credit -= len_scaled; | si->credit -= len_scaled; | ||||
/* Move packet in the delay line */ | /* Move packet in the delay line */ | ||||
dn_tag_get(m)->output_time = dn_cfg.curr_time + s->link.delay ; | dn_tag_get(m)->output_time = dn_cfg.curr_time + s->link.delay ; | ||||
mq_append(&si->dline.mq, m); | mq_append(&si->dline.mq, m); | ||||
} | } | ||||
/* | /* | ||||
* If credit >= 0 the instance is idle, mark time. | * If credit >= 0 the instance is idle, mark time. | ||||
* Otherwise put back in the heap, and adjust the output | * Otherwise put back in the heap, and adjust the output | ||||
Context not available. | |||||
} | } | ||||
if (delay_line_idle && done) | if (delay_line_idle && done) | ||||
transmit_event(q, &si->dline, now); | transmit_event(q, &si->dline, now); | ||||
if (s->profile && | |||||
s->profile->clear_cb_on_empty && | |||||
(si->dline.mq.head == NULL) && | |||||
(si->ni.len_bytes == 0)) { | |||||
/* | |||||
* The queue & delay line's are empty. | |||||
*/ | |||||
s->profile->bytes_used = 0; | |||||
} | |||||
return q->head; | return q->head; | ||||
} | } | ||||
Context not available. | |||||
if (q == NULL) | if (q == NULL) | ||||
goto dropit; | goto dropit; | ||||
} | } | ||||
if (si->sched->profile && | |||||
si->sched->profile->clear_cb_on_empty && | |||||
(si->dline.mq.head == NULL) && | |||||
(si->ni.len_bytes == 0)) { | |||||
/* | |||||
* The queue & delay line's are empty. | |||||
*/ | |||||
si->sched->profile->bytes_used = 0; | |||||
} | |||||
if (fs->sched->fp->enqueue(si, q, m)) { | if (fs->sched->fp->enqueue(si, q, m)) { | ||||
/* packet was dropped by enqueue() */ | /* packet was dropped by enqueue() */ | ||||
m = *m0 = NULL; | m = *m0 = NULL; | ||||
Context not available. |