Lines Matching refs:ifd
65 #define reset_cutoff(ifd) { ifd->cutoff_ = RM_MAXDEPTH; } argument
179 rmc_newclass(int pri, struct rm_ifdat *ifd, u_int nsecPerByte, in rmc_newclass() argument
232 cl->ifdat_ = ifd; in rmc_newclass()
310 IFQ_LOCK(ifd->ifq_); in rmc_newclass()
311 if ((peer = ifd->active_[pri]) != NULL) { in rmc_newclass()
314 while (peer->peer_ != ifd->active_[pri]) in rmc_newclass()
318 ifd->active_[pri] = cl; in rmc_newclass()
337 if (ifd->wrr_) { in rmc_newclass()
338 ifd->num_[pri]++; in rmc_newclass()
339 ifd->alloc_[pri] += cl->allotment_; in rmc_newclass()
340 rmc_wrr_set_weights(ifd); in rmc_newclass()
342 IFQ_UNLOCK(ifd->ifq_); in rmc_newclass()
351 struct rm_ifdat *ifd; in rmc_modclass() local
355 ifd = cl->ifdat_; in rmc_modclass()
359 IFQ_LOCK(ifd->ifq_); in rmc_modclass()
389 if (ifd->wrr_) { in rmc_modclass()
390 ifd->alloc_[cl->pri_] += cl->allotment_ - old_allotment; in rmc_modclass()
391 rmc_wrr_set_weights(ifd); in rmc_modclass()
393 IFQ_UNLOCK(ifd->ifq_); in rmc_modclass()
408 rmc_wrr_set_weights(struct rm_ifdat *ifd) in rmc_wrr_set_weights() argument
418 if (ifd->num_[i] == 0) in rmc_wrr_set_weights()
419 ifd->M_[i] = 0; in rmc_wrr_set_weights()
421 ifd->M_[i] = ifd->alloc_[i] / in rmc_wrr_set_weights()
422 (ifd->num_[i] * ifd->maxpkt_); in rmc_wrr_set_weights()
430 if (ifd->active_[i] != NULL) { in rmc_wrr_set_weights()
431 clh = cl = ifd->active_[i]; in rmc_wrr_set_weights()
434 if (ifd->M_[i] == 0) in rmc_wrr_set_weights()
438 ifd->M_[i]; in rmc_wrr_set_weights()
446 rmc_get_weight(struct rm_ifdat *ifd, int pri) in rmc_get_weight() argument
449 return (ifd->M_[pri]); in rmc_get_weight()
544 rmc_delete_class(struct rm_ifdat *ifd, struct rm_class *cl) in rmc_delete_class() argument
555 IFQ_LOCK(ifd->ifq_); in rmc_delete_class()
592 if ((p = ifd->active_[cl->pri_]) != NULL) { in rmc_delete_class()
602 if (ifd->active_[cl->pri_] == cl) in rmc_delete_class()
603 ifd->active_[cl->pri_] = cl->peer_; in rmc_delete_class()
606 ifd->active_[cl->pri_] = NULL; in rmc_delete_class()
613 if (ifd->wrr_) { in rmc_delete_class()
614 ifd->alloc_[cl->pri_] -= cl->allotment_; in rmc_delete_class()
615 ifd->num_[cl->pri_]--; in rmc_delete_class()
616 rmc_wrr_set_weights(ifd); in rmc_delete_class()
625 rmc_depth_recompute(ifd->root_); in rmc_delete_class()
628 IFQ_UNLOCK(ifd->ifq_); in rmc_delete_class()
669 rmc_init(struct ifaltq *ifq, struct rm_ifdat *ifd, u_int nsecPerByte, in rmc_init() argument
680 bzero((char *)ifd, sizeof (*ifd)); in rmc_init()
682 ifd->ifq_ = ifq; in rmc_init()
683 ifd->restart = restart; in rmc_init()
684 ifd->maxqueued_ = maxqueued; in rmc_init()
685 ifd->ns_per_byte_ = nsecPerByte; in rmc_init()
686 ifd->maxpkt_ = mtu; in rmc_init()
687 ifd->wrr_ = (flags & RMCF_WRR) ? 1 : 0; in rmc_init()
688 ifd->efficient_ = (flags & RMCF_EFFICIENT) ? 1 : 0; in rmc_init()
690 ifd->maxiftime_ = mtu * nsecPerByte / 1000 * 16; in rmc_init()
692 ifd->maxiftime_ /= 4; in rmc_init()
695 reset_cutoff(ifd); in rmc_init()
696 CBQTRACE(rmc_init, 'INIT', ifd->cutoff_); in rmc_init()
702 ifd->alloc_[i] = 0; in rmc_init()
703 ifd->M_[i] = 0; in rmc_init()
704 ifd->num_[i] = 0; in rmc_init()
705 ifd->na_[i] = 0; in rmc_init()
706 ifd->active_[i] = NULL; in rmc_init()
712 ifd->qi_ = 0; in rmc_init()
713 ifd->qo_ = 0; in rmc_init()
715 ifd->class_[i] = NULL; in rmc_init()
716 ifd->curlen_[i] = 0; in rmc_init()
717 ifd->borrowed_[i] = NULL; in rmc_init()
723 if ((ifd->root_ = rmc_newclass(0, ifd, in rmc_init()
731 ifd->root_->depth_ = 0; in rmc_init()
749 struct rm_ifdat *ifd = cl->ifdat_; in rmc_queue_packet() local
754 if (ifd->cutoff_ > 0) { in rmc_queue_packet()
756 if (ifd->cutoff_ > cl->depth_) in rmc_queue_packet()
757 ifd->cutoff_ = cl->depth_; in rmc_queue_packet()
770 borrow->depth_ < ifd->cutoff_) { in rmc_queue_packet()
772 ifd->cutoff_ = borrow->depth_; in rmc_queue_packet()
773 CBQTRACE(rmc_queue_packet, 'ffob', ifd->cutoff_); in rmc_queue_packet()
780 else if ((ifd->cutoff_ > 1) && cl->borrow_) { in rmc_queue_packet()
782 ifd->cutoff_ = cl->borrow_->depth_; in rmc_queue_packet()
796 ifd->na_[cpri]++; in rmc_queue_packet()
814 rmc_tl_satisfied(struct rm_ifdat *ifd, struct timeval *now) in rmc_tl_satisfied() argument
820 if ((bp = ifd->active_[i]) != NULL) { in rmc_tl_satisfied()
824 ifd->cutoff_ = p->depth_; in rmc_tl_satisfied()
832 reset_cutoff(ifd); in rmc_tl_satisfied()
877 struct rm_ifdat *ifd = cl->ifdat_; in rmc_under_limit() local
879 ifd->borrowed_[ifd->qi_] = NULL; in rmc_under_limit()
900 (cl->depth_ > ifd->cutoff_)) { in rmc_under_limit()
917 CBQTRACE(rmc_under_limit, 'ffou', ifd->cutoff_); in rmc_under_limit()
933 ifd->borrowed_[ifd->qi_] = cl; in rmc_under_limit()
955 _rmc_wrr_dequeue_next(struct rm_ifdat *ifd, int op) in _rmc_wrr_dequeue_next() argument
969 if (op == ALTDQ_REMOVE && ifd->pollcache_) { in _rmc_wrr_dequeue_next()
970 cl = ifd->pollcache_; in _rmc_wrr_dequeue_next()
972 if (ifd->efficient_) { in _rmc_wrr_dequeue_next()
978 ifd->pollcache_ = NULL; in _rmc_wrr_dequeue_next()
983 ifd->pollcache_ = NULL; in _rmc_wrr_dequeue_next()
984 ifd->borrowed_[ifd->qi_] = NULL; in _rmc_wrr_dequeue_next()
990 if (ifd->na_[cpri] == 0) in _rmc_wrr_dequeue_next()
1003 cl = ifd->active_[cpri]; in _rmc_wrr_dequeue_next()
1017 ifd->borrowed_[ifd->qi_] = NULL; in _rmc_wrr_dequeue_next()
1026 } while (cl != ifd->active_[cpri]); in _rmc_wrr_dequeue_next()
1041 if (first != NULL && ifd->cutoff_ < ifd->root_->depth_) { in _rmc_wrr_dequeue_next()
1042 ifd->cutoff_++; in _rmc_wrr_dequeue_next()
1043 CBQTRACE(_rmc_wrr_dequeue_next, 'ojda', ifd->cutoff_); in _rmc_wrr_dequeue_next()
1052 reset_cutoff(ifd); in _rmc_wrr_dequeue_next()
1053 CBQTRACE(_rmc_wrr_dequeue_next, 'otsr', ifd->cutoff_); in _rmc_wrr_dequeue_next()
1055 if (!ifd->efficient_ || first == NULL) in _rmc_wrr_dequeue_next()
1066 ifd->borrowed_[ifd->qi_] = cl->borrow_; in _rmc_wrr_dequeue_next()
1067 ifd->cutoff_ = cl->borrow_->depth_; in _rmc_wrr_dequeue_next()
1078 ifd->na_[cpri]--; in _rmc_wrr_dequeue_next()
1087 ifd->active_[cl->pri_] = cl->peer_; in _rmc_wrr_dequeue_next()
1089 ifd->active_[cl->pri_] = cl; in _rmc_wrr_dequeue_next()
1091 ifd->class_[ifd->qi_] = cl; in _rmc_wrr_dequeue_next()
1092 ifd->curlen_[ifd->qi_] = m_pktlen(m); in _rmc_wrr_dequeue_next()
1093 ifd->now_[ifd->qi_] = now; in _rmc_wrr_dequeue_next()
1094 ifd->qi_ = (ifd->qi_ + 1) % ifd->maxqueued_; in _rmc_wrr_dequeue_next()
1095 ifd->queued_++; in _rmc_wrr_dequeue_next()
1099 ifd->pollcache_ = cl; in _rmc_wrr_dequeue_next()
1111 _rmc_prr_dequeue_next(struct rm_ifdat *ifd, int op) in _rmc_prr_dequeue_next() argument
1124 if (op == ALTDQ_REMOVE && ifd->pollcache_) { in _rmc_prr_dequeue_next()
1125 cl = ifd->pollcache_; in _rmc_prr_dequeue_next()
1127 ifd->pollcache_ = NULL; in _rmc_prr_dequeue_next()
1131 ifd->pollcache_ = NULL; in _rmc_prr_dequeue_next()
1132 ifd->borrowed_[ifd->qi_] = NULL; in _rmc_prr_dequeue_next()
1138 if (ifd->na_[cpri] == 0) in _rmc_prr_dequeue_next()
1140 cl = ifd->active_[cpri]; in _rmc_prr_dequeue_next()
1151 } while (cl != ifd->active_[cpri]); in _rmc_prr_dequeue_next()
1159 if (first != NULL && ifd->cutoff_ < ifd->root_->depth_) { in _rmc_prr_dequeue_next()
1160 ifd->cutoff_++; in _rmc_prr_dequeue_next()
1169 reset_cutoff(ifd); in _rmc_prr_dequeue_next()
1170 if (!ifd->efficient_ || first == NULL) in _rmc_prr_dequeue_next()
1181 ifd->borrowed_[ifd->qi_] = cl->borrow_; in _rmc_prr_dequeue_next()
1182 ifd->cutoff_ = cl->borrow_->depth_; in _rmc_prr_dequeue_next()
1193 ifd->na_[cpri]--; in _rmc_prr_dequeue_next()
1195 ifd->active_[cpri] = cl->peer_; in _rmc_prr_dequeue_next()
1197 ifd->class_[ifd->qi_] = cl; in _rmc_prr_dequeue_next()
1198 ifd->curlen_[ifd->qi_] = m_pktlen(m); in _rmc_prr_dequeue_next()
1199 ifd->now_[ifd->qi_] = now; in _rmc_prr_dequeue_next()
1200 ifd->qi_ = (ifd->qi_ + 1) % ifd->maxqueued_; in _rmc_prr_dequeue_next()
1201 ifd->queued_++; in _rmc_prr_dequeue_next()
1205 ifd->pollcache_ = cl; in _rmc_prr_dequeue_next()
1225 rmc_dequeue_next(struct rm_ifdat *ifd, int mode) in rmc_dequeue_next() argument
1227 if (ifd->queued_ >= ifd->maxqueued_) in rmc_dequeue_next()
1229 else if (ifd->wrr_) in rmc_dequeue_next()
1230 return (_rmc_wrr_dequeue_next(ifd, mode)); in rmc_dequeue_next()
1232 return (_rmc_prr_dequeue_next(ifd, mode)); in rmc_dequeue_next()
1249 rmc_update_class_util(struct rm_ifdat *ifd) in rmc_update_class_util() argument
1260 if ((cl = ifd->class_[ifd->qo_]) == NULL) in rmc_update_class_util()
1263 pktlen = ifd->curlen_[ifd->qo_]; in rmc_update_class_util()
1264 borrowed = ifd->borrowed_[ifd->qo_]; in rmc_update_class_util()
1279 nowp = &ifd->now_[ifd->qo_]; in rmc_update_class_util()
1282 pkt_time = ifd->curlen_[ifd->qo_] * ifd->ns_per_byte_; in rmc_update_class_util()
1285 pkt_time = ifd->curlen_[ifd->qo_] * ifd->ns_per_byte_ / 1000; in rmc_update_class_util()
1288 if (TV_LT(nowp, &ifd->ifnow_)) { in rmc_update_class_util()
1297 TV_DELTA(&ifd->ifnow_, nowp, iftime); in rmc_update_class_util()
1298 if (iftime+pkt_time < ifd->maxiftime_) { in rmc_update_class_util()
1299 TV_ADD_DELTA(&ifd->ifnow_, pkt_time, &ifd->ifnow_); in rmc_update_class_util()
1301 TV_ADD_DELTA(nowp, ifd->maxiftime_, &ifd->ifnow_); in rmc_update_class_util()
1304 TV_ADD_DELTA(nowp, pkt_time, &ifd->ifnow_); in rmc_update_class_util()
1307 if (TV_LT(nowp, &ifd->ifnow_)) { in rmc_update_class_util()
1308 TV_ADD_DELTA(&ifd->ifnow_, pkt_time, &ifd->ifnow_); in rmc_update_class_util()
1310 TV_ADD_DELTA(nowp, pkt_time, &ifd->ifnow_); in rmc_update_class_util()
1315 TV_DELTA(&ifd->ifnow_, &cl->last_, idle); in rmc_update_class_util()
1368 cl->last_ = ifd->ifnow_; in rmc_update_class_util()
1384 cl = ifd->class_[ifd->qo_]; in rmc_update_class_util()
1385 if (borrowed && (ifd->cutoff_ >= borrowed->depth_)) { in rmc_update_class_util()
1388 rmc_tl_satisfied(ifd, nowp); in rmc_update_class_util()
1389 CBQTRACE(rmc_update_class_util, 'broe', ifd->cutoff_); in rmc_update_class_util()
1391 ifd->cutoff_ = borrowed->depth_; in rmc_update_class_util()
1396 reset_cutoff(ifd); in rmc_update_class_util()
1398 rmc_tl_satisfied(ifd, &now); in rmc_update_class_util()
1400 CBQTRACE(rmc_update_class_util, 'broe', ifd->cutoff_); in rmc_update_class_util()
1402 ifd->cutoff_ = borrowed->depth_; in rmc_update_class_util()
1411 ifd->borrowed_[ifd->qo_] = NULL; in rmc_update_class_util()
1412 ifd->class_[ifd->qo_] = NULL; in rmc_update_class_util()
1413 ifd->qo_ = (ifd->qo_ + 1) % ifd->maxqueued_; in rmc_update_class_util()
1414 ifd->queued_--; in rmc_update_class_util()
1430 struct rm_ifdat *ifd = cl->ifdat_; in rmc_drop_action() local
1435 ifd->na_[cl->pri_]--; in rmc_drop_action()
1440 struct rm_ifdat *ifd = cl->ifdat_; in rmc_dropall() local
1445 ifd->na_[cl->pri_]--; in rmc_dropall()
1548 struct rm_ifdat *ifd = cl->ifdat_; in rmc_restart() local
1554 IFQ_LOCK(ifd->ifq_); in rmc_restart()
1555 CURVNET_SET(ifd->ifq_->altq_ifp->if_vnet); in rmc_restart()
1560 if (ifd->queued_ < ifd->maxqueued_ && ifd->restart != NULL) { in rmc_restart()
1562 (ifd->restart)(ifd->ifq_); in rmc_restart()
1566 IFQ_UNLOCK(ifd->ifq_); in rmc_restart()