Lines Matching refs:vifp
230 #define VIF_REFHOLD(vifp) { \
231 mutex_enter(&(vifp)->v_lock); \
232 (vifp)->v_refcnt++; \
233 mutex_exit(&(vifp)->v_lock); \
236 #define VIF_REFRELE_LOCKED(vifp) { \
237 (vifp)->v_refcnt--; \
238 if ((vifp)->v_refcnt == 0 && \
239 ((vifp)->v_marks & VIF_MARK_CONDEMNED)) { \
240 del_vifp(vifp); \
242 mutex_exit(&(vifp)->v_lock); \
246 #define VIF_REFRELE(vifp) { \
247 mutex_enter(&(vifp)->v_lock); \
248 (vifp)->v_refcnt--; \
249 if ((vifp)->v_refcnt == 0 && \
250 ((vifp)->v_marks & VIF_MARK_CONDEMNED)) { \
251 del_vifp(vifp); \
253 mutex_exit(&(vifp)->v_lock); \
650 struct vif *vifp = ipst->ips_vifs + vifi;
652 mutex_enter(&vifp->v_lock);
656 if (vifp->v_marks & VIF_MARK_GOOD) {
657 ASSERT(vifp->v_ipif != NULL);
658 ipif_refhold(vifp->v_ipif);
660 if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) {
661 ipif_t *ipif = vifp->v_ipif;
662 ilm_t *ilm = vifp->v_ilm;
664 vifp->v_ilm = NULL;
665 vifp->v_marks &= ~VIF_MARK_GOOD;
666 vifp->v_marks |= VIF_MARK_CONDEMNED;
668 mutex_exit(&(vifp)->v_lock);
676 mutex_enter(&vifp->v_lock);
678 ipif_refrele(vifp->v_ipif);
683 VIF_REFRELE_LOCKED(vifp);
685 mutex_exit(&vifp->v_lock);
801 unlock_good_vif(struct vif *vifp)
803 ASSERT(vifp->v_ipif != NULL);
804 ipif_refrele(vifp->v_ipif);
805 VIF_REFRELE(vifp);
809 lock_good_vif(struct vif *vifp)
811 mutex_enter(&vifp->v_lock);
812 if (!(vifp->v_marks & VIF_MARK_GOOD)) {
813 mutex_exit(&vifp->v_lock);
817 ASSERT(vifp->v_ipif != NULL);
818 mutex_enter(&vifp->v_ipif->ipif_ill->ill_lock);
819 if (!IPIF_CAN_LOOKUP(vifp->v_ipif)) {
820 mutex_exit(&vifp->v_ipif->ipif_ill->ill_lock);
821 mutex_exit(&vifp->v_lock);
824 ipif_refhold_locked(vifp->v_ipif);
825 mutex_exit(&vifp->v_ipif->ipif_ill->ill_lock);
826 vifp->v_refcnt++;
827 mutex_exit(&vifp->v_lock);
837 struct vif *vifp = ipst->ips_vifs + vifcp->vifc_vifi;
853 mutex_enter(&vifp->v_lock);
866 if (vifp->v_lcl_addr.s_addr != 0 ||
867 vifp->v_marks != 0 ||
868 vifp->v_refcnt != 0) {
869 mutex_exit(&vifp->v_lock);
875 mutex_exit(&vifp->v_lock);
879 vifp->v_refcnt++;
880 mutex_exit(&vifp->v_lock);
885 VIF_REFRELE(vifp);
895 mutex_enter(&vifp->v_lock);
911 VIF_REFRELE_LOCKED(vifp);
915 vifp->v_rmt_addr = vifcp->vifc_rmt_addr;
932 VIF_REFRELE_LOCKED(vifp);
940 VIF_REFRELE_LOCKED(vifp);
950 mutex_exit(&vifp->v_lock);
969 mutex_enter(&vifp->v_lock);
985 VIF_REFRELE_LOCKED(vifp);
989 vifp->v_ilm = ilm;
992 vifp->v_tbf = v_tbf;
993 gethrestime(&vifp->v_tbf->tbf_last_pkt_t);
994 vifp->v_tbf->tbf_n_tok = 0;
995 vifp->v_tbf->tbf_q_len = 0;
996 vifp->v_tbf->tbf_max_q_len = MAXQSIZE;
997 vifp->v_tbf->tbf_q = vifp->v_tbf->tbf_t = NULL;
999 vifp->v_flags = vifcp->vifc_flags;
1000 vifp->v_threshold = vifcp->vifc_threshold;
1001 vifp->v_lcl_addr = vifcp->vifc_lcl_addr;
1002 vifp->v_ipif = ipif;
1005 vifp->v_rate_limit = vifcp->vifc_rate_limit * (1024/1000);
1006 vifp->v_timeout_id = 0;
1008 vifp->v_pkt_in = 0;
1009 vifp->v_pkt_out = 0;
1010 vifp->v_bytes_in = 0;
1011 vifp->v_bytes_out = 0;
1012 mutex_init(&vifp->v_tbf->tbf_lock, NULL, MUTEX_DEFAULT, NULL);
1030 vifp->v_marks = VIF_MARK_GOOD;
1031 mutex_exit(&vifp->v_lock);
1038 del_vifp(struct vif *vifp)
1040 struct tbf *t = vifp->v_tbf;
1043 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
1046 ASSERT(vifp->v_marks & VIF_MARK_CONDEMNED);
1051 "del_vif: src 0x%x\n", vifp->v_lcl_addr.s_addr);
1054 if (vifp->v_timeout_id != 0) {
1055 (void) untimeout(vifp->v_timeout_id);
1056 vifp->v_timeout_id = 0;
1077 if (vifp == ipst->ips_last_encap_vif) {
1085 bzero(vifp->v_tbf, sizeof (*(vifp->v_tbf)));
1095 bzero(vifp, sizeof (*vifp));
1101 struct vif *vifp = ipst->ips_vifs + *vifip;
1106 mutex_enter(&vifp->v_lock);
1110 * i.e vifp->v_marks == 0 and refcnt > 0.
1112 if (vifp->v_lcl_addr.s_addr == 0 ||
1113 !(vifp->v_marks & VIF_MARK_GOOD)) {
1114 mutex_exit(&vifp->v_lock);
1119 vifp->v_marks &= ~VIF_MARK_GOOD;
1120 vifp->v_marks |= VIF_MARK_CONDEMNED;
1123 if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) {
1124 ipif_t *ipif = vifp->v_ipif;
1125 ilm_t *ilm = vifp->v_ilm;
1127 vifp->v_ilm = NULL;
1134 mutex_exit(&(vifp)->v_lock);
1140 mutex_enter(&(vifp)->v_lock);
1143 if (vifp->v_flags & VIFF_REGISTER) {
1152 VIF_REFRELE_LOCKED(vifp);
1979 struct vif *vifp;
1995 #define MC_SEND(ipha, mp, vifp, dst) { \
1996 if ((vifp)->v_flags & VIFF_TUNNEL) \
1997 encap_send((ipha), (mp), (vifp), (dst)); \
1998 else if ((vifp)->v_flags & VIFF_REGISTER) \
1999 register_send((ipha), (mp), (vifp), (dst)); \
2001 phyint_send((ipha), (mp), (vifp), (dst)); \
2133 for (vifp = ipst->ips_vifs, vifi = 0;
2135 vifp++, vifi++) {
2136 if (!lock_good_vif(vifp))
2144 ASSERT(vifp->v_ipif != NULL);
2145 vifp->v_pkt_out++;
2146 vifp->v_bytes_out += plen;
2147 MC_SEND(ipha, mp, vifp, dst);
2150 unlock_good_vif(vifp);
2164 phyint_send(ipha_t *ipha, mblk_t *mp, struct vif *vifp, ipaddr_t dst)
2167 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
2177 if (vifp->v_rate_limit <= 0)
2178 tbf_send_packet(vifp, mp_copy);
2183 "vifp 0x%p mp 0x%p dst 0x%x",
2184 vifp->v_rate_limit, (void *)vifp, (void *)mp, dst);
2186 tbf_control(vifp, mp_copy, (ipha_t *)mp_copy->b_rptr);
2196 register_send(ipha_t *ipha, mblk_t *mp, struct vif *vifp, ipaddr_t dst)
2201 ill_t *ill = vifp->v_ipif->ipif_ill;
2536 encap_send(ipha_t *ipha, mblk_t *mp, struct vif *vifp, ipaddr_t dst)
2541 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
2547 (ptrdiff_t)(vifp - ipst->ips_vifs));
2574 ipha_copy->ipha_src = vifp->v_lcl_addr.s_addr;
2575 ipha_copy->ipha_dst = vifp->v_rmt_addr.s_addr;
2590 if (vifp->v_rate_limit <= 0)
2591 tbf_send_packet(vifp, mp_copy);
2594 tbf_control(vifp, mp_copy, ipha);
2613 struct vif *vifp;
2665 vifp = ipst->ips_vifs;
2666 vife = vifp + ipst->ips_numvifs;
2669 for (; vifp < vife; ++vifp) {
2670 if (!lock_good_vif(vifp))
2672 if (vifp->v_rmt_addr.s_addr == src) {
2673 if (vifp->v_flags & VIFF_TUNNEL)
2674 ipst->ips_last_encap_vif = vifp;
2680 (ptrdiff_t)(vifp - ipst->ips_vifs),
2683 unlock_good_vif(vifp);
2686 unlock_good_vif(vifp);
2689 if ((vifp = ipst->ips_last_encap_vif) == 0) {
2696 (ptrdiff_t)(vifp - ipst->ips_vifs), ntohl(src)));
2827 tbf_control(struct vif *vifp, mblk_t *mp, ipha_t *ipha)
2830 struct tbf *t = vifp->v_tbf;
2832 ill_t *ill = vifp->v_ipif->ipif_ill;
2847 (ptrdiff_t)(vifp - ipst->ips_vifs), t->tbf_q_len,
2853 tbf_update_tokens(vifp);
2862 (ptrdiff_t)(vifp - ipst->ips_vifs), t->tbf_n_tok, p_len,
2871 tbf_send_packet(vifp, mp);
2875 tbf_queue(vifp, mp);
2876 ASSERT(vifp->v_timeout_id == 0);
2877 vifp->v_timeout_id = timeout(tbf_reprocess_q, vifp,
2882 tbf_queue(vifp, mp);
2883 tbf_process_q(vifp);
2897 (ptrdiff_t)(vifp - ipst->ips_vifs),
2900 mutex_exit(&vifp->v_tbf->tbf_lock);
2910 if (!tbf_dq_sel(vifp, ipha)) {
2916 tbf_queue(vifp, mp);
2917 tbf_process_q(vifp);
2921 id = vifp->v_timeout_id;
2922 vifp->v_timeout_id = 0;
2924 mutex_exit(&vifp->v_tbf->tbf_lock);
2934 tbf_queue(struct vif *vifp, mblk_t *mp)
2936 struct tbf *t = vifp->v_tbf;
2937 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
2942 "tbf_queue: vif %ld", (ptrdiff_t)(vifp - ipst->ips_vifs));
2968 tbf_process_q(struct vif *vifp)
2971 struct tbf *t = vifp->v_tbf;
2973 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
2979 (ptrdiff_t)(vifp - ipst->ips_vifs), t->tbf_q_len);
3007 tbf_send_packet(vifp, mp);
3018 struct vif *vifp = arg;
3019 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
3022 mutex_enter(&vifp->v_tbf->tbf_lock);
3023 vifp->v_timeout_id = 0;
3024 tbf_update_tokens(vifp);
3026 tbf_process_q(vifp);
3028 if (vifp->v_tbf->tbf_q_len > 0) {
3029 vifp->v_timeout_id = timeout(tbf_reprocess_q, vifp,
3032 mutex_exit(&vifp->v_tbf->tbf_lock);
3037 (ptrdiff_t)(vifp - ipst->ips_vifs), vifp->v_timeout_id);
3048 tbf_dq_sel(struct vif *vifp, ipha_t *ipha)
3051 struct tbf *t = vifp->v_tbf;
3054 ill_t *ill = vifp->v_ipif->ipif_ill;
3061 (ptrdiff_t)(vifp - ipst->ips_vifs), ntohl(ipha->ipha_dst));
3065 p = priority(vifp, ipha);
3070 if (p > (priority(vifp, (ipha_t *)mp->b_rptr))) {
3097 tbf_send_packet(struct vif *vifp, mblk_t *mp)
3099 ipif_t *ipif = vifp->v_ipif;
3107 if (vifp->v_flags & VIFF_TUNNEL) {
3113 (ptrdiff_t)(vifp - ipst->ips_vifs));
3130 * BSD gets the cached route vifp->v_route from ip_output()
3161 (ptrdiff_t)(vifp - ipst->ips_vifs), ntohl(dst));
3200 tbf_update_tokens(struct vif *vifp)
3204 struct tbf *t = vifp->v_tbf;
3205 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
3224 t->tbf_n_tok += (tm/1000) * vifp->v_rate_limit / 1024 / 8;
3232 tm, t->tbf_n_tok, (ptrdiff_t)(vifp - ipst->ips_vifs));
3244 priority(struct vif *vifp, ipha_t *ipha)
3247 ip_stack_t *ipst = vifp->v_ipif->ipif_ill->ill_ipst;
3252 ASSERT(MUTEX_HELD(&vifp->v_tbf->tbf_lock));