45#include <sys/kernel.h>
46#include <sys/malloc.h>
56#define NG_CAR_QUEUE_SIZE 100
57#define NG_CAR_QUEUE_MIN_TH 8
194 priv = malloc(
sizeof(*
priv), M_NETGRAPH, M_WAITOK | M_ZERO);
216 mtx_init(&
priv->
upper.q_mtx,
"ng_car_u", NULL, MTX_DEF);
231 mtx_init(&
priv->
lower.q_mtx,
"ng_car_l", NULL, MTX_DEF);
280#define NG_CAR_PERFORM_MATCH_ACTION(a,col) \
283 case NG_CAR_ACTION_FORWARD: \
286 case NG_CAR_ACTION_MARK: \
287 if (colp == NULL) { \
288 colp = (void *)m_tag_alloc( \
289 M_QOS_COOKIE, M_QOS_COLOR, \
290 MTAG_SIZE(m_qos_color), M_NOWAIT); \
292 m_tag_prepend(m, &colp->tag); \
297 case NG_CAR_ACTION_DROP: \
300 NG_FREE_ITEM(item); \
301 ++hinfo->stats.dropped_pkts; \
310 len = m->m_pkthdr.len;
349 if (len - (hinfo->
tc - len) > hinfo->
conf.
ebs ||
360 }
else if (hinfo->
te + (len - hinfo->
tc) < hinfo->
conf.
ebs &&
364 hinfo->
te += len - hinfo->
tc;
398#undef NG_CAR_PERFORM_MATCH_ACTION
429 sizeof(*bstats), M_NOWAIT);
454 sizeof(*bconf), M_NOWAIT);
576 free(
priv, M_NETGRAPH);
620 struct bintime newt, deltat;
621 unsigned int deltat_us;
631 if (deltat.sec < 0) {
637 if (deltat.sec >= 1000) {
638 deltat_us = (1000 << 20);
641 deltat_us = (deltat.sec << 20) + (deltat.frac >> 44);
647 h->
tc += (h->
conf.
cir * deltat_us) >> 23;
660 h->
tc += (h->
conf.
cir * deltat_us) >> 23;
665 h->
te += (h->
conf.
pir * deltat_us) >> 23;
671 h->
tc += (h->
conf.
cir * deltat_us) >> 23;
688 delay = (-(hinfo->
tc)) * hz * 8 / hinfo->
conf.
cir + 1;
708 while (hinfo->
tc >= 0) {
730 hinfo->
tc -= m->m_pkthdr.len;
762 mtx_lock(&hinfo->
q_mtx);
798 hinfo->
tc -= m->m_pkthdr.len;
807 mtx_unlock(&hinfo->
q_mtx);
#define NG_HOOK_NODE(hook)
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
#define NG_FWD_ITEM_HOOK(error, item, hook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_RESPOND_MSG(error, here, item, resp)
#define NG_NODE_IS_VALID(node)
#define NG_NODE_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
int ng_rmnode_self(node_p here)
#define ng_callout_init(c)
#define NG_SEND_DATA_ONLY(error, hook, m)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
int ng_uncallout(struct callout *c, node_p node)
#define NG_FREE_ITEM(item)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks, ng_item_fn *fn, void *arg1, int arg2)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_HOOK_PRIVATE(hook)
#define NG_CAR_QUEUE_SIZE
NETGRAPH_INIT(car, &ng_car_typestruct)
static ng_rcvdata_t ng_car_rcvdata
static ng_newhook_t ng_car_newhook
static const struct ng_parse_type ng_car_hookconf_type
#define NG_CAR_PERFORM_MATCH_ACTION(a, col)
static ng_disconnect_t ng_car_disconnect
static const struct ng_parse_struct_field ng_car_hookconf_type_fields[]
static const struct ng_parse_type ng_car_bulkconf_type
static const struct ng_parse_type ng_car_bulkstats_type
void ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2)
static ng_shutdown_t ng_car_shutdown
static const struct ng_parse_struct_field ng_car_bulkstats_type_fields[]
static struct ng_type ng_car_typestruct
static void ng_car_enqueue(struct hookinfo *h, item_p item)
static struct ng_cmdlist ng_car_cmdlist[]
static void ng_car_schedule(struct hookinfo *h)
static const struct ng_parse_struct_field ng_car_hookstats_type_fields[]
static void ng_car_refillhook(struct hookinfo *h)
static const struct ng_parse_type ng_car_hookstats_type
static ng_constructor_t ng_car_constructor
#define NG_CAR_QUEUE_MIN_TH
static const struct ng_parse_struct_field ng_car_bulkconf_type_fields[]
static ng_rcvmsg_t ng_car_rcvmsg
#define NG_CAR_COUNT_PACKETS
#define NG_CAR_HOOK_LOWER
#define NG_CAR_HOOK_UPPER
#define NG_CAR_BULKSTATS(hstatstype)
#define NG_CAR_BULKCONF(hconftype)
#define NG_CAR_COLOR_AWARE
#define NG_MKRESPONSE(rsp, msg, len, how)
const struct ng_parse_type ng_parse_struct_type
struct mbuf * q[NG_CAR_QUEUE_SIZE]
struct bintime lastRefill
struct ng_car_hookstats stats
struct ng_car_hookconf conf
struct ng_car_hookconf upstream
struct ng_car_hookconf downstream
struct ng_car_hookstats downstream
struct ng_car_hookstats upstream
struct ng_mesg::ng_msghdr header