head 1.54; access; symbols netbsd-10-0-RELEASE:1.54 netbsd-10-0-RC6:1.54 netbsd-10-0-RC5:1.54 netbsd-10-0-RC4:1.54 netbsd-10-0-RC3:1.54 netbsd-10-0-RC2:1.54 thorpej-ifq:1.54.0.8 thorpej-ifq-base:1.54 thorpej-altq-separation:1.54.0.6 thorpej-altq-separation-base:1.54 netbsd-10-0-RC1:1.54 netbsd-10:1.54.0.4 netbsd-10-base:1.54 bouyer-sunxi-drm:1.54.0.2 bouyer-sunxi-drm-base:1.54 netbsd-9-3-RELEASE:1.46 thorpej-i2c-spi-conf2:1.52.0.20 thorpej-i2c-spi-conf2-base:1.52 thorpej-futex2:1.52.0.18 thorpej-futex2-base:1.52 thorpej-cfargs2:1.52.0.16 thorpej-cfargs2-base:1.52 cjep_sun2x-base1:1.52 cjep_sun2x:1.52.0.14 cjep_sun2x-base:1.52 cjep_staticlib_x-base1:1.52 netbsd-9-2-RELEASE:1.46 cjep_staticlib_x:1.52.0.12 cjep_staticlib_x-base:1.52 thorpej-i2c-spi-conf:1.52.0.10 thorpej-i2c-spi-conf-base:1.52 thorpej-cfargs:1.52.0.8 thorpej-cfargs-base:1.52 thorpej-futex:1.52.0.6 thorpej-futex-base:1.52 netbsd-9-1-RELEASE:1.46 bouyer-xenpvh-base2:1.52 phil-wifi-20200421:1.52 bouyer-xenpvh-base1:1.52 phil-wifi-20200411:1.52 bouyer-xenpvh:1.52.0.4 bouyer-xenpvh-base:1.52 is-mlppp:1.52.0.2 is-mlppp-base:1.52 phil-wifi-20200406:1.52 netbsd-8-2-RELEASE:1.32.6.3 ad-namecache-base3:1.51 netbsd-9-0-RELEASE:1.46 netbsd-9-0-RC2:1.46 ad-namecache-base2:1.49 ad-namecache-base1:1.48 ad-namecache:1.48.0.2 ad-namecache-base:1.48 netbsd-9-0-RC1:1.46 phil-wifi-20191119:1.48 netbsd-9:1.46.0.2 netbsd-9-base:1.46 phil-wifi-20190609:1.46 netbsd-8-1-RELEASE:1.32.6.3 netbsd-8-1-RC1:1.32.6.3 isaki-audio2:1.41.0.2 isaki-audio2-base:1.41 pgoyette-compat-merge-20190127:1.35.2.1 pgoyette-compat-20190127:1.36 pgoyette-compat-20190118:1.36 pgoyette-compat-1226:1.36 pgoyette-compat-1126:1.36 pgoyette-compat-1020:1.36 pgoyette-compat-0930:1.36 pgoyette-compat-0906:1.36 netbsd-7-2-RELEASE:1.30 pgoyette-compat-0728:1.36 netbsd-8-0-RELEASE:1.32.6.2 phil-wifi:1.36.0.2 phil-wifi-base:1.36 pgoyette-compat-0625:1.36 netbsd-8-0-RC2:1.32.6.2 pgoyette-compat-0521:1.36 pgoyette-compat-0502:1.36 pgoyette-compat-0422:1.36 netbsd-8-0-RC1:1.32.6.2 pgoyette-compat-0415:1.36 pgoyette-compat-0407:1.36 pgoyette-compat-0330:1.35 pgoyette-compat-0322:1.35 pgoyette-compat-0315:1.35 netbsd-7-1-2-RELEASE:1.30 pgoyette-compat:1.35.0.2 pgoyette-compat-base:1.35 netbsd-7-1-1-RELEASE:1.30 tls-maxphys-base-20171202:1.35 matt-nb8-mediatek:1.32.0.10 matt-nb8-mediatek-base:1.32 nick-nhusb-base-20170825:1.32 perseant-stdc-iso10646:1.32.0.8 perseant-stdc-iso10646-base:1.32 netbsd-8:1.32.0.6 netbsd-8-base:1.32 prg-localcount2-base3:1.32 prg-localcount2-base2:1.32 prg-localcount2-base1:1.32 prg-localcount2:1.32.0.4 prg-localcount2-base:1.32 pgoyette-localcount-20170426:1.32 bouyer-socketcan-base1:1.32 jdolecek-ncq:1.32.0.2 jdolecek-ncq-base:1.32 pgoyette-localcount-20170320:1.32 netbsd-7-1:1.30.0.50 netbsd-7-1-RELEASE:1.30 netbsd-7-1-RC2:1.30 nick-nhusb-base-20170204:1.32 netbsd-7-nhusb-base-20170116:1.30 bouyer-socketcan:1.30.0.48 bouyer-socketcan-base:1.30 pgoyette-localcount-20170107:1.30 netbsd-7-1-RC1:1.30 nick-nhusb-base-20161204:1.30 pgoyette-localcount-20161104:1.30 netbsd-7-0-2-RELEASE:1.30 nick-nhusb-base-20161004:1.30 localcount-20160914:1.30 netbsd-7-nhusb:1.30.0.46 netbsd-7-nhusb-base:1.30 pgoyette-localcount-20160806:1.30 pgoyette-localcount-20160726:1.30 pgoyette-localcount:1.30.0.44 pgoyette-localcount-base:1.30 nick-nhusb-base-20160907:1.30 nick-nhusb-base-20160529:1.30 netbsd-7-0-1-RELEASE:1.30 nick-nhusb-base-20160422:1.30 nick-nhusb-base-20160319:1.30 nick-nhusb-base-20151226:1.30 netbsd-7-0:1.30.0.42 netbsd-7-0-RELEASE:1.30 nick-nhusb-base-20150921:1.30 netbsd-7-0-RC3:1.30 netbsd-7-0-RC2:1.30 netbsd-7-0-RC1:1.30 nick-nhusb-base-20150606:1.30 nick-nhusb-base-20150406:1.30 nick-nhusb:1.30.0.40 nick-nhusb-base:1.30 netbsd-5-2-3-RELEASE:1.29 netbsd-5-1-5-RELEASE:1.29 netbsd-6-0-6-RELEASE:1.30 netbsd-6-1-5-RELEASE:1.30 netbsd-7:1.30.0.38 netbsd-7-base:1.30 yamt-pagecache-base9:1.30 yamt-pagecache-tag8:1.30 netbsd-6-1-4-RELEASE:1.30 netbsd-6-0-5-RELEASE:1.30 tls-earlyentropy:1.30.0.36 tls-earlyentropy-base:1.30 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.30 riastradh-drm2-base3:1.30 netbsd-6-1-3-RELEASE:1.30 netbsd-6-0-4-RELEASE:1.30 netbsd-5-2-2-RELEASE:1.29 netbsd-5-1-4-RELEASE:1.29 netbsd-6-1-2-RELEASE:1.30 netbsd-6-0-3-RELEASE:1.30 netbsd-5-2-1-RELEASE:1.29 netbsd-5-1-3-RELEASE:1.29 rmind-smpnet-nbase:1.30 netbsd-6-1-1-RELEASE:1.30 riastradh-drm2-base2:1.30 riastradh-drm2-base1:1.30 riastradh-drm2:1.30.0.34 riastradh-drm2-base:1.30 rmind-smpnet:1.30.0.26 rmind-smpnet-base:1.30 netbsd-6-1:1.30.0.32 netbsd-6-0-2-RELEASE:1.30 netbsd-6-1-RELEASE:1.30 khorben-n900:1.30.0.30 netbsd-6-1-RC4:1.30 netbsd-6-1-RC3:1.30 agc-symver:1.30.0.28 agc-symver-base:1.30 netbsd-6-1-RC2:1.30 netbsd-6-1-RC1:1.30 yamt-pagecache-base8:1.30 netbsd-5-2:1.29.0.20 netbsd-6-0-1-RELEASE:1.30 yamt-pagecache-base7:1.30 netbsd-5-2-RELEASE:1.29 netbsd-5-2-RC1:1.29 matt-nb6-plus-nbase:1.30 yamt-pagecache-base6:1.30 netbsd-6-0:1.30.0.24 netbsd-6-0-RELEASE:1.30 netbsd-6-0-RC2:1.30 tls-maxphys:1.30.0.22 tls-maxphys-base:1.30 matt-nb6-plus:1.30.0.20 matt-nb6-plus-base:1.30 netbsd-6-0-RC1:1.30 jmcneill-usbmp-base10:1.30 yamt-pagecache-base5:1.30 jmcneill-usbmp-base9:1.30 yamt-pagecache-base4:1.30 jmcneill-usbmp-base8:1.30 jmcneill-usbmp-base7:1.30 jmcneill-usbmp-base6:1.30 jmcneill-usbmp-base5:1.30 jmcneill-usbmp-base4:1.30 jmcneill-usbmp-base3:1.30 jmcneill-usbmp-pre-base2:1.30 jmcneill-usbmp-base2:1.30 netbsd-6:1.30.0.18 netbsd-6-base:1.30 netbsd-5-1-2-RELEASE:1.29 netbsd-5-1-1-RELEASE:1.29 jmcneill-usbmp:1.30.0.16 jmcneill-usbmp-base:1.30 jmcneill-audiomp3:1.30.0.14 jmcneill-audiomp3-base:1.30 yamt-pagecache-base3:1.30 yamt-pagecache-base2:1.30 yamt-pagecache:1.30.0.12 yamt-pagecache-base:1.30 rmind-uvmplock-nbase:1.30 cherry-xenmp:1.30.0.10 cherry-xenmp-base:1.30 bouyer-quota2-nbase:1.30 bouyer-quota2:1.30.0.8 bouyer-quota2-base:1.30 jruoho-x86intr:1.30.0.6 jruoho-x86intr-base:1.30 matt-mips64-premerge-20101231:1.30 matt-nb5-mips64-premerge-20101231:1.29 matt-nb5-pq3:1.29.0.18 matt-nb5-pq3-base:1.29 netbsd-5-1:1.29.0.16 netbsd-5-1-RELEASE:1.29 uebayasi-xip-base4:1.30 uebayasi-xip-base3:1.30 yamt-nfs-mp-base11:1.30 netbsd-5-1-RC4:1.29 matt-nb5-mips64-k15:1.29 uebayasi-xip-base2:1.30 yamt-nfs-mp-base10:1.30 netbsd-5-1-RC3:1.29 netbsd-5-1-RC2:1.29 uebayasi-xip-base1:1.30 netbsd-5-1-RC1:1.29 rmind-uvmplock:1.30.0.4 rmind-uvmplock-base:1.30 yamt-nfs-mp-base9:1.30 uebayasi-xip:1.30.0.2 uebayasi-xip-base:1.30 netbsd-5-0-2-RELEASE:1.29 matt-nb5-mips64-premerge-20091211:1.29 matt-premerge-20091211:1.30 yamt-nfs-mp-base8:1.29 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.29 matt-nb4-mips64-k7-u2a-k9b:1.29 matt-nb5-mips64-u1-k1-k5:1.29 yamt-nfs-mp-base7:1.29 matt-nb5-mips64:1.29.0.14 netbsd-5-0-1-RELEASE:1.29 jymxensuspend-base:1.29 yamt-nfs-mp-base6:1.29 yamt-nfs-mp-base5:1.29 yamt-nfs-mp-base4:1.29 jym-xensuspend-nbase:1.30 yamt-nfs-mp-base3:1.29 nick-hppapmap-base4:1.29 nick-hppapmap-base3:1.29 netbsd-5-0:1.29.0.12 netbsd-5-0-RELEASE:1.29 netbsd-5-0-RC4:1.29 netbsd-5-0-RC3:1.29 nick-hppapmap-base2:1.29 netbsd-5-0-RC2:1.29 jym-xensuspend:1.29.0.10 jym-xensuspend-base:1.29 netbsd-5-0-RC1:1.29 haad-dm-base2:1.29 haad-nbase2:1.29 ad-audiomp2:1.29.0.8 ad-audiomp2-base:1.29 netbsd-5:1.29.0.6 netbsd-5-base:1.29 nick-hppapmap:1.29.0.4 nick-hppapmap-base:1.29 matt-mips64-base2:1.29 matt-mips64:1.26.0.24 haad-dm-base1:1.29 wrstuden-revivesa-base-4:1.29 netbsd-4-0-1-RELEASE:1.25 wrstuden-revivesa-base-3:1.29 wrstuden-revivesa-base-2:1.29 wrstuden-fixsa-newbase:1.25 nick-csl-alignment-base5:1.26 haad-dm:1.29.0.2 haad-dm-base:1.29 wrstuden-revivesa-base-1:1.29 simonb-wapbl-nbase:1.29 yamt-pf42-base4:1.29 simonb-wapbl:1.28.0.4 simonb-wapbl-base:1.29 yamt-pf42-base3:1.28 hpcarm-cleanup-nbase:1.28 yamt-pf42-baseX:1.27 yamt-pf42-base2:1.28 yamt-nfs-mp-base2:1.28 wrstuden-revivesa:1.28.0.2 wrstuden-revivesa-base:1.29 yamt-nfs-mp:1.27.0.10 yamt-nfs-mp-base:1.27 yamt-pf42:1.27.0.8 yamt-pf42-base:1.27 ad-socklock-base1:1.27 yamt-lazymbuf-base15:1.27 yamt-lazymbuf-base14:1.27 keiichi-mipv6-nbase:1.27 mjf-devfs2:1.27.0.6 mjf-devfs2-base:1.29 nick-net80211-sync:1.27.0.4 nick-net80211-sync-base:1.27 keiichi-mipv6:1.27.0.2 keiichi-mipv6-base:1.27 bouyer-xeni386-merge1:1.26.20.1 matt-armv6-prevmlocking:1.26 wrstuden-fixsa-base-1:1.25 vmlocking2-base3:1.26 netbsd-4-0:1.25.0.42 netbsd-4-0-RELEASE:1.25 bouyer-xeni386-nbase:1.27 yamt-kmem-base3:1.26 cube-autoconf:1.26.0.22 cube-autoconf-base:1.26 yamt-kmem-base2:1.26 bouyer-xeni386:1.26.0.20 bouyer-xeni386-base:1.27 yamt-kmem:1.26.0.18 yamt-kmem-base:1.26 vmlocking2-base2:1.26 reinoud-bufcleanup-nbase:1.26 vmlocking2:1.26.0.16 vmlocking2-base1:1.26 netbsd-4-0-RC5:1.25 matt-nb4-arm:1.25.0.40 matt-nb4-arm-base:1.25 matt-armv6-nbase:1.27 jmcneill-base:1.26 netbsd-4-0-RC4:1.25 mjf-devfs:1.26.0.14 mjf-devfs-base:1.27 bouyer-xenamd64-base2:1.26 vmlocking-nbase:1.26 yamt-x86pmap-base4:1.26 bouyer-xenamd64:1.26.0.12 bouyer-xenamd64-base:1.26 netbsd-4-0-RC3:1.25 yamt-x86pmap-base3:1.26 yamt-x86pmap-base2:1.26 netbsd-4-0-RC2:1.25 yamt-x86pmap:1.26.0.10 yamt-x86pmap-base:1.26 netbsd-4-0-RC1:1.25 matt-armv6:1.26.0.8 matt-armv6-base:1.26 matt-mips64-base:1.26 jmcneill-pm:1.26.0.6 jmcneill-pm-base:1.26 hpcarm-cleanup:1.26.0.4 hpcarm-cleanup-base:1.27 nick-csl-alignment:1.26.0.2 nick-csl-alignment-base:1.26 netbsd-3-1-1-RELEASE:1.24 netbsd-3-0-3-RELEASE:1.24 yamt-idlelwp-base8:1.25 wrstuden-fixsa:1.25.0.38 wrstuden-fixsa-base:1.25 thorpej-atomic:1.25.0.36 thorpej-atomic-base:1.25 reinoud-bufcleanup:1.25.0.34 reinoud-bufcleanup-base:1.26 mjf-ufs-trans:1.25.0.32 mjf-ufs-trans-base:1.26 vmlocking:1.25.0.30 vmlocking-base:1.26 ad-audiomp:1.25.0.28 ad-audiomp-base:1.25 yamt-idlelwp:1.25.0.26 post-newlock2-merge:1.25 newlock2-nbase:1.25 yamt-splraiseipl-base5:1.25 yamt-splraiseipl-base4:1.25 yamt-splraiseipl-base3:1.25 abandoned-netbsd-4-base:1.25 abandoned-netbsd-4:1.25.0.18 netbsd-3-1:1.24.0.14 netbsd-3-1-RELEASE:1.24 netbsd-3-0-2-RELEASE:1.24 yamt-splraiseipl-base2:1.25 netbsd-3-1-RC4:1.24 yamt-splraiseipl:1.25.0.22 yamt-splraiseipl-base:1.25 netbsd-3-1-RC3:1.24 yamt-pdpolicy-base9:1.25 newlock2:1.25.0.20 newlock2-base:1.25 yamt-pdpolicy-base8:1.25 netbsd-3-1-RC2:1.24 netbsd-3-1-RC1:1.24 yamt-pdpolicy-base7:1.25 netbsd-4:1.25.0.24 netbsd-4-base:1.25 yamt-pdpolicy-base6:1.25 chap-midi-nbase:1.25 netbsd-3-0-1-RELEASE:1.24 gdamore-uart:1.25.0.16 gdamore-uart-base:1.25 simonb-timcounters-final:1.25 yamt-pdpolicy-base5:1.25 chap-midi:1.25.0.14 chap-midi-base:1.25 yamt-pdpolicy-base4:1.25 yamt-pdpolicy-base3:1.25 peter-altq-base:1.25 peter-altq:1.25.0.12 yamt-pdpolicy-base2:1.25 elad-kernelauth-base:1.25 elad-kernelauth:1.25.0.10 yamt-pdpolicy:1.25.0.8 yamt-pdpolicy-base:1.25 yamt-uio_vmspace-base5:1.25 simonb-timecounters:1.25.0.6 simonb-timecounters-base:1.25 rpaulo-netinet-merge-pcb:1.25.0.4 rpaulo-netinet-merge-pcb-base:1.25 yamt-uio_vmspace:1.25.0.2 netbsd-3-0:1.24.0.12 netbsd-3-0-RELEASE:1.24 netbsd-3-0-RC6:1.24 yamt-readahead-base3:1.24 netbsd-3-0-RC5:1.24 netbsd-3-0-RC4:1.24 netbsd-3-0-RC3:1.24 yamt-readahead-base2:1.24 netbsd-3-0-RC2:1.24 yamt-readahead-pervnode:1.24 yamt-readahead-perfile:1.24 yamt-readahead:1.24.0.10 yamt-readahead-base:1.24 netbsd-3-0-RC1:1.24 yamt-vop-base3:1.24 netbsd-2-0-3-RELEASE:1.21.2.1 netbsd-2-1:1.21.4.1.0.2 yamt-vop-base2:1.24 thorpej-vnode-attr:1.24.0.8 thorpej-vnode-attr-base:1.24 netbsd-2-1-RELEASE:1.21.4.1 yamt-vop:1.24.0.6 yamt-vop-base:1.24 netbsd-2-1-RC6:1.21.4.1 netbsd-2-1-RC5:1.21.4.1 netbsd-2-1-RC4:1.21.4.1 netbsd-2-1-RC3:1.21.4.1 netbsd-2-1-RC2:1.21.4.1 netbsd-2-1-RC1:1.21.4.1 yamt-lazymbuf:1.24.0.4 yamt-km-base4:1.24 netbsd-2-0-2-RELEASE:1.21.2.1 yamt-km-base3:1.24 netbsd-3:1.24.0.2 netbsd-3-base:1.24 yamt-km-base2:1.23 yamt-km:1.23.0.4 yamt-km-base:1.23 kent-audio2:1.23.0.2 kent-audio2-base:1.24 netbsd-2-0-1-RELEASE:1.21.2.1 kent-audio1-beforemerge:1.23 netbsd-2:1.21.0.4 netbsd-2-base:1.21 kent-audio1:1.22.0.2 kent-audio1-base:1.22 netbsd-2-0-RELEASE:1.21 netbsd-2-0-RC5:1.21 netbsd-2-0-RC4:1.21 netbsd-2-0-RC3:1.21 netbsd-2-0-RC2:1.21 netbsd-2-0-RC1:1.21 netbsd-2-0:1.21.0.2 netbsd-2-0-base:1.21 netbsd-1-6-PATCH002-RELEASE:1.15 netbsd-1-6-PATCH002:1.15 netbsd-1-6-PATCH002-RC4:1.15 netbsd-1-6-PATCH002-RC3:1.15 netbsd-1-6-PATCH002-RC2:1.15 netbsd-1-6-PATCH002-RC1:1.15 ktrace-lwp:1.18.0.6 ktrace-lwp-base:1.24 netbsd-1-6-PATCH001:1.15 netbsd-1-6-PATCH001-RELEASE:1.15 netbsd-1-6-PATCH001-RC3:1.15 netbsd-1-6-PATCH001-RC2:1.15 netbsd-1-6-PATCH001-RC1:1.15 nathanw_sa_end:1.13.2.5 nathanw_sa_before_merge:1.18 fvdl_fs64_base:1.18 gmcgarry_ctxsw:1.18.0.4 gmcgarry_ctxsw_base:1.18 gmcgarry_ucred:1.18.0.2 gmcgarry_ucred_base:1.18 nathanw_sa_base:1.18 kqueue-aftermerge:1.16 kqueue-beforemerge:1.16 netbsd-1-6-RELEASE:1.15 netbsd-1-6-RC3:1.15 netbsd-1-6-RC2:1.15 netbsd-1-6-RC1:1.15 netbsd-1-6:1.15.0.10 netbsd-1-6-base:1.15 gehenna-devsw:1.15.0.8 gehenna-devsw-base:1.15 netbsd-1-5-PATCH003:1.11 eeh-devprop:1.15.0.6 eeh-devprop-base:1.15 newlock:1.15.0.4 newlock-base:1.15 ifpoll-base:1.15 thorpej-mips-cache:1.14.0.6 thorpej-mips-cache-base:1.14 thorpej-devvp-base3:1.14 thorpej-devvp-base2:1.14 post-chs-ubcperf:1.14 pre-chs-ubcperf:1.14 thorpej-devvp:1.14.0.4 thorpej-devvp-base:1.14 netbsd-1-5-PATCH002:1.11 kqueue:1.14.0.2 kqueue-base:1.16 netbsd-1-5-PATCH001:1.11 thorpej_scsipi_beforemerge:1.13 nathanw_sa:1.13.0.2 thorpej_scsipi_nbase:1.13 netbsd-1-5-RELEASE:1.11 netbsd-1-5-BETA2:1.11 netbsd-1-5-BETA:1.11 netbsd-1-4-PATCH003:1.3.6.1 netbsd-1-5-ALPHA2:1.11 netbsd-1-5:1.11.0.4 netbsd-1-5-base:1.11 minoura-xpg4dl-base:1.11 minoura-xpg4dl:1.11.0.2 netbsd-1-4-PATCH002:1.3 chs-ubc2-newbase:1.8 wrstuden-devbsize-19991221:1.7 wrstuden-devbsize:1.5.0.6 wrstuden-devbsize-base:1.7 kame_141_19991130:1.3 comdex-fall-1999:1.6.0.2 comdex-fall-1999-base:1.6 fvdl-softdep:1.5.0.4 fvdl-softdep-base:1.7 thorpej_scsipi:1.5.0.2 thorpej_scsipi_base:1.13 netbsd-1-4-PATCH001:1.3 kame_14_19990705:1.3 kame_14_19990628:1.3 kame:1.3.0.10 chs-ubc2:1.3.0.8 chs-ubc2-base:1.5 netbsd-1-4-RELEASE:1.3 netbsd-1-4:1.3.0.6 netbsd-1-4-base:1.3 netbsd-1-3-PATCH003:1.1 netbsd-1-3-PATCH003-CANDIDATE2:1.1 kenh-if-detach:1.3.0.4 kenh-if-detach-base:1.3 netbsd-1-3-PATCH003-CANDIDATE1:1.1 netbsd-1-3-PATCH003-CANDIDATE0:1.1 chs-ubc:1.3.0.2 chs-ubc-base:1.3 eeh-paddr_t:1.1.0.10 eeh-paddr_t-base:1.1 netbsd-1-3-PATCH002:1.1 netbsd-1-3-PATCH001:1.1 netbsd-1-3-RELEASE:1.1 netbsd-1-3-BETA:1.1 netbsd-1-3:1.1.0.8 netbsd-1-3-base:1.1 thorpej-signal:1.1.0.6 thorpej-signal-base:1.1 marc-pcmcia:1.1.0.4 marc-pcmcia-bp:1.1 marc-pcmcia-base:1.1 bouyer-scsipi:1.1.0.2; locks; strict; comment @ * @; 1.54 date 2022.09.03.02.47.59; author thorpej; state Exp; branches; next 1.53; commitid tQS7Hn7Gj3DaymSD; 1.53 date 2021.10.06.20.42.44; author andvar; state Exp; branches; next 1.52; commitid 31QNggDy4qauaNbD; 1.52 date 2020.03.15.23.04.51; author thorpej; state Exp; branches; next 1.51; commitid R0dFG2H87iZWgy0C; 1.51 date 2020.02.01.20.56.16; author thorpej; state Exp; branches; next 1.50; commitid mCpgkK9QPJMPW0VB; 1.50 date 2020.01.31.00.49.18; author thorpej; state Exp; branches; next 1.49; commitid toD0rSMvD9FgiMUB; 1.49 date 2020.01.20.19.35.39; author thorpej; state Exp; branches; next 1.48; commitid jTVXIvfu09ueSsTB; 1.48 date 2019.10.01.17.45.25; author chs; state Exp; branches 1.48.2.1; next 1.47; commitid DdiR50bF5asrQbFB; 1.47 date 2019.08.10.01.04.05; author mrg; state Exp; branches; next 1.46; commitid VFFKEAkuuTXpYpyB; 1.46 date 2019.05.21.09.18.37; author msaitoh; state Exp; branches; next 1.45; commitid 8jH9vFeczmKEj3oB; 1.45 date 2019.05.17.07.37.12; author msaitoh; state Exp; branches; next 1.44; commitid XYuCMLR1eE4pSwnB; 1.44 date 2019.05.10.08.24.54; author msaitoh; state Exp; branches; next 1.43; commitid mgROStDYZuianDmB; 1.43 date 2019.04.23.07.29.04; author msaitoh; state Exp; branches; next 1.42; commitid N7W0PwzONP5TBrkB; 1.42 date 2019.04.22.11.10.52; author msaitoh; state Exp; branches; next 1.41; commitid ujTdUQ3HMY7WRkkB; 1.41 date 2019.04.16.06.48.33; author msaitoh; state Exp; branches; next 1.40; commitid idNVVz4QsQsUBxjB; 1.40 date 2019.04.10.08.23.46; author msaitoh; state Exp; branches; next 1.39; commitid FS5yDPvMsdPykMiB; 1.39 date 2019.04.10.08.22.18; author msaitoh; state Exp; branches; next 1.38; commitid LkdfnGfgiAN3kMiB; 1.38 date 2019.02.28.05.40.58; author msaitoh; state Exp; branches; next 1.37; commitid AweDPjArjeooKudB; 1.37 date 2019.02.28.05.25.35; author msaitoh; state Exp; branches; next 1.36; commitid Y5c2g3pGWsE8FudB; 1.36 date 2018.03.30.13.21.24; author mlelstv; state Exp; branches 1.36.2.1; next 1.35; commitid brxveVwDeVa03uwA; 1.35 date 2017.11.22.03.03.18; author ozaki-r; state Exp; branches 1.35.2.1; next 1.34; commitid btSOv8Z7XpZ4LYfA; 1.34 date 2017.10.23.03.54.40; author msaitoh; state Exp; branches; next 1.33; commitid aV3EuFxZJGvo08cA; 1.33 date 2017.10.20.08.04.39; author msaitoh; state Exp; branches; next 1.32; commitid UjTn9Nxn0p86uLbA; 1.32 date 2017.01.25.07.19.24; author msaitoh; state Exp; branches 1.32.6.1; next 1.31; 1.31 date 2017.01.25.07.17.19; author msaitoh; state Exp; branches; next 1.30; 1.30 date 2009.10.05.21.27.36; author dyoung; state Exp; branches 1.30.22.1 1.30.40.1 1.30.44.1 1.30.48.1; next 1.29; 1.29 date 2008.06.15.16.33.58; author christos; state Exp; branches; next 1.28; 1.28 date 2008.04.28.20.24.09; author martin; state Exp; branches 1.28.2.1 1.28.4.1; next 1.27; 1.27 date 2008.01.10.08.00.22; author dyoung; state Exp; branches 1.27.6.1 1.27.8.1 1.27.10.1; next 1.26; 1.26 date 2007.05.29.21.32.30; author christos; state Exp; branches 1.26.8.1 1.26.14.1 1.26.20.1; next 1.25; 1.25 date 2005.12.11.12.24.51; author christos; state Exp; branches 1.25.30.1 1.25.32.1; next 1.24; 1.24 date 2005.02.26.22.45.09; author perry; state Exp; branches 1.24.4.1; next 1.23; 1.23 date 2004.12.08.20.37.43; author dyoung; state Exp; branches 1.23.2.1 1.23.4.1; next 1.22; 1.22 date 2004.04.09.20.44.57; author thorpej; state Exp; branches; next 1.21; 1.21 date 2004.02.19.11.58.30; author ragge; state Exp; branches 1.21.2.1 1.21.4.1; next 1.20; 1.20 date 2003.11.03.14.43.32; author briggs; state Exp; branches; next 1.19; 1.19 date 2003.07.25.19.35.57; author christos; state Exp; branches; next 1.18; 1.18 date 2002.11.12.16.54.45; author chs; state Exp; branches 1.18.6.1; next 1.17; 1.17 date 2002.11.07.08.00.47; author thorpej; state Exp; branches; next 1.16; 1.16 date 2002.09.11.05.36.27; author itojun; state Exp; branches; next 1.15; 1.15 date 2001.11.12.23.49.40; author lukem; state Exp; branches; next 1.14; 1.14 date 2001.05.18.08.56.27; author drochner; state Exp; branches 1.14.2.1; next 1.13; 1.13 date 2001.02.26.09.42.00; author joda; state Exp; branches 1.13.2.1; next 1.12; 1.12 date 2001.01.17.19.04.03; author jdolecek; state Exp; branches; next 1.11; 1.11 date 2000.03.30.09.45.36; author augustss; state Exp; branches; next 1.10; 1.10 date 2000.03.13.23.52.39; author soren; state Exp; branches; next 1.9; 1.9 date 2000.03.06.20.50.29; author thorpej; state Exp; branches; next 1.8; 1.8 date 2000.01.26.21.58.17; author thorpej; state Exp; branches; next 1.7; 1.7 date 99.11.03.23.06.35; author thorpej; state Exp; branches; next 1.6; 1.6 date 99.10.27.17.59.24; author thorpej; state Exp; branches; next 1.5; 1.5 date 99.04.30.17.47.36; author thorpej; state Exp; branches 1.5.2.1 1.5.4.1 1.5.6.1; next 1.4; 1.4 date 99.04.30.17.30.49; author abs; state Exp; branches; next 1.3; 1.3 date 98.08.30.07.39.39; author enami; state Exp; branches 1.3.6.1 1.3.8.1; next 1.2; 1.2 date 98.08.06.02.19.34; author thorpej; state Exp; branches; next 1.1; 1.1 date 97.03.17.02.55.15; author thorpej; state Exp; branches; next ; 1.48.2.1 date 2020.01.25.22.38.52; author ad; state Exp; branches; next 1.48.2.2; commitid ethRERRmx7bMJ7UB; 1.48.2.2 date 2020.02.29.20.21.06; author ad; state Exp; branches; next ; commitid OjSb8ro7YQETQBYB; 1.36.2.1 date 2019.06.10.22.09.45; author christos; state Exp; branches; next 1.36.2.2; commitid jtc8rnCzWiEEHGqB; 1.36.2.2 date 2020.04.13.08.05.15; author martin; state Exp; branches; next ; commitid X01YhRUPVUDaec4C; 1.35.2.1 date 2018.04.07.04.12.19; author pgoyette; state Exp; branches; next ; commitid ZMkKSYuBapz7LsxA; 1.32.6.1 date 2017.11.22.14.36.55; author martin; state Exp; branches; next 1.32.6.2; commitid IGrQQdVjf1T1B2gA; 1.32.6.2 date 2018.01.02.10.20.33; author snj; state Exp; branches; next 1.32.6.3; commitid 07oy8c4rjfdaRhlA; 1.32.6.3 date 2019.05.14.11.37.12; author martin; state Exp; branches; next ; commitid Il0SaAqCG3qcjanB; 1.30.22.1 date 2017.12.03.11.39.02; author jdolecek; state Exp; branches; next ; commitid XcIYRZTAh1LmerhA; 1.30.40.1 date 2017.02.05.13.40.58; author skrll; state Exp; branches; next ; 1.30.44.1 date 2017.03.20.06.57.50; author pgoyette; state Exp; branches; next ; 1.30.48.1 date 2017.04.21.16.54.05; author bouyer; state Exp; branches; next ; 1.28.2.1 date 2008.06.23.04.31.58; author wrstuden; state Exp; branches; next ; 1.28.4.1 date 2008.06.18.16.33.50; author simonb; state Exp; branches; next ; 1.27.6.1 date 2008.06.02.13.24.22; author mjf; state Exp; branches; next 1.27.6.2; 1.27.6.2 date 2008.06.29.09.33.18; author mjf; state Exp; branches; next ; 1.27.8.1 date 2008.05.18.12.35.27; author yamt; state Exp; branches; next 1.27.8.2; 1.27.8.2 date 2008.06.17.09.15.13; author yamt; state Exp; branches; next ; 1.27.10.1 date 2008.05.16.02.25.40; author yamt; state Exp; branches; next 1.27.10.2; 1.27.10.2 date 2009.05.04.08.14.15; author yamt; state Exp; branches; next 1.27.10.3; 1.27.10.3 date 2010.03.11.15.04.27; author yamt; state Exp; branches; next ; 1.26.8.1 date 2008.03.23.02.05.05; author matt; state Exp; branches; next ; 1.26.14.1 date 2008.02.18.21.07.01; author mjf; state Exp; branches; next ; 1.26.20.1 date 2008.01.10.23.44.34; author bouyer; state Exp; branches; next ; 1.25.30.1 date 2007.06.09.23.58.11; author ad; state Exp; branches; next ; 1.25.32.1 date 2007.07.11.20.10.57; author mjf; state Exp; branches; next ; 1.24.4.1 date 2007.09.03.14.42.09; author yamt; state Exp; branches; next 1.24.4.2; 1.24.4.2 date 2008.01.21.09.47.04; author yamt; state Exp; branches; next ; 1.23.2.1 date 2005.04.29.11.29.31; author kent; state Exp; branches; next ; 1.23.4.1 date 2005.03.19.08.36.31; author yamt; state Exp; branches; next ; 1.21.2.1 date 2005.01.07.15.26.53; author jdc; state Exp; branches; next ; 1.21.4.1 date 2005.01.07.15.27.00; author jdc; state Exp; branches; next ; 1.18.6.1 date 2004.08.03.10.54.15; author skrll; state Exp; branches; next 1.18.6.2; 1.18.6.2 date 2004.09.18.14.54.16; author skrll; state Exp; branches; next 1.18.6.3; 1.18.6.3 date 2004.09.21.13.36.38; author skrll; state Exp; branches; next 1.18.6.4; 1.18.6.4 date 2004.12.18.09.32.50; author skrll; state Exp; branches; next 1.18.6.5; 1.18.6.5 date 2005.03.04.16.52.58; author skrll; state Exp; branches; next ; 1.14.2.1 date 2002.01.10.20.02.08; author thorpej; state Exp; branches; next 1.14.2.2; 1.14.2.2 date 2002.10.10.18.43.44; author jdolecek; state Exp; branches; next ; 1.13.2.1 date 2001.06.21.20.08.07; author nathanw; state Exp; branches; next 1.13.2.2; 1.13.2.2 date 2001.11.14.19.17.23; author nathanw; state Exp; branches; next 1.13.2.3; 1.13.2.3 date 2002.09.17.21.22.50; author nathanw; state Exp; branches; next 1.13.2.4; 1.13.2.4 date 2002.11.11.22.15.00; author nathanw; state Exp; branches; next 1.13.2.5; 1.13.2.5 date 2002.12.11.06.46.32; author thorpej; state Exp; branches; next ; 1.5.2.1 date 2000.11.20.18.10.04; author bouyer; state Exp; branches; next 1.5.2.2; 1.5.2.2 date 2001.02.11.19.17.09; author bouyer; state Exp; branches; next 1.5.2.3; 1.5.2.3 date 2001.03.12.13.31.48; author bouyer; state Exp; branches; next ; 1.5.4.1 date 99.11.15.00.42.12; author fvdl; state Exp; branches; next ; 1.5.6.1 date 99.12.27.18.36.10; author wrstuden; state Exp; branches; next ; 1.3.6.1 date 2000.05.11.09.25.19; author he; state Exp; branches; next ; 1.3.8.1 date 99.06.21.01.27.34; author thorpej; state Exp; branches; next ; desc @@ 1.54 log @Garbage-collect the remaining vestiges of netisr. @ text @/* $NetBSD: if_media.c,v 1.53 2021/10/06 20:42:44 andvar Exp $ */ /*- * Copyright (c) 1998, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * NASA Ames Research Center. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1997 * Jonathan Stone and Jason R. Thorpe. All rights reserved. * * This software is derived from information provided by Matt Thomas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Jonathan Stone * and Jason R. Thorpe for the NetBSD Project. * 4. The names of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * BSD/OS-compatible network interface media selection. * * Where it is safe to do so, this code strays slightly from the BSD/OS * design. Software which uses the API (device drivers, basically) * shouldn't notice any difference. * * Many thanks to Matt Thomas for providing the information necessary * to implement this interface. */ #include __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.53 2021/10/06 20:42:44 andvar Exp $"); #define __IFMEDIA_PRIVATE #include #include #include #include #include #include #include #include static void ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *); static struct ifmedia_entry * ifmedia_match_locked(struct ifmedia *, u_int, u_int); /* * Compile-time options: * IFMEDIA_DEBUG: * Turn on implementation-level debug printfs. * Useful for debugging newly-ported drivers. */ #ifdef IFMEDIA_DEBUG int ifmedia_debug = 0; static void ifmedia_printword(int); #endif /* * We need to implement a recursive mutex to handle the un-converted * driver case. For a fully MP-safe driver, the media lock will be * held before calling any of the entry points that require it. However, * this is not necessarily the case for a driver that hasn't yet been * converted, and the entry point calls may be nested (for example * mii_ifmedia_change -> ether_mediachange -> mii_mediachg). Luckily, * the nesting won't be very deep, and 4 nested holds should be plenty. */ #define IFM_L_OWNLOCK 0x01 #define IFM_L_COUNT_MASK 0x3UL #define IFM_L_CPU_MASK ~(IFM_L_COUNT_MASK) void ifmedia_lock_for_legacy(struct ifmedia *ifm) { uintptr_t cnt = IFM_L_OWNLOCK; uintptr_t ci; if (mutex_tryenter(ifm->ifm_lock)) { goto gotit; } kpreempt_disable(); ci = (uintptr_t)curcpu(); if ((ifm->ifm_legacy & IFM_L_CPU_MASK) == ci) { cnt = ifm->ifm_legacy & IFM_L_COUNT_MASK; KASSERT(cnt < IFM_L_COUNT_MASK); cnt++; kpreempt_enable(); goto gotit; } kpreempt_enable(); mutex_enter(ifm->ifm_lock); gotit: KASSERT(kpreempt_disabled()); ci = (uintptr_t)curcpu(); KASSERT((ci & IFM_L_CPU_MASK) == ci); ifm->ifm_legacy = ci | cnt; } void ifmedia_unlock_for_legacy(struct ifmedia *ifm) { uintptr_t cnt; uintptr_t ci = (uintptr_t)curcpu(); KASSERT(kpreempt_disabled()); KASSERT((ifm->ifm_legacy & IFM_L_CPU_MASK) == ci); cnt = ifm->ifm_legacy & IFM_L_COUNT_MASK; KASSERT(cnt != 0); if (cnt == IFM_L_OWNLOCK) { ifm->ifm_legacy = IFM_L_OWNLOCK; mutex_exit(ifm->ifm_lock); return; } cnt--; ifm->ifm_legacy = ci | cnt; } /* * Initialize if_media struct for a specific interface instance. */ void ifmedia_init_with_lock(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback, kmutex_t *lock) { /* * XXX Would really like to assert: * * !if_is_mpsafe(ifp) || ((if_is_mpsafe(ifp) && lock != NULL) * * ...but we don't have access to the ifnet here. */ TAILQ_INIT(&ifm->ifm_list); ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; ifm->ifm_mask = dontcare_mask; /* IF don't-care bits */ ifm->ifm_change = change_callback; ifm->ifm_status = status_callback; ifm->ifm_legacy = 0; if (lock == NULL) { /* * This is to support drivers that are not yet MP-safe * with regard to the ifmedia layer. In these cases, * we supply the lock and we ensure it's taken upon entry * to various routines that expect it to be held. When * we do this, we expect that the driver is in general a * non-MP-safe driver and has already gone to splnet(). */ lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); ifm->ifm_legacy = IFM_L_OWNLOCK; } ifm->ifm_lock = lock; } void ifmedia_init(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback) { ifmedia_init_with_lock(ifm, dontcare_mask, change_callback, status_callback, NULL); } /* * Free resources associated with an ifmedia. */ void ifmedia_fini(struct ifmedia *ifm) { ifmedia_removeall(ifm); if (ifm->ifm_legacy) { KASSERT(ifm->ifm_legacy == IFM_L_OWNLOCK); mutex_obj_free(ifm->ifm_lock); } ifm->ifm_legacy = 0; ifm->ifm_lock = NULL; } int ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) { int rv; IFMEDIA_LOCK_FOR_LEGACY(ifm); KASSERT(ifmedia_locked(ifm)); if (ifm->ifm_change) rv = (*ifm->ifm_change)(ifp); else rv = -1; IFMEDIA_UNLOCK_FOR_LEGACY(ifm); return rv; } static void ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp, struct ifmediareq *ifmr) { KASSERT(ifmedia_locked(ifm)); if (ifm->ifm_status == NULL) return; (*ifm->ifm_status)(ifp, ifmr); } /* * Add a media configuration to the list of supported media * for a specific interface instance. */ static void ifmedia_add_entry(struct ifmedia *ifm, int mword, int data, void *aux, struct ifmedia_entry *entry) { #ifdef IFMEDIA_DEBUG if (ifmedia_debug) { if (ifm == NULL) { printf("ifmedia_add: null ifm\n"); return; } printf("Adding entry for "); ifmedia_printword(mword); } #endif entry->ifm_media = mword; entry->ifm_data = data; entry->ifm_aux = aux; TAILQ_INSERT_TAIL(&ifm->ifm_list, entry, ifm_list); } void ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) { struct ifmedia_entry *entry; entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); ifmedia_lock(ifm); ifmedia_add_entry(ifm, mword, data, aux, entry); ifmedia_unlock(ifm); } /* * Add an array of media configurations to the list of * supported media for a specific interface instance. */ void ifmedia_list_add(struct ifmedia *ifm, struct ifmedia_entry *lp, int count) { int i; for (i = 0; i < count; i++) ifmedia_add(ifm, lp[i].ifm_media, lp[i].ifm_data, lp[i].ifm_aux); } /* * Set the default active media. * * Called by device-specific code which is assumed to have already * selected the default media in hardware. We do _not_ call the * media-change callback. */ void ifmedia_set(struct ifmedia *ifm, int target) { struct ifmedia_entry *match, *entry = NULL; ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); /* * If we didn't find the requested media, then we try to fall * back to target-type (IFM_ETHER, e.g.) | IFM_NONE. If that's * not on the list, then we add it and set the media to it. * * Since ifmedia_set is almost always called with IFM_AUTO or * with a known-good media, this really should only occur if we: * * a) didn't find any PHYs, or * b) didn't find an autoselect option on the PHY when the * parent ethernet driver expected to. * * In either case, it makes sense to select no media. */ if (match == NULL) { printf("ifmedia_set: no match for 0x%x/0x%x\n", target, ~ifm->ifm_mask); target = (target & IFM_NMASK) | IFM_NONE; match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); if (match == NULL) { ifmedia_unlock(ifm); entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); if (match == NULL) { ifmedia_add_entry(ifm, target, 0, NULL, entry); entry = NULL; } match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); if (match == NULL) panic("ifmedia_set failed"); } } ifm->ifm_cur = match; ifmedia_unlock(ifm); if (entry) kmem_free(entry, sizeof(*entry)); #ifdef IFMEDIA_DEBUG if (ifmedia_debug) { printf("ifmedia_set: target "); ifmedia_printword(target); printf("ifmedia_set: setting to "); ifmedia_printword(ifm->ifm_cur->ifm_media); } #endif } static int ifmedia_getwords(struct ifmedia * const ifm, int *words, int maxwords) { struct ifmedia_entry *ep; int nwords = 0; KASSERT(ifmedia_locked(ifm)); TAILQ_FOREACH(ep, &ifm->ifm_list, ifm_list) { if (words != NULL && nwords < maxwords) { words[nwords] = ep->ifm_media; } nwords++; } return nwords; } #define IFMEDIA_IOCTL_LOCK(ifm) \ do { \ if (ifmedia_islegacy(ifm)) \ ifmedia_lock_for_legacy(ifm); \ else \ ifmedia_lock(ifm); \ } while (/*CONSTCOND*/0) #define IFMEDIA_IOCTL_UNLOCK(ifm) \ do { \ if (ifmedia_islegacy(ifm)) \ ifmedia_unlock_for_legacy(ifm); \ else \ ifmedia_unlock(ifm); \ } while (/*CONSTCOND*/0) /* * Device-independent media ioctl support function. */ int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd) { struct ifmedia_entry *match; struct ifmediareq *ifmr = (struct ifmediareq *)ifr; int error = 0; if (ifp == NULL || ifr == NULL || ifm == NULL) return EINVAL; KERNEL_LOCK_UNLESS_IFP_MPSAFE(ifp); switch (cmd) { case SIOCSIFMEDIA: /* Set the current media. */ { struct ifmedia_entry *oldentry; u_int oldmedia; u_int newmedia = ifr->ifr_media; IFMEDIA_IOCTL_LOCK(ifm); match = ifmedia_match_locked(ifm, newmedia, ifm->ifm_mask); if (match == NULL) { #ifdef IFMEDIA_DEBUG if (ifmedia_debug) { printf("ifmedia_ioctl: no media found for " "0x%08x\n", newmedia); } #endif IFMEDIA_IOCTL_UNLOCK(ifm); error = EINVAL; break; } /* * If no change, we're done. * XXX Automedia may involve software intervention. * Keep going in case the connected media changed. * Similarly, if best match changed (kernel debugger?). */ if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) && (newmedia == ifm->ifm_media) && (match == ifm->ifm_cur)) { IFMEDIA_IOCTL_UNLOCK(ifm); break; } /* * We found a match, now make the driver switch to it. * Make sure to preserve our old media type in case the * driver can't switch. */ #ifdef IFMEDIA_DEBUG if (ifmedia_debug) { printf("ifmedia_ioctl: switching %s to ", ifp->if_xname); ifmedia_printword(match->ifm_media); } #endif oldentry = ifm->ifm_cur; oldmedia = ifm->ifm_media; ifm->ifm_cur = match; ifm->ifm_media = newmedia; error = ifmedia_change(ifm, ifp); if (error) { ifm->ifm_cur = oldentry; ifm->ifm_media = oldmedia; } IFMEDIA_IOCTL_UNLOCK(ifm); break; } /* Get list of available media and current media on interface. */ case SIOCGIFMEDIA: { int nwords1, nwords2; if (ifmr->ifm_count < 0) { error = EINVAL; break; } IFMEDIA_IOCTL_LOCK(ifm); ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ? ifm->ifm_cur->ifm_media : IFM_NONE; ifmr->ifm_mask = ifm->ifm_mask; ifmr->ifm_status = 0; ifmedia_status(ifm, ifp, ifmr); /* * Count them so we know how much is the max we'll * need. */ nwords1 = nwords2 = ifmedia_getwords(ifm, NULL, 0); IFMEDIA_IOCTL_UNLOCK(ifm); if (ifmr->ifm_count != 0) { int maxwords = MIN(nwords1, ifmr->ifm_count); int *kptr = kmem_zalloc(maxwords * sizeof(int), KM_SLEEP); ifmedia_lock(ifm); nwords2 = ifmedia_getwords(ifm, kptr, maxwords); ifmedia_unlock(ifm); error = copyout(kptr, ifmr->ifm_ulist, maxwords * sizeof(int)); if (error == 0 && nwords2 > nwords1) error = E2BIG; /* oops! */ kmem_free(kptr, maxwords * sizeof(int)); } /* Update with the real number */ ifmr->ifm_count = nwords2; break; } default: error = EINVAL; break; } KERNEL_UNLOCK_UNLESS_IFP_MPSAFE(ifp); return error; } /* * Find media entry matching a given ifm word. */ static struct ifmedia_entry * ifmedia_match_locked(struct ifmedia *ifm, u_int target, u_int mask) { struct ifmedia_entry *match, *next; match = NULL; mask = ~mask; TAILQ_FOREACH(next, &ifm->ifm_list, ifm_list) { if ((next->ifm_media & mask) == (target & mask)) { if (match) { #if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC) printf("ifmedia_match: multiple match for " "0x%x/0x%x, selected instance %d\n", target, mask, IFM_INST(match->ifm_media)); #endif break; } match = next; } } return match; } struct ifmedia_entry * ifmedia_match(struct ifmedia *ifm, u_int target, u_int mask) { struct ifmedia_entry *match; /* * N.B. We expect the caller is responsible fot the lifecycle * of the media entries. Use with extreme caution. */ ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, mask); ifmedia_unlock(ifm); return match; } /* * Delete all media for a given instance. */ void ifmedia_delete_instance(struct ifmedia *ifm, u_int inst) { struct ifmedia_entry *ife, *nife; TAILQ_HEAD(, ifmedia_entry) dead_entries; TAILQ_INIT(&dead_entries); ifmedia_lock(ifm); TAILQ_FOREACH_SAFE(ife, &ifm->ifm_list, ifm_list, nife) { if (inst == IFM_INST_ANY || inst == IFM_INST(ife->ifm_media)) { if (ifm->ifm_cur == ife) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); TAILQ_INSERT_TAIL(&dead_entries, ife, ifm_list); } } ifmedia_unlock(ifm); TAILQ_FOREACH_SAFE(ife, &dead_entries, ifm_list, nife) { TAILQ_REMOVE(&dead_entries, ife, ifm_list); kmem_free(ife, sizeof(*ife)); } } void ifmedia_removeall(struct ifmedia *ifm) { ifmedia_delete_instance(ifm, IFM_INST_ANY); } /* * Compute the interface `baudrate' from the media, for the interface * metrics (used by routing daemons). */ static const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = IFM_BAUDRATE_DESCRIPTIONS; uint64_t ifmedia_baudrate(int mword) { int i; for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) { if (IFM_TYPE_SUBTYPE_MATCH(mword, ifmedia_baudrate_descriptions[i].ifmb_word)) return ifmedia_baudrate_descriptions[i].ifmb_baudrate; } /* Not known. */ return 0; } #ifdef IFMEDIA_DEBUG static const struct ifmedia_description ifm_type_descriptions[] = IFM_TYPE_DESCRIPTIONS; static const struct ifmedia_description ifm_subtype_descriptions[] = IFM_SUBTYPE_DESCRIPTIONS; static const struct ifmedia_description ifm_option_descriptions[] = IFM_OPTION_DESCRIPTIONS; /* * print a media word. */ static void ifmedia_printword(int ifmw) { const struct ifmedia_description *desc; int seen_option = 0; /* Print the top-level interface type. */ for (desc = ifm_type_descriptions; desc->ifmt_string != NULL; desc++) { if (IFM_TYPE(ifmw) == desc->ifmt_word) break; } if (desc->ifmt_string == NULL) printf(" "); else printf("%s ", desc->ifmt_string); /* Print the subtype. */ for (desc = ifm_subtype_descriptions; desc->ifmt_string != NULL; desc++) { if (IFM_TYPE_MATCH(desc->ifmt_word, ifmw) && IFM_SUBTYPE(desc->ifmt_word) == IFM_SUBTYPE(ifmw)) break; } if (desc->ifmt_string == NULL) printf(""); else printf("%s", desc->ifmt_string); /* Print any options. */ for (desc = ifm_option_descriptions; desc->ifmt_string != NULL; desc++) { if (IFM_TYPE_MATCH(desc->ifmt_word, ifmw) && (ifmw & desc->ifmt_word) != 0 && (seen_option & IFM_OPTIONS(desc->ifmt_word)) == 0) { if (seen_option == 0) printf(" <"); printf("%s%s", seen_option ? "," : "", desc->ifmt_string); seen_option |= IFM_OPTIONS(desc->ifmt_word); } } printf("%s\n", seen_option ? ">" : ""); } #endif /* IFMEDIA_DEBUG */ @ 1.53 log @s/acccess/access/ @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.52 2020/03/15 23:04:51 thorpej Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.52 2020/03/15 23:04:51 thorpej Exp $"); a91 1 #include @ 1.52 log @Define and implement a locking protocol for the ifmedia / mii layers: - MP-safe drivers provide a mutex to ifmedia that is used to serialize access to media-related structures / hardware regsiters. Converted drivers use the new ifmedia_init_with_lock() function for this. The new name is provided to ease the transition. - Un-converted drivers continue to call ifmedia_init(), which will supply a compatibility lock to be used instead. Several media-related entry points must be aware of this compatibility lock, and are able to acquire it recursively a limited number of times, if needed. This is a SPIN mutex with priority IPL_NET. - This same lock is used to serialize access to PHY registers and other MII-related data structures. The PHY drivers are modified to acquire and release the lock, as needed, and assert the lock is held as a diagnostic aid. The "usbnet" framework has had an overhaul of its internal locking protocols to fit in with the media / mii changes, and the drivers adapted. USB wifi drivers have been changed to provide their own adaptive mutex to the ifmedia later via a new ieee80211_media_init_with_lock() function. This is required because the USB drivers need an adaptive mutex. Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv. mcx also now calls ifmedia_init_with_lock() because it needs to also use an adaptive mutex. The mcx driver still needs to be fully converted to NET_MPSAFE. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.51 2020/02/01 20:56:16 thorpej Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.51 2020/02/01 20:56:16 thorpej Exp $"); d186 1 a186 1 * ...but we don't have acccess to the ifnet here. @ 1.51 log @- Add an ifmedia_fini() routine, to free resources assocated with an ifmedia. Currently calls ifmedia_removeall(). All drivers that call ifmedia_init() and support detach should call this routine. - In ifmedia_delete_instance(), set ifm->ifm_cur to NULL and ifm->ifm_media to IFM_NONE when removing / freeing that entry, not simply when we've been asked to delete every media instance. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.50 2020/01/31 00:49:18 thorpej Exp $ */ d4 1 a4 1 * Copyright (c) 1998 The NetBSD Foundation, Inc. d79 3 a81 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.50 2020/01/31 00:49:18 thorpej Exp $"); d95 3 a97 3 struct ifmediareq *); static int ifmedia_ioctl_locked(struct ifnet *, struct ifreq *, struct ifmedia *, u_long); d112 61 d176 3 a178 2 ifmedia_init(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback) d181 8 d195 23 d228 7 d240 9 d250 1 a250 3 if (ifm->ifm_change == NULL) return -1; return (*ifm->ifm_change)(ifp); d257 1 d267 3 a269 2 void ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) a270 1 struct ifmedia_entry *entry; a282 1 entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); d289 11 d324 1 a324 1 struct ifmedia_entry *match; d326 2 a327 1 match = ifmedia_match(ifm, target, ifm->ifm_mask); d347 1 a347 1 match = ifmedia_match(ifm, target, ifm->ifm_mask); d349 11 a359 2 ifmedia_add(ifm, target, 0, NULL); match = ifmedia_match(ifm, target, ifm->ifm_mask); d365 4 d386 2 d398 16 d417 2 a418 2 static int ifmedia_ioctl_locked(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, d428 2 d437 3 a439 1 match = ifmedia_match(ifm, newmedia, ifm->ifm_mask); d447 3 a449 1 return EINVAL; d459 4 a462 2 (newmedia == ifm->ifm_media) && (match == ifm->ifm_cur)) return 0; d485 1 d494 4 a497 2 if (ifmr->ifm_count < 0) return EINVAL; d499 1 d507 1 a507 1 * Count them so we know a-priori how much is the max we'll d511 1 d518 1 d520 1 d533 2 a534 1 return EINVAL; d537 2 a541 25 int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd) { int e; /* * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here and * ipl will not have been raised (well, maybe it has, but * it doesn't matter), but ifmedia_ioctl_locked isn't MP-safe * yet, so we go to splnet and grab the KERNEL_LOCK. * * In the non-mpsafe case, the interface's ioctl routine * will already be running at splnet() and so raising it * again is redundant, but also harmless. */ int s = splnet(); KERNEL_LOCK_IF_IFP_MPSAFE(ifp); e = ifmedia_ioctl_locked(ifp, ifr, ifm, cmd); KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp); splx(s); return e; } d545 2 a546 2 struct ifmedia_entry * ifmedia_match(struct ifmedia *ifm, u_int target, u_int mask) d570 16 d593 3 d597 1 d606 1 a606 1 kmem_free(ife, sizeof(*ife)); d609 6 a623 1 @ 1.50 log @- Use kmem(9) instead of malloc(9). - When handling SIOCGIFMEDIA, don't traverse the media list directly; refactor that out into a ifmedia_getwords() function. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $"); d125 10 d436 4 a443 4 if (inst == IFM_INST_ANY) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } @ 1.49 log @In ifmedia_ioctl(), go to splnet() before acquiring the KERNEL_LOCK. For non-NET_MPSAFE, this is benign, because we can nest raising to splnet(). For the NET_MPSAFE, it means that drivers don't need to raise to splnet() just in order to call ifmedia_ioctl(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.48 2019/10/01 17:45:25 chs Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.48 2019/10/01 17:45:25 chs Exp $"); d86 1 a86 1 #include a108 2 MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state"); d163 1 a163 1 entry = malloc(sizeof(*entry), M_IFMEDIA, M_WAITOK); d236 16 d321 1 a321 2 struct ifmedia_entry *ep; size_t nwords; d336 1 a336 3 ep = TAILQ_FIRST(&ifm->ifm_list); for (nwords = 0; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) nwords++; d339 3 a341 11 size_t count; size_t minwords = nwords > (size_t)ifmr->ifm_count ? (size_t)ifmr->ifm_count : nwords; int *kptr = malloc(minwords * sizeof(int), M_TEMP, M_WAITOK); /* Get the media words from the interface's list. */ ep = TAILQ_FIRST(&ifm->ifm_list); for (count = 0; ep != NULL && count < minwords; ep = TAILQ_NEXT(ep, ifm_list), count++) kptr[count] = ep->ifm_media; d343 1 d345 2 a346 2 minwords * sizeof(int)); if (error == 0 && ep != NULL) d348 1 a348 1 free(kptr, M_TEMP); d351 1 a351 1 ifmr->ifm_count = nwords; d427 1 a427 1 free(ife, M_IFMEDIA); @ 1.48 log @in ifmedia_add(), use a wait-style memory allocation rather than not waiting and panic'ing if the allocation fails. Reported-by: syzbot+249ca42197f0b066e154@@syzkaller.appspotmail.com @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.47 2019/08/10 01:04:05 mrg Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.47 2019/08/10 01:04:05 mrg Exp $"); d365 8 a372 2 * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, * but ifmedia_ioctl_locked isn't MP-safe yet, so we must hold the lock. d374 1 d378 2 @ 1.48.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $"); d365 2 a366 8 * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here and * ipl will not have been raised (well, maybe it has, but * it doesn't matter), but ifmedia_ioctl_locked isn't MP-safe * yet, so we go to splnet and grab the KERNEL_LOCK. * * In the non-mpsafe case, the interface's ioctl routine * will already be running at splnet() and so raising it * again is redundant, but also harmless. a367 1 int s = splnet(); a370 2 splx(s); @ 1.48.2.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.51 2020/02/01 20:56:16 thorpej Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.51 2020/02/01 20:56:16 thorpej Exp $"); d86 1 a86 1 #include d109 2 a126 10 /* * Free resources associated with an ifmedia. */ void ifmedia_fini(struct ifmedia *ifm) { ifmedia_removeall(ifm); } d165 1 a165 1 entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); a237 16 static int ifmedia_getwords(struct ifmedia * const ifm, int *words, int maxwords) { struct ifmedia_entry *ep; int nwords = 0; TAILQ_FOREACH(ep, &ifm->ifm_list, ifm_list) { if (words != NULL && nwords < maxwords) { words[nwords] = ep->ifm_media; } nwords++; } return nwords; } d307 2 a308 1 int nwords1, nwords2; d323 3 a325 1 nwords1 = nwords2 = ifmedia_getwords(ifm, NULL, 0); d328 11 a338 3 int maxwords = MIN(nwords1, ifmr->ifm_count); int *kptr = kmem_zalloc(maxwords * sizeof(int), KM_SLEEP); a339 1 nwords2 = ifmedia_getwords(ifm, kptr, maxwords); d341 2 a342 2 maxwords * sizeof(int)); if (error == 0 && nwords2 > nwords1) d344 1 a344 1 kmem_free(kptr, maxwords * sizeof(int)); d347 1 a347 1 ifmr->ifm_count = nwords2; a421 4 if (ifm->ifm_cur == ife) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } d423 1 a423 1 kmem_free(ife, sizeof(*ife)); d426 4 @ 1.47 log @rename _ifmedia_ioctl() to ifmedia_ioctl_locked(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.46 2019/05/21 09:18:37 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.46 2019/05/21 09:18:37 msaitoh Exp $"); d165 1 a165 4 entry = malloc(sizeof(*entry), M_IFMEDIA, M_NOWAIT); if (entry == NULL) panic("ifmedia_add: can't malloc entry"); a168 1 a333 2 if (kptr == NULL) return ENOMEM; @ 1.46 log @ KNF. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.45 2019/05/17 07:37:12 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.45 2019/05/17 07:37:12 msaitoh Exp $"); d94 1 a94 1 static int _ifmedia_ioctl(struct ifnet *, struct ifreq *, d246 1 a246 1 _ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, d372 1 a372 1 * but _ifmedia_ioctl isn't MP-safe yet, so we must hold the lock. d375 1 a375 1 e = _ifmedia_ioctl(ifp, ifr, ifm, cmd); @ 1.45 log @ The max subtype of the ifmedia word is 31. It's too small for Ethernet now. We currently use use it up to 30. We should extend the limit to be able to use more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem so we should redesign the interface, but it's too late for netbsd-9 to do it. So, we keep the data structure size and modify the structure a bit. The strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet have not used, so use some of them for Ethernet's subtype. The differences against FreeBSD are: - We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA). - FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15". - FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH() macro for matching both TYPE and SUBTYPE. - Added up to 400GBASE-SR16. New layout of the media word is as follows (from ifmedia_h): * if_media Options word: * Bits Use * ---- ------- * 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others * 5-7 Media type * 8-15 Type specific options * 16-18 Mode (for multi-mode devices) * 19 (Reserved for Future Use) * 20-27 Shared (global) options * 28-31 Instance * * 3 2 1 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * +-------+---------------+-+-----+---------------+-----+---------+ * | | |R| | | | | * | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK | * | | |U| |XTMSK| | | | * +-------+---------------+-+-----+-----+---------+-----+---------+ * <-----> <---> <---> * IFM_INST() IFM_MODE() IFM_TYPE() * * IFM_SUBTYPE(other than ETH)<-------> * * <---> IFM_SUBTYPE(ETH)<-------> * * * <-------------> <-------------> * IFM_OPTIONS() @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.44 2019/05/10 08:24:54 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.44 2019/05/10 08:24:54 msaitoh Exp $"); d137 1 a137 2 ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp, struct ifmediareq *ifmr) @ 1.44 log @Use %08x to print ifmedia word (IFMEDIA_DEBUG). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.43 2019/04/23 07:29:04 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.43 2019/04/23 07:29:04 msaitoh Exp $"); d353 1 d451 2 a452 2 if ((mword & (IFM_NMASK|IFM_TMASK)) == ifmedia_baudrate_descriptions[i].ifmb_word) @ 1.43 log @ KNF. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.42 2019/04/22 11:10:52 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.42 2019/04/22 11:10:52 msaitoh Exp $"); d268 2 a269 3 printf( "ifmedia_ioctl: no media found for 0x%x\n", newmedia); @ 1.42 log @ Add missing error check. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.41 2019/04/16 06:48:33 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.41 2019/04/16 06:48:33 msaitoh Exp $"); d100 2 a101 2 * turn on implementation-level debug printfs. * Useful for debugging newly-ported drivers. d255 1 a255 1 return (EINVAL); d258 1 a258 4 /* * Set the current media. */ case SIOCSIFMEDIA: d310 1 a310 3 /* * Get list of available media and current media on interface. */ d453 1 a453 1 return (ifmedia_baudrate_descriptions[i].ifmb_baudrate); @ 1.41 log @ It's not required (and can't do) to convert OSIOCSIFMEDIA in ifmedia_ioct() because the conversiosn is done in doifioctl(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.40 2019/04/10 08:23:46 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.40 2019/04/10 08:23:46 msaitoh Exp $"); d345 2 @ 1.40 log @ KNF. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.39 2019/04/10 08:22:18 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.39 2019/04/10 08:22:18 msaitoh Exp $"); a91 2 #include a252 3 #ifdef OSIOCSIFMEDIA struct oifreq *oifr = (struct oifreq *)ifr; #endif a257 6 #ifdef OSIOCSIFMEDIA case OSIOCSIFMEDIA: ifr->ifr_media = oifr->ifr_media; #endif /* FALLTHROUGH */ @ 1.39 log @ Fix a bug that OSIOCSIFMEDIA can't treat. Add missing inclusion of compat/sys/sockio.h. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.38 2019/02/28 05:40:58 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.38 2019/02/28 05:40:58 msaitoh Exp $"); d94 4 a97 2 static void ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *); static int _ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long); d355 2 a356 3 /* * Get the media words from the interface's list. */ @ 1.38 log @- Remove extra cast. - Cosmetic change. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.37 2019/02/28 05:25:35 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.37 2019/02/28 05:25:35 msaitoh Exp $"); d92 2 a264 1 /*FALLTHROUGH*/ d266 1 @ 1.37 log @No functional change: - Use TAILQ_FOREACH{,_SAFE}() macro. - KNF. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $"); d348 3 a350 4 ? (size_t)ifmr->ifm_count : nwords; int *kptr = (int *)malloc(minwords * sizeof(int), M_TEMP, M_WAITOK); @ 1.36 log @add prototypes, validate ifm_change and ifm_status vectors. NFC. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $"); d249 1 a249 1 struct ifmediareq *ifmr = (struct ifmediareq *) ifr; d293 1 a293 2 (newmedia == ifm->ifm_media) && (match == ifm->ifm_cur)) d384 2 a385 2 * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, but _ifmedia_ioctl * isn't MP-safe yet, so we must hold the lock. d404 1 a404 2 for (next = TAILQ_FIRST(&ifm->ifm_list); next != NULL; next = TAILQ_NEXT(next, ifm_list)) { d429 1 a429 2 for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); @ 1.36.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.46 2019/05/21 09:18:37 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.46 2019/05/21 09:18:37 msaitoh Exp $"); d92 2 a93 4 static void ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *); static int _ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long); d98 2 a99 2 * Turn on implementation-level debug printfs. * Useful for debugging newly-ported drivers. d135 2 a136 1 ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp, struct ifmediareq *ifmr) d249 1 a249 1 struct ifmediareq *ifmr = (struct ifmediareq *)ifr; d251 3 d256 1 a256 1 return EINVAL; d259 10 a268 1 case SIOCSIFMEDIA: /* Set the current media. */ d278 3 a280 2 printf("ifmedia_ioctl: no media found for " "0x%08x\n", newmedia); d293 2 a294 1 (newmedia == ifm->ifm_media) && (match == ifm->ifm_cur)) d321 3 a323 1 /* Get list of available media and current media on interface. */ d349 7 a355 7 ? (size_t)ifmr->ifm_count : nwords; int *kptr = malloc(minwords * sizeof(int), M_TEMP, M_WAITOK); if (kptr == NULL) return ENOMEM; /* Get the media words from the interface's list. */ a366 1 /* Update with the real number */ d385 2 a386 2 * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, * but _ifmedia_ioctl isn't MP-safe yet, so we must hold the lock. d405 2 a406 1 TAILQ_FOREACH(next, &ifm->ifm_list, ifm_list) { d431 2 a432 1 TAILQ_FOREACH_SAFE(ife, &ifm->ifm_list, ifm_list, nife) { d466 3 a468 3 if (IFM_TYPE_SUBTYPE_MATCH(mword, ifmedia_baudrate_descriptions[i].ifmb_word)) return ifmedia_baudrate_descriptions[i].ifmb_baudrate; @ 1.36.2.2 log @Mostly merge changes from HEAD upto 20200411 @ text @d1 1 a1 1 /* $NetBSD$ */ d4 1 a4 1 * Copyright (c) 1998, 2020 The NetBSD Foundation, Inc. d79 1 a79 3 __KERNEL_RCSID(0, "$NetBSD$"); #define __IFMEDIA_PRIVATE d86 1 a86 1 #include d93 3 a95 3 struct ifmediareq *); static struct ifmedia_entry * ifmedia_match_locked(struct ifmedia *, u_int, u_int); d109 1 a109 60 /* * We need to implement a recursive mutex to handle the un-converted * driver case. For a fully MP-safe driver, the media lock will be * held before calling any of the entry points that require it. However, * this is not necessarily the case for a driver that hasn't yet been * converted, and the entry point calls may be nested (for example * mii_ifmedia_change -> ether_mediachange -> mii_mediachg). Luckily, * the nesting won't be very deep, and 4 nested holds should be plenty. */ #define IFM_L_OWNLOCK 0x01 #define IFM_L_COUNT_MASK 0x3UL #define IFM_L_CPU_MASK ~(IFM_L_COUNT_MASK) void ifmedia_lock_for_legacy(struct ifmedia *ifm) { uintptr_t cnt = IFM_L_OWNLOCK; uintptr_t ci; if (mutex_tryenter(ifm->ifm_lock)) { goto gotit; } kpreempt_disable(); ci = (uintptr_t)curcpu(); if ((ifm->ifm_legacy & IFM_L_CPU_MASK) == ci) { cnt = ifm->ifm_legacy & IFM_L_COUNT_MASK; KASSERT(cnt < IFM_L_COUNT_MASK); cnt++; kpreempt_enable(); goto gotit; } kpreempt_enable(); mutex_enter(ifm->ifm_lock); gotit: KASSERT(kpreempt_disabled()); ci = (uintptr_t)curcpu(); KASSERT((ci & IFM_L_CPU_MASK) == ci); ifm->ifm_legacy = ci | cnt; } void ifmedia_unlock_for_legacy(struct ifmedia *ifm) { uintptr_t cnt; uintptr_t ci = (uintptr_t)curcpu(); KASSERT(kpreempt_disabled()); KASSERT((ifm->ifm_legacy & IFM_L_CPU_MASK) == ci); cnt = ifm->ifm_legacy & IFM_L_COUNT_MASK; KASSERT(cnt != 0); if (cnt == IFM_L_OWNLOCK) { ifm->ifm_legacy = IFM_L_OWNLOCK; mutex_exit(ifm->ifm_lock); return; } cnt--; ifm->ifm_legacy = ci | cnt; } d115 2 a116 3 ifmedia_init_with_lock(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback, kmutex_t *lock) a118 8 /* * XXX Would really like to assert: * * !if_is_mpsafe(ifp) || ((if_is_mpsafe(ifp) && lock != NULL) * * ...but we don't have acccess to the ifnet here. */ a124 40 ifm->ifm_legacy = 0; if (lock == NULL) { /* * This is to support drivers that are not yet MP-safe * with regard to the ifmedia layer. In these cases, * we supply the lock and we ensure it's taken upon entry * to various routines that expect it to be held. When * we do this, we expect that the driver is in general a * non-MP-safe driver and has already gone to splnet(). */ lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); ifm->ifm_legacy = IFM_L_OWNLOCK; } ifm->ifm_lock = lock; } void ifmedia_init(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback) { ifmedia_init_with_lock(ifm, dontcare_mask, change_callback, status_callback, NULL); } /* * Free resources associated with an ifmedia. */ void ifmedia_fini(struct ifmedia *ifm) { ifmedia_removeall(ifm); if (ifm->ifm_legacy) { KASSERT(ifm->ifm_legacy == IFM_L_OWNLOCK); mutex_obj_free(ifm->ifm_lock); } ifm->ifm_legacy = 0; ifm->ifm_lock = NULL; a129 1 int rv; d131 3 a133 9 IFMEDIA_LOCK_FOR_LEGACY(ifm); KASSERT(ifmedia_locked(ifm)); if (ifm->ifm_change) rv = (*ifm->ifm_change)(ifp); else rv = -1; IFMEDIA_UNLOCK_FOR_LEGACY(ifm); return rv; a139 1 KASSERT(ifmedia_locked(ifm)); d149 2 a150 3 static void ifmedia_add_entry(struct ifmedia *ifm, int mword, int data, void *aux, struct ifmedia_entry *entry) d152 1 d165 4 d172 1 a175 11 void ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) { struct ifmedia_entry *entry; entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); ifmedia_lock(ifm); ifmedia_add_entry(ifm, mword, data, aux, entry); ifmedia_unlock(ifm); } d200 1 a200 1 struct ifmedia_entry *match, *entry = NULL; d202 1 a202 2 ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); d222 1 a222 1 match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); d224 2 a225 11 ifmedia_unlock(ifm); entry = kmem_zalloc(sizeof(*entry), KM_SLEEP); ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); if (match == NULL) { ifmedia_add_entry(ifm, target, 0, NULL, entry); entry = NULL; } match = ifmedia_match_locked(ifm, target, ifm->ifm_mask); a230 4 ifmedia_unlock(ifm); if (entry) kmem_free(entry, sizeof(*entry)); a241 34 static int ifmedia_getwords(struct ifmedia * const ifm, int *words, int maxwords) { struct ifmedia_entry *ep; int nwords = 0; KASSERT(ifmedia_locked(ifm)); TAILQ_FOREACH(ep, &ifm->ifm_list, ifm_list) { if (words != NULL && nwords < maxwords) { words[nwords] = ep->ifm_media; } nwords++; } return nwords; } #define IFMEDIA_IOCTL_LOCK(ifm) \ do { \ if (ifmedia_islegacy(ifm)) \ ifmedia_lock_for_legacy(ifm); \ else \ ifmedia_lock(ifm); \ } while (/*CONSTCOND*/0) #define IFMEDIA_IOCTL_UNLOCK(ifm) \ do { \ if (ifmedia_islegacy(ifm)) \ ifmedia_unlock_for_legacy(ifm); \ else \ ifmedia_unlock(ifm); \ } while (/*CONSTCOND*/0) d245 2 a246 2 int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, a255 2 KERNEL_LOCK_UNLESS_IFP_MPSAFE(ifp); d263 1 a263 3 IFMEDIA_IOCTL_LOCK(ifm); match = ifmedia_match_locked(ifm, newmedia, ifm->ifm_mask); d271 1 a271 3 IFMEDIA_IOCTL_UNLOCK(ifm); error = EINVAL; break; d281 2 a282 4 (newmedia == ifm->ifm_media) && (match == ifm->ifm_cur)) { IFMEDIA_IOCTL_UNLOCK(ifm); break; } a304 1 IFMEDIA_IOCTL_UNLOCK(ifm); d311 2 a312 1 int nwords1, nwords2; d314 2 a315 4 if (ifmr->ifm_count < 0) { error = EINVAL; break; } a316 1 IFMEDIA_IOCTL_LOCK(ifm); d324 1 a324 1 * Count them so we know how much is the max we'll d327 3 a329 2 nwords1 = nwords2 = ifmedia_getwords(ifm, NULL, 0); IFMEDIA_IOCTL_UNLOCK(ifm); d332 14 a345 7 int maxwords = MIN(nwords1, ifmr->ifm_count); int *kptr = kmem_zalloc(maxwords * sizeof(int), KM_SLEEP); ifmedia_lock(ifm); nwords2 = ifmedia_getwords(ifm, kptr, maxwords); ifmedia_unlock(ifm); d347 2 a348 2 maxwords * sizeof(int)); if (error == 0 && nwords2 > nwords1) d350 1 a350 1 kmem_free(kptr, maxwords * sizeof(int)); d353 1 a353 1 ifmr->ifm_count = nwords2; d358 1 a358 2 error = EINVAL; break; d361 8 a368 1 KERNEL_UNLOCK_UNLESS_IFP_MPSAFE(ifp); d370 8 a377 1 return error; d383 2 a384 2 static struct ifmedia_entry * ifmedia_match_locked(struct ifmedia *ifm, u_int target, u_int mask) a407 16 struct ifmedia_entry * ifmedia_match(struct ifmedia *ifm, u_int target, u_int mask) { struct ifmedia_entry *match; /* * N.B. We expect the caller is responsible fot the lifecycle * of the media entries. Use with extreme caution. */ ifmedia_lock(ifm); match = ifmedia_match_locked(ifm, target, mask); ifmedia_unlock(ifm); return match; } a414 3 TAILQ_HEAD(, ifmedia_entry) dead_entries; TAILQ_INIT(&dead_entries); a415 1 ifmedia_lock(ifm); a418 4 if (ifm->ifm_cur == ife) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } d420 1 a420 1 TAILQ_INSERT_TAIL(&dead_entries, ife, ifm_list); d423 3 a425 5 ifmedia_unlock(ifm); TAILQ_FOREACH_SAFE(ife, &dead_entries, ifm_list, nife) { TAILQ_REMOVE(&dead_entries, ife, ifm_list); kmem_free(ife, sizeof(*ife)); d436 1 @ 1.35 log @Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE If IFEF_MPSAFE is set, hold the lock and otherwise don't hold. This change requires additions of KERNEL_LOCK to subsequence functions from if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe components. Proposed on tech-kern@@ and tech-net@@ @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.34 2017/10/23 03:54:40 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.34 2017/10/23 03:54:40 msaitoh Exp $"); d92 3 d128 3 d134 10 d336 1 a336 2 /* ifmedia_status */ (*ifm->ifm_status)(ifp, ifmr); @ 1.35.2.1 log @Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$ @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $"); a91 3 static void ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *); static int _ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long); a124 3 if (ifm->ifm_change == NULL) return -1; a127 10 static void ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp, struct ifmediareq *ifmr) { if (ifm->ifm_status == NULL) return; (*ifm->ifm_status)(ifp, ifmr); } d320 2 a321 1 ifmedia_status(ifm, ifp, ifmr); @ 1.34 log @ Clear ifm_cur and ifm_media after removing all ifmedia entries(IFM_INST_ANY) in ifmedia_delete_instance() like if_media.c rev. 1.32. Now if_media_delete_instance(IFM_INST_ANY) is the same as ifmedia_removeall(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.33 2017/10/20 08:04:39 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.33 2017/10/20 08:04:39 msaitoh Exp $"); d228 2 a229 2 int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, d363 16 @ 1.33 log @No functional change: - Simplify ifmedia_removeall using with ifmedia_delete_instance(IFM_INST_ANY). - KNF. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); d408 4 a418 2 ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; @ 1.32 log @ifmedia_removeall(): Clear ifm_cur and ifm_media after removing all ifmedia entries. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.31 2017/01/25 07:17:19 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.31 2017/01/25 07:17:19 msaitoh Exp $"); d209 1 a209 1 if (match == NULL) { a210 1 } d267 1 a267 1 return (EINVAL); d357 1 a357 1 return (EINVAL); d360 1 a360 1 return (error); d400 1 a400 2 for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { a412 1 struct ifmedia_entry *ife, *nife; d414 1 a414 5 for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } d439 1 a439 1 return (0); @ 1.32.6.1 log @Pull up following revision(s) (requested by msaitoh in ticket #370): sys/net/if_media.c: revision 1.33 sys/net/if_media.c: revision 1.34 No functional change: - Simplify ifmedia_removeall using with ifmedia_delete_instance(IFM_INST_ANY). - KNF. Clear ifm_cur and ifm_media after removing all ifmedia entries(IFM_INST_ANY) in ifmedia_delete_instance() like if_media.c rev. 1.32. Now if_media_delete_instance(IFM_INST_ANY) is the same as ifmedia_removeall(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); d209 1 a209 1 if (match == NULL) d211 1 d268 1 a268 1 return EINVAL; d358 1 a358 1 return EINVAL; d361 1 a361 1 return error; d401 2 a402 1 for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { a409 4 if (inst == IFM_INST_ANY) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } d415 1 d417 7 a423 1 ifmedia_delete_instance(ifm, IFM_INST_ANY); d446 1 a446 1 return 0; @ 1.32.6.2 log @Pull up following revision(s) (requested by ozaki-r in ticket #456): sys/arch/arm/sunxi/sunxi_emac.c: 1.9 sys/dev/ic/dwc_gmac.c: 1.43-1.44 sys/dev/pci/if_iwm.c: 1.75 sys/dev/pci/if_wm.c: 1.543 sys/dev/pci/ixgbe/ixgbe.c: 1.112 sys/dev/pci/ixgbe/ixv.c: 1.74 sys/kern/sys_socket.c: 1.75 sys/net/agr/if_agr.c: 1.43 sys/net/bpf.c: 1.219 sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416 sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257 sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146 sys/net/if_etherip.c: 1.40 sys/net/if_ethersubr.c: 1.243, 1.246 sys/net/if_faith.c: 1.57 sys/net/if_gif.c: 1.132 sys/net/if_l2tp.c: 1.15, 1.17 sys/net/if_loop.c: 1.98-1.101 sys/net/if_media.c: 1.35 sys/net/if_pppoe.c: 1.131-1.132 sys/net/if_spppsubr.c: 1.176-1.177 sys/net/if_tun.c: 1.142 sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121 sys/net/npf/npf_ifaddr.c: 1.3 sys/net/npf/npf_os.c: 1.8-1.9 sys/net/rtsock.c: 1.230 sys/netcan/if_canloop.c: 1.3-1.5 sys/netinet/if_arp.c: 1.255 sys/netinet/igmp.c: 1.65 sys/netinet/in.c: 1.210-1.211 sys/netinet/in_pcb.c: 1.180 sys/netinet/ip_carp.c: 1.92, 1.94 sys/netinet/ip_flow.c: 1.81 sys/netinet/ip_input.c: 1.362 sys/netinet/ip_mroute.c: 1.147 sys/netinet/ip_output.c: 1.283, 1.285, 1.287 sys/netinet6/frag6.c: 1.61 sys/netinet6/in6.c: 1.251, 1.255 sys/netinet6/in6_pcb.c: 1.162 sys/netinet6/ip6_flow.c: 1.35 sys/netinet6/ip6_input.c: 1.183 sys/netinet6/ip6_output.c: 1.196 sys/netinet6/mld6.c: 1.90 sys/netinet6/nd6.c: 1.239-1.240 sys/netinet6/nd6_nbr.c: 1.139 sys/netinet6/nd6_rtr.c: 1.136 sys/netipsec/ipsec_output.c: 1.65 sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10 kmem_intr_free kmem_intr_[z]alloced memory the underlying pools are the same but api-wise those should match Unify IFEF_*_MPSAFE into IFEF_MPSAFE There are already two flags for if_output and if_start, however, it seems such MPSAFE flags are eventually needed for all if_XXX operations. Having discrete flags for each operation is wasteful of if_extflags bits. So let's unify the flags into one: IFEF_MPSAFE. Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so we can change them without breaking backward compatibility of the releases (though the kernel version of -current should be bumped). Note that if an interface have both MP-safe and non-MP-safe operations at a time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe opeartions take the kernel lock. Proposed on tech-kern@@ and tech-net@@ Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..." scattered all over the source code and makes it easy to identify remaining KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE. No functional change Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE If IFEF_MPSAFE is set, hold the lock and otherwise don't hold. This change requires additions of KERNEL_LOCK to subsequence functions from if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe components. Proposed on tech-kern@@ and tech-net@@ Ensure to hold if_ioctl_lock when calling if_flags_set Fix locking against myself on ifpromisc vlan_unconfig_locked could be called with holding if_ioctl_lock. Ensure to not turn on IFF_RUNNING of an interface until its initialization completes And ensure to turn off it before destruction as per IFF_RUNNING's description "resource allocated". (The description is a bit doubtful though, I believe the change is still proper.) Ensure to hold if_ioctl_lock on if_up and if_down One exception for if_down is if_detach; in the case the lock isn't needed because it's guaranteed that no other one can access ifp at that point. Make if_link_queue MP-safe if IFEF_MPSAFE if_link_queue is a queue to store events of link state changes, which is used to pass events from (typically) an interrupt handler to if_link_state_change softint. The queue was protected by KERNEL_LOCK so far, but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it by a spin mutex. Additionally with this change KERNEL_LOCK of if_link_state_change softint is omitted if NET_MPSAFE is enabled. Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of if_timer (see the comment). Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH At that point no other one modifies the list so IFADDR_READER_FOREACH is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though, if we try to detect contract violations of pserialize, using it violates the contract. So avoid using it makes life easy. Ensure to call if_addr_init with holding if_ioctl_lock Get rid of outdated comments Fix build of kernels without ether By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that created a unnecessary dependency from if.c to if_ethersubr.c. PR kern/52790 Rename IFNET_LOCK to IFNET_GLOBAL_LOCK IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then). Wrap if_ioctl_lock with IFNET_* macros (NFC) Also if_ioctl_lock perhaps needs to be renamed to something because it's now not just for ioctl... Reorder some destruction routines in if_detach - Destroy if_ioctl_lock at the end of the if_detach because it's used in various destruction routines - Move psref_target_destroy after pr_purgeif because we want to use psref in pr_purgeif (otherwise destruction procedures can be tricky) Ensure to call if_mcast_op with holding IFNET_LOCK Note that CARP doesn't deal with IFNET_LOCK yet. Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held Describe which lock is used to protect each member variable of struct ifnet Requested by skrll@@ Write a guideline for converting an interface to IFEF_MPSAFE Requested by skrll@@ Note that IFNET_LOCK must not be held in softint Don't set IFEF_MPSAFE unless NET_MPSAFE at this point Because recent investigations show that interfaces with IFEF_MPSAFE need to follow additional restrictions to work with the flag safely. We should enable it on an interface by default only if the interface surely satisfies the restrictions, which are described in if.h. Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because the network stack is still serialized by the big kernel locks by default. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32.6.1 2017/11/22 14:36:55 martin Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32.6.1 2017/11/22 14:36:55 martin Exp $"); d228 2 a229 2 static int _ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, a362 16 int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd) { int e; /* * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, but _ifmedia_ioctl * isn't MP-safe yet, so we must hold the lock. */ KERNEL_LOCK_IF_IFP_MPSAFE(ifp); e = _ifmedia_ioctl(ifp, ifr, ifm, cmd); KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp); return e; } @ 1.32.6.3 log @Pull up following revision(s) (requested by msaitoh in ticket #1266): sys/net/if_media.c: revision 1.42 (via patch) Add missing error check. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32.6.2 2018/01/02 10:20:33 snj Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32.6.2 2018/01/02 10:20:33 snj Exp $"); a337 3 if (kptr == NULL) return ENOMEM; @ 1.31 log @ifmedia_init(): Clear ifm_media with IFM_NONE instead of 0. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.30 2009/10/05 21:27:36 dyoung Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.30 2009/10/05 21:27:36 dyoung Exp $"); d422 2 @ 1.30 log @Replace u_quad_t with uint64_t. u_quad_t is just a typedef for uint64_t, so no ABI/API breakage will result from this change. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.29 2008/06/15 16:33:58 christos Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.29 2008/06/15 16:33:58 christos Exp $"); d116 1 a116 1 ifm->ifm_media = 0; @ 1.30.22.1 log @update from HEAD @ text @d1 1 a1 1 /* $NetBSD$ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD$"); d116 1 a116 1 ifm->ifm_media = IFM_NONE; d209 1 a209 1 if (match == NULL) d211 1 d229 2 a230 2 static int _ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, d268 1 a268 1 return EINVAL; d358 1 a358 1 return EINVAL; d361 1 a361 17 return error; } int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd) { int e; /* * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, but _ifmedia_ioctl * isn't MP-safe yet, so we must hold the lock. */ KERNEL_LOCK_IF_IFP_MPSAFE(ifp); e = _ifmedia_ioctl(ifp, ifr, ifm, cmd); KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp); return e; d401 2 a402 1 for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { a409 4 if (inst == IFM_INST_ANY) { ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; } d415 1 d417 5 a421 1 ifmedia_delete_instance(ifm, IFM_INST_ANY); d444 1 a444 1 return 0; @ 1.30.48.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); d116 1 a116 1 ifm->ifm_media = IFM_NONE; a421 2 ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; @ 1.30.44.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); d116 1 a116 1 ifm->ifm_media = IFM_NONE; a421 2 ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; @ 1.30.40.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); d116 1 a116 1 ifm->ifm_media = IFM_NONE; a421 2 ifm->ifm_cur = NULL; ifm->ifm_media = IFM_NONE; @ 1.29 log @- Add more definitions from FreeBSD - Add ifmedia_removeall from FreeBSD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.28 2008/04/28 20:24:09 martin Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.28 2008/04/28 20:24:09 martin Exp $"); d432 1 a432 1 u_quad_t @ 1.28 log @Remove clause 3 and 4 from TNF licenses @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $"); d412 13 @ 1.28.2.1 log @Sync w/ -current. 34 merge conflicts to follow. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.28 2008/04/28 20:24:09 martin Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.28 2008/04/28 20:24:09 martin Exp $"); a411 13 void ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } } @ 1.28.4.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.29 2008/06/15 16:33:58 christos Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.29 2008/06/15 16:33:58 christos Exp $"); a411 13 void ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } } @ 1.27 log @Add a helper subroutine for ethernet drivers, ifmedia_change(). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp $ */ a18 7 * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp $"); @ 1.27.6.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d19 7 d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD$"); @ 1.27.6.2 log @Sync with HEAD. @ text @a411 13 void ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } } @ 1.27.8.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $ */ d19 7 d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $"); @ 1.27.8.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27.8.1 2008/05/18 12:35:27 yamt Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27.8.1 2008/05/18 12:35:27 yamt Exp $"); a411 13 void ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } } @ 1.27.10.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $ */ d19 7 d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $"); @ 1.27.10.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27.10.1 2008/05/16 02:25:40 yamt Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27.10.1 2008/05/16 02:25:40 yamt Exp $"); a411 13 void ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_IFMEDIA); } } @ 1.27.10.3 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27.10.2 2009/05/04 08:14:15 yamt Exp $ */ d79 1 a79 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27.10.2 2009/05/04 08:14:15 yamt Exp $"); d432 1 a432 1 uint64_t @ 1.26 log @Add a sockaddr_storage member to "struct ifreq" maintaining backwards compatibility with the older ioctls. This avoids stack smashing and abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that were longer than "struct sockaddr". XXX: Some of the emulations might be broken; I tried to add code for them but I did not test them. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.25 2005/12/11 12:24:51 christos Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.25 2005/12/11 12:24:51 christos Exp $"); d129 6 d305 1 a305 1 error = (*ifm->ifm_change)(ifp); d328 1 @ 1.26.8.1 log @sync with HEAD @ text @d1 1 a1 1 /* if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp */ d86 1 a86 1 __KERNEL_RCSID(0, "if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp"); a128 6 int ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) { return (*ifm->ifm_change)(ifp); } d299 1 a299 1 error = ifmedia_change(ifm, ifp); a321 1 /* ifmedia_status */ @ 1.26.14.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.27 2008/01/10 08:00:22 dyoung Exp $"); a128 6 int ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) { return (*ifm->ifm_change)(ifp); } d299 1 a299 1 error = ifmedia_change(ifm, ifp); a321 1 /* ifmedia_status */ @ 1.26.20.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD$ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD$"); a128 6 int ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) { return (*ifm->ifm_change)(ifp); } d299 1 a299 1 error = ifmedia_change(ifm, ifp); a321 1 /* ifmedia_status */ @ 1.25 log @merge ktrace-lwp. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.18.6.5 2005/03/04 16:52:58 skrll Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.18.6.5 2005/03/04 16:52:58 skrll Exp $"); d237 3 d246 5 @ 1.25.32.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.26 2007/05/29 21:32:30 christos Exp $"); a236 3 #ifdef OSIOCSIFMEDIA struct oifreq *oifr = (struct oifreq *)ifr; #endif a242 5 #ifdef OSIOCSIFMEDIA case OSIOCSIFMEDIA: ifr->ifr_media = oifr->ifr_media; /*FALLTHROUGH*/ #endif @ 1.25.30.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.25 2005/12/11 12:24:51 christos Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.25 2005/12/11 12:24:51 christos Exp $"); a236 3 #ifdef OSIOCSIFMEDIA struct oifreq *oifr = (struct oifreq *)ifr; #endif a242 5 #ifdef OSIOCSIFMEDIA case OSIOCSIFMEDIA: ifr->ifr_media = oifr->ifr_media; /*FALLTHROUGH*/ #endif @ 1.24 log @nuke trailing whitespace @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $"); @ 1.24.4.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.24 2005/02/26 22:45:09 perry Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.24 2005/02/26 22:45:09 perry Exp $"); a236 3 #ifdef OSIOCSIFMEDIA struct oifreq *oifr = (struct oifreq *)ifr; #endif a242 5 #ifdef OSIOCSIFMEDIA case OSIOCSIFMEDIA: ifr->ifr_media = oifr->ifr_media; /*FALLTHROUGH*/ #endif @ 1.24.4.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.24.4.1 2007/09/03 14:42:09 yamt Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.24.4.1 2007/09/03 14:42:09 yamt Exp $"); a128 6 int ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) { return (*ifm->ifm_change)(ifp); } d299 1 a299 1 error = ifmedia_change(ifm, ifp); a321 1 /* ifmedia_status */ @ 1.23 log @As pointed out by Greg Troxel, ifmedia_entrys were allocated with malloc_type M_IFADDR and freed with malloc_type M_DEVBUF. This causes a panic(9) in DIAGNOSTIC kernels. Add malloc_type M_IFMEDIA and use it for both malloc'ing and free'ing ifmedia_entrys. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $"); d175 1 a175 1 * Set the default active media. d257 1 a257 1 "ifmedia_ioctl: no media found for 0x%x\n", d302 1 a302 1 case SIOCGIFMEDIA: d326 1 a326 1 size_t minwords = nwords > (size_t)ifmr->ifm_count @ 1.23.2.1 log @sync with -current @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.24 2005/02/26 22:45:09 perry Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.24 2005/02/26 22:45:09 perry Exp $"); d175 1 a175 1 * Set the default active media. d257 1 a257 1 "ifmedia_ioctl: no media found for 0x%x\n", d302 1 a302 1 case SIOCGIFMEDIA: d326 1 a326 1 size_t minwords = nwords > (size_t)ifmr->ifm_count @ 1.23.4.1 log @sync with head. xen and whitespace. xen part is not finished. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $"); d175 1 a175 1 * Set the default active media. d257 1 a257 1 "ifmedia_ioctl: no media found for 0x%x\n", d302 1 a302 1 case SIOCGIFMEDIA: d326 1 a326 1 size_t minwords = nwords > (size_t)ifmr->ifm_count @ 1.22 log @De-__P'ify. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $"); d111 2 d149 1 a149 1 entry = malloc(sizeof(*entry), M_IFADDR, M_NOWAIT); d399 1 a399 1 free(ife, M_DEVBUF); @ 1.21 log @Add media type 10GbaseLR. Change ifmb_baudrate and ifmedia_baudrate() to u_quad_t instead of int (common speed today exceeds 2Gbit). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.20 2003/11/03 14:43:32 briggs Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.20 2003/11/03 14:43:32 briggs Exp $"); d108 1 a108 1 static void ifmedia_printword __P((int)); d115 2 a116 5 ifmedia_init(ifm, dontcare_mask, change_callback, status_callback) struct ifmedia *ifm; int dontcare_mask; ifm_change_cb_t change_callback; ifm_stat_cb_t status_callback; d132 1 a132 5 ifmedia_add(ifm, mword, data, aux) struct ifmedia *ifm; int mword; int data; void *aux; d163 1 a163 4 ifmedia_list_add(ifm, lp, count) struct ifmedia *ifm; struct ifmedia_entry *lp; int count; d180 1 a180 3 ifmedia_set(ifm, target) struct ifmedia *ifm; int target; d229 2 a230 5 ifmedia_ioctl(ifp, ifr, ifm, cmd) struct ifnet *ifp; struct ifreq *ifr; struct ifmedia *ifm; u_long cmd; d244 1 a244 1 case SIOCSIFMEDIA: d300 1 a300 1 case SIOCGIFMEDIA: d358 1 a358 4 ifmedia_match(ifm, target, mask) struct ifmedia *ifm; u_int target; u_int mask; d387 1 a387 3 ifmedia_delete_instance(ifm, inst) struct ifmedia *ifm; u_int inst; d439 1 a439 2 ifmedia_printword(ifmw) int ifmw; @ 1.21.4.1 log @Pull up revision 1.23 (requested by dyoung in ticket #1030). As pointed out by Greg Troxel, ifmedia_entrys were allocated with malloc_type M_IFADDR and freed with malloc_type M_DEVBUF. This causes a panic(9) in DIAGNOSTIC kernels. Add malloc_type M_IFMEDIA and use it for both malloc'ing and free'ing ifmedia_entrys. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $"); a110 2 MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state"); d154 1 a154 1 entry = malloc(sizeof(*entry), M_IFMEDIA, M_NOWAIT); d417 1 a417 1 free(ife, M_IFMEDIA); @ 1.21.2.1 log @Pull up revision 1.23 (requested by dyoung in ticket #1030). As pointed out by Greg Troxel, ifmedia_entrys were allocated with malloc_type M_IFADDR and freed with malloc_type M_DEVBUF. This causes a panic(9) in DIAGNOSTIC kernels. Add malloc_type M_IFMEDIA and use it for both malloc'ing and free'ing ifmedia_entrys. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $"); a110 2 MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state"); d154 1 a154 1 entry = malloc(sizeof(*entry), M_IFMEDIA, M_NOWAIT); d417 1 a417 1 free(ife, M_IFMEDIA); @ 1.20 log @ifmedia_set() should not panic, nor can it really fail. So if there is some problem setting the media to the requested value (usually IFM_AUTO), we now force the media selection to IFM_NONE. This addresses PR/14029 ``panic("ifmedia_set") a little too brutal'' and may address to some degree PR/19504 and PR/23341. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.19 2003/07/25 19:35:57 christos Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.19 2003/07/25 19:35:57 christos Exp $"); d429 2 a430 3 int ifmedia_baudrate(mword) int mword; @ 1.19 log @Avoid DOS attack by setting ifm->ifm_media to a high number and running the kernel out of memory. Thanks to Andreas Oman. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.18 2002/11/12 16:54:45 chs Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.18 2002/11/12 16:54:45 chs Exp $"); a192 1 d198 14 d215 9 a223 1 panic("ifmedia_set"); @ 1.18 log @when there are multiple matches for the requested media, select the first matching instance rather than the last one. this restores the behaviour in the multiple-match case to what it was when all the drivers only allowed instance 0 (and in particular, makes autonegotiation of the on-board fxp on my DK440LX board work again by default, which has two PHYs that both advertise "auto"). as discussed on tech-net. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.17 2002/11/07 08:00:47 thorpej Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.17 2002/11/07 08:00:47 thorpej Exp $"); d228 1 a228 1 int error = 0, sticky; d297 1 a297 1 int *kptr, count; d299 2 a300 1 kptr = NULL; /* XXX gcc */ d308 4 a311 1 count = 0; d313 2 d317 5 a321 1 kptr = (int *)malloc(ifmr->ifm_count * sizeof(int), a322 1 d326 2 a327 1 for (; ep != NULL && count < ifmr->ifm_count; d331 3 a333 1 if (ep != NULL) d335 1 d337 1 a337 30 /* * If there are more interfaces on the list, count * them. This allows the caller to set ifmr->ifm_count * to 0 on the first call to know how much space to * callocate. */ for (; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) count++; /* * We do the copyout on E2BIG, because that's * just our way of telling userland that there * are more. This is the behavior I've observed * under BSD/OS 3.0 */ sticky = error; if ((error == 0 || error == E2BIG) && ifmr->ifm_count != 0) { error = copyout((caddr_t)kptr, (caddr_t)ifmr->ifm_ulist, ifmr->ifm_count * sizeof(int)); } if (error == 0) error = sticky; if (ifmr->ifm_count != 0) free(kptr, M_TEMP); ifmr->ifm_count = count; @ 1.18.6.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $"); d108 1 a108 1 static void ifmedia_printword(int); d115 5 a119 2 ifmedia_init(struct ifmedia *ifm, int dontcare_mask, ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback) d135 5 a139 1 ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) d170 4 a173 1 ifmedia_list_add(struct ifmedia *ifm, struct ifmedia_entry *lp, int count) d190 4 a193 1 ifmedia_set(struct ifmedia *ifm, int target) a198 14 /* * If we didn't find the requested media, then we try to fall * back to target-type (IFM_ETHER, e.g.) | IFM_NONE. If that's * not on the list, then we add it and set the media to it. * * Since ifmedia_set is almost always called with IFM_AUTO or * with a known-good media, this really should only occur if we: * * a) didn't find any PHYs, or * b) didn't find an autoselect option on the PHY when the * parent ethernet driver expected to. * * In either case, it makes sense to select no media. */ d202 1 a202 9 target = (target & IFM_NMASK) | IFM_NONE; match = ifmedia_match(ifm, target, ifm->ifm_mask); if (match == NULL) { ifmedia_add(ifm, target, 0, NULL); match = ifmedia_match(ifm, target, ifm->ifm_mask); if (match == NULL) { panic("ifmedia_set failed"); } } d220 5 a224 2 ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd) d228 1 a228 1 int error = 0; d238 1 a238 1 case SIOCSIFMEDIA: d294 1 a294 1 case SIOCGIFMEDIA: d297 1 a297 1 size_t nwords; d299 1 a299 2 if (ifmr->ifm_count < 0) return EINVAL; d307 1 a307 4 /* * Count them so we know a-priori how much is the max we'll * need. */ a308 2 for (nwords = 0; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) nwords++; d311 1 a311 5 size_t count; size_t minwords = nwords > (size_t)ifmr->ifm_count ? (size_t)ifmr->ifm_count : nwords; int *kptr = (int *)malloc(minwords * sizeof(int), d313 1 d317 1 a317 2 ep = TAILQ_FIRST(&ifm->ifm_list); for (count = 0; ep != NULL && count < minwords; d321 1 a321 3 error = copyout(kptr, ifmr->ifm_ulist, minwords * sizeof(int)); if (error == 0 && ep != NULL) d323 28 d352 2 a353 2 } ifmr->ifm_count = nwords; d368 4 a371 1 ifmedia_match(struct ifmedia *ifm, u_int target, u_int mask) d400 3 a402 1 ifmedia_delete_instance(struct ifmedia *ifm, u_int inst) d424 3 a426 2 u_quad_t ifmedia_baudrate(int mword) d455 2 a456 1 ifmedia_printword(int ifmw) @ 1.18.6.2 log @Sync with HEAD. @ text @@ 1.18.6.3 log @Fix the sync with head I botched. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.18.6.1 2004/08/03 10:54:15 skrll Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.18.6.1 2004/08/03 10:54:15 skrll Exp $"); @ 1.18.6.4 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.18.6.3 2004/09/21 13:36:38 skrll Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.18.6.3 2004/09/21 13:36:38 skrll Exp $"); a110 2 MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state"); d147 1 a147 1 entry = malloc(sizeof(*entry), M_IFMEDIA, M_NOWAIT); d397 1 a397 1 free(ife, M_IFMEDIA); @ 1.18.6.5 log @Sync with HEAD. Hi Perry! @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.18.6.4 2004/12/18 09:32:50 skrll Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.18.6.4 2004/12/18 09:32:50 skrll Exp $"); d175 1 a175 1 * Set the default active media. d257 1 a257 1 "ifmedia_ioctl: no media found for 0x%x\n", d302 1 a302 1 case SIOCGIFMEDIA: d326 1 a326 1 size_t minwords = nwords > (size_t)ifmr->ifm_count @ 1.17 log @Fix more signed/unsigned comparison warnings. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.16 2002/09/11 05:36:27 itojun Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.16 2002/09/11 05:36:27 itojun Exp $"); d381 1 a382 1 if (match) { d384 4 a387 1 "0x%x/0x%x\n", target, mask); a388 1 #endif @ 1.16 log @KNF - return is not a function. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.15 2001/11/12 23:49:40 lukem Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.15 2001/11/12 23:49:40 lukem Exp $"); d241 2 a242 2 int oldmedia; int newmedia = ifr->ifr_media; d370 2 a371 2 int target; int mask; d400 1 a400 1 int inst; @ 1.15 log @add RCSIDs @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.14 2001/05/18 08:56:27 drochner Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD$"); d231 1 a231 1 return(EINVAL); @ 1.14 log @fix typo in comment @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.13 2001/02/26 09:42:00 joda Exp $ */ d84 3 @ 1.14.2.1 log @Sync kqueue branch with -current. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.15 2001/11/12 23:49:40 lukem Exp $ */ a83 3 #include __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.15 2001/11/12 23:49:40 lukem Exp $"); @ 1.14.2.2 log @sync kqueue with -current; this includes merge of gehenna-devsw branch, merge of i386 MP branch, and part of autoconf rototil work @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.14.2.1 2002/01/10 20:02:08 thorpej Exp $ */ d86 1 a86 1 __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.14.2.1 2002/01/10 20:02:08 thorpej Exp $"); d231 1 a231 1 return (EINVAL); @ 1.13 log @when changing to an unsupported media type, return EINVAL instead of ENXIO @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.12 2001/01/17 19:04:03 jdolecek Exp $ */ d255 1 a255 1 * XXX Automedia may invole software intervention. @ 1.13.2.1 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.13 2001/02/26 09:42:00 joda Exp $ */ d255 1 a255 1 * XXX Automedia may involve software intervention. @ 1.13.2.2 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.13.2.1 2001/06/21 20:08:07 nathanw Exp $ */ a83 3 #include __KERNEL_RCSID(0, "$NetBSD$"); @ 1.13.2.3 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD$ */ d231 1 a231 1 return (EINVAL); @ 1.13.2.4 log @Catch up to -current @ text @d241 2 a242 2 u_int oldmedia; u_int newmedia = ifr->ifr_media; d370 2 a371 2 u_int target; u_int mask; d400 1 a400 1 u_int inst; @ 1.13.2.5 log @Sync with HEAD. @ text @d381 1 a382 1 #if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC) d384 2 a385 2 "0x%x/0x%x, selected instance %d\n", target, mask, IFM_INST(match->ifm_media)); a386 2 break; } @ 1.12 log @make local const stuff as static const, so that it's pushed to text segment @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.11 2000/03/30 09:45:36 augustss Exp $ */ d250 1 a250 1 return (ENXIO); @ 1.11 log @Kill some more register declarations. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.10 2000/03/13 23:52:39 soren Exp $ */ d416 1 a416 1 struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = d437 1 a437 1 struct ifmedia_description ifm_type_descriptions[] = d440 1 a440 1 struct ifmedia_description ifm_subtype_descriptions[] = d443 1 a443 1 struct ifmedia_description ifm_option_descriptions[] = d453 1 a453 1 struct ifmedia_description *desc; @ 1.10 log @Fix doubled 'the's in comments. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.9 2000/03/06 20:50:29 thorpej Exp $ */ d138 1 a138 1 register struct ifmedia_entry *entry; @ 1.9 log @Add ifmedia_baudrate(), which returns a value suitable for ifi_baudrate given a media word, or 0 for unknown. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.8 2000/01/26 21:58:17 thorpej Exp $ */ d256 1 a256 1 * Keep going in case the the connected media changed. @ 1.8 log @Add a way to delete all media for a specified instance. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.7 1999/11/03 23:06:35 thorpej Exp $ */ d410 23 @ 1.7 log @Make the ifmedia_entry list a TAILQ. This is pretty much for cosmetics (media added to tail, so that when e.g. the list is run to print out what media exist, they appear in-order). @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.6 1999/10/27 17:59:24 thorpej Exp $ */ d389 21 @ 1.6 log @Expose the ifmedia_match() function. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.5 1999/04/30 17:47:36 thorpej Exp $ */ d119 1 a119 1 LIST_INIT(&ifm->ifm_list); d159 1 a159 1 LIST_INSERT_HEAD(&ifm->ifm_list, entry, ifm_list); d305 1 a305 1 ep = ifm->ifm_list.lh_first; d315 1 a315 1 ep = ep->ifm_list.le_next, count++) d328 1 a328 1 for (; ep != NULL; ep = ep->ifm_list.le_next) d375 2 a376 2 for (next = ifm->ifm_list.lh_first; next != NULL; next = next->ifm_list.le_next) { @ 1.5 log @Back out previous. It was just ... braindamaged. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.3 1998/08/30 07:39:39 enami Exp $ */ a102 3 struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm, int flags, int mask)); a362 1 * @ 1.5.2.1 log @Update thorpej_scsipi to -current as of a month ago @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.11 2000/03/30 09:45:36 augustss Exp $ */ d103 3 d122 1 a122 1 TAILQ_INIT(&ifm->ifm_list); d141 1 a141 1 struct ifmedia_entry *entry; d162 1 a162 1 TAILQ_INSERT_TAIL(&ifm->ifm_list, entry, ifm_list); d259 1 a259 1 * Keep going in case the connected media changed. d308 1 a308 1 ep = TAILQ_FIRST(&ifm->ifm_list); d318 1 a318 1 ep = TAILQ_NEXT(ep, ifm_list), count++) d331 1 a331 1 for (; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) d366 1 d379 2 a380 2 for (next = TAILQ_FIRST(&ifm->ifm_list); next != NULL; next = TAILQ_NEXT(next, ifm_list)) { a392 44 } /* * Delete all media for a given instance. */ void ifmedia_delete_instance(ifm, inst) struct ifmedia *ifm; int inst; { struct ifmedia_entry *ife, *nife; for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { nife = TAILQ_NEXT(ife, ifm_list); if (inst == IFM_INST_ANY || inst == IFM_INST(ife->ifm_media)) { TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); free(ife, M_DEVBUF); } } } /* * Compute the interface `baudrate' from the media, for the interface * metrics (used by routing daemons). */ struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = IFM_BAUDRATE_DESCRIPTIONS; int ifmedia_baudrate(mword) int mword; { int i; for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) { if ((mword & (IFM_NMASK|IFM_TMASK)) == ifmedia_baudrate_descriptions[i].ifmb_word) return (ifmedia_baudrate_descriptions[i].ifmb_baudrate); } /* Not known. */ return (0); @ 1.5.2.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.5.2.1 2000/11/20 18:10:04 bouyer Exp $ */ d416 1 a416 1 static const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = d437 1 a437 1 static const struct ifmedia_description ifm_type_descriptions[] = d440 1 a440 1 static const struct ifmedia_description ifm_subtype_descriptions[] = d443 1 a443 1 static const struct ifmedia_description ifm_option_descriptions[] = d453 1 a453 1 const struct ifmedia_description *desc; @ 1.5.2.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.5.2.2 2001/02/11 19:17:09 bouyer Exp $ */ d250 1 a250 1 return (EINVAL); @ 1.5.6.1 log @Pull up to last week's -current. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.7 1999/11/03 23:06:35 thorpej Exp $ */ d103 3 d122 1 a122 1 TAILQ_INIT(&ifm->ifm_list); d162 1 a162 1 TAILQ_INSERT_TAIL(&ifm->ifm_list, entry, ifm_list); d308 1 a308 1 ep = TAILQ_FIRST(&ifm->ifm_list); d318 1 a318 1 ep = TAILQ_NEXT(ep, ifm_list), count++) d331 1 a331 1 for (; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) d366 1 d379 2 a380 2 for (next = TAILQ_FIRST(&ifm->ifm_list); next != NULL; next = TAILQ_NEXT(next, ifm_list)) { @ 1.5.4.1 log @Sync with -current @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.7 1999/11/03 23:06:35 thorpej Exp $ */ d103 3 d122 1 a122 1 TAILQ_INIT(&ifm->ifm_list); d162 1 a162 1 TAILQ_INSERT_TAIL(&ifm->ifm_list, entry, ifm_list); d308 1 a308 1 ep = TAILQ_FIRST(&ifm->ifm_list); d318 1 a318 1 ep = TAILQ_NEXT(ep, ifm_list), count++) d331 1 a331 1 for (; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list)) d366 1 d379 2 a380 2 for (next = TAILQ_FIRST(&ifm->ifm_list); next != NULL; next = TAILQ_NEXT(next, ifm_list)) { @ 1.4 log @If the driver only supports one media type, and ifmedia_ioctl() is called to select the current medium, (and it is not autoselect), assume no change and do not try to select the medium. Fixes 'ifconfig le0 medium 10base5' on sparc2 without requiring a 'do nothing' mediachange callback. @ text @d263 1 a263 2 (newmedia == ifm->ifm_media || (ifm->ifm_media == 0 && LIST_NEXT(ifm->ifm_list.lh_first,ifm_list)==0)) && @ 1.3 log @Make this compile with -DIFMEDIA_DEBUG. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.2 1998/08/06 02:19:34 thorpej Exp $ */ d263 2 a264 1 (newmedia == ifm->ifm_media) && @ 1.3.6.1 log @Pull up revision 1.9 (requested by jhawk): Add a driver for ``wi'', Lucent "Orinoco"/Wavelan. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.3 1998/08/30 07:39:39 enami Exp $ */ a392 23 } /* * Compute the interface `baudrate' from the media, for the interface * metrics (used by routing daemons). */ struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = IFM_BAUDRATE_DESCRIPTIONS; int ifmedia_baudrate(mword) int mword; { int i; for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) { if ((mword & (IFM_NMASK|IFM_TMASK)) == ifmedia_baudrate_descriptions[i].ifmb_word) return (ifmedia_baudrate_descriptions[i].ifmb_baudrate); } /* Not known. */ return (0); @ 1.3.8.1 log @Sync w/ -current. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.5 1999/04/30 17:47:36 thorpej Exp $ */ @ 1.2 log @Completely rewrite the way media descriptions are represented. The same data structure is used, but a much saner matching mechanism is used, one which allows greater ease in adding new types. @ text @d1 1 a1 1 /* $NetBSD: if_media.c,v 1.1 1997/03/17 02:55:15 thorpej Exp $ */ d447 1 a447 1 printf("%s%s", seen_option ? "," : "" @ 1.1 log @BSD/OS-style network interface media selection, implemented by Jonathan Stone and myself. Many thanks to Matt Thomas for providing the information necessary to implement this interface, and for helping to shake out the bugs. @ text @d1 38 a38 1 /* $NetBSD$ */ d396 1 d400 2 a401 20 struct ifmedia_description ifm_subtype_ethernet_descriptions[] = IFM_SUBTYPE_ETHERNET_DESCRIPTIONS; struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] = IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS; struct ifmedia_description ifm_subtype_tokenring_descriptions[] = IFM_SUBTYPE_TOKENRING_DESCRIPTIONS; struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] = IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS; struct ifmedia_description ifm_subtype_fddi_descriptions[] = IFM_SUBTYPE_FDDI_DESCRIPTIONS; struct ifmedia_description ifm_subtype_fddi_option_descriptions[] = IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS; struct ifmedia_description ifm_subtype_shared_descriptions[] = IFM_SUBTYPE_SHARED_DESCRIPTIONS; d403 2 a404 23 struct ifmedia_description ifm_shared_option_descriptions[] = IFM_SHARED_OPTION_DESCRIPTIONS; struct ifmedia_type_to_subtype { struct ifmedia_description *subtypes; struct ifmedia_description *options; }; /* must be in the same order as IFM_TYPE_DESCRIPTIONS */ struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = { { &ifm_subtype_ethernet_descriptions[0], &ifm_subtype_ethernet_option_descriptions[0] }, { &ifm_subtype_tokenring_descriptions[0], &ifm_subtype_tokenring_option_descriptions[0] }, { &ifm_subtype_fddi_descriptions[0], &ifm_subtype_fddi_option_descriptions[0] }, }; a413 1 struct ifmedia_type_to_subtype *ttos; d416 3 a418 3 /* Find the top-level interface type. */ for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes; desc->ifmt_string != NULL; desc++, ttos++) a420 3 if (desc->ifmt_string == NULL) { printf("\n"); return; d422 10 a431 13 printf(desc->ifmt_string); /* * Check for the shared subtype descriptions first, then the * type-specific ones. */ for (desc = ifm_subtype_shared_descriptions; desc->ifmt_string != NULL; desc++) if (IFM_SUBTYPE(ifmw) == desc->ifmt_word) goto got_subtype; for (desc = ttos->subtypes; desc->ifmt_string != NULL; desc++) if (IFM_SUBTYPE(ifmw) == desc->ifmt_word) a432 3 if (desc->ifmt_string == NULL) { printf(" \n"); return; d434 11 a444 10 got_subtype: printf(" %s", desc->ifmt_string); /* * Look for shared options. */ for (desc = ifm_shared_option_descriptions; desc->ifmt_string != NULL; desc++) { if (ifmw & desc->ifmt_word) { d447 1 a447 1 printf("%s%s", seen_option++ ? "," : "", d449 1 a449 12 } } /* * Look for subtype-specific options. */ for (desc = ttos->options; desc->ifmt_string != NULL; desc++) { if (ifmw & desc->ifmt_word) { if (seen_option == 0) printf(" <"); printf("%s%s", seen_option++ ? "," : "", desc->ifmt_string); d454 1 @