Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci refactor: rearrange function arguments without i...
details: https://anonhg.NetBSD.org/src/rev/5b4dd7d13282
branches: trunk
changeset: 811115:5b4dd7d13282
user: knakahara <knakahara%NetBSD.org@localhost>
date: Tue Oct 13 08:27:11 2015 +0000
description:
refactor: rearrange function arguments without interrupt handlers
diffstat:
sys/dev/pci/if_wm.c | 295 +++++++++++++++++++++++++--------------------------
1 files changed, 143 insertions(+), 152 deletions(-)
diffs (truncated from 699 to 300 lines):
diff -r 5b5fb5dc02e3 -r 5b4dd7d13282 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Tue Oct 13 08:24:35 2015 +0000
+++ b/sys/dev/pci/if_wm.c Tue Oct 13 08:27:11 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.361 2015/10/13 08:23:31 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.362 2015/10/13 08:27:11 knakahara 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.361 2015/10/13 08:23:31 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.362 2015/10/13 08:27:11 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -534,9 +534,9 @@
/*
* Descriptor sync/init functions.
*/
-static inline void wm_cdtxsync(struct wm_softc *, int, int, int);
-static inline void wm_cdrxsync(struct wm_softc *, int, int);
-static inline void wm_init_rxdesc(struct wm_softc *, int);
+static inline void wm_cdtxsync(struct wm_txqueue *, int, int, int);
+static inline void wm_cdrxsync(struct wm_rxqueue *, int, int);
+static inline void wm_init_rxdesc(struct wm_rxqueue *, int);
/*
* Device driver interface functions and commonly used functions.
@@ -567,8 +567,8 @@
static void wm_initialize_hardware_bits(struct wm_softc *);
static uint32_t wm_rxpbs_adjust_82580(uint32_t);
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_add_rxbuf(struct wm_rxqueue *, int);
+static void wm_rxdrain(struct wm_rxqueue *);
static int wm_init(struct ifnet *);
static int wm_init_locked(struct ifnet *);
static void wm_stop(struct ifnet *, int);
@@ -579,21 +579,21 @@
static void wm_82547_txfifo_stall(void *);
static int wm_82547_txfifo_bugchk(struct wm_softc *, struct mbuf *);
/* DMA related */
-static int wm_alloc_tx_descs(struct wm_softc *);
-static void wm_free_tx_descs(struct wm_softc *);
-static void wm_init_tx_descs(struct wm_softc *);
-static void wm_init_tx_regs(struct wm_softc *);
-static int wm_alloc_rx_descs(struct wm_softc *);
-static void wm_free_rx_descs(struct wm_softc *);
-static void wm_init_rx_regs(struct wm_softc *);
-static int wm_alloc_tx_buffer(struct wm_softc *);
-static void wm_free_tx_buffer(struct wm_softc *);
-static void wm_init_tx_buffer(struct wm_softc *);
-static int wm_alloc_rx_buffer(struct wm_softc *);
-static void wm_free_rx_buffer(struct wm_softc *);
-static int wm_init_rx_buffer(struct wm_softc *);
-static void wm_init_tx_queue(struct wm_softc *);
-static int wm_init_rx_queue(struct wm_softc *);
+static int wm_alloc_tx_descs(struct wm_softc *, struct wm_txqueue *);
+static void wm_free_tx_descs(struct wm_softc *, struct wm_txqueue *);
+static void wm_init_tx_descs(struct wm_softc *, struct wm_txqueue *);
+static void wm_init_tx_regs(struct wm_softc *, struct wm_txqueue *);
+static int wm_alloc_rx_descs(struct wm_softc *, struct wm_rxqueue *);
+static void wm_free_rx_descs(struct wm_softc *, struct wm_rxqueue *);
+static void wm_init_rx_regs(struct wm_softc *, struct wm_rxqueue *);
+static int wm_alloc_tx_buffer(struct wm_softc *, struct wm_txqueue *);
+static void wm_free_tx_buffer(struct wm_softc *, struct wm_txqueue *);
+static void wm_init_tx_buffer(struct wm_softc *, struct wm_txqueue *);
+static int wm_alloc_rx_buffer(struct wm_softc *, struct wm_rxqueue *);
+static void wm_free_rx_buffer(struct wm_softc *, struct wm_rxqueue *);
+static int wm_init_rx_buffer(struct wm_softc *, struct wm_rxqueue *);
+static void wm_init_tx_queue(struct wm_softc *, struct wm_txqueue *);
+static int wm_init_rx_queue(struct wm_softc *, struct wm_rxqueue *);
static int wm_alloc_txrx_queues(struct wm_softc *);
static void wm_free_txrx_queues(struct wm_softc *);
static int wm_init_txrx_queues(struct wm_softc *);
@@ -606,7 +606,7 @@
static void wm_nq_start_locked(struct ifnet *);
/* Interrupt */
static int wm_txeof(struct wm_softc *);
-static void wm_rxeof(struct wm_softc *);
+static void wm_rxeof(struct wm_rxqueue *);
static void wm_linkintr_gmii(struct wm_softc *, uint32_t);
static void wm_linkintr_tbi(struct wm_softc *, uint32_t);
static void wm_linkintr_serdes(struct wm_softc *, uint32_t);
@@ -1352,9 +1352,9 @@
* Descriptor sync/init functions.
*/
static inline void
-wm_cdtxsync(struct wm_softc *sc, int start, int num, int ops)
-{
- struct wm_txqueue *txq = sc->sc_txq;
+wm_cdtxsync(struct wm_txqueue *txq, int start, int num, int ops)
+{
+ struct wm_softc *sc = txq->txq_sc;
/* If it will wrap around, sync to the end of the ring. */
if ((start + num) > WM_NTXDESC(txq)) {
@@ -1371,18 +1371,18 @@
}
static inline void
-wm_cdrxsync(struct wm_softc *sc, int start, int ops)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_cdrxsync(struct wm_rxqueue *rxq, int start, int ops)
+{
+ struct wm_softc *sc = rxq->rxq_sc;
bus_dmamap_sync(sc->sc_dmat, rxq->rxq_desc_dmamap,
WM_CDRXOFF(start), sizeof(wiseman_rxdesc_t), ops);
}
static inline void
-wm_init_rxdesc(struct wm_softc *sc, int start)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_init_rxdesc(struct wm_rxqueue *rxq, int start)
+{
+ struct wm_softc *sc = rxq->rxq_sc;
struct wm_rxsoft *rxs = &rxq->rxq_soft[start];
wiseman_rxdesc_t *rxd = &rxq->rxq_descs[start];
struct mbuf *m = rxs->rxs_mbuf;
@@ -1410,7 +1410,7 @@
rxd->wrx_status = 0;
rxd->wrx_errors = 0;
rxd->wrx_special = 0;
- wm_cdrxsync(sc, start, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+ wm_cdrxsync(rxq, start, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
CSR_WRITE(sc, rxq->rxq_rdt_reg, start);
}
@@ -2601,7 +2601,7 @@
/* Unload RX dmamaps and free mbufs */
WM_RX_LOCK(rxq);
- wm_rxdrain(sc);
+ wm_rxdrain(rxq);
WM_RX_UNLOCK(rxq);
/* Must unlock here */
@@ -3962,9 +3962,9 @@
* Add a receive buffer to the indiciated descriptor.
*/
static int
-wm_add_rxbuf(struct wm_softc *sc, int idx)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_add_rxbuf(struct wm_rxqueue *rxq, int idx)
+{
+ struct wm_softc *sc = rxq->rxq_sc;
struct wm_rxsoft *rxs = &rxq->rxq_soft[idx];
struct mbuf *m;
int error;
@@ -4002,9 +4002,9 @@
if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
if ((sc->sc_rctl & RCTL_EN) != 0)
- wm_init_rxdesc(sc, idx);
+ wm_init_rxdesc(rxq, idx);
} else
- wm_init_rxdesc(sc, idx);
+ wm_init_rxdesc(rxq, idx);
return 0;
}
@@ -4015,9 +4015,9 @@
* Drain the receive queue.
*/
static void
-wm_rxdrain(struct wm_softc *sc)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_rxdrain(struct wm_rxqueue *rxq)
+{
+ struct wm_softc *sc = rxq->rxq_sc;
struct wm_rxsoft *rxs;
int i;
@@ -4613,9 +4613,13 @@
}
/* On 575 and later set RDT only if RX enabled */
- if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
+ if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
+ struct wm_rxqueue *rxq = sc->sc_rxq;
+ WM_RX_LOCK(rxq);
for (i = 0; i < WM_NRXDESC; i++)
- wm_init_rxdesc(sc, i);
+ wm_init_rxdesc(rxq, i);
+ WM_RX_UNLOCK(rxq);
+ }
sc->sc_stopping = false;
@@ -4718,7 +4722,7 @@
if (disable) {
WM_RX_LOCK(rxq);
- wm_rxdrain(sc);
+ wm_rxdrain(rxq);
WM_RX_UNLOCK(rxq);
}
@@ -4913,7 +4917,7 @@
t->tcpip_tucs = htole32(tucs);
t->tcpip_cmdlen = htole32(cmdlen);
t->tcpip_seg = htole32(seg);
- wm_cdtxsync(sc, txq->txq_next, 1, BUS_DMASYNC_PREWRITE);
+ wm_cdtxsync(txq, txq->txq_next, 1, BUS_DMASYNC_PREWRITE);
txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
txs->txs_ndesc++;
@@ -5043,9 +5047,8 @@
}
static int
-wm_alloc_tx_descs(struct wm_softc *sc)
-{
- struct wm_txqueue *txq = sc->sc_txq;
+wm_alloc_tx_descs(struct wm_softc *sc, struct wm_txqueue *txq)
+{
int error;
/*
@@ -5111,9 +5114,8 @@
}
static void
-wm_free_tx_descs(struct wm_softc *sc)
-{
- struct wm_txqueue *txq = sc->sc_txq;
+wm_free_tx_descs(struct wm_softc *sc, struct wm_txqueue *txq)
+{
bus_dmamap_unload(sc->sc_dmat, txq->txq_desc_dmamap);
bus_dmamap_destroy(sc->sc_dmat, txq->txq_desc_dmamap);
@@ -5123,9 +5125,8 @@
}
static int
-wm_alloc_rx_descs(struct wm_softc *sc)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_alloc_rx_descs(struct wm_softc *sc, struct wm_rxqueue *rxq)
+{
int error;
/*
@@ -5184,9 +5185,8 @@
}
static void
-wm_free_rx_descs(struct wm_softc *sc)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_free_rx_descs(struct wm_softc *sc, struct wm_rxqueue *rxq)
+{
bus_dmamap_unload(sc->sc_dmat, rxq->rxq_desc_dmamap);
bus_dmamap_destroy(sc->sc_dmat, rxq->rxq_desc_dmamap);
@@ -5197,9 +5197,8 @@
static int
-wm_alloc_tx_buffer(struct wm_softc *sc)
-{
- struct wm_txqueue *txq = sc->sc_txq;
+wm_alloc_tx_buffer(struct wm_softc *sc, struct wm_txqueue *txq)
+{
int i, error;
/* Create the transmit buffer DMA maps. */
@@ -5229,9 +5228,8 @@
}
static void
-wm_free_tx_buffer(struct wm_softc *sc)
-{
- struct wm_txqueue *txq = sc->sc_txq;
+wm_free_tx_buffer(struct wm_softc *sc, struct wm_txqueue *txq)
+{
int i;
for (i = 0; i < WM_TXQUEUELEN(txq); i++) {
@@ -5242,9 +5240,8 @@
}
static int
-wm_alloc_rx_buffer(struct wm_softc *sc)
-{
- struct wm_rxqueue *rxq = sc->sc_rxq;
+wm_alloc_rx_buffer(struct wm_softc *sc, struct wm_rxqueue *rxq)
+{
int i, error;
/* Create the receive buffer DMA maps. */
Home |
Main Index |
Thread Index |
Old Index