Module Name: src
Committed By: snj
Date: Thu Jul 26 20:40:39 UTC 2018
Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #928):
sys/dev/pci/if_wm.c: 1.573-1.576, 1.579 and 1.582 via patch
wm(4):
- Count timeout correctly. This change reduce timeout value for 80003
as expected. Reported by mouse@.
- Print "device timeout (lost interrupt)" when all descriptors in a
queue are free.
- Rename txq_watchdog to txq_sending to make the meaning clear.
- KNF. No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.508.4.20 -r1.508.4.21 src/sys/dev/pci/if_wm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.20 src/sys/dev/pci/if_wm.c:1.508.4.21
--- src/sys/dev/pci/if_wm.c:1.508.4.20 Thu Jun 7 17:42:25 2018
+++ src/sys/dev/pci/if_wm.c Thu Jul 26 20:40:39 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.508.4.20 2018/06/07 17:42:25 martin Exp $ */
+/* $NetBSD: if_wm.c,v 1.508.4.21 2018/07/26 20:40:39 snj Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.20 2018/06/07 17:42:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.21 2018/07/26 20:40:39 snj Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -193,7 +193,7 @@ static int wm_watchdog_timeout = WM_WATC
/*
* Transmit descriptor list size. Due to errata, we can only have
* 256 hardware descriptors in the ring on < 82544, but we use 4096
- * on >= 82544. We tell the upper layers that they can queue a lot
+ * on >= 82544. We tell the upper layers that they can queue a lot
* of packets, and we go ahead and manage up to 64 (16 for the i82547)
* of them at a time.
*
@@ -247,13 +247,13 @@ static int wm_watchdog_timeout = WM_WATC
typedef union txdescs {
wiseman_txdesc_t sctxu_txdescs[WM_NTXDESC_82544];
- nq_txdesc_t sctxu_nq_txdescs[WM_NTXDESC_82544];
+ nq_txdesc_t sctxu_nq_txdescs[WM_NTXDESC_82544];
} txdescs_t;
typedef union rxdescs {
wiseman_rxdesc_t sctxu_rxdescs[WM_NRXDESC];
- ext_rxdesc_t sctxu_ext_rxdescs[WM_NRXDESC]; /* 82574 only */
- nq_rxdesc_t sctxu_nq_rxdescs[WM_NRXDESC]; /* 82575 and newer */
+ ext_rxdesc_t sctxu_ext_rxdescs[WM_NRXDESC]; /* 82574 only */
+ nq_rxdesc_t sctxu_nq_rxdescs[WM_NRXDESC]; /* 82575 and newer */
} rxdescs_t;
#define WM_CDTXOFF(txq, x) ((txq)->txq_descsize * (x))
@@ -271,9 +271,9 @@ struct wm_txsoft {
};
/*
- * Software state for receive buffers. Each descriptor gets a
- * 2k (MCLBYTES) buffer and a DMA map. For packets which fill
- * more than one buffer, we chain them together.
+ * Software state for receive buffers. Each descriptor gets a 2k (MCLBYTES)
+ * buffer and a DMA map. For packets which fill more than one buffer, we chain
+ * them together.
*/
struct wm_rxsoft {
struct mbuf *rxs_mbuf; /* head of our mbuf chain */
@@ -301,14 +301,14 @@ struct wm_softc;
struct evcnt qname##_ev_##evname;
#define WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, evtype) \
- do{ \
+ do { \
snprintf((q)->qname##_##evname##_evcnt_name, \
sizeof((q)->qname##_##evname##_evcnt_name), \
"%s%02d%s", #qname, (qnum), #evname); \
evcnt_attach_dynamic(&(q)->qname##_ev_##evname, \
(evtype), NULL, (xname), \
(q)->qname##_##evname##_evcnt_name); \
- }while(0)
+ } while (0)
#define WM_Q_MISC_EVCNT_ATTACH(qname, evname, q, qnum, xname) \
WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, EVCNT_TYPE_MISC)
@@ -333,7 +333,7 @@ struct wm_txqueue {
int txq_ndesc; /* must be a power of two */
size_t txq_descsize; /* a tx descriptor size */
txdescs_t *txq_descs_u;
- bus_dmamap_t txq_desc_dmamap; /* control data DMA map */
+ bus_dmamap_t txq_desc_dmamap; /* control data DMA map */
bus_dma_segment_t txq_desc_seg; /* control data segment */
int txq_desc_rseg; /* real number of control segment */
#define txq_desc_dma txq_desc_dmamap->dm_segs[0].ds_addr
@@ -370,7 +370,7 @@ struct wm_txqueue {
bool txq_stopping;
- bool txq_watchdog;
+ bool txq_sending;
time_t txq_lastsent;
uint32_t txq_packets; /* for AIM */
@@ -384,7 +384,7 @@ struct wm_txqueue {
/* XXX not used? */
WM_Q_EVCNT_DEFINE(txq, txipsum) /* IP checksums comp. out-bound */
- WM_Q_EVCNT_DEFINE(txq,txtusum) /* TCP/UDP cksums comp. out-bound */
+ WM_Q_EVCNT_DEFINE(txq, txtusum) /* TCP/UDP cksums comp. out-bound */
WM_Q_EVCNT_DEFINE(txq, txtusum6) /* TCP/UDP v6 cksums comp. out-bound */
WM_Q_EVCNT_DEFINE(txq, txtso) /* TCP seg offload out-bound (IPv4) */
WM_Q_EVCNT_DEFINE(txq, txtso6) /* TCP seg offload out-bound (IPv6) */
@@ -442,7 +442,7 @@ struct wm_rxqueue {
};
struct wm_queue {
- int wmq_id; /* index of transmit and receive queues */
+ int wmq_id; /* index of TX/RX queues */
int wmq_intr_idx; /* index of MSI-X tables */
uint32_t wmq_itr; /* interrupt interval per queue. */
@@ -547,7 +547,7 @@ struct wm_softc {
/* Event counters. */
struct evcnt sc_ev_linkintr; /* Link interrupts */
- /* WM_T_82542_2_1 only */
+ /* WM_T_82542_2_1 only */
struct evcnt sc_ev_tx_xoff; /* Tx PAUSE(!0) frames */
struct evcnt sc_ev_tx_xon; /* Tx PAUSE(0) frames */
struct evcnt sc_ev_rx_xoff; /* Rx PAUSE(!0) frames */
@@ -669,7 +669,7 @@ static inline uint32_t wm_io_read(struct
#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);
+ uint32_t, uint32_t);
static inline void wm_set_dma_addr(volatile wiseman_addr_t *, bus_addr_t);
/*
@@ -690,8 +690,10 @@ 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_watchdog_txq(struct ifnet *, struct wm_txqueue *, uint16_t *);
-static void wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *, uint16_t *);
+static void wm_watchdog_txq(struct ifnet *, struct wm_txqueue *,
+ uint16_t *);
+static void wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *,
+ uint16_t *);
static void wm_tick(void *);
static int wm_ifflags_cb(struct ethercom *);
static int wm_ioctl(struct ifnet *, u_long, void *);
@@ -765,14 +767,16 @@ static void wm_start(struct ifnet *);
static void wm_start_locked(struct ifnet *);
static int wm_transmit(struct ifnet *, struct mbuf *);
static void wm_transmit_locked(struct ifnet *, struct wm_txqueue *);
-static void wm_send_common_locked(struct ifnet *, struct wm_txqueue *, bool);
+static void wm_send_common_locked(struct ifnet *, struct wm_txqueue *,
+ bool);
static int wm_nq_tx_offload(struct wm_softc *, struct wm_txqueue *,
struct wm_txsoft *, uint32_t *, uint32_t *, bool *);
static void wm_nq_start(struct ifnet *);
static void wm_nq_start_locked(struct ifnet *);
static int wm_nq_transmit(struct ifnet *, struct mbuf *);
static void wm_nq_transmit_locked(struct ifnet *, struct wm_txqueue *);
-static void wm_nq_send_common_locked(struct ifnet *, struct wm_txqueue *, bool);
+static void wm_nq_send_common_locked(struct ifnet *, struct wm_txqueue *,
+ bool);
static void wm_deferred_start_locked(struct wm_txqueue *);
static void wm_handle_queue(void *);
/* Interrupt */
@@ -797,7 +801,7 @@ static int wm_linkintr_msix(void *);
static void wm_tbi_serdes_set_linkled(struct wm_softc *);
/* GMII related */
static void wm_gmii_reset(struct wm_softc *);
-static void wm_gmii_setup_phytype(struct wm_softc *sc, uint32_t, uint16_t);
+static void wm_gmii_setup_phytype(struct wm_softc *, uint32_t, uint16_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 *);
@@ -874,7 +878,7 @@ static int wm_nvm_valid_bank_detect_ich8
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,
- uint32_t *);
+ uint32_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 int32_t wm_read_ich8_dword(struct wm_softc *, uint32_t, uint32_t *);
@@ -1642,13 +1646,13 @@ wm_init_rxdesc(struct wm_rxqueue *rxq, i
if (sc->sc_type == WM_T_82574) {
ext_rxdesc_t *rxd = &rxq->rxq_ext_descs[start];
rxd->erx_data.erxd_addr =
- htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
+ htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
rxd->erx_data.erxd_dd = 0;
} else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
nq_rxdesc_t *rxd = &rxq->rxq_nq_descs[start];
rxd->nqrx_data.nrxd_paddr =
- htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
+ htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
/* Currently, split header is not supported. */
rxd->nqrx_data.nrxd_haddr = 0;
} else {
@@ -1806,7 +1810,7 @@ wm_attach(device_t parent, device_t self
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
memh_valid = (pci_mapreg_map(pa, WM_PCI_MMBA,
- memtype, 0, &memt, &memh, NULL, &memsize) == 0);
+ memtype, 0, &memt, &memh, NULL, &memsize) == 0);
break;
default:
memh_valid = 0;
@@ -1874,8 +1878,8 @@ wm_attach(device_t parent, device_t self
pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg);
/* power up chip */
- if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self,
- NULL)) && error != EOPNOTSUPP) {
+ if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, NULL))
+ && error != EOPNOTSUPP) {
aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error);
return;
}
@@ -1932,7 +1936,7 @@ alloc_retry:
counts[PCI_INTR_TYPE_INTX] = 1;
goto alloc_retry;
}
- } else if (pci_intr_type(pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_MSI) {
+ } else if (pci_intr_type(pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_MSI) {
wm_adjust_qnum(sc, 0); /* must not use multiqueue */
error = wm_setup_legacy(sc);
if (error) {
@@ -1958,7 +1962,7 @@ alloc_retry:
* Check the function ID (unit number of the chip).
*/
if ((sc->sc_type == WM_T_82546) || (sc->sc_type == WM_T_82546_3)
- || (sc->sc_type == WM_T_82571) || (sc->sc_type == WM_T_80003)
+ || (sc->sc_type == WM_T_82571) || (sc->sc_type == WM_T_80003)
|| (sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
|| (sc->sc_type == WM_T_82580)
|| (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
@@ -1985,7 +1989,7 @@ alloc_retry:
if (sc->sc_type == WM_T_82547) {
callout_init(&sc->sc_txfifo_ch, CALLOUT_FLAGS);
callout_setfunc(&sc->sc_txfifo_ch,
- wm_82547_txfifo_stall, sc);
+ wm_82547_txfifo_stall, sc);
aprint_verbose_dev(sc->sc_dev,
"using 82547 Tx FIFO stall work-around\n");
}
@@ -2040,7 +2044,7 @@ alloc_retry:
512 << bytecnt, 512 << maxb);
pcix_cmd = (pcix_cmd &
~PCIX_CMD_BYTECNT_MASK) |
- (maxb << PCIX_CMD_BYTECNT_SHIFT);
+ (maxb << PCIX_CMD_BYTECNT_SHIFT);
pci_conf_write(pa->pa_pc, pa->pa_tag,
sc->sc_pcixe_capoff + PCIX_CMD,
pcix_cmd);
@@ -2199,7 +2203,7 @@ alloc_retry:
/* SPI */
sc->sc_flags |= WM_F_EEPROM_SPI;
wm_nvm_set_addrbits_size_eecd(sc);
- if((sc->sc_type == WM_T_80003)
+ if ((sc->sc_type == WM_T_80003)
|| (sc->sc_nvm_wordsize < (1 << 15))) {
sc->nvm.read = wm_nvm_read_eerd;
/* Don't use WM_F_LOCK_EECD because we use EERD */
@@ -2252,8 +2256,8 @@ alloc_retry:
sc->sc_flashh = sc->sc_sh;
sc->sc_ich8_flash_base = 0;
sc->sc_nvm_wordsize =
- (((CSR_READ(sc, WMREG_STRAP) >> 1) & 0x1F) + 1)
- * NVM_SIZE_MULTIPLIER;
+ (((CSR_READ(sc, WMREG_STRAP) >> 1) & 0x1F) + 1)
+ * NVM_SIZE_MULTIPLIER;
/* It is size in bytes, we want words */
sc->sc_nvm_wordsize /= 2;
/* assume 2 banks */
@@ -2828,7 +2832,7 @@ alloc_retry:
ether_set_ifflags_cb(&sc->sc_ethercom, wm_ifflags_cb);
if_register(ifp);
rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET,
- RND_FLAG_DEFAULT);
+ RND_FLAG_DEFAULT);
#ifdef WM_EVENT_COUNTERS
/* Attach event counters. */
@@ -3006,7 +3010,7 @@ wm_watchdog_txq(struct ifnet *ifp, struc
{
mutex_enter(txq->txq_lock);
- if (txq->txq_watchdog &&
+ if (txq->txq_sending &&
time_uptime - txq->txq_lastsent > wm_watchdog_timeout) {
wm_watchdog_txq_locked(ifp, txq, hang);
}
@@ -3014,7 +3018,8 @@ wm_watchdog_txq(struct ifnet *ifp, struc
}
static void
-wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq, uint16_t *hang)
+wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq,
+ uint16_t *hang)
{
struct wm_softc *sc = ifp->if_softc;
struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
@@ -3026,10 +3031,14 @@ wm_watchdog_txq_locked(struct ifnet *ifp
* before we report an error.
*/
wm_txeof(txq, UINT_MAX);
- if (txq->txq_watchdog)
+
+ if (txq->txq_sending)
*hang |= __BIT(wmq->wmq_id);
- if (txq->txq_free != WM_NTXDESC(txq)) {
+ if (txq->txq_free == WM_NTXDESC(txq)) {
+ log(LOG_ERR, "%s: device timeout (lost interrupt)\n",
+ device_xname(sc->sc_dev));
+ } else {
#ifdef WM_DEBUG
int i, j;
struct wm_txsoft *txs;
@@ -3040,13 +3049,12 @@ wm_watchdog_txq_locked(struct ifnet *ifp
txq->txq_next);
ifp->if_oerrors++;
#ifdef WM_DEBUG
- for (i = txq->txq_sdirty; i != txq->txq_snext ;
+ for (i = txq->txq_sdirty; i != txq->txq_snext;
i = WM_NEXTTXS(txq, i)) {
txs = &txq->txq_soft[i];
printf("txs %d tx %d -> %d\n",
i, txs->txs_firstdesc, txs->txs_lastdesc);
- for (j = txs->txs_firstdesc; ;
- j = WM_NEXTTX(txq, j)) {
+ for (j = txs->txs_firstdesc; ; j = WM_NEXTTX(txq, j)) {
if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
printf("\tdesc %d: 0x%" PRIx64 "\n", j,
txq->txq_nq_descs[j].nqtx_data.nqtxd_addr);
@@ -4324,7 +4332,7 @@ wm_flush_desc_rings(struct wm_softc *sc)
nexttx = txq->txq_next;
txd = &txq->txq_descs[nexttx];
wm_set_dma_addr(&txd->wtx_addr, WM_CDTXADDR(txq, nexttx));
- txd->wtx_cmdlen = htole32(WTX_CMD_IFCS| 512);
+ txd->wtx_cmdlen = htole32(WTX_CMD_IFCS | 512);
txd->wtx_fields.wtxu_status = 0;
txd->wtx_fields.wtxu_options = 0;
txd->wtx_fields.wtxu_vlan = 0;
@@ -4404,7 +4412,7 @@ wm_reset(struct wm_softc *sc)
txq->txq_fifo_head = 0;
txq->txq_fifo_addr = sc->sc_pba << PBA_ADDR_SHIFT;
txq->txq_fifo_size =
- (PBA_40K - sc->sc_pba) << PBA_BYTE_SHIFT;
+ (PBA_40K - sc->sc_pba) << PBA_BYTE_SHIFT;
txq->txq_fifo_stall = 0;
}
break;
@@ -4542,12 +4550,12 @@ wm_reset(struct wm_softc *sc)
/*
* On some chipsets, a reset through a memory-mapped write
* cycle can cause the chip to reset before completing the
- * write cycle. This causes major headache that can be
- * avoided by issuing the reset via indirect register writes
- * through I/O space.
+ * write cycle. This causes major headache that can be avoided
+ * by issuing the reset via indirect register writes through
+ * I/O space.
*
* So, if we successfully mapped the I/O BAR at attach time,
- * use that. Otherwise, try our luck with a memory-mapped
+ * use that. Otherwise, try our luck with a memory-mapped
* reset.
*/
if (sc->sc_flags & WM_F_IOH_VALID)
@@ -4839,8 +4847,7 @@ wm_add_rxbuf(struct wm_rxqueue *rxq, int
if (error) {
/* XXX XXX XXX */
aprint_error_dev(sc->sc_dev,
- "unable to load rx DMA map %d, error = %d\n",
- idx, error);
+ "unable to load rx DMA map %d, error = %d\n", idx, error);
panic("wm_add_rxbuf");
}
@@ -4897,7 +4904,7 @@ wm_init_rss(struct wm_softc *sc)
int qid, reta_ent;
qid = i % sc->sc_nqueues;
- switch(sc->sc_type) {
+ switch (sc->sc_type) {
case WM_T_82574:
reta_ent = __SHIFTIN(qid,
RETA_ENT_QINDEX_MASK_82574);
@@ -4956,7 +4963,7 @@ wm_adjust_qnum(struct wm_softc *sc, int
return;
}
- switch(sc->sc_type) {
+ switch (sc->sc_type) {
case WM_T_82572:
hw_ntxqueues = 2;
hw_nrxqueues = 2;
@@ -5010,11 +5017,10 @@ wm_adjust_qnum(struct wm_softc *sc, int
* As queues more than MSI-X vectors cannot improve scaling, we limit
* the number of queues used actually.
*/
- if (nvectors < hw_nqueues + 1) {
+ if (nvectors < hw_nqueues + 1)
sc->sc_nqueues = nvectors - 1;
- } else {
+ else
sc->sc_nqueues = hw_nqueues;
- }
/*
* As queues more then cpus cannot improve scaling, we limit
@@ -5190,7 +5196,7 @@ wm_setup_msix(struct wm_softc *sc)
snprintf(intr_xname, sizeof(intr_xname), "%sLINK",
device_xname(sc->sc_dev));
vih = pci_intr_establish_xname(pc, sc->sc_intrs[intr_idx],
- IPL_NET, wm_linkintr_msix, sc, intr_xname);
+ IPL_NET, wm_linkintr_msix, sc, intr_xname);
if (vih == NULL) {
aprint_error_dev(sc->sc_dev,
"unable to establish MSI-X(for LINK)%s%s\n",
@@ -5230,7 +5236,7 @@ wm_unset_stopping_flags(struct wm_softc
/*
* must unset stopping flags in ascending order.
*/
- for(i = 0; i < sc->sc_nqueues; i++) {
+ for (i = 0; i < sc->sc_nqueues; i++) {
struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
struct wm_rxqueue *rxq = &sc->sc_queue[i].wmq_rxq;
@@ -5258,7 +5264,7 @@ wm_set_stopping_flags(struct wm_softc *s
/*
* must set stopping flags in ascending order.
*/
- for(i = 0; i < sc->sc_nqueues; i++) {
+ for (i = 0; i < sc->sc_nqueues; i++) {
struct wm_rxqueue *rxq = &sc->sc_queue[i].wmq_rxq;
struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
@@ -5301,7 +5307,7 @@ wm_itrs_writereg(struct wm_softc *sc, st
* the multi queue function with MSI-X.
*/
CSR_WRITE(sc, WMREG_EITR_82574(wmq->wmq_intr_idx),
- wmq->wmq_itr & EITR_ITR_INT_MASK_82574);
+ wmq->wmq_itr & EITR_ITR_INT_MASK_82574);
} else {
KASSERT(wmq->wmq_id == 0);
CSR_WRITE(sc, WMREG_ITR, wmq->wmq_itr);
@@ -5822,12 +5828,12 @@ wm_init_locked(struct ifnet *ifp)
wm_init_manageability(sc);
/*
- * Set up the receive control register; we actually program
- * the register when we set the receive filter. Use multicast
- * address offset type 0.
+ * Set up the receive control register; we actually program the
+ * register when we set the receive filter. Use multicast address
+ * offset type 0.
*
- * Only the i82544 has the ability to strip the incoming
- * CRC, so we don't enable that feature.
+ * Only the i82544 has the ability to strip the incoming CRC, so we
+ * don't enable that feature.
*/
sc->sc_mchash_type = 0;
sc->sc_rctl = RCTL_EN | RCTL_LBM_NONE | RCTL_RDMTS_1_2 | RCTL_DPF
@@ -6007,7 +6013,7 @@ wm_stop_locked(struct ifnet *ifp, int di
struct wm_queue *wmq = &sc->sc_queue[qidx];
struct wm_txqueue *txq = &wmq->wmq_txq;
mutex_enter(txq->txq_lock);
- txq->txq_watchdog = false; /* ensure watchdog disabled */
+ txq->txq_sending = false; /* ensure watchdog disabled */
for (i = 0; i < WM_TXQUEUELEN(txq); i++) {
txs = &txq->txq_soft[i];
if (txs->txs_mbuf != NULL) {
@@ -6111,7 +6117,7 @@ out:
* if the Tx FIFO ring buffer, otherwise the chip will croak.
*
* We do this by checking the amount of space before the end
- * of the Tx FIFO buffer. If the packet will not fit, we "stall"
+ * of the Tx FIFO buffer. If the packet will not fit, we "stall"
* the Tx FIFO, wait for all remaining packets to drain, reset
* the internal FIFO pointers to the beginning, and restart
* transmission on the interface.
@@ -6697,7 +6703,7 @@ wm_init_tx_queue(struct wm_softc *sc, st
wm_init_tx_buffer(sc, txq);
txq->txq_flags = 0; /* Clear WM_TXQ_NO_SPACE */
- txq->txq_watchdog = false;
+ txq->txq_sending = false;
}
static void
@@ -6731,7 +6737,8 @@ wm_init_rx_regs(struct wm_softc *sc, str
CSR_WRITE(sc, WMREG_RDBAH(qid), WM_CDRXADDR_HI(rxq, 0));
CSR_WRITE(sc, WMREG_RDBAL(qid), WM_CDRXADDR_LO(rxq, 0));
- CSR_WRITE(sc, WMREG_RDLEN(qid), rxq->rxq_descsize * rxq->rxq_ndesc);
+ CSR_WRITE(sc, WMREG_RDLEN(qid),
+ rxq->rxq_descsize * rxq->rxq_ndesc);
if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
if (MCLBYTES & ((1 << SRRCTL_BSIZEPKT_SHIFT) - 1))
@@ -6749,7 +6756,8 @@ wm_init_rx_regs(struct wm_softc *sc, str
CSR_WRITE(sc, WMREG_RDH(qid), 0);
CSR_WRITE(sc, WMREG_RDT(qid), 0);
/* XXX should update with AIM? */
- CSR_WRITE(sc, WMREG_RDTR, (wmq->wmq_itr / 4) | RDTR_FPD);
+ CSR_WRITE(sc, WMREG_RDTR,
+ (wmq->wmq_itr / 4) | RDTR_FPD);
/* MUST be same */
CSR_WRITE(sc, WMREG_RADV, wmq->wmq_itr / 4);
CSR_WRITE(sc, WMREG_RXDCTL(qid), RXDCTL_PTHRESH(0) |
@@ -6925,7 +6933,7 @@ wm_tx_offload(struct wm_softc *sc, struc
(hlen + sizeof(struct tcphdr)))) {
/*
* TCP/IP headers are not in the first mbuf; we need
- * to do this the slow and painful way. Let's just
+ * to do this the slow and painful way. Let's just
* hope this doesn't happen very often.
*/
struct tcphdr th;
@@ -7021,7 +7029,7 @@ wm_tx_offload(struct wm_softc *sc, struc
fields |= WTX_TXSM;
tucs = WTX_TCPIP_TUCSS(offset) |
WTX_TCPIP_TUCSO(offset +
- M_CSUM_DATA_IPv4_OFFSET(m0->m_pkthdr.csum_data)) |
+ M_CSUM_DATA_IPv4_OFFSET(m0->m_pkthdr.csum_data)) |
WTX_TCPIP_TUCSE(0) /* rest of packet */;
} else if ((m0->m_pkthdr.csum_flags &
(M_CSUM_TCPv6 | M_CSUM_UDPv6 | M_CSUM_TSOv6)) != 0) {
@@ -7029,7 +7037,7 @@ wm_tx_offload(struct wm_softc *sc, struc
fields |= WTX_TXSM;
tucs = WTX_TCPIP_TUCSS(offset) |
WTX_TCPIP_TUCSO(offset +
- M_CSUM_DATA_IPv6_OFFSET(m0->m_pkthdr.csum_data)) |
+ M_CSUM_DATA_IPv6_OFFSET(m0->m_pkthdr.csum_data)) |
WTX_TCPIP_TUCSE(0) /* rest of packet */;
} else {
/* Just initialize it to a valid TCP context. */
@@ -7074,7 +7082,7 @@ wm_select_txqueue(struct ifnet *ifp, str
* TODO:
* distribute by flowid(RSS has value).
*/
- return (cpuid + ncpu - sc->sc_affinity_offset) % sc->sc_nqueues;
+ return (cpuid + ncpu - sc->sc_affinity_offset) % sc->sc_nqueues;
}
/*
@@ -7205,7 +7213,7 @@ wm_send_common_locked(struct ifnet *ifp,
DPRINTF(WM_DEBUG_TX,
("%s: TX: have packet to transmit: %p\n",
- device_xname(sc->sc_dev), m0));
+ device_xname(sc->sc_dev), m0));
txs = &txq->txq_soft[txq->txq_snext];
dmamap = txs->txs_dmamap;
@@ -7217,7 +7225,7 @@ wm_send_common_locked(struct ifnet *ifp,
* So says the Linux driver:
* The controller does a simple calculation to make sure
* there is enough room in the FIFO before initiating the
- * DMA for each buffer. The calc is:
+ * DMA for each buffer. The calc is:
* 4 = ceil(buffer len / MSS)
* To make sure we don't overrun the FIFO, adjust the max
* buffer len if the MSS drops.
@@ -7250,7 +7258,7 @@ wm_send_common_locked(struct ifnet *ifp,
/* Short on resources, just stop for now. */
DPRINTF(WM_DEBUG_TX,
("%s: TX: dmamap load failed: %d\n",
- device_xname(sc->sc_dev), error));
+ device_xname(sc->sc_dev), error));
break;
}
@@ -7262,7 +7270,7 @@ wm_send_common_locked(struct ifnet *ifp,
/*
* Ensure we have enough descriptors free to describe
- * the packet. Note, we always reserve one descriptor
+ * the packet. Note, we always reserve one descriptor
* at the end of the ring due to the semantics of the
* TDT register, plus one more in the event we need
* to load offload context.
@@ -7272,13 +7280,13 @@ wm_send_common_locked(struct ifnet *ifp,
* Not enough free descriptors to transmit this
* packet. We haven't committed anything yet,
* so just unload the DMA map, put the packet
- * pack on the queue, and punt. Notify the upper
+ * pack on the queue, and punt. Notify the upper
* layer that there are no more slots left.
*/
DPRINTF(WM_DEBUG_TX,
("%s: TX: need %d (%d) descriptors, have %d\n",
- device_xname(sc->sc_dev), dmamap->dm_nsegs,
- segs_needed, txq->txq_free - 1));
+ device_xname(sc->sc_dev), dmamap->dm_nsegs,
+ segs_needed, txq->txq_free - 1));
if (!is_transmit)
ifp->if_flags |= IFF_OACTIVE;
txq->txq_flags |= WM_TXQ_NO_SPACE;
@@ -7288,7 +7296,7 @@ wm_send_common_locked(struct ifnet *ifp,
}
/*
- * Check for 82547 Tx FIFO bug. We need to do this
+ * Check for 82547 Tx FIFO bug. We need to do this
* once we know we can transmit the packet, since we
* do some internal FIFO space accounting here.
*/
@@ -7296,7 +7304,7 @@ wm_send_common_locked(struct ifnet *ifp,
wm_82547_txfifo_bugchk(sc, m0)) {
DPRINTF(WM_DEBUG_TX,
("%s: TX: 82547 Tx FIFO bug detected\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
if (!is_transmit)
ifp->if_flags |= IFF_OACTIVE;
txq->txq_flags |= WM_TXQ_NO_SPACE;
@@ -7381,9 +7389,9 @@ wm_send_common_locked(struct ifnet *ifp,
DPRINTF(WM_DEBUG_TX,
("%s: TX: desc %d: low %#" PRIx64 ", "
- "len %#04zx\n",
- device_xname(sc->sc_dev), nexttx,
- (uint64_t)curaddr, curlen));
+ "len %#04zx\n",
+ device_xname(sc->sc_dev), nexttx,
+ (uint64_t)curaddr, curlen));
}
}
@@ -7391,7 +7399,7 @@ wm_send_common_locked(struct ifnet *ifp,
/*
* Set up the command byte on the last descriptor of
- * the packet. If we're in the interrupt delay window,
+ * the packet. If we're in the interrupt delay window,
* delay the interrupt.
*/
txq->txq_descs[lasttx].wtx_cmdlen |=
@@ -7414,8 +7422,8 @@ wm_send_common_locked(struct ifnet *ifp,
DPRINTF(WM_DEBUG_TX,
("%s: TX: desc %d: cmdlen 0x%08x\n",
- device_xname(sc->sc_dev),
- lasttx, le32toh(txq->txq_descs[lasttx].wtx_cmdlen)));
+ device_xname(sc->sc_dev),
+ lasttx, le32toh(txq->txq_descs[lasttx].wtx_cmdlen)));
/* Sync the descriptors we're using. */
wm_cdtxsync(txq, txq->txq_next, txs->txs_ndesc,
@@ -7429,7 +7437,7 @@ wm_send_common_locked(struct ifnet *ifp,
DPRINTF(WM_DEBUG_TX,
("%s: TX: finished transmitting packet, job %d\n",
- device_xname(sc->sc_dev), txq->txq_snext));
+ device_xname(sc->sc_dev), txq->txq_snext));
/* Advance the tx pointer. */
txq->txq_free -= txs->txs_ndesc;
@@ -7462,7 +7470,7 @@ wm_send_common_locked(struct ifnet *ifp,
if (txq->txq_free != ofree) {
/* Set a watchdog timer in case the chip flakes out. */
txq->txq_lastsent = time_uptime;
- txq->txq_watchdog = true;
+ txq->txq_sending = true;
}
}
@@ -7522,7 +7530,7 @@ wm_nq_tx_offload(struct wm_softc *sc, st
if (vlan_has_tag(m0)) {
vl_len |= ((vlan_get_tag(m0) & NQTXC_VLLEN_VLAN_MASK)
- << NQTXC_VLLEN_VLAN_SHIFT);
+ << NQTXC_VLLEN_VLAN_SHIFT);
*cmdlenp |= NQTX_CMD_VLE;
}
@@ -7537,7 +7545,7 @@ wm_nq_tx_offload(struct wm_softc *sc, st
(hlen + sizeof(struct tcphdr)))) {
/*
* TCP/IP headers are not in the first mbuf; we need
- * to do this the slow and painful way. Let's just
+ * to do this the slow and painful way. Let's just
* hope this doesn't happen very often.
*/
struct tcphdr th;
@@ -7664,7 +7672,7 @@ wm_nq_tx_offload(struct wm_softc *sc, st
wm_cdtxsync(txq, txq->txq_next, 1, BUS_DMASYNC_PREWRITE);
DPRINTF(WM_DEBUG_TX,
("%s: TX: context desc %d 0x%08x%08x\n", device_xname(sc->sc_dev),
- txq->txq_next, 0, vl_len));
+ txq->txq_next, 0, vl_len));
DPRINTF(WM_DEBUG_TX, ("\t0x%08x%08x\n", mssidx, cmdc));
txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
txs->txs_ndesc++;
@@ -7734,8 +7742,9 @@ wm_nq_transmit(struct ifnet *ifp, struct
* (2) contention with deferred if_start softint(wm_handle_queue())
* In the case of (1), the last packet enqueued to txq->txq_interq is
* dequeued by wm_deferred_start_locked(). So, it does not get stuck.
- * In the case of (2), the last packet enqueued to txq->txq_interq is also
- * dequeued by wm_deferred_start_locked(). So, it does not get stuck, either.
+ * In the case of (2), the last packet enqueued to txq->txq_interq is
+ * also dequeued by wm_deferred_start_locked(). So, it does not get
+ * stuck, either.
*/
if (mutex_tryenter(txq->txq_lock)) {
if (!txq->txq_stopping)
@@ -7833,7 +7842,7 @@ wm_nq_send_common_locked(struct ifnet *i
/* Short on resources, just stop for now. */
DPRINTF(WM_DEBUG_TX,
("%s: TX: dmamap load failed: %d\n",
- device_xname(sc->sc_dev), error));
+ device_xname(sc->sc_dev), error));
break;
}
@@ -7841,7 +7850,7 @@ wm_nq_send_common_locked(struct ifnet *i
/*
* Ensure we have enough descriptors free to describe
- * the packet. Note, we always reserve one descriptor
+ * the packet. Note, we always reserve one descriptor
* at the end of the ring due to the semantics of the
* TDT register, plus one more in the event we need
* to load offload context.
@@ -7851,13 +7860,13 @@ wm_nq_send_common_locked(struct ifnet *i
* Not enough free descriptors to transmit this
* packet. We haven't committed anything yet,
* so just unload the DMA map, put the packet
- * pack on the queue, and punt. Notify the upper
+ * pack on the queue, and punt. Notify the upper
* layer that there are no more slots left.
*/
DPRINTF(WM_DEBUG_TX,
("%s: TX: need %d (%d) descriptors, have %d\n",
- device_xname(sc->sc_dev), dmamap->dm_nsegs,
- segs_needed, txq->txq_free - 1));
+ device_xname(sc->sc_dev), dmamap->dm_nsegs,
+ segs_needed, txq->txq_free - 1));
if (!is_transmit)
ifp->if_flags |= IFF_OACTIVE;
txq->txq_flags |= WM_TXQ_NO_SPACE;
@@ -7939,11 +7948,11 @@ wm_nq_send_common_locked(struct ifnet *i
htole32(fields);
DPRINTF(WM_DEBUG_TX,
("%s: TX: adv data desc %d 0x%" PRIx64 "\n",
- device_xname(sc->sc_dev), nexttx,
- (uint64_t)dmamap->dm_segs[0].ds_addr));
+ device_xname(sc->sc_dev), nexttx,
+ (uint64_t)dmamap->dm_segs[0].ds_addr));
DPRINTF(WM_DEBUG_TX,
("\t 0x%08x%08x\n", fields,
- (uint32_t)dmamap->dm_segs[0].ds_len | cmdlen));
+ (uint32_t)dmamap->dm_segs[0].ds_len | cmdlen));
dcmdlen = NQTX_DTYP_D | NQTX_CMD_DEXT;
}
@@ -7954,7 +7963,7 @@ wm_nq_send_common_locked(struct ifnet *i
* is the same here
*/
for (seg = 1; seg < dmamap->dm_nsegs;
- seg++, nexttx = WM_NEXTTX(txq, nexttx)) {
+ seg++, nexttx = WM_NEXTTX(txq, nexttx)) {
txq->txq_nq_descs[nexttx].nqtx_data.nqtxd_addr =
htole64(dmamap->dm_segs[seg].ds_addr);
txq->txq_nq_descs[nexttx].nqtx_data.nqtxd_cmdlen =
@@ -7964,18 +7973,17 @@ wm_nq_send_common_locked(struct ifnet *i
lasttx = nexttx;
DPRINTF(WM_DEBUG_TX,
- ("%s: TX: desc %d: %#" PRIx64 ", "
- "len %#04zx\n",
- device_xname(sc->sc_dev), nexttx,
- (uint64_t)dmamap->dm_segs[seg].ds_addr,
- dmamap->dm_segs[seg].ds_len));
+ ("%s: TX: desc %d: %#" PRIx64 ", len %#04zx\n",
+ device_xname(sc->sc_dev), nexttx,
+ (uint64_t)dmamap->dm_segs[seg].ds_addr,
+ dmamap->dm_segs[seg].ds_len));
}
KASSERT(lasttx != -1);
/*
* Set up the command byte on the last descriptor of
- * the packet. If we're in the interrupt delay window,
+ * the packet. If we're in the interrupt delay window,
* delay the interrupt.
*/
KASSERT((WTX_CMD_EOP | WTX_CMD_RS) ==
@@ -8002,7 +8010,7 @@ wm_nq_send_common_locked(struct ifnet *i
DPRINTF(WM_DEBUG_TX,
("%s: TX: finished transmitting packet, job %d\n",
- device_xname(sc->sc_dev), txq->txq_snext));
+ device_xname(sc->sc_dev), txq->txq_snext));
/* Advance the tx pointer. */
txq->txq_free -= txs->txs_ndesc;
@@ -8035,7 +8043,7 @@ wm_nq_send_common_locked(struct ifnet *i
if (sent) {
/* Set a watchdog timer in case the chip flakes out. */
txq->txq_lastsent = time_uptime;
- txq->txq_watchdog = true;
+ txq->txq_sending = true;
}
}
@@ -8180,7 +8188,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l
* timer.
*/
if (txq->txq_sfree == WM_TXQUEUELEN(txq))
- txq->txq_watchdog = false;
+ txq->txq_sending = false;
return more;
}
@@ -8309,16 +8317,20 @@ wm_rxdesc_has_errors(struct wm_rxqueue *
/* XXXX missing error bit for newqueue? */
if (wm_rxdesc_is_set_error(sc, errors,
- WRX_ER_CE|WRX_ER_SE|WRX_ER_SEQ|WRX_ER_CXE|WRX_ER_RXE,
- EXTRXC_ERROR_CE|EXTRXC_ERROR_SE|EXTRXC_ERROR_SEQ|EXTRXC_ERROR_CXE|EXTRXC_ERROR_RXE,
+ WRX_ER_CE | WRX_ER_SE | WRX_ER_SEQ | WRX_ER_CXE | WRX_ER_RXE,
+ EXTRXC_ERROR_CE | EXTRXC_ERROR_SE | EXTRXC_ERROR_SEQ
+ | EXTRXC_ERROR_CXE | EXTRXC_ERROR_RXE,
NQRXC_ERROR_RXE)) {
- if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_SE, EXTRXC_ERROR_SE, 0))
+ if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_SE,
+ EXTRXC_ERROR_SE, 0))
log(LOG_WARNING, "%s: symbol error\n",
device_xname(sc->sc_dev));
- else if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_SEQ, EXTRXC_ERROR_SEQ, 0))
+ else if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_SEQ,
+ EXTRXC_ERROR_SEQ, 0))
log(LOG_WARNING, "%s: receive sequence error\n",
device_xname(sc->sc_dev));
- else if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_CE, EXTRXC_ERROR_CE, 0))
+ else if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_CE,
+ EXTRXC_ERROR_CE, 0))
log(LOG_WARNING, "%s: CRC error\n",
device_xname(sc->sc_dev));
return true;
@@ -8343,8 +8355,8 @@ wm_rxdesc_dd(struct wm_rxqueue *rxq, int
}
static inline bool
-wm_rxdesc_input_vlantag(struct wm_rxqueue *rxq, uint32_t status, uint16_t vlantag,
- struct mbuf *m)
+wm_rxdesc_input_vlantag(struct wm_rxqueue *rxq, uint32_t status,
+ uint16_t vlantag, struct mbuf *m)
{
if (wm_rxdesc_is_set_status(rxq->rxq_sc, status,
@@ -8368,8 +8380,7 @@ wm_rxdesc_ensure_checksum(struct wm_rxqu
m->m_pkthdr.csum_flags |= M_CSUM_IPv4;
if (wm_rxdesc_is_set_error(sc, errors,
WRX_ER_IPE, EXTRXC_ERROR_IPE, NQRXC_ERROR_IPE))
- m->m_pkthdr.csum_flags |=
- M_CSUM_IPv4_BAD;
+ m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD;
}
if (wm_rxdesc_is_set_status(sc, status,
WRX_ST_TCPCS, EXTRXC_STATUS_TCPCS, NQRXC_STATUS_L4I)) {
@@ -8380,12 +8391,11 @@ wm_rxdesc_ensure_checksum(struct wm_rxqu
*/
WM_Q_EVCNT_INCR(rxq, rxtusum);
m->m_pkthdr.csum_flags |=
- M_CSUM_TCPv4 | M_CSUM_UDPv4 |
- M_CSUM_TCPv6 | M_CSUM_UDPv6;
- if (wm_rxdesc_is_set_error(sc, errors,
- WRX_ER_TCPE, EXTRXC_ERROR_TCPE, NQRXC_ERROR_L4E))
- m->m_pkthdr.csum_flags |=
- M_CSUM_TCP_UDP_BAD;
+ M_CSUM_TCPv4 | M_CSUM_UDPv4 |
+ M_CSUM_TCPv6 | M_CSUM_UDPv6;
+ if (wm_rxdesc_is_set_error(sc, errors, WRX_ER_TCPE,
+ EXTRXC_ERROR_TCPE, NQRXC_ERROR_L4E))
+ m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD;
}
}
}
@@ -8424,8 +8434,9 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
DPRINTF(WM_DEBUG_RX,
("%s: RX: checking descriptor %d\n",
- device_xname(sc->sc_dev), i));
- wm_cdrxsync(rxq, i,BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
+ device_xname(sc->sc_dev), i));
+ wm_cdrxsync(rxq, i,
+ BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
status = wm_rxdesc_get_status(rxq, i);
errors = wm_rxdesc_get_errors(rxq, i);
@@ -8449,13 +8460,13 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
if (__predict_false(rxq->rxq_discard)) {
DPRINTF(WM_DEBUG_RX,
("%s: RX: discarding contents of descriptor %d\n",
- device_xname(sc->sc_dev), i));
+ device_xname(sc->sc_dev), i));
wm_init_rxdesc(rxq, i);
if (wm_rxdesc_is_eop(rxq, status)) {
/* Reset our state. */
DPRINTF(WM_DEBUG_RX,
("%s: RX: resetting rxdiscard -> 0\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
rxq->rxq_discard = 0;
}
continue;
@@ -8488,7 +8499,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
DPRINTF(WM_DEBUG_RX,
("%s: RX: Rx buffer allocation failed, "
"dropping packet%s\n", device_xname(sc->sc_dev),
- rxq->rxq_discard ? " (discard)" : ""));
+ rxq->rxq_discard ? " (discard)" : ""));
continue;
}
@@ -8496,19 +8507,19 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
rxq->rxq_len += len;
DPRINTF(WM_DEBUG_RX,
("%s: RX: buffer at %p len %d\n",
- device_xname(sc->sc_dev), m->m_data, len));
+ device_xname(sc->sc_dev), m->m_data, len));
/* If this is not the end of the packet, keep looking. */
if (!wm_rxdesc_is_eop(rxq, status)) {
WM_RXCHAIN_LINK(rxq, m);
DPRINTF(WM_DEBUG_RX,
("%s: RX: not yet EOP, rxlen -> %d\n",
- device_xname(sc->sc_dev), rxq->rxq_len));
+ device_xname(sc->sc_dev), rxq->rxq_len));
continue;
}
/*
- * Okay, we have the entire packet now. The chip is
+ * Okay, we have the entire packet now. The chip is
* configured to include the FCS except I350 and I21[01]
* (not all chips can be configured to strip it),
* so we need to trim it.
@@ -8539,7 +8550,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
DPRINTF(WM_DEBUG_RX,
("%s: RX: have entire packet, len -> %d\n",
- device_xname(sc->sc_dev), len));
+ device_xname(sc->sc_dev), len));
/* If an error occurred, update stats and drop the packet. */
if (wm_rxdesc_has_errors(rxq, errors)) {
@@ -8709,8 +8720,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
* Tolerance Reporting (LTR)
*/
wm_platform_pm_pch_lpt(sc,
- ((sc->sc_mii.mii_media_status & IFM_ACTIVE)
- != 0));
+ ((sc->sc_mii.mii_media_status & IFM_ACTIVE) != 0));
}
/* FEXTNVM6 K1-off workaround */
@@ -8747,8 +8757,8 @@ wm_linkintr_tbi(struct wm_softc *sc, uin
if (icr & ICR_LSC) {
if (status & STATUS_LU) {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n",
- device_xname(sc->sc_dev),
- (status & STATUS_FD) ? "FDX" : "HDX"));
+ device_xname(sc->sc_dev),
+ (status & STATUS_FD) ? "FDX" : "HDX"));
/*
* NOTE: CTRL will update TFCE and RFCE automatically,
* so we should update sc->sc_ctrl
@@ -8767,22 +8777,20 @@ wm_linkintr_tbi(struct wm_softc *sc, uin
sc->sc_fcrtl |= FCRTL_XONE;
CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ?
- WMREG_OLD_FCRTL : WMREG_FCRTL,
- sc->sc_fcrtl);
+ WMREG_OLD_FCRTL : WMREG_FCRTL, sc->sc_fcrtl);
sc->sc_tbi_linkup = 1;
if_link_state_change(ifp, LINK_STATE_UP);
} else {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
sc->sc_tbi_linkup = 0;
if_link_state_change(ifp, LINK_STATE_DOWN);
}
/* Update LED */
wm_tbi_serdes_set_linkled(sc);
} else if (icr & ICR_RXSEQ) {
- DPRINTF(WM_DEBUG_LINK,
- ("%s: LINK: Receive sequence error\n",
- device_xname(sc->sc_dev)));
+ DPRINTF(WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n",
+ device_xname(sc->sc_dev)));
}
}
@@ -8857,8 +8865,7 @@ wm_linkintr_serdes(struct wm_softc *sc,
/* Update LED */
wm_tbi_serdes_set_linkled(sc);
} else {
- DPRINTF(WM_DEBUG_LINK,
- ("%s: LINK: Receive sequence error\n",
+ DPRINTF(WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n",
device_xname(sc->sc_dev)));
}
}
@@ -8922,8 +8929,8 @@ wm_intr_legacy(void *arg)
if (icr & (ICR_RXDMT0 | ICR_RXT0)) {
DPRINTF(WM_DEBUG_RX,
("%s: RX: got Rx intr 0x%08x\n",
- device_xname(sc->sc_dev),
- icr & (ICR_RXDMT0 | ICR_RXT0)));
+ device_xname(sc->sc_dev),
+ icr & (ICR_RXDMT0 | ICR_RXT0)));
WM_Q_EVCNT_INCR(rxq, rxintr);
}
#endif
@@ -8946,7 +8953,7 @@ wm_intr_legacy(void *arg)
if (icr & ICR_TXDW) {
DPRINTF(WM_DEBUG_TX,
("%s: TX: got TXDW interrupt\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
WM_Q_EVCNT_INCR(txq, txdw);
}
#endif
@@ -8991,9 +8998,11 @@ wm_txrxintr_disable(struct wm_queue *wmq
struct wm_softc *sc = wmq->wmq_txq.txq_sc;
if (sc->sc_type == WM_T_82574)
- CSR_WRITE(sc, WMREG_IMC, ICR_TXQ(wmq->wmq_id) | ICR_RXQ(wmq->wmq_id));
+ CSR_WRITE(sc, WMREG_IMC,
+ ICR_TXQ(wmq->wmq_id) | ICR_RXQ(wmq->wmq_id));
else if (sc->sc_type == WM_T_82575)
- CSR_WRITE(sc, WMREG_EIMC, EITR_TX_QUEUE(wmq->wmq_id) | EITR_RX_QUEUE(wmq->wmq_id));
+ CSR_WRITE(sc, WMREG_EIMC,
+ EITR_TX_QUEUE(wmq->wmq_id) | EITR_RX_QUEUE(wmq->wmq_id));
else
CSR_WRITE(sc, WMREG_EIMC, 1 << wmq->wmq_intr_idx);
}
@@ -9012,9 +9021,11 @@ wm_txrxintr_enable(struct wm_queue *wmq)
* while each wm_handle_queue(wmq) is runnig.
*/
if (sc->sc_type == WM_T_82574)
- CSR_WRITE(sc, WMREG_IMS, ICR_TXQ(wmq->wmq_id) | ICR_RXQ(wmq->wmq_id) | ICR_OTHER);
+ CSR_WRITE(sc, WMREG_IMS,
+ ICR_TXQ(wmq->wmq_id) | ICR_RXQ(wmq->wmq_id) | ICR_OTHER);
else if (sc->sc_type == WM_T_82575)
- CSR_WRITE(sc, WMREG_EIMS, EITR_TX_QUEUE(wmq->wmq_id) | EITR_RX_QUEUE(wmq->wmq_id));
+ CSR_WRITE(sc, WMREG_EIMS,
+ EITR_TX_QUEUE(wmq->wmq_id) | EITR_RX_QUEUE(wmq->wmq_id));
else
CSR_WRITE(sc, WMREG_EIMS, 1 << wmq->wmq_intr_idx);
}
@@ -9129,7 +9140,7 @@ wm_linkintr_msix(void *arg)
if (sc->sc_core_stopping)
goto out;
- if((reg & ICR_LSC) != 0) {
+ if ((reg & ICR_LSC) != 0) {
WM_EVCNT_INCR(&sc->sc_ev_linkintr);
wm_linkintr(sc, ICR_LSC);
}
@@ -9974,7 +9985,7 @@ wm_gmii_i82543_readreg(device_t dev, int
rv = wm_i82543_mii_recvbits(sc) & 0xffff;
DPRINTF(WM_DEBUG_GMII, ("%s: GMII: read phy %d reg %d -> 0x%04x\n",
- device_xname(dev), phy, reg, rv));
+ device_xname(dev), phy, reg, rv));
return rv;
}
@@ -10099,7 +10110,8 @@ wm_gmii_i82544_readreg(device_t dev, int
case WMPHY_IGP:
case WMPHY_IGP_2:
case WMPHY_IGP_3:
- wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT, reg);
+ wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT,
+ reg);
break;
default:
#ifdef WM_DEBUG
@@ -10136,7 +10148,8 @@ wm_gmii_i82544_writereg(device_t dev, in
case WMPHY_IGP:
case WMPHY_IGP_2:
case WMPHY_IGP_3:
- wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT, reg);
+ wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT,
+ reg);
break;
default:
#ifdef WM_DEBUG
@@ -10886,8 +10899,7 @@ wm_sgmii_readreg(device_t dev, int phy,
}
i2ccmd = (reg << I2CCMD_REG_ADDR_SHIFT)
- | (phy << I2CCMD_PHY_ADDR_SHIFT)
- | I2CCMD_OPCODE_READ;
+ | (phy << I2CCMD_PHY_ADDR_SHIFT) | I2CCMD_OPCODE_READ;
CSR_WRITE(sc, WMREG_I2CCMD, i2ccmd);
/* Poll the ready bit */
@@ -10921,17 +10933,16 @@ wm_sgmii_writereg(device_t dev, int phy,
struct wm_softc *sc = device_private(dev);
uint32_t i2ccmd;
int i;
- int val_swapped;
+ int swapdata;
if (sc->phy.acquire(sc) != 0) {
device_printf(dev, "%s: failed to get semaphore\n", __func__);
return;
}
/* Swap the data bytes for the I2C interface */
- val_swapped = ((val >> 8) & 0x00FF) | ((val << 8) & 0xFF00);
+ swapdata = ((val >> 8) & 0x00FF) | ((val << 8) & 0xFF00);
i2ccmd = (reg << I2CCMD_REG_ADDR_SHIFT)
- | (phy << I2CCMD_PHY_ADDR_SHIFT)
- | I2CCMD_OPCODE_WRITE | val_swapped;
+ | (phy << I2CCMD_PHY_ADDR_SHIFT) | I2CCMD_OPCODE_WRITE | swapdata;
CSR_WRITE(sc, WMREG_I2CCMD, i2ccmd);
/* Poll the ready bit */
@@ -11068,7 +11079,7 @@ wm_tbi_mediachange(struct ifnet *ifp)
sc->sc_txcw |= TXCW_SYM_PAUSE | TXCW_ASYM_PAUSE;
DPRINTF(WM_DEBUG_LINK,("%s: sc_txcw = 0x%x after autoneg check\n",
- device_xname(sc->sc_dev), sc->sc_txcw));
+ device_xname(sc->sc_dev), sc->sc_txcw));
CSR_WRITE(sc, WMREG_TXCW, sc->sc_txcw);
CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
CSR_WRITE_FLUSH(sc);
@@ -11090,7 +11101,7 @@ wm_tbi_mediachange(struct ifnet *ifp)
}
DPRINTF(WM_DEBUG_LINK,("%s: i = %d after waiting for link\n",
- device_xname(sc->sc_dev),i));
+ device_xname(sc->sc_dev),i));
status = CSR_READ(sc, WMREG_STATUS);
DPRINTF(WM_DEBUG_LINK,
@@ -11100,8 +11111,8 @@ wm_tbi_mediachange(struct ifnet *ifp)
/* Link is up. */
DPRINTF(WM_DEBUG_LINK,
("%s: LINK: set media -> link up %s\n",
- device_xname(sc->sc_dev),
- (status & STATUS_FD) ? "FDX" : "HDX"));
+ device_xname(sc->sc_dev),
+ (status & STATUS_FD) ? "FDX" : "HDX"));
/*
* NOTE: CTRL will update TFCE and RFCE automatically,
@@ -11120,8 +11131,7 @@ wm_tbi_mediachange(struct ifnet *ifp)
sc->sc_fcrtl |= FCRTL_XONE;
CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ?
- WMREG_OLD_FCRTL : WMREG_FCRTL,
- sc->sc_fcrtl);
+ WMREG_OLD_FCRTL : WMREG_FCRTL, sc->sc_fcrtl);
sc->sc_tbi_linkup = 1;
} else {
if (i == WM_LINKUP_TIMEOUT)
@@ -11129,12 +11139,12 @@ wm_tbi_mediachange(struct ifnet *ifp)
/* Link is down. */
DPRINTF(WM_DEBUG_LINK,
("%s: LINK: set media -> link down\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
sc->sc_tbi_linkup = 0;
}
} else {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: set media -> no signal\n",
- device_xname(sc->sc_dev)));
+ device_xname(sc->sc_dev)));
sc->sc_tbi_linkup = 0;
}
@@ -11212,14 +11222,14 @@ wm_check_for_link(struct wm_softc *sc)
/*
* SWDPIN LU RXCW
- * 0 0 0
- * 0 0 1 (should not happen)
- * 0 1 0 (should not happen)
- * 0 1 1 (should not happen)
- * 1 0 0 Disable autonego and force linkup
- * 1 0 1 got /C/ but not linkup yet
- * 1 1 0 (linkup)
- * 1 1 1 If IFM_AUTO, back to autonego
+ * 0 0 0
+ * 0 0 1 (should not happen)
+ * 0 1 0 (should not happen)
+ * 0 1 1 (should not happen)
+ * 1 0 0 Disable autonego and force linkup
+ * 1 0 1 got /C/ but not linkup yet
+ * 1 1 0 (linkup)
+ * 1 1 1 If IFM_AUTO, back to autonego
*
*/
if (((ctrl & CTRL_SWDPIN(1)) == sig)
@@ -11281,13 +11291,11 @@ wm_tbi_tick(struct wm_softc *sc)
/* set link status */
if ((status & STATUS_LU) == 0) {
- DPRINTF(WM_DEBUG_LINK,
- ("%s: LINK: checklink -> down\n",
+ DPRINTF(WM_DEBUG_LINK, ("%s: LINK: checklink -> down\n",
device_xname(sc->sc_dev)));
sc->sc_tbi_linkup = 0;
} else if (sc->sc_tbi_linkup == 0) {
- DPRINTF(WM_DEBUG_LINK,
- ("%s: LINK: checklink -> up %s\n",
+ DPRINTF(WM_DEBUG_LINK, ("%s: LINK: checklink -> up %s\n",
device_xname(sc->sc_dev),
(status & STATUS_FD) ? "FDX" : "HDX"));
sc->sc_tbi_linkup = 1;
@@ -11611,10 +11619,10 @@ wm_sfp_get_media_type(struct wm_softc *s
if ((val & (SFF_SFP_ETH_FLAGS_1000SX | SFF_SFP_ETH_FLAGS_1000LX)) != 0)
mediatype = WM_MEDIATYPE_SERDES;
- else if ((val & SFF_SFP_ETH_FLAGS_1000T) != 0){
+ else if ((val & SFF_SFP_ETH_FLAGS_1000T) != 0) {
sc->sc_flags |= WM_F_SGMII;
mediatype = WM_MEDIATYPE_COPPER;
- } else if ((val & SFF_SFP_ETH_FLAGS_100FX) != 0){
+ } else if ((val & SFF_SFP_ETH_FLAGS_100FX) != 0) {
sc->sc_flags |= WM_F_SGMII;
mediatype = WM_MEDIATYPE_SERDES;
}
@@ -11936,8 +11944,7 @@ wm_poll_eerd_eewr_done(struct wm_softc *
}
static int
-wm_nvm_read_eerd(struct wm_softc *sc, int offset, int wordcnt,
- uint16_t *data)
+wm_nvm_read_eerd(struct wm_softc *sc, int offset, int wordcnt, uint16_t *data)
{
int i, eerd = 0;
int rv = 0;
@@ -11974,7 +11981,7 @@ wm_nvm_valid_bank_detect_ich8lan(struct
uint32_t bank1_offset = sc->sc_ich8_flash_bank_size * sizeof(uint16_t);
uint32_t nvm_dword = 0;
uint8_t sig_byte = 0;
- int rv;
+ int rv;
switch (sc->sc_type) {
case WM_T_PCH_SPT:
@@ -12348,7 +12355,7 @@ wm_read_ich8_dword(struct wm_softc *sc,
static int
wm_nvm_read_ich8(struct wm_softc *sc, int offset, int words, uint16_t *data)
{
- int32_t rv = 0;
+ int32_t rv = 0;
uint32_t flash_bank = 0;
uint32_t act_offset = 0;
uint32_t bank_offset = 0;
@@ -12364,7 +12371,7 @@ wm_nvm_read_ich8(struct wm_softc *sc, in
/*
* We need to know which is the valid flash bank. In the event
* that we didn't allocate eeprom_shadow_ram, we may not be
- * managing flash_bank. So it cannot be trusted and needs
+ * managing flash_bank. So it cannot be trusted and needs
* to be updated with each read.
*/
rv = wm_nvm_valid_bank_detect_ich8lan(sc, &flash_bank);
@@ -12408,7 +12415,7 @@ wm_nvm_read_ich8(struct wm_softc *sc, in
static int
wm_nvm_read_spt(struct wm_softc *sc, int offset, int words, uint16_t *data)
{
- int32_t rv = 0;
+ int32_t rv = 0;
uint32_t flash_bank = 0;
uint32_t act_offset = 0;
uint32_t bank_offset = 0;
@@ -12424,7 +12431,7 @@ wm_nvm_read_spt(struct wm_softc *sc, int
/*
* We need to know which is the valid flash bank. In the event
* that we didn't allocate eeprom_shadow_ram, we may not be
- * managing flash_bank. So it cannot be trusted and needs
+ * managing flash_bank. So it cannot be trusted and needs
* to be updated with each read.
*/
rv = wm_nvm_valid_bank_detect_ich8lan(sc, &flash_bank);
@@ -12466,7 +12473,7 @@ wm_nvm_read_spt(struct wm_softc *sc, int
static int
wm_nvm_read_word_invm(struct wm_softc *sc, uint16_t address, uint16_t *data)
{
- int32_t rv = 0;
+ int32_t rv = 0;
uint32_t invm_dword;
uint16_t i;
uint8_t record_type, word_address;
@@ -13055,7 +13062,7 @@ wm_get_swfw_semaphore(struct wm_softc *s
else
timeout = 200;
- for (timeout = 0; timeout < 200; timeout++) {
+ while (timeout) {
if (wm_get_swsm_semaphore(sc)) {
aprint_error_dev(sc->sc_dev,
"%s: failed to get semaphore\n",
@@ -13071,6 +13078,7 @@ wm_get_swfw_semaphore(struct wm_softc *s
}
wm_put_swsm_semaphore(sc);
delay(5000);
+ timeout--;
}
printf("%s: failed to get swfw semaphore mask 0x%x swfw 0x%x\n",
device_xname(sc->sc_dev), mask, swfw_sync);
@@ -13700,7 +13708,7 @@ wm_init_manageability(struct wm_softc *s
/* Enable receiving management packets to the host */
if (sc->sc_type >= WM_T_82571) {
manc |= MANC_EN_MNG2HOST;
- manc2h |= MANC2H_PORT_623| MANC2H_PORT_624;
+ manc2h |= MANC2H_PORT_623 | MANC2H_PORT_624;
CSR_WRITE(sc, WMREG_MANC2H, manc2h);
}
@@ -14006,8 +14014,8 @@ wm_enable_wakeup(struct wm_softc *sc)
if (((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
|| (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
|| (sc->sc_type == WM_T_PCH2))
- && (sc->sc_phytype == WMPHY_IGP_3))
- wm_igp3_phy_powerdown_workaround_ich8lan(sc);
+ && (sc->sc_phytype == WMPHY_IGP_3))
+ wm_igp3_phy_powerdown_workaround_ich8lan(sc);
/* Request PME */
pmode = pci_conf_read(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR);
@@ -14077,8 +14085,7 @@ wm_disable_aspm(struct wm_softc *sc)
/* Print only in wm_attach() */
if ((sc->sc_flags & WM_F_ATTACHED) == 0)
aprint_verbose_dev(sc->sc_dev,
- "ASPM %s disabled to workaround the errata.\n",
- str);
+ "ASPM %s disabled to workaround the errata.\n", str);
}
/* LPLU */
@@ -14311,10 +14318,12 @@ wm_k1_gig_workaround_hv(struct wm_softc
k1_enable = 0;
/* Link stall fix for link up */
- wm_gmii_hv_writereg_locked(sc->sc_dev, 1, IGP3_KMRN_DIAG, 0x0100);
+ wm_gmii_hv_writereg_locked(sc->sc_dev, 1, IGP3_KMRN_DIAG,
+ 0x0100);
} else {
/* Link stall fix for link down */
- wm_gmii_hv_writereg_locked(sc->sc_dev, 1, IGP3_KMRN_DIAG, 0x4100);
+ wm_gmii_hv_writereg_locked(sc->sc_dev, 1, IGP3_KMRN_DIAG,
+ 0x4100);
}
wm_configure_k1_ich8lan(sc, k1_enable);