Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_dn_io.c
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
static long tick_last; /* Last tick duration (usec). */ | static long tick_last; /* Last tick duration (usec). */ | ||||
static long tick_delta; /* Last vs standard tick diff (usec). */ | static long tick_delta; /* Last vs standard tick diff (usec). */ | ||||
static long tick_delta_sum; /* Accumulated tick difference (usec).*/ | static long tick_delta_sum; /* Accumulated tick difference (usec).*/ | ||||
static long tick_adjustment; /* Tick adjustments done. */ | static long tick_adjustment; /* Tick adjustments done. */ | ||||
static long tick_lost; /* Lost(coalesced) ticks number. */ | static long tick_lost; /* Lost(coalesced) ticks number. */ | ||||
/* Adjusted vs non-adjusted curr_time difference (ticks). */ | /* Adjusted vs non-adjusted curr_time difference (ticks). */ | ||||
static long tick_diff; | static long tick_diff; | ||||
static unsigned long io_pkt; | |||||
static unsigned long io_pkt_fast; | |||||
#ifdef NEW_AQM | |||||
unsigned long io_pkt_drop; | |||||
#else | |||||
static unsigned long io_pkt_drop; | |||||
#endif | |||||
/* | /* | ||||
* We use a heap to store entities for which we have pending timer events. | * We use a heap to store entities for which we have pending timer events. | ||||
* The heap is checked at every tick and all entities with expired events | * The heap is checked at every tick and all entities with expired events | ||||
* are extracted. | * are extracted. | ||||
*/ | */ | ||||
MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap"); | MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap"); | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, schk_count, | ||||
CTLFLAG_RD, DC(schk_count), 0, "Number of schedulers"); | CTLFLAG_RD, DC(schk_count), 0, "Number of schedulers"); | ||||
SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, si_count, | SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, si_count, | ||||
CTLFLAG_RD, DC(si_count), 0, "Number of scheduler instances"); | CTLFLAG_RD, DC(si_count), 0, "Number of scheduler instances"); | ||||
SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, fsk_count, | SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, fsk_count, | ||||
CTLFLAG_RD, DC(fsk_count), 0, "Number of flowsets"); | CTLFLAG_RD, DC(fsk_count), 0, "Number of flowsets"); | ||||
SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, queue_count, | SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, queue_count, | ||||
CTLFLAG_RD, DC(queue_count), 0, "Number of queues"); | CTLFLAG_RD, DC(queue_count), 0, "Number of queues"); | ||||
SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt, | SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt, | ||||
CTLFLAG_RD, &io_pkt, 0, | CTLFLAG_RD, DC(io_pkt), 0, | ||||
"Number of packets passed to dummynet."); | "Number of packets passed to dummynet."); | ||||
SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast, | SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast, | ||||
CTLFLAG_RD, &io_pkt_fast, 0, | CTLFLAG_RD, DC(io_pkt_fast), 0, | ||||
"Number of packets bypassed dummynet scheduler."); | "Number of packets bypassed dummynet scheduler."); | ||||
SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop, | SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop, | ||||
CTLFLAG_RD, &io_pkt_drop, 0, | CTLFLAG_RD, DC(io_pkt_drop), 0, | ||||
"Number of packets dropped by dummynet."); | "Number of packets dropped by dummynet."); | ||||
#undef DC | #undef DC | ||||
SYSEND | SYSEND | ||||
#endif | #endif | ||||
static void dummynet_send(struct mbuf *); | static void dummynet_send(struct mbuf *); | ||||
▲ Show 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | #endif | ||||
mq_append(&q->mq, m); | mq_append(&q->mq, m); | ||||
q->ni.length++; | q->ni.length++; | ||||
q->ni.len_bytes += len; | q->ni.len_bytes += len; | ||||
ni->length++; | ni->length++; | ||||
ni->len_bytes += len; | ni->len_bytes += len; | ||||
return (0); | return (0); | ||||
drop: | drop: | ||||
io_pkt_drop++; | dn_cfg.io_pkt_drop++; | ||||
q->ni.drops++; | q->ni.drops++; | ||||
ni->drops++; | ni->drops++; | ||||
FREE_PKT(m); | FREE_PKT(m); | ||||
return (1); | return (1); | ||||
} | } | ||||
/* | /* | ||||
* Fetch packets from the delay line which are due now. If there are | * Fetch packets from the delay line which are due now. If there are | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | if (fwa->flags & IPFW_ARGS_IN) | ||||
dir = DIR_IN; | dir = DIR_IN; | ||||
else | else | ||||
dir = DIR_OUT; | dir = DIR_OUT; | ||||
if (fwa->flags & IPFW_ARGS_ETHER) | if (fwa->flags & IPFW_ARGS_ETHER) | ||||
dir |= PROTO_LAYER2; | dir |= PROTO_LAYER2; | ||||
else if (fwa->flags & IPFW_ARGS_IP6) | else if (fwa->flags & IPFW_ARGS_IP6) | ||||
dir |= PROTO_IPV6; | dir |= PROTO_IPV6; | ||||
DN_BH_WLOCK(); | DN_BH_WLOCK(); | ||||
io_pkt++; | dn_cfg.io_pkt++; | ||||
/* we could actually tag outside the lock, but who cares... */ | /* we could actually tag outside the lock, but who cares... */ | ||||
if (tag_mbuf(m, dir, fwa)) | if (tag_mbuf(m, dir, fwa)) | ||||
goto dropit; | goto dropit; | ||||
if (dn_cfg.busy) { | if (dn_cfg.busy) { | ||||
/* if the upper half is busy doing something expensive, | /* if the upper half is busy doing something expensive, | ||||
* lets queue the packet and move forward | * lets queue the packet and move forward | ||||
*/ | */ | ||||
mq_append(&dn_cfg.pending, m); | mq_append(&dn_cfg.pending, m); | ||||
Show All 19 Lines | if (fs->sched->fp->flags & DN_MULTIQUEUE) { | ||||
if (q == NULL) | if (q == NULL) | ||||
goto dropit; | goto dropit; | ||||
} | } | ||||
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; | ||||
/* dn_enqueue already increases io_pkt_drop */ | /* dn_enqueue already increases io_pkt_drop */ | ||||
io_pkt_drop--; | dn_cfg.io_pkt_drop--; | ||||
goto dropit; | goto dropit; | ||||
} | } | ||||
if (si->kflags & DN_ACTIVE) { | if (si->kflags & DN_ACTIVE) { | ||||
m = *m0 = NULL; /* consumed */ | m = *m0 = NULL; /* consumed */ | ||||
goto done; /* already active, nothing to do */ | goto done; /* already active, nothing to do */ | ||||
} | } | ||||
Show All 21 Lines | dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) | ||||
* | * | ||||
*/ | */ | ||||
if (/*dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { | if (/*dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { | ||||
/* fast io, rename the tag * to carry reinject info. */ | /* fast io, rename the tag * to carry reinject info. */ | ||||
struct m_tag *tag = m_tag_first(m); | struct m_tag *tag = m_tag_first(m); | ||||
tag->m_tag_cookie = MTAG_IPFW_RULE; | tag->m_tag_cookie = MTAG_IPFW_RULE; | ||||
tag->m_tag_id = 0; | tag->m_tag_id = 0; | ||||
io_pkt_fast++; | dn_cfg.io_pkt_fast++; | ||||
if (m->m_nextpkt != NULL) { | if (m->m_nextpkt != NULL) { | ||||
printf("dummynet: fast io: pkt chain detected!\n"); | printf("dummynet: fast io: pkt chain detected!\n"); | ||||
m->m_nextpkt = NULL; | m->m_nextpkt = NULL; | ||||
} | } | ||||
m = NULL; | m = NULL; | ||||
} else { | } else { | ||||
*m0 = NULL; | *m0 = NULL; | ||||
} | } | ||||
done: | done: | ||||
DN_BH_WUNLOCK(); | DN_BH_WUNLOCK(); | ||||
if (m) | if (m) | ||||
dummynet_send(m); | dummynet_send(m); | ||||
return 0; | return 0; | ||||
dropit: | dropit: | ||||
io_pkt_drop++; | dn_cfg.io_pkt_drop++; | ||||
DN_BH_WUNLOCK(); | DN_BH_WUNLOCK(); | ||||
if (m) | if (m) | ||||
FREE_PKT(m); | FREE_PKT(m); | ||||
*m0 = NULL; | *m0 = NULL; | ||||
return (fs && (fs->fs.flags & DN_NOERROR)) ? 0 : ENOBUFS; | return (fs && (fs->fs.flags & DN_NOERROR)) ? 0 : ENOBUFS; | ||||
} | } |