Author: adrian
Date: Tue Jul 31 02:28:32 2012
New Revision: 238930
URL: http://svn.freebsd.org/changeset/base/238930

Log:
  Break out the hardware handoff and TX DMA restart code into methods.
  
  These (and a few others) will differ based on the underlying DMA
  implementation.
  
  For the EDMA NICs, simply stub them out in a fashion which will let
  me focus on implementing the necessary descriptor API changes.

Modified:
  head/sys/dev/ath/if_ath_tx.c
  head/sys/dev/ath/if_ath_tx.h
  head/sys/dev/ath/if_ath_tx_edma.c

Modified: head/sys/dev/ath/if_ath_tx.c
==============================================================================
--- head/sys/dev/ath/if_ath_tx.c        Tue Jul 31 02:18:10 2012        
(r238929)
+++ head/sys/dev/ath/if_ath_tx.c        Tue Jul 31 02:28:32 2012        
(r238930)
@@ -639,8 +639,8 @@ ath_tx_handoff_hw(struct ath_softc *sc, 
  *
  * This must be called whether the queue is empty or not.
  */
-void
-ath_txq_restart_dma(struct ath_softc *sc, struct ath_txq *txq)
+static void
+ath_legacy_tx_dma_restart(struct ath_softc *sc, struct ath_txq *txq)
 {
        struct ath_hal *ah = sc->sc_ah;
        struct ath_buf *bf, *bf_last;
@@ -668,7 +668,8 @@ ath_txq_restart_dma(struct ath_softc *sc
  * The relevant hardware txq should be locked.
  */
 static void
-ath_tx_handoff(struct ath_softc *sc, struct ath_txq *txq, struct ath_buf *bf)
+ath_legacy_xmit_handoff(struct ath_softc *sc, struct ath_txq *txq,
+    struct ath_buf *bf)
 {
        ATH_TXQ_LOCK_ASSERT(txq);
 
@@ -4493,4 +4494,7 @@ ath_xmit_setup_legacy(struct ath_softc *
 
        sc->sc_tx.xmit_setup = ath_legacy_dma_txsetup;
        sc->sc_tx.xmit_teardown = ath_legacy_dma_txteardown;
+
+       sc->sc_tx.xmit_dma_restart = ath_legacy_tx_dma_restart;
+       sc->sc_tx.xmit_handoff = ath_legacy_xmit_handoff;
 }

Modified: head/sys/dev/ath/if_ath_tx.h
==============================================================================
--- head/sys/dev/ath/if_ath_tx.h        Tue Jul 31 02:18:10 2012        
(r238929)
+++ head/sys/dev/ath/if_ath_tx.h        Tue Jul 31 02:28:32 2012        
(r238930)
@@ -79,7 +79,6 @@
 #define        BAW_WITHIN(_start, _bawsz, _seqno)      \
            ((((_seqno) - (_start)) & 4095) < (_bawsz))
 
-extern void ath_txq_restart_dma(struct ath_softc *sc, struct ath_txq *txq);
 extern void ath_freetx(struct mbuf *m);
 extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
 extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
@@ -131,6 +130,10 @@ extern     void ath_addba_response_timeout(s
        (_sc)->sc_tx.xmit_setup(_sc)
 #define        ath_txdma_teardown(_sc)                 \
        (_sc)->sc_tx.xmit_teardown(_sc)
+#define        ath_txq_restart_dma(_sc, _txq)          \
+       (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq))
+#define        ath_tx_handoff(_sc, _txq, _bf)          \
+       (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf))
 extern void ath_xmit_setup_legacy(struct ath_softc *sc);
 
 #endif

Modified: head/sys/dev/ath/if_ath_tx_edma.c
==============================================================================
--- head/sys/dev/ath/if_ath_tx_edma.c   Tue Jul 31 02:18:10 2012        
(r238929)
+++ head/sys/dev/ath/if_ath_tx_edma.c   Tue Jul 31 02:28:32 2012        
(r238930)
@@ -130,6 +130,62 @@ __FBSDID("$FreeBSD$");
 
 MALLOC_DECLARE(M_ATHDEV);
 
+/*
+ * Re-initialise the DMA FIFO with the current contents of
+ * said FIFO.
+ *
+ * This should only be called as part of the chip reset path, as it
+ * assumes the FIFO is currently empty.
+ *
+ * TODO: verify that a cold/warm reset does clear the TX FIFO, so
+ * writing in a partially-filled FIFO will not cause double-entries
+ * to appear.
+ */
+static void
+ath_edma_dma_restart(struct ath_softc *sc, struct ath_txq *txq)
+{
+
+       device_printf(sc->sc_dev, "%s: called: txq=%p, qnum=%d\n",
+           __func__,
+           txq,
+           txq->axq_qnum);
+}
+
+/*
+ * Handoff this frame to the hardware.
+ *
+ * For the multicast queue, this will treat it as a software queue
+ * and append it to the list, after updating the MORE_DATA flag
+ * in the previous frame.  The cabq processing code will ensure
+ * that the queue contents gets transferred over.
+ *
+ * For the hardware queues, this will queue a frame to the queue
+ * like before, then populate the FIFO from that.  Since the
+ * EDMA hardware has 8 FIFO slots per TXQ, this ensures that
+ * frames such as management frames don't get prematurely dropped.
+ *
+ * This does imply that a similar flush-hwq-to-fifoq method will
+ * need to be called from the processq function, before the
+ * per-node software scheduler is called.
+ */
+static void
+ath_edma_xmit_handoff(struct ath_softc *sc, struct ath_txq *txq,
+    struct ath_buf *bf)
+{
+
+       device_printf(sc->sc_dev, "%s: called; bf=%p, txq=%p, qnum=%d\n",
+           __func__,
+           bf,
+           txq,
+           txq->axq_qnum);
+
+       /*
+        * XXX For now this is a placeholder; free the buffer
+        * and inform the stack that the TX failed.
+        */
+       ath_tx_default_comp(sc, bf, 1);
+}
+
 static int
 ath_edma_setup_txfifo(struct ath_softc *sc, int qnum)
 {
@@ -217,4 +273,7 @@ ath_xmit_setup_edma(struct ath_softc *sc
 
        sc->sc_tx.xmit_setup = ath_edma_dma_txsetup;
        sc->sc_tx.xmit_teardown = ath_edma_dma_txteardown;
+
+       sc->sc_tx.xmit_dma_restart = ath_edma_dma_restart;
+       sc->sc_tx.xmit_handoff = ath_edma_xmit_handoff;
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to