Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/dev/pci Pull up following revision(s) (requested by m...
details: https://anonhg.NetBSD.org/src/rev/43ebb42a45b8
branches: netbsd-6
changeset: 776806:43ebb42a45b8
user: snj <snj%NetBSD.org@localhost>
date: Thu Dec 04 06:04:07 2014 +0000
description:
Pull up following revision(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: revisions 1.271, 1.273-1.274, 1.277-1.278,
1.280, 1.282, 1.284-1.285, 1.287,
1.293-1.294, 1.297-1.298,
1.300-1.301, 1.305-1.307 via patch
sys/dev/pci/if_wmreg.h: revisions 1.57-1.62, 1.64-1.65 via patch
sys/dev/pci/if_wmvar.h: revisions 1.19, 1.21 via patch
- Acquire SW semaphore in wm_get_swsm_semaphore().
- Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Don't check SWSM_SMBI bit if WM_F_LOCK_SWSM isn't set. Fix a problem when
using vmware with e1000"e". With e1000e which is regarded as 82574L,
wm_gmii_init() fails with "could not acquire SWSM SMBI" message without
this change. This problem doesn't occur with real 82574L card.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
- It's not required to print "failed to detect NVM bank" message.
Only print while debugging. Same as {Free,Open}BSD.
- Add some new I218 devices.
- Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Sort definitions in if_wmreg.h
- move NVM related values to the bottom.
- sort in register's address' order.
- Simplify wm_read_mac_addr().
- Fix debug message.
- Add missing prototypes.
- Rename some functions for consistency and clarify.
- Rename some macros for consistency.
- Remove a duplicated error message.
- Fix typo in comment.
- Cleanup comments.
- KNF.
diffstat:
sys/dev/pci/if_wm.c | 906 ++++++++++++++++++++++++++++--------------------
sys/dev/pci/if_wmreg.h | 425 +++++++++++-----------
sys/dev/pci/if_wmvar.h | 39 +-
3 files changed, 756 insertions(+), 614 deletions(-)
diffs (truncated from 2426 to 300 lines):
diff -r e9ece839977e -r 43ebb42a45b8 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Thu Dec 04 05:54:51 2014 +0000
+++ b/sys/dev/pci/if_wm.c Thu Dec 04 06:04:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.227.2.13 2014/11/09 12:13:15 martin Exp $ */
+/* $NetBSD: if_wm.c,v 1.227.2.14 2014/12/04 06:04:07 snj Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.227.2.13 2014/11/09 12:13:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.227.2.14 2014/12/04 06:04:07 snj Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -276,7 +276,8 @@
void *sc_ih; /* interrupt cookie */
callout_t sc_tick_ch; /* tick callout */
- int sc_ee_addrbits; /* EEPROM address bits */
+ int sc_nvm_addrbits; /* NVM address bits */
+ unsigned int sc_nvm_wordsize; /* NVM word size */
int sc_ich8_flash_base;
int sc_ich8_flash_bank_size;
int sc_nvm_k1_enabled;
@@ -374,8 +375,6 @@
int sc_tbi_linkup; /* TBI link status */
int sc_tbi_anegticks; /* autonegotiation ticks */
int sc_tbi_ticks; /* tbi ticks */
- int sc_tbi_nrxcfg; /* count of ICR_RXCFG */
- int sc_tbi_lastnrxcfg; /* count of ICR_RXCFG (on last tick) */
int sc_mchash_type; /* multicast filter offset */
@@ -494,43 +493,78 @@
CSR_WRITE((sc), (sc)->sc_rdt_reg, (x)); \
} while (/*CONSTCOND*/0)
-static void wm_start(struct ifnet *);
-static void wm_nq_start(struct ifnet *);
-static void wm_watchdog(struct ifnet *);
-static int wm_ifflags_cb(struct ethercom *);
-static int wm_ioctl(struct ifnet *, u_long, void *);
-static int wm_init(struct ifnet *);
-static void wm_stop(struct ifnet *, int);
+/*
+ * Register read/write functions.
+ * Other than CSR_{READ|WRITE}().
+ */
+#if 0
+static inline uint32_t wm_io_read(struct wm_softc *, int);
+#endif
+static inline void wm_io_write(struct wm_softc *, int, uint32_t);
+static inline void wm_82575_write_8bit_ctlr_reg(struct wm_softc *, uint32_t,
+ uint32_t, uint32_t);
+static inline void wm_set_dma_addr(volatile wiseman_addr_t *, bus_addr_t);
+/*
+ * Device driver interface functions and commonly used functions.
+ * match, attach, detach, init, start, stop, ioctl, watchdog and so on.
+ */
+static const struct wm_product *wm_lookup(const struct pci_attach_args *);
+static int wm_match(device_t, cfdata_t, void *);
+static void wm_attach(device_t, device_t, void *);
+static int wm_detach(device_t, int);
static bool wm_suspend(device_t, const pmf_qual_t *);
static bool wm_resume(device_t, const pmf_qual_t *);
-
+static void wm_watchdog(struct ifnet *);
+static void wm_tick(void *);
+static int wm_ifflags_cb(struct ethercom *);
+static int wm_ioctl(struct ifnet *, u_long, void *);
+/* MAC address related */
+static uint16_t wm_check_alt_mac_addr(struct wm_softc *);
+static int wm_read_mac_addr(struct wm_softc *, uint8_t *);
+static void wm_set_ral(struct wm_softc *, const uint8_t *, int);
+static uint32_t wm_mchash(struct wm_softc *, const uint8_t *);
+static void wm_set_filter(struct wm_softc *);
+/* Reset and init related */
+static void wm_set_vlan(struct wm_softc *);
+static void wm_set_pcie_completion_timeout(struct wm_softc *);
+static void wm_get_auto_rd_done(struct wm_softc *);
+static void wm_lan_init_done(struct wm_softc *);
+static void wm_get_cfg_done(struct wm_softc *);
static void wm_reset(struct wm_softc *);
-static void wm_rxdrain(struct wm_softc *);
static int wm_add_rxbuf(struct wm_softc *, int);
-static int wm_read_eeprom(struct wm_softc *, int, int, u_int16_t *);
-static int wm_read_eeprom_eerd(struct wm_softc *, int, int, u_int16_t *);
-static int wm_validate_eeprom_checksum(struct wm_softc *);
-static int wm_check_alt_mac_addr(struct wm_softc *);
-static int wm_read_mac_addr(struct wm_softc *, uint8_t *);
-static void wm_tick(void *);
-
-static void wm_set_filter(struct wm_softc *);
-static void wm_set_vlan(struct wm_softc *);
-
-static int wm_intr(void *);
+static void wm_rxdrain(struct wm_softc *);
+static int wm_init(struct ifnet *);
+static void wm_stop(struct ifnet *, int);
+static int wm_tx_offload(struct wm_softc *, struct wm_txsoft *,
+ uint32_t *, uint8_t *);
+static void wm_dump_mbuf_chain(struct wm_softc *, struct mbuf *);
+static void wm_82547_txfifo_stall(void *);
+static int wm_82547_txfifo_bugchk(struct wm_softc *, struct mbuf *);
+/* Start */
+static void wm_start(struct ifnet *);
+static int wm_nq_tx_offload(struct wm_softc *, struct wm_txsoft *,
+ uint32_t *, uint32_t *, bool *);
+static void wm_nq_start(struct ifnet *);
+/* Interrupt */
static void wm_txintr(struct wm_softc *);
static void wm_rxintr(struct wm_softc *);
+static void wm_linkintr_gmii(struct wm_softc *, uint32_t);
+static void wm_linkintr_tbi(struct wm_softc *, uint32_t);
static void wm_linkintr(struct wm_softc *, uint32_t);
-
-static void wm_tbi_mediainit(struct wm_softc *);
-static int wm_tbi_mediachange(struct ifnet *);
-static void wm_tbi_mediastatus(struct ifnet *, struct ifmediareq *);
-
-static void wm_tbi_set_linkled(struct wm_softc *);
-static void wm_tbi_check_link(struct wm_softc *);
-
+static int wm_intr(void *);
+
+/*
+ * Media related.
+ * GMII, SGMII, TBI (and SERDES)
+ */
+/* GMII related */
static void wm_gmii_reset(struct wm_softc *);
-
+static int wm_get_phy_id_82575(struct wm_softc *);
+static void wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
+static void wm_gmii_mediastatus(struct ifnet *, struct ifmediareq *);
+static int wm_gmii_mediachange(struct ifnet *);
+static void wm_i82543_mii_sendbits(struct wm_softc *, uint32_t, int);
+static uint32_t wm_i82543_mii_recvbits(struct wm_softc *);
static int wm_gmii_i82543_readreg(device_t, int, int);
static void wm_gmii_i82543_writereg(device_t, int, int, int);
static int wm_gmii_i82544_readreg(device_t, int, int);
@@ -539,35 +573,65 @@
static void wm_gmii_i80003_writereg(device_t, int, int, int);
static int wm_gmii_bm_readreg(device_t, int, int);
static void wm_gmii_bm_writereg(device_t, int, int, int);
+static void wm_access_phy_wakeup_reg_bm(device_t, int, int16_t *, int);
static int wm_gmii_hv_readreg(device_t, int, int);
static void wm_gmii_hv_writereg(device_t, int, int, int);
static int wm_gmii_82580_readreg(device_t, int, int);
static void wm_gmii_82580_writereg(device_t, int, int, int);
+static void wm_gmii_statchg(device_t);
+static int wm_kmrn_readreg(struct wm_softc *, int);
+static void wm_kmrn_writereg(struct wm_softc *, int, int);
+/* SGMII */
static bool wm_sgmii_uses_mdio(struct wm_softc *);
static int wm_sgmii_readreg(device_t, int, int);
static void wm_sgmii_writereg(device_t, int, int, int);
-
-static void wm_gmii_statchg(device_t);
-
-static int wm_get_phy_id_82575(struct wm_softc *);
-static void wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
-static int wm_gmii_mediachange(struct ifnet *);
-static void wm_gmii_mediastatus(struct ifnet *, struct ifmediareq *);
-
-static int wm_kmrn_readreg(struct wm_softc *, int);
-static void wm_kmrn_writereg(struct wm_softc *, int, int);
-
-static void wm_set_spiaddrbits(struct wm_softc *);
-static int wm_match(device_t, cfdata_t, void *);
-static void wm_attach(device_t, device_t, void *);
-static int wm_detach(device_t, int);
-static int wm_is_onboard_nvm_eeprom(struct wm_softc *);
-static void wm_get_auto_rd_done(struct wm_softc *);
-static void wm_lan_init_done(struct wm_softc *);
-static void wm_get_cfg_done(struct wm_softc *);
+/* TBI related */
+static int wm_check_for_link(struct wm_softc *);
+static void wm_tbi_mediainit(struct wm_softc *);
+static void wm_tbi_mediastatus(struct ifnet *, struct ifmediareq *);
+static int wm_tbi_mediachange(struct ifnet *);
+static void wm_tbi_set_linkled(struct wm_softc *);
+static void wm_tbi_check_link(struct wm_softc *);
+
+/*
+ * NVM related.
+ * Microwire, SPI (w/wo EERD) and Flash.
+ */
+/* Misc functions */
+static void wm_eeprom_sendbits(struct wm_softc *, uint32_t, int);
+static void wm_eeprom_recvbits(struct wm_softc *, uint32_t *, int);
+static int wm_nvm_set_addrbits_size_eecd(struct wm_softc *);
+/* Microwire */
+static int wm_nvm_read_uwire(struct wm_softc *, int, int, uint16_t *);
+/* SPI */
+static int wm_nvm_ready_spi(struct wm_softc *);
+static int wm_nvm_read_spi(struct wm_softc *, int, int, uint16_t *);
+/* Using with EERD */
+static int wm_poll_eerd_eewr_done(struct wm_softc *, int);
+static int wm_nvm_read_eerd(struct wm_softc *, int, int, uint16_t *);
+/* Flash */
+static int wm_nvm_valid_bank_detect_ich8lan(struct wm_softc *,
+ unsigned int *);
+static int32_t wm_ich8_cycle_init(struct wm_softc *);
+static int32_t wm_ich8_flash_cycle(struct wm_softc *, uint32_t);
+static int32_t wm_read_ich8_data(struct wm_softc *, uint32_t, uint32_t,
+ uint16_t *);
+static int32_t wm_read_ich8_byte(struct wm_softc *, uint32_t, uint8_t *);
+static int32_t wm_read_ich8_word(struct wm_softc *, uint32_t, uint16_t *);
+static int wm_nvm_read_ich8(struct wm_softc *, int, int, uint16_t *);
+/* Lock, detecting NVM type, validate checksum and read */
+static int wm_nvm_acquire(struct wm_softc *);
+static void wm_nvm_release(struct wm_softc *);
+static int wm_nvm_is_onboard_eeprom(struct wm_softc *);
+static int wm_nvm_validate_checksum(struct wm_softc *);
+static int wm_nvm_read(struct wm_softc *, int, int, uint16_t *);
+
+/*
+ * Hardware semaphores.
+ * Very complexed...
+ */
static int wm_get_swsm_semaphore(struct wm_softc *);
static void wm_put_swsm_semaphore(struct wm_softc *);
-static int wm_poll_eerd_eewr_done(struct wm_softc *, int);
static int wm_get_swfw_semaphore(struct wm_softc *, uint16_t);
static void wm_put_swfw_semaphore(struct wm_softc *, uint16_t);
static int wm_get_swfwhw_semaphore(struct wm_softc *);
@@ -575,15 +639,10 @@
static int wm_get_hw_semaphore_82573(struct wm_softc *);
static void wm_put_hw_semaphore_82573(struct wm_softc *);
-static int wm_read_eeprom_ich8(struct wm_softc *, int, int, uint16_t *);
-static int32_t wm_ich8_cycle_init(struct wm_softc *);
-static int32_t wm_ich8_flash_cycle(struct wm_softc *, uint32_t);
-static int32_t wm_read_ich8_data(struct wm_softc *, uint32_t,
- uint32_t, uint16_t *);
-static int32_t wm_read_ich8_byte(struct wm_softc *, uint32_t, uint8_t *);
-static int32_t wm_read_ich8_word(struct wm_softc *, uint32_t, uint16_t *);
-static void wm_82547_txfifo_stall(void *);
-static void wm_gate_hw_phy_config_ich8lan(struct wm_softc *, int);
+/*
+ * Management mode and power management related subroutines.
+ * BMC, AMT, suspend/resume and EEE.
+ */
static int wm_check_mng_mode(struct wm_softc *);
static int wm_check_mng_mode_ich8lan(struct wm_softc *);
static int wm_check_mng_mode_82574(struct wm_softc *);
@@ -591,29 +650,32 @@
static int wm_enable_mng_pass_thru(struct wm_softc *);
static int wm_check_reset_block(struct wm_softc *);
static void wm_get_hw_control(struct wm_softc *);
-static int wm_check_for_link(struct wm_softc *);
+static void wm_release_hw_control(struct wm_softc *);
+static void wm_gate_hw_phy_config_ich8lan(struct wm_softc *, int);
+static void wm_smbustopci(struct wm_softc *);
+static void wm_init_manageability(struct wm_softc *);
+static void wm_release_manageability(struct wm_softc *);
+static void wm_get_wakeup(struct wm_softc *);
+#ifdef WM_WOL
+static void wm_enable_phy_wakeup(struct wm_softc *);
+static void wm_igp3_phy_powerdown_workaround_ich8lan(struct wm_softc *);
+static void wm_enable_wakeup(struct wm_softc *);
+#endif
+/* EEE */
+static void wm_set_eee_i350(struct wm_softc *);
+
+/*
+ * Workarounds (mainly PHY related).
+ * Basically, PHY's workarounds are in the PHY drivers.
+ */
static void wm_kmrn_lock_loss_workaround_ich8lan(struct wm_softc *);
static void wm_gig_downshift_workaround_ich8lan(struct wm_softc *);
-#ifdef WM_WOL
-static void wm_igp3_phy_powerdown_workaround_ich8lan(struct wm_softc *);
-#endif
static void wm_hv_phy_workaround_ich8lan(struct wm_softc *);
static void wm_lv_phy_workaround_ich8lan(struct wm_softc *);
static void wm_k1_gig_workaround_hv(struct wm_softc *, int);
static void wm_set_mdio_slow_mode_hv(struct wm_softc *);
static void wm_configure_k1_ich8lan(struct wm_softc *, int);
-static void wm_smbustopci(struct wm_softc *);
-static void wm_set_pcie_completion_timeout(struct wm_softc *);
static void wm_reset_init_script_82575(struct wm_softc *);
-static void wm_release_manageability(struct wm_softc *);
-static void wm_release_hw_control(struct wm_softc *);
-static void wm_get_wakeup(struct wm_softc *);
-#ifdef WM_WOL
-static void wm_enable_phy_wakeup(struct wm_softc *);
-static void wm_enable_wakeup(struct wm_softc *);
-#endif
-static void wm_init_manageability(struct wm_softc *);
-static void wm_set_eee_i350(struct wm_softc *);
CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
@@ -1003,12 +1065,6 @@
Home |
Main Index |
Thread Index |
Old Index