aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2023-09-28 20:34:47 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2023-10-05 15:34:39 +0000
commitafa0f66e81ccd6a946133bb9aceaf1fe59370431 (patch)
tree3ca7201fdf5cae4803e323c48c713b9a09ed0e94
parent62519d5a4f719a420803a3a0823268da6e950fcb (diff)
downloadsrc-afa0f66e81ccd6a946133bb9aceaf1fe59370431.tar.gz
src-afa0f66e81ccd6a946133bb9aceaf1fe59370431.zip
dwc: Move the txstart dma part to dwc1000_dma
This is dma related to move it to the dma file. No functional changes intended.
-rw-r--r--sys/dev/dwc/dwc1000_dma.c48
-rw-r--r--sys/dev/dwc/dwc1000_dma.h8
-rw-r--r--sys/dev/dwc/if_dwc.c36
3 files changed, 50 insertions, 42 deletions
diff --git a/sys/dev/dwc/dwc1000_dma.c b/sys/dev/dwc/dwc1000_dma.c
index a04f65de8501..505e3fcaebef 100644
--- a/sys/dev/dwc/dwc1000_dma.c
+++ b/sys/dev/dwc/dwc1000_dma.c
@@ -60,6 +60,15 @@
#include <dev/dwc/dwc1000_reg.h>
#include <dev/dwc/dwc1000_dma.h>
+#define WATCHDOG_TIMEOUT_SECS 5
+
+static inline uint32_t
+next_txidx(struct dwc_softc *sc, uint32_t curidx)
+{
+
+ return ((curidx + 1) % TX_DESC_COUNT);
+}
+
static inline uint32_t
next_rxidx(struct dwc_softc *sc, uint32_t curidx)
{
@@ -373,6 +382,45 @@ dma1000_txfinish_locked(struct dwc_softc *sc)
}
void
+dma1000_txstart(struct dwc_softc *sc)
+{
+ int enqueued;
+ struct mbuf *m;
+
+ enqueued = 0;
+
+ for (;;) {
+ if (sc->tx_desccount > (TX_DESC_COUNT - TX_MAP_MAX_SEGS + 1)) {
+ if_setdrvflagbits(sc->ifp, IFF_DRV_OACTIVE, 0);
+ break;
+ }
+
+ if (sc->tx_mapcount == (TX_MAP_COUNT - 1)) {
+ if_setdrvflagbits(sc->ifp, IFF_DRV_OACTIVE, 0);
+ break;
+ }
+
+ m = if_dequeue(sc->ifp);
+ if (m == NULL)
+ break;
+ if (dma1000_setup_txbuf(sc, sc->tx_map_head, &m) != 0) {
+ if_sendq_prepend(sc->ifp, m);
+ if_setdrvflagbits(sc->ifp, IFF_DRV_OACTIVE, 0);
+ break;
+ }
+ bpf_mtap_if(sc->ifp, m);
+ sc->tx_map_head = next_txidx(sc, sc->tx_map_head);
+ sc->tx_mapcount++;
+ ++enqueued;
+ }
+
+ if (enqueued != 0) {
+ WRITE4(sc, TRANSMIT_POLL_DEMAND, 0x1);
+ sc->tx_watchdog_count = WATCHDOG_TIMEOUT_SECS;
+ }
+}
+
+void
dma1000_rxfinish_locked(struct dwc_softc *sc)
{
struct mbuf *m;
diff --git a/sys/dev/dwc/dwc1000_dma.h b/sys/dev/dwc/dwc1000_dma.h
index 613faeee91ff..97cebd07f215 100644
--- a/sys/dev/dwc/dwc1000_dma.h
+++ b/sys/dev/dwc/dwc1000_dma.h
@@ -149,12 +149,6 @@ void dma1000_stop(struct dwc_softc *sc);
int dma1000_setup_txbuf(struct dwc_softc *sc, int idx, struct mbuf **mp);
void dma1000_txfinish_locked(struct dwc_softc *sc);
void dma1000_rxfinish_locked(struct dwc_softc *sc);
-
-static inline uint32_t
-next_txidx(struct dwc_softc *sc, uint32_t curidx)
-{
-
- return ((curidx + 1) % TX_DESC_COUNT);
-}
+void dma1000_txstart(struct dwc_softc *sc);
#endif /* __DWC1000_DMA_H__ */
diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
index 29f78dd94a9a..107158cebf02 100644
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -79,7 +79,6 @@
#include "miibus_if.h"
#define MAC_RESET_TIMEOUT 100
-#define WATCHDOG_TIMEOUT_SECS 5
static struct resource_spec dwc_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
@@ -139,8 +138,6 @@ static void
dwc_txstart_locked(struct dwc_softc *sc)
{
if_t ifp;
- struct mbuf *m;
- int enqueued;
DWC_ASSERT_LOCKED(sc);
@@ -152,38 +149,7 @@ dwc_txstart_locked(struct dwc_softc *sc)
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return;
-
- enqueued = 0;
-
- for (;;) {
- if (sc->tx_desccount > (TX_DESC_COUNT - TX_MAP_MAX_SEGS + 1)) {
- if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
- break;
- }
-
- if (sc->tx_mapcount == (TX_MAP_COUNT - 1)) {
- if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
- break;
- }
-
- m = if_dequeue(ifp);
- if (m == NULL)
- break;
- if (dma1000_setup_txbuf(sc, sc->tx_map_head, &m) != 0) {
- if_sendq_prepend(ifp, m);
- if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
- break;
- }
- bpf_mtap_if(ifp, m);
- sc->tx_map_head = next_txidx(sc, sc->tx_map_head);
- sc->tx_mapcount++;
- ++enqueued;
- }
-
- if (enqueued != 0) {
- WRITE4(sc, TRANSMIT_POLL_DEMAND, 0x1);
- sc->tx_watchdog_count = WATCHDOG_TIMEOUT_SECS;
- }
+ dma1000_txstart(sc);
}
static void