1 | #include <sys/param.h> |
---|---|
2 | #include <sys/systm.h> |
3 | #include <sys/kernel.h> |
4 | #include <sys/errno.h> |
5 | #include <sys/device.h> |
6 | |
7 | #include <net/if.h> |
8 | #include <net/if_types.h> |
9 | |
10 | #include <net/if_ether.h> |
11 | #include <net/if_media.h> |
12 | #include <dev/mii/mii.h> |
13 | #include <dev/mii/miivar.h> |
14 | |
15 | int |
16 | ether_mediachange(struct ifnet *ifp) |
17 | { |
18 | struct ethercom *ec = (struct ethercom *)ifp; |
19 | int rc; |
20 | |
21 | KASSERT(ec->ec_mii != NULL); |
22 | |
23 | if ((ifp->if_flags & IFF_UP) == 0) |
24 | return 0; |
25 | if ((rc = mii_mediachg(ec->ec_mii)) == ENXIO) |
26 | return 0; |
27 | return rc; |
28 | } |
29 | |
30 | void |
31 | ether_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) |
32 | { |
33 | struct ethercom *ec = (struct ethercom *)ifp; |
34 | struct mii_data *mii; |
35 | |
36 | KASSERT(ec->ec_mii != NULL); |
37 | |
38 | #ifdef notyet |
39 | if ((ifp->if_flags & IFF_RUNNING) == 0) { |
40 | ifmr->ifm_active = IFM_ETHER | IFM_NONE; |
41 | ifmr->ifm_status = 0; |
42 | return; |
43 | } |
44 | #endif |
45 | |
46 | mii = ec->ec_mii; |
47 | |
48 | mii_pollstat(mii); |
49 | ifmr->ifm_active = mii->mii_media_active; |
50 | ifmr->ifm_status = mii->mii_media_status; |
51 | } |
52 |