Lines Matching +full:one +full:- +full:to +full:- +full:many

5 /*-
9 * Subject to the following obligations and disclaimer of warranty, use and
15 * 2. No rights are granted, in any manner or form, to use Whistle
21 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
44 * Packets received on the "one" hook are sent out each of the
45 * "many" hooks according to an algorithm. Packets received on any
46 * "many" hook are always delivered to the "one" hook.
62 /* Per-link private data */
68 /* Per-node private data */
70 node_p node; /* link to node */
72 struct ng_one2many_link one; /* "one" hook */ member
73 struct ng_one2many_link many[NG_ONE2MANY_MAX_LINKS]; member
74 u_int16_t nextMany; /* next round-robin */
75 u_int16_t numActiveMany; /* # active "many" */
121 /* List of commands and how to convert arguments to/from ASCII */
189 priv->conf.xmitAlg = NG_ONE2MANY_XMIT_ROUNDROBIN; in ng_one2many_constructor()
190 priv->conf.failAlg = NG_ONE2MANY_FAIL_MANUAL; in ng_one2many_constructor()
194 priv->node = node; in ng_one2many_constructor()
224 link = &priv->many[linkNum]; in ng_one2many_newhook()
227 link = &priv->one; in ng_one2many_newhook()
232 if (link->hook != NULL) in ng_one2many_newhook()
237 link->hook = hook; in ng_one2many_newhook()
238 bzero(&link->stats, sizeof(link->stats)); in ng_one2many_newhook()
240 priv->conf.enabledLinks[linkNum] = 1; /* auto-enable link */ in ng_one2many_newhook()
260 switch (msg->header.typecookie) { in ng_one2many_rcvmsg()
262 switch (msg->header.cmd) { in ng_one2many_rcvmsg()
269 if (msg->header.arglen != sizeof(*conf)) { in ng_one2many_rcvmsg()
273 conf = (struct ng_one2many_config *)msg->data; in ng_one2many_rcvmsg()
274 switch (conf->xmitAlg) { in ng_one2many_rcvmsg()
283 switch (conf->failAlg) { in ng_one2many_rcvmsg()
294 /* Normalized many link enabled bits */ in ng_one2many_rcvmsg()
296 conf->enabledLinks[i] = !!conf->enabledLinks[i]; in ng_one2many_rcvmsg()
299 bcopy(conf, &priv->conf, sizeof(*conf)); in ng_one2many_rcvmsg()
312 conf = (struct ng_one2many_config *)resp->data; in ng_one2many_rcvmsg()
313 bcopy(&priv->conf, conf, sizeof(priv->conf)); in ng_one2many_rcvmsg()
324 if (msg->header.arglen != sizeof(int32_t)) { in ng_one2many_rcvmsg()
328 linkNum = *((int32_t *)msg->data); in ng_one2many_rcvmsg()
330 link = &priv->one; in ng_one2many_rcvmsg()
333 link = &priv->many[linkNum]; in ng_one2many_rcvmsg()
340 if (msg->header.cmd != NGM_ONE2MANY_CLR_STATS) { in ng_one2many_rcvmsg()
342 sizeof(link->stats), M_NOWAIT); in ng_one2many_rcvmsg()
347 bcopy(&link->stats, in ng_one2many_rcvmsg()
348 resp->data, sizeof(link->stats)); in ng_one2many_rcvmsg()
350 if (msg->header.cmd != NGM_ONE2MANY_GET_STATS) in ng_one2many_rcvmsg()
351 bzero(&link->stats, sizeof(link->stats)); in ng_one2many_rcvmsg()
360 * One of our downstreams notifies us of link change. If we are in ng_one2many_rcvmsg()
361 * configured to listen to these message, then we remove/add in ng_one2many_rcvmsg()
368 if (priv->conf.failAlg != NG_ONE2MANY_FAIL_NOTIFY) in ng_one2many_rcvmsg()
381 switch (msg->header.cmd) { in ng_one2many_rcvmsg()
383 priv->conf.enabledLinks[linkNum] = 1; in ng_one2many_rcvmsg()
387 priv->conf.enabledLinks[linkNum] = 0; in ng_one2many_rcvmsg()
430 &priv->one : &priv->many[linkNum]; in ng_one2many_rcvdata()
431 KASSERT(src->hook != NULL, ("%s: no src%d", __func__, linkNum)); in ng_one2many_rcvdata()
434 src->stats.recvPackets++; in ng_one2many_rcvdata()
435 src->stats.recvOctets += m->m_pkthdr.len; in ng_one2many_rcvdata()
439 if (priv->numActiveMany == 0) { in ng_one2many_rcvdata()
443 switch(priv->conf.xmitAlg) { in ng_one2many_rcvdata()
445 dst = &priv->many[priv->activeMany[priv->nextMany]]; in ng_one2many_rcvdata()
446 priv->nextMany = (priv->nextMany + 1) % priv->numActiveMany; in ng_one2many_rcvdata()
449 /* no need to copy data for the 1st one */ in ng_one2many_rcvdata()
450 dst = &priv->many[priv->activeMany[0]]; in ng_one2many_rcvdata()
453 * links except the first one, which we'll do last in ng_one2many_rcvdata()
455 for (i = 1; i < priv->numActiveMany; i++) { in ng_one2many_rcvdata()
459 mdst = &priv->many[priv->activeMany[i]]; in ng_one2many_rcvdata()
462 mdst->stats.memoryFailures++; in ng_one2many_rcvdata()
468 mdst->stats.xmitPackets++; in ng_one2many_rcvdata()
469 mdst->stats.xmitOctets += m->m_pkthdr.len; in ng_one2many_rcvdata()
470 NG_SEND_DATA_ONLY(error, mdst->hook, m2); in ng_one2many_rcvdata()
474 dst = &priv->many[priv->activeMany[0]]; in ng_one2many_rcvdata()
482 dst = &priv->one; in ng_one2many_rcvdata()
486 dst->stats.xmitPackets++; in ng_one2many_rcvdata()
487 dst->stats.xmitOctets += m->m_pkthdr.len; in ng_one2many_rcvdata()
490 NG_FWD_ITEM_HOOK(error, item, dst->hook); in ng_one2many_rcvdata()
502 KASSERT(priv->numActiveMany == 0, in ng_one2many_shutdown()
503 ("%s: numActiveMany=%d", __func__, priv->numActiveMany)); in ng_one2many_shutdown()
527 priv->one.hook = NULL; in ng_one2many_disconnect()
529 priv->many[linkNum].hook = NULL; in ng_one2many_disconnect()
530 priv->conf.enabledLinks[linkNum] = 0; in ng_one2many_disconnect()
546 * Update internal state after the addition or removal of a "many" link
551 uint16_t saveActive = priv->numActiveMany; in ng_one2many_update_many()
554 /* Update list of which "many" links are up */ in ng_one2many_update_many()
555 priv->numActiveMany = 0; in ng_one2many_update_many()
557 switch (priv->conf.failAlg) { in ng_one2many_update_many()
560 if (priv->many[linkNum].hook != NULL in ng_one2many_update_many()
561 && priv->conf.enabledLinks[linkNum]) { in ng_one2many_update_many()
562 priv->activeMany[priv->numActiveMany] = linkNum; in ng_one2many_update_many()
563 priv->numActiveMany++; in ng_one2many_update_many()
573 if (priv->numActiveMany == 0 && saveActive > 0) in ng_one2many_update_many()
576 if (saveActive == 0 && priv->numActiveMany > 0) in ng_one2many_update_many()
580 switch (priv->conf.xmitAlg) { in ng_one2many_update_many()
582 if (priv->numActiveMany > 0) in ng_one2many_update_many()
583 priv->nextMany %= priv->numActiveMany; in ng_one2many_update_many()
596 * Notify upstream if we are out of links, or we have at least one link.
604 if (priv->one.hook == NULL) in ng_one2many_notify()
609 NG_SEND_MSG_HOOK(dummy_error, priv->node, msg, priv->one.hook, 0); in ng_one2many_notify()