Lines Matching defs:ifp
96 ifnet_kpi_free(ifnet_t ifp)
98 ifnet_detached_func detach_func = ifp->if_kpi_storage;
101 detach_func(ifp);
103 if (ifp->if_broadcast.length > sizeof (ifp->if_broadcast.u.buffer)) {
104 FREE(ifp->if_broadcast.u.ptr, M_IFADDR);
105 ifp->if_broadcast.u.ptr = NULL;
108 dlil_if_release(ifp);
149 struct ifnet *ifp = NULL;
191 einit.uniqueid_len, &ifp);
197 * Cast ifp->if_name as non const. dlil_if_acquire sets it up
201 strncpy(_cast_non_const(ifp->if_name), einit.name, IFNAMSIZ);
202 ifp->if_type = einit.type;
203 ifp->if_family = einit.family;
204 ifp->if_unit = einit.unit;
205 ifp->if_output = einit.output;
206 ifp->if_pre_enqueue = einit.pre_enqueue;
207 ifp->if_start = einit.start;
208 ifp->if_output_ctl = einit.output_ctl;
209 ifp->if_output_sched_model = einit.output_sched_model;
210 ifp->if_output_bw.eff_bw = einit.output_bw;
211 ifp->if_output_bw.max_bw = einit.output_bw_max;
212 ifp->if_input_poll = einit.input_poll;
213 ifp->if_input_ctl = einit.input_ctl;
214 ifp->if_input_bw.eff_bw = einit.input_bw;
215 ifp->if_input_bw.max_bw = einit.input_bw_max;
216 ifp->if_demux = einit.demux;
217 ifp->if_add_proto = einit.add_proto;
218 ifp->if_del_proto = einit.del_proto;
219 ifp->if_check_multi = einit.check_multi;
220 ifp->if_framer = einit.framer;
221 ifp->if_softc = einit.softc;
222 ifp->if_ioctl = einit.ioctl;
223 ifp->if_set_bpf_tap = einit.set_bpf_tap;
224 ifp->if_free = ifnet_kpi_free;
225 ifp->if_event = einit.event;
226 ifp->if_kpi_storage = einit.detach;
228 if (ifp->if_output_bw.eff_bw > ifp->if_output_bw.max_bw)
229 ifp->if_output_bw.max_bw = ifp->if_output_bw.eff_bw;
230 else if (ifp->if_output_bw.eff_bw == 0)
231 ifp->if_output_bw.eff_bw = ifp->if_output_bw.max_bw;
233 if (ifp->if_input_bw.eff_bw > ifp->if_input_bw.max_bw)
234 ifp->if_input_bw.max_bw = ifp->if_input_bw.eff_bw;
235 else if (ifp->if_input_bw.eff_bw == 0)
236 ifp->if_input_bw.eff_bw = ifp->if_input_bw.max_bw;
238 if (ifp->if_output_bw.max_bw == 0)
239 ifp->if_output_bw = ifp->if_input_bw;
240 else if (ifp->if_input_bw.max_bw == 0)
241 ifp->if_input_bw = ifp->if_output_bw;
243 if (ifp->if_ioctl == NULL)
244 ifp->if_ioctl = ifp_if_ioctl;
247 br = MAX(ifp->if_output_bw.max_bw, ifp->if_input_bw.max_bw);
249 ifp->if_baudrate = (br > 0xFFFFFFFF) ? 0xFFFFFFFF : br;
251 if (ifp->if_start != NULL) {
252 ifp->if_eflags |= IFEF_TXSTART;
253 if (ifp->if_pre_enqueue == NULL)
254 ifp->if_pre_enqueue = ifnet_enqueue;
255 ifp->if_output = ifp->if_pre_enqueue;
257 ifp->if_eflags &= ~IFEF_TXSTART;
260 if (ifp->if_input_poll != NULL)
261 ifp->if_eflags |= IFEF_RXPOLL;
263 ifp->if_eflags &= ~IFEF_RXPOLL;
266 (ifp->if_pre_enqueue == NULL && ifp->if_start == NULL &&
267 ifp->if_output_ctl == NULL && ifp->if_input_poll == NULL &&
268 ifp->if_input_ctl == NULL));
270 (ifp->if_input_poll != NULL && ifp->if_input_ctl != NULL));
274 sizeof (ifp->if_broadcast.u.buffer)) {
275 MALLOC(ifp->if_broadcast.u.ptr, u_char *,
277 if (ifp->if_broadcast.u.ptr == NULL) {
281 ifp->if_broadcast.u.ptr,
286 ifp->if_broadcast.u.buffer,
289 ifp->if_broadcast.length = einit.broadcast_len;
291 bzero(&ifp->if_broadcast, sizeof (ifp->if_broadcast));
294 IFCQ_MAXLEN(&ifp->if_snd) = einit.sndq_maxlen;
297 *interface = ifp;
299 ifnet_reference(ifp);
301 dlil_if_release(ifp);
320 ifnet_reference(ifnet_t ifp)
322 return (dlil_if_ref(ifp));
326 ifnet_release(ifnet_t ifp)
328 return (dlil_if_free(ifp));
430 ifnet_awdl_check_eflags(ifnet_t ifp, u_int32_t *new_eflags, u_int32_t *mask)
434 ifnet_lock_assert(ifp, IFNET_LCK_ASSERT_EXCLUSIVE);
436 eflags = (*new_eflags & *mask) | (ifp->if_eflags & ~(*mask));
438 if (ifp->if_eflags & IFEF_AWDL) {
482 ifnet_set_idle_flags_locked(ifnet_t ifp, u_int32_t new_flags, u_int32_t mask)
486 if (ifp == NULL)
490 ifnet_lock_assert(ifp, IFNET_LCK_ASSERT_EXCLUSIVE);
497 if (!ifnet_is_attached(ifp, 0)) {
498 ifp->if_idle_new_flags = new_flags;
499 ifp->if_idle_new_flags_mask = mask;
502 ifp->if_idle_new_flags = ifp->if_idle_new_flags_mask = 0;
505 before = ifp->if_idle_flags;
506 ifp->if_idle_flags = (new_flags & mask) | (ifp->if_idle_flags & ~mask);
507 after = ifp->if_idle_flags;
509 if ((after - before) < 0 && ifp->if_idle_flags == 0 &&
510 ifp->if_want_aggressive_drain != 0) {
511 ifp->if_want_aggressive_drain = 0;
513 panic("%s: ifp=%p negative aggdrain!", __func__, ifp);
516 } else if ((after - before) > 0 && ifp->if_want_aggressive_drain == 0) {
517 ifp->if_want_aggressive_drain++;
519 panic("%s: ifp=%p wraparound aggdrain!", __func__, ifp);
528 ifnet_set_idle_flags(ifnet_t ifp, u_int32_t new_flags, u_int32_t mask)
533 ifnet_lock_exclusive(ifp);
534 err = ifnet_set_idle_flags_locked(ifp, new_flags, mask);
535 ifnet_lock_done(ifp);
542 ifnet_idle_flags(ifnet_t ifp)
544 return ((ifp == NULL) ? 0 : ifp->if_idle_flags);
548 ifnet_set_link_quality(ifnet_t ifp, int quality)
552 if (ifp == NULL || quality < IFNET_LQM_MIN || quality > IFNET_LQM_MAX) {
557 if (!ifnet_is_attached(ifp, 0)) {
562 if_lqm_update(ifp, quality);
569 ifnet_link_quality(ifnet_t ifp)
573 if (ifp == NULL)
576 ifnet_lock_shared(ifp);
577 lqm = ifp->if_lqm;
578 ifnet_lock_done(ifp);
584 ifnet_defrouter_llreachinfo(ifnet_t ifp, int af,
587 if (ifp == NULL || iflri == NULL)
592 return (ifnet_llreach_get_defrouter(ifp, af, iflri));
596 ifnet_inet_defrouter_llreachinfo(ifnet_t ifp, struct ifnet_llreach_info *iflri)
598 return (ifnet_defrouter_llreachinfo(ifp, AF_INET, iflri));
602 ifnet_inet6_defrouter_llreachinfo(ifnet_t ifp, struct ifnet_llreach_info *iflri)
604 return (ifnet_defrouter_llreachinfo(ifp, AF_INET6, iflri));
608 ifnet_set_capabilities_supported(ifnet_t ifp, u_int32_t new_caps,
614 if (ifp == NULL)
617 ifnet_lock_exclusive(ifp);
618 tmp = (new_caps & mask) | (ifp->if_capabilities & ~mask);
622 ifp->if_capabilities = tmp;
623 ifnet_lock_done(ifp);
629 ifnet_capabilities_supported(ifnet_t ifp)
631 return ((ifp == NULL) ? 0 : ifp->if_capabilities);
636 ifnet_set_capabilities_enabled(ifnet_t ifp, u_int32_t new_caps,
644 if (ifp == NULL)
647 ifnet_lock_exclusive(ifp);
648 tmp = (new_caps & mask) | (ifp->if_capenable & ~mask);
649 if ((tmp & ~IFCAP_VALID) || (tmp & ~ifp->if_capabilities))
652 ifp->if_capenable = tmp;
653 ifnet_lock_done(ifp);
663 strlcpy(&ev_data.if_name[0], ifp->if_name, IFNAMSIZ);
664 ev_data.if_family = ifp->if_family;
665 ev_data.if_unit = (u_int32_t)ifp->if_unit;
675 ifnet_capabilities_enabled(ifnet_t ifp)
677 return ((ifp == NULL) ? 0 : ifp->if_capenable);
978 ifnet_set_baudrate(struct ifnet *ifp, u_int64_t baudrate)
980 if (ifp == NULL)
983 ifp->if_output_bw.max_bw = ifp->if_input_bw.max_bw =
984 ifp->if_output_bw.eff_bw = ifp->if_input_bw.eff_bw = baudrate;
987 ifp->if_baudrate = (baudrate > 0xFFFFFFFF) ? 0xFFFFFFFF : baudrate;
993 ifnet_baudrate(struct ifnet *ifp)
995 return ((ifp == NULL) ? 0 : ifp->if_baudrate);
999 ifnet_set_bandwidths(struct ifnet *ifp, struct if_bandwidths *output_bw,
1002 if (ifp == NULL)
1006 (void) ifnet_set_input_bandwidths(ifp, input_bw);
1009 (void) ifnet_set_output_bandwidths(ifp, output_bw, FALSE);
1015 ifnet_set_output_bandwidths(struct ifnet *ifp, struct if_bandwidths *bw,
1022 ifq = &ifp->if_snd;
1027 old_bw = ifp->if_output_bw;
1030 ifp->if_output_bw.eff_bw = bw->eff_bw;
1032 ifp->if_output_bw.max_bw = bw->max_bw;
1033 if (ifp->if_output_bw.eff_bw > ifp->if_output_bw.max_bw)
1034 ifp->if_output_bw.max_bw = ifp->if_output_bw.eff_bw;
1035 else if (ifp->if_output_bw.eff_bw == 0)
1036 ifp->if_output_bw.eff_bw = ifp->if_output_bw.max_bw;
1040 br = MAX(ifp->if_output_bw.max_bw, ifp->if_input_bw.max_bw);
1042 ifp->if_baudrate = (br > 0xFFFFFFFF) ? 0xFFFFFFFF : br;
1045 if (old_bw.eff_bw != ifp->if_output_bw.eff_bw ||
1046 old_bw.max_bw != ifp->if_output_bw.max_bw)
1056 ifnet_set_input_bandwidths(struct ifnet *ifp, struct if_bandwidths *bw)
1060 old_bw = ifp->if_input_bw;
1062 ifp->if_input_bw.eff_bw = bw->eff_bw;
1064 ifp->if_input_bw.max_bw = bw->max_bw;
1065 if (ifp->if_input_bw.eff_bw > ifp->if_input_bw.max_bw)
1066 ifp->if_input_bw.max_bw = ifp->if_input_bw.eff_bw;
1067 else if (ifp->if_input_bw.eff_bw == 0)
1068 ifp->if_input_bw.eff_bw = ifp->if_input_bw.max_bw;
1070 if (old_bw.eff_bw != ifp->if_input_bw.eff_bw ||
1071 old_bw.max_bw != ifp->if_input_bw.max_bw)
1072 ifnet_update_rcv(ifp, CLASSQ_EV_LINK_SPEED);
1078 ifnet_output_linkrate(struct ifnet *ifp)
1080 struct ifclassq *ifq = &ifp->if_snd;
1085 rate = ifp->if_output_bw.eff_bw;
1087 u_int64_t tbr_rate = ifp->if_snd.ifcq_tbr.tbr_rate_raw;
1089 rate = MIN(rate, ifp->if_snd.ifcq_tbr.tbr_rate_raw);
1096 ifnet_input_linkrate(struct ifnet *ifp)
1098 return (ifp->if_input_bw.eff_bw);
1102 ifnet_bandwidths(struct ifnet *ifp, struct if_bandwidths *output_bw,
1105 if (ifp == NULL)
1109 *output_bw = ifp->if_output_bw;
1111 *input_bw = ifp->if_input_bw;
1117 ifnet_stat_increment(struct ifnet *ifp,
1120 if (ifp == NULL)
1124 atomic_add_64(&ifp->if_data.ifi_ipackets, s->packets_in);
1126 atomic_add_64(&ifp->if_data.ifi_ibytes, s->bytes_in);
1128 atomic_add_64(&ifp->if_data.ifi_ierrors, s->errors_in);
1131 atomic_add_64(&ifp->if_data.ifi_opackets, s->packets_out);
1133 atomic_add_64(&ifp->if_data.ifi_obytes, s->bytes_out);
1135 atomic_add_64(&ifp->if_data.ifi_oerrors, s->errors_out);
1138 atomic_add_64(&ifp->if_data.ifi_collisions, s->collisions);
1140 atomic_add_64(&ifp->if_data.ifi_iqdrops, s->dropped);
1143 TOUCHLASTCHANGE(&ifp->if_lastchange);
1149 ifnet_stat_increment_in(struct ifnet *ifp, u_int32_t packets_in,
1152 if (ifp == NULL)
1156 atomic_add_64(&ifp->if_data.ifi_ipackets, packets_in);
1158 atomic_add_64(&ifp->if_data.ifi_ibytes, bytes_in);
1160 atomic_add_64(&ifp->if_data.ifi_ierrors, errors_in);
1162 TOUCHLASTCHANGE(&ifp->if_lastchange);
1168 ifnet_stat_increment_out(struct ifnet *ifp, u_int32_t packets_out,
1171 if (ifp == NULL)
1175 atomic_add_64(&ifp->if_data.ifi_opackets, packets_out);
1177 atomic_add_64(&ifp->if_data.ifi_obytes, bytes_out);
1179 atomic_add_64(&ifp->if_data.ifi_oerrors, errors_out);
1181 TOUCHLASTCHANGE(&ifp->if_lastchange);
1187 ifnet_set_stat(struct ifnet *ifp, const struct ifnet_stats_param *s)
1189 if (ifp == NULL)
1192 atomic_set_64(&ifp->if_data.ifi_ipackets, s->packets_in);
1193 atomic_set_64(&ifp->if_data.ifi_ibytes, s->bytes_in);
1194 atomic_set_64(&ifp->if_data.ifi_imcasts, s->multicasts_in);
1195 atomic_set_64(&ifp->if_data.ifi_ierrors, s->errors_in);
1197 atomic_set_64(&ifp->if_data.ifi_opackets, s->packets_out);
1198 atomic_set_64(&ifp->if_data.ifi_obytes, s->bytes_out);
1199 atomic_set_64(&ifp->if_data.ifi_omcasts, s->multicasts_out);
1200 atomic_set_64(&ifp->if_data.ifi_oerrors, s->errors_out);
1202 atomic_set_64(&ifp->if_data.ifi_collisions, s->collisions);
1203 atomic_set_64(&ifp->if_data.ifi_iqdrops, s->dropped);
1204 atomic_set_64(&ifp->if_data.ifi_noproto, s->no_protocol);
1207 TOUCHLASTCHANGE(&ifp->if_lastchange);
1213 ifnet_stat(struct ifnet *ifp, struct ifnet_stats_param *s)
1215 if (ifp == NULL)
1218 atomic_get_64(s->packets_in, &ifp->if_data.ifi_ipackets);
1219 atomic_get_64(s->bytes_in, &ifp->if_data.ifi_ibytes);
1220 atomic_get_64(s->multicasts_in, &ifp->if_data.ifi_imcasts);
1221 atomic_get_64(s->errors_in, &ifp->if_data.ifi_ierrors);
1223 atomic_get_64(s->packets_out, &ifp->if_data.ifi_opackets);
1224 atomic_get_64(s->bytes_out, &ifp->if_data.ifi_obytes);
1225 atomic_get_64(s->multicasts_out, &ifp->if_data.ifi_omcasts);
1226 atomic_get_64(s->errors_out, &ifp->if_data.ifi_oerrors);
1228 atomic_get_64(s->collisions, &ifp->if_data.ifi_collisions);
1229 atomic_get_64(s->dropped, &ifp->if_data.ifi_iqdrops);
1230 atomic_get_64(s->no_protocol, &ifp->if_data.ifi_noproto);
1286 struct ifnet *ifp;
1303 ifp = interface;
1304 if (ifp == NULL) {
1312 TAILQ_FOREACH(ifp, &ifnet_head, if_link) {
1313 if (interface != NULL && ifp != interface)
1316 ifnet_lock_shared(ifp);
1317 if (interface == NULL || interface == ifp) {
1319 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1330 ifnet_lock_done(ifp);
1343 ifnet_lock_done(ifp);
1559 ifnet_get_multicast_list(ifnet_t ifp, ifmultiaddr_t **addresses)
1565 if (ifp == NULL || addresses == NULL)
1568 ifnet_lock_shared(ifp);
1569 LIST_FOREACH(addr, &ifp->if_multiaddrs, ifma_link) {
1576 ifnet_lock_done(ifp);
1580 LIST_FOREACH(addr, &ifp->if_multiaddrs, ifma_link) {
1588 ifnet_lock_done(ifp);
1610 struct ifnet *ifp;
1621 TAILQ_FOREACH(ifp, &ifnet_head, if_link) {
1625 ifa = ifnet_addrs[ifp->if_index - 1];
1635 *ifpp = ifp;
1643 return ((ifp == NULL) ? ENXIO : 0);
1670 struct ifnet *ifp;
1684 TAILQ_FOREACH(ifp, &ifnet_head, if_link) {
1685 if (family == IFNET_FAMILY_ANY || ifp->if_family == family) {
1693 ifl->ifl_ifp = ifp;
1694 ifnet_reference(ifp);
1743 ifnet_transmit_burst_start(ifnet_t ifp, mbuf_t pkt)
1747 if (ifp == NULL || !(pkt->m_flags & M_PKTHDR))
1751 &ifp->if_bw.flags);
1757 ifp->if_bw.start_seq = pkt->m_pkthdr.pf_mtag.pftag_pktseq;
1758 ifp->if_bw.start_ts = mach_absolute_time();
1762 ifnet_transmit_burst_end(ifnet_t ifp, mbuf_t pkt)
1767 if ( ifp == NULL || !(pkt->m_flags & M_PKTHDR))
1770 flags = OSBitOrAtomic(IF_MEASURED_BW_CALCULATION, &ifp->if_bw.flags);
1788 if (ifp->if_bw.start_seq > 0 && oseq > ifp->if_bw.start_seq) {
1789 ts = ots - ifp->if_bw.start_ts;
1792 bytes = oseq - ifp->if_bw.start_seq;
1793 ifp->if_bw.bytes = bytes;
1794 ifp->if_bw.ts = ts;
1802 if (ifp->if_bw.bw > 0) {
1807 ifp->if_bw.bw = (bw +
1808 ((ifp->if_bw.bw << shft) -
1809 ifp->if_bw.bw)) >> shft;
1811 ifp->if_bw.bw = bw;
1815 ifp->if_bw.last_seq = oseq;
1816 ifp->if_bw.last_ts = ots;
1822 OSBitAndAtomic(flags, &ifp->if_bw.flags);
1947 struct ifnet *ifp;
1953 ifp = ifa->ifa_ifp;
1955 return (ifp);
2159 ifnet_get_local_ports(ifnet_t ifp, uint8_t *bitfield)
2166 udp_get_ports_used(ifp ? ifp->if_index : 0, bitfield);
2167 tcp_get_ports_used(ifp ? ifp->if_index : 0, bitfield);
2173 ifnet_notice_node_presence(ifnet_t ifp, struct sockaddr* sa, int32_t rssi,
2176 if (ifp == NULL || sa == NULL || srvinfo == NULL)
2183 dlil_node_present(ifp, sa, rssi, lqm, npm, srvinfo);
2188 ifnet_notice_node_absence(ifnet_t ifp, struct sockaddr* sa)
2190 if (ifp == NULL || sa == NULL)
2197 dlil_node_absent(ifp, sa);
2202 ifnet_notice_master_elected(ifnet_t ifp)
2204 if (ifp == NULL)
2207 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_MASTER_ELECTED, NULL, 0);