Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci No functional change:



details:   https://anonhg.NetBSD.org/src/rev/1532f298895d
branches:  trunk
changeset: 797592:1532f298895d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jul 23 09:44:52 2014 +0000

description:
No functional change:
- Add missing prototypes.
- Rename functions for consistency and clarify.
- KNF.

diffstat:

 sys/dev/pci/if_wm.c |  388 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 236 insertions(+), 152 deletions(-)

diffs (truncated from 772 to 300 lines):

diff -r eeca32977553 -r 1532f298895d sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Wed Jul 23 08:52:32 2014 +0000
+++ b/sys/dev/pci/if_wm.c       Wed Jul 23 09:44:52 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.279 2014/07/22 04:20:39 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.280 2014/07/23 09:44:52 msaitoh 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.279 2014/07/22 04:20:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.280 2014/07/23 09:44:52 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -512,47 +512,83 @@
        CSR_WRITE((sc), (sc)->sc_rdt_reg, (x));                         \
 } while (/*CONSTCOND*/0)
 
-static void    wm_start(struct ifnet *);
-static void    wm_start_locked(struct ifnet *);
-static void    wm_nq_start(struct ifnet *);
-static void    wm_nq_start_locked(struct ifnet *);
+/*
+ * 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 int     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 int     wm_add_rxbuf(struct wm_softc *, int);
+static void    wm_rxdrain(struct wm_softc *);
 static int     wm_init(struct ifnet *);
 static int     wm_init_locked(struct ifnet *);
 static void    wm_stop(struct ifnet *, int);
 static void    wm_stop_locked(struct ifnet *, int);
-static bool    wm_suspend(device_t, const pmf_qual_t *);
-static bool    wm_resume(device_t, const pmf_qual_t *);
-
-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 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 void    wm_start_locked(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 *);
+static void    wm_nq_start_locked(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);
@@ -561,35 +597,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(struct ifnet *);
+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(struct ifnet *);
-
-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);
-
+/* 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.
+ */
+/* Both spi and uwire */
+static void    wm_eeprom_sendbits(struct wm_softc *, uint32_t, int);
+static void    wm_eeprom_recvbits(struct wm_softc *, uint32_t *, int);
+/* Microwire */
+static int     wm_nvm_read_uwire(struct wm_softc *, int, int, uint16_t *);
+/* SPI */
 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 *);
+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 *);
@@ -597,15 +663,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 *);
@@ -613,29 +674,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);
@@ -1095,6 +1159,12 @@
 static char wm_txseg_evcnt_names[WM_NTXSEGS][sizeof("txsegXXX")];
 #endif /* WM_EVENT_COUNTERS */
 
+
+/*
+ * Register read/write functions.
+ * Other than CSR_{READ|WRITE}().
+ */
+
 #if 0 /* Not currently used */
 static inline uint32_t
 wm_io_read(struct wm_softc *sc, int reg)
@@ -1130,7 +1200,8 @@
                        break;



Home | Main Index | Thread Index | Old Index