| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_wm.c,v 1.432 2016/10/28 05:50:18 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_wm.c,v 1.433 2016/10/28 06:27:11 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -74,27 +74,27 @@ | | | @@ -74,27 +74,27 @@ |
74 | * | | 74 | * |
75 | * - Check XXX'ed comments | | 75 | * - Check XXX'ed comments |
76 | * - Disable D0 LPLU on 8257[12356], 82580 and I350. | | 76 | * - Disable D0 LPLU on 8257[12356], 82580 and I350. |
77 | * - TX Multi queue improvement (refine queue selection logic) | | 77 | * - TX Multi queue improvement (refine queue selection logic) |
78 | * - Advanced Receive Descriptor | | 78 | * - Advanced Receive Descriptor |
79 | * - EEE (Energy Efficiency Ethernet) | | 79 | * - EEE (Energy Efficiency Ethernet) |
80 | * - Virtual Function | | 80 | * - Virtual Function |
81 | * - Set LED correctly (based on contents in EEPROM) | | 81 | * - Set LED correctly (based on contents in EEPROM) |
82 | * - Rework how parameters are loaded from the EEPROM. | | 82 | * - Rework how parameters are loaded from the EEPROM. |
83 | * - Image Unique ID | | 83 | * - Image Unique ID |
84 | */ | | 84 | */ |
85 | | | 85 | |
86 | #include <sys/cdefs.h> | | 86 | #include <sys/cdefs.h> |
87 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.432 2016/10/28 05:50:18 msaitoh Exp $"); | | 87 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.433 2016/10/28 06:27:11 msaitoh Exp $"); |
88 | | | 88 | |
89 | #ifdef _KERNEL_OPT | | 89 | #ifdef _KERNEL_OPT |
90 | #include "opt_net_mpsafe.h" | | 90 | #include "opt_net_mpsafe.h" |
91 | #endif | | 91 | #endif |
92 | | | 92 | |
93 | #include <sys/param.h> | | 93 | #include <sys/param.h> |
94 | #include <sys/systm.h> | | 94 | #include <sys/systm.h> |
95 | #include <sys/callout.h> | | 95 | #include <sys/callout.h> |
96 | #include <sys/mbuf.h> | | 96 | #include <sys/mbuf.h> |
97 | #include <sys/malloc.h> | | 97 | #include <sys/malloc.h> |
98 | #include <sys/kmem.h> | | 98 | #include <sys/kmem.h> |
99 | #include <sys/kernel.h> | | 99 | #include <sys/kernel.h> |
100 | #include <sys/socket.h> | | 100 | #include <sys/socket.h> |
| @@ -8242,30 +8242,32 @@ wm_gmii_mediainit(struct wm_softc *sc, p | | | @@ -8242,30 +8242,32 @@ wm_gmii_mediainit(struct wm_softc *sc, p |
8242 | break; | | 8242 | break; |
8243 | default: | | 8243 | default: |
8244 | if (((sc->sc_flags & WM_F_SGMII) != 0) | | 8244 | if (((sc->sc_flags & WM_F_SGMII) != 0) |
8245 | && !wm_sgmii_uses_mdio(sc)){ | | 8245 | && !wm_sgmii_uses_mdio(sc)){ |
8246 | /* SGMII */ | | 8246 | /* SGMII */ |
8247 | mii->mii_readreg = wm_sgmii_readreg; | | 8247 | mii->mii_readreg = wm_sgmii_readreg; |
8248 | mii->mii_writereg = wm_sgmii_writereg; | | 8248 | mii->mii_writereg = wm_sgmii_writereg; |
8249 | } else if (sc->sc_type >= WM_T_ICH8) { | | 8249 | } else if (sc->sc_type >= WM_T_ICH8) { |
8250 | /* non-82567 ICH8, 9 and 10 */ | | 8250 | /* non-82567 ICH8, 9 and 10 */ |
8251 | mii->mii_readreg = wm_gmii_i82544_readreg; | | 8251 | mii->mii_readreg = wm_gmii_i82544_readreg; |
8252 | mii->mii_writereg = wm_gmii_i82544_writereg; | | 8252 | mii->mii_writereg = wm_gmii_i82544_writereg; |
8253 | } else if (sc->sc_type >= WM_T_80003) { | | 8253 | } else if (sc->sc_type >= WM_T_80003) { |
8254 | /* 80003 */ | | 8254 | /* 80003 */ |
| | | 8255 | sc->sc_phytype = WMPHY_GG82563; |
8255 | mii->mii_readreg = wm_gmii_i80003_readreg; | | 8256 | mii->mii_readreg = wm_gmii_i80003_readreg; |
8256 | mii->mii_writereg = wm_gmii_i80003_writereg; | | 8257 | mii->mii_writereg = wm_gmii_i80003_writereg; |
8257 | } else if (sc->sc_type >= WM_T_I210) { | | 8258 | } else if (sc->sc_type >= WM_T_I210) { |
8258 | /* I210 and I211 */ | | 8259 | /* I210 and I211 */ |
| | | 8260 | sc->sc_phytype = WMPHY_210; |
8259 | mii->mii_readreg = wm_gmii_gs40g_readreg; | | 8261 | mii->mii_readreg = wm_gmii_gs40g_readreg; |
8260 | mii->mii_writereg = wm_gmii_gs40g_writereg; | | 8262 | mii->mii_writereg = wm_gmii_gs40g_writereg; |
8261 | } else if (sc->sc_type >= WM_T_82580) { | | 8263 | } else if (sc->sc_type >= WM_T_82580) { |
8262 | /* 82580, I350 and I354 */ | | 8264 | /* 82580, I350 and I354 */ |
8263 | sc->sc_phytype = WMPHY_82580; | | 8265 | sc->sc_phytype = WMPHY_82580; |
8264 | mii->mii_readreg = wm_gmii_82580_readreg; | | 8266 | mii->mii_readreg = wm_gmii_82580_readreg; |
8265 | mii->mii_writereg = wm_gmii_82580_writereg; | | 8267 | mii->mii_writereg = wm_gmii_82580_writereg; |
8266 | } else if (sc->sc_type >= WM_T_82544) { | | 8268 | } else if (sc->sc_type >= WM_T_82544) { |
8267 | /* 82544, 0, [56], [17], 8257[1234] and 82583 */ | | 8269 | /* 82544, 0, [56], [17], 8257[1234] and 82583 */ |
8268 | mii->mii_readreg = wm_gmii_i82544_readreg; | | 8270 | mii->mii_readreg = wm_gmii_i82544_readreg; |
8269 | mii->mii_writereg = wm_gmii_i82544_writereg; | | 8271 | mii->mii_writereg = wm_gmii_i82544_writereg; |
8270 | } else { | | 8272 | } else { |
8271 | mii->mii_readreg = wm_gmii_i82543_readreg; | | 8273 | mii->mii_readreg = wm_gmii_i82543_readreg; |
| @@ -8752,27 +8754,27 @@ wm_gmii_bm_readreg(device_t self, int ph | | | @@ -8752,27 +8754,27 @@ wm_gmii_bm_readreg(device_t self, int ph |
8752 | | | 8754 | |
8753 | if (sc->phy.acquire(sc)) { | | 8755 | if (sc->phy.acquire(sc)) { |
8754 | aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n", | | 8756 | aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n", |
8755 | __func__); | | 8757 | __func__); |
8756 | return 0; | | 8758 | return 0; |
8757 | } | | 8759 | } |
8758 | | | 8760 | |
8759 | if (reg > BME1000_MAX_MULTI_PAGE_REG) { | | 8761 | if (reg > BME1000_MAX_MULTI_PAGE_REG) { |
8760 | if (phy == 1) | | 8762 | if (phy == 1) |
8761 | wm_gmii_mdic_writereg(self, phy, | | 8763 | wm_gmii_mdic_writereg(self, phy, |
8762 | MII_IGPHY_PAGE_SELECT, reg); | | 8764 | MII_IGPHY_PAGE_SELECT, reg); |
8763 | else | | 8765 | else |
8764 | wm_gmii_mdic_writereg(self, phy, | | 8766 | wm_gmii_mdic_writereg(self, phy, |
8765 | GG82563_PHY_PAGE_SELECT, | | 8767 | BME1000_PHY_PAGE_SELECT, |
8766 | reg >> GG82563_PAGE_SHIFT); | | 8768 | reg >> GG82563_PAGE_SHIFT); |
8767 | } | | 8769 | } |
8768 | | | 8770 | |
8769 | rv = wm_gmii_mdic_readreg(self, phy, reg & MII_ADDRMASK); | | 8771 | rv = wm_gmii_mdic_readreg(self, phy, reg & MII_ADDRMASK); |
8770 | sc->phy.release(sc); | | 8772 | sc->phy.release(sc); |
8771 | return rv; | | 8773 | return rv; |
8772 | } | | 8774 | } |
8773 | | | 8775 | |
8774 | /* | | 8776 | /* |
8775 | * wm_gmii_bm_writereg: [mii interface function] | | 8777 | * wm_gmii_bm_writereg: [mii interface function] |
8776 | * | | 8778 | * |
8777 | * Write a PHY register on the kumeran. | | 8779 | * Write a PHY register on the kumeran. |
8778 | * This could be handled by the PHY layer if we didn't have to lock the | | 8780 | * This could be handled by the PHY layer if we didn't have to lock the |
| @@ -8785,27 +8787,27 @@ wm_gmii_bm_writereg(device_t self, int p | | | @@ -8785,27 +8787,27 @@ wm_gmii_bm_writereg(device_t self, int p |
8785 | | | 8787 | |
8786 | if (sc->phy.acquire(sc)) { | | 8788 | if (sc->phy.acquire(sc)) { |
8787 | aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n", | | 8789 | aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n", |
8788 | __func__); | | 8790 | __func__); |
8789 | return; | | 8791 | return; |
8790 | } | | 8792 | } |
8791 | | | 8793 | |
8792 | if (reg > BME1000_MAX_MULTI_PAGE_REG) { | | 8794 | if (reg > BME1000_MAX_MULTI_PAGE_REG) { |
8793 | if (phy == 1) | | 8795 | if (phy == 1) |
8794 | wm_gmii_mdic_writereg(self, phy, | | 8796 | wm_gmii_mdic_writereg(self, phy, |
8795 | MII_IGPHY_PAGE_SELECT, reg); | | 8797 | MII_IGPHY_PAGE_SELECT, reg); |
8796 | else | | 8798 | else |
8797 | wm_gmii_mdic_writereg(self, phy, | | 8799 | wm_gmii_mdic_writereg(self, phy, |
8798 | GG82563_PHY_PAGE_SELECT, | | 8800 | BME1000_PHY_PAGE_SELECT, |
8799 | reg >> GG82563_PAGE_SHIFT); | | 8801 | reg >> GG82563_PAGE_SHIFT); |
8800 | } | | 8802 | } |
8801 | | | 8803 | |
8802 | wm_gmii_mdic_writereg(self, phy, reg & MII_ADDRMASK, val); | | 8804 | wm_gmii_mdic_writereg(self, phy, reg & MII_ADDRMASK, val); |
8803 | sc->phy.release(sc); | | 8805 | sc->phy.release(sc); |
8804 | } | | 8806 | } |
8805 | | | 8807 | |
8806 | static void | | 8808 | static void |
8807 | wm_access_phy_wakeup_reg_bm(device_t self, int offset, int16_t *val, int rd) | | 8809 | wm_access_phy_wakeup_reg_bm(device_t self, int offset, int16_t *val, int rd) |
8808 | { | | 8810 | { |
8809 | struct wm_softc *sc = device_private(self); | | 8811 | struct wm_softc *sc = device_private(self); |
8810 | uint16_t regnum = BM_PHY_REG_NUM(offset); | | 8812 | uint16_t regnum = BM_PHY_REG_NUM(offset); |
8811 | uint16_t wuce; | | 8813 | uint16_t wuce; |