Author: br
Date: Thu Jun 27 18:08:18 2019
New Revision: 349466
URL: https://svnweb.freebsd.org/changeset/base/349466

Log:
  Add support for extended descriptor format to Altera mSGDMA driver.
  
  The format to use depends on hardware configuration (synthesis-time),
  so make it compile-time kernel option.
  
  Extended format allows DMA engine to operate with 64-bit memory addresses.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/conf/options
  head/sys/dev/altera/msgdma/msgdma.c
  head/sys/dev/altera/msgdma/msgdma.h
  head/sys/mips/conf/BERI_DE4_BASE

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options       Thu Jun 27 17:59:15 2019        (r349465)
+++ head/sys/conf/options       Thu Jun 27 18:08:18 2019        (r349466)
@@ -861,6 +861,12 @@ AH_INTERRUPT_DEBUGGING     opt_ah.h
 # XXX do not use this for AR9130
 AH_AR5416_INTERRUPT_MITIGATION opt_ah.h
 
+# options for the Altera mSGDMA driver (altera_msgdma)
+ALTERA_MSGDMA_DESC_STD         opt_altera_msgdma.h
+ALTERA_MSGDMA_DESC_EXT         opt_altera_msgdma.h
+ALTERA_MSGDMA_DESC_PF_STD      opt_altera_msgdma.h
+ALTERA_MSGDMA_DESC_PF_EXT      opt_altera_msgdma.h
+
 # options for the Broadcom BCM43xx driver (bwi)
 BWI_DEBUG              opt_bwi.h
 BWI_DEBUG_VERBOSE      opt_bwi.h

Modified: head/sys/dev/altera/msgdma/msgdma.c
==============================================================================
--- head/sys/dev/altera/msgdma/msgdma.c Thu Jun 27 17:59:15 2019        
(r349465)
+++ head/sys/dev/altera/msgdma/msgdma.c Thu Jun 27 18:08:18 2019        
(r349466)
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/xdma/xdma.h>
 #include "xdma_if.h"
+#include "opt_altera_msgdma.h"
 
 #include <dev/altera/msgdma/msgdma.h>
 
@@ -470,8 +471,8 @@ msgdma_channel_submit_sg(device_t dev, struct xdma_cha
        struct msgdma_channel *chan;
        struct msgdma_desc *desc;
        struct msgdma_softc *sc;
-       uint32_t src_addr_lo;
-       uint32_t dst_addr_lo;
+       bus_addr_t src_addr_lo;
+       bus_addr_t dst_addr_lo;
        uint32_t len;
        uint32_t tmp;
        int i;
@@ -481,14 +482,18 @@ msgdma_channel_submit_sg(device_t dev, struct xdma_cha
        chan = (struct msgdma_channel *)xchan->chan;
 
        for (i = 0; i < sg_n; i++) {
-               src_addr_lo = (uint32_t)sg[i].src_addr;
-               dst_addr_lo = (uint32_t)sg[i].dst_addr;
+               src_addr_lo = sg[i].src_addr;
+               dst_addr_lo = sg[i].dst_addr;
                len = (uint32_t)sg[i].len;
 
                dprintf("%s: src %x dst %x len %d\n", __func__,
                    src_addr_lo, dst_addr_lo, len);
 
                desc = chan->descs[chan->idx_head];
+#if defined(ALTERA_MSGDMA_DESC_EXT) || defined(ALTERA_MSGDMA_DESC_PF_EXT)
+               desc->read_hi = htole32(src_addr_lo >> 32);
+               desc->write_hi = htole32(dst_addr_lo >> 32);
+#endif
                desc->read_lo = htole32(src_addr_lo);
                desc->write_lo = htole32(dst_addr_lo);
                desc->length = htole32(len);

Modified: head/sys/dev/altera/msgdma/msgdma.h
==============================================================================
--- head/sys/dev/altera/msgdma/msgdma.h Thu Jun 27 17:59:15 2019        
(r349465)
+++ head/sys/dev/altera/msgdma/msgdma.h Thu Jun 27 18:08:18 2019        
(r349466)
@@ -30,6 +30,8 @@
  * $FreeBSD$
  */
 
+#include "opt_altera_msgdma.h"
+
 /* Altera mSGDMA registers. */
 #define        DMA_STATUS              0x00
 #define         STATUS_RESETTING       (1 << 6)
@@ -75,22 +77,74 @@
 #define        WRITE4_DESC(_sc, _reg, _val)    \
        bus_space_write_4(_sc->bst_d, _sc->bsh_d, _reg, htole32(_val))
 
-/* Prefetcher-disabled descriptor format. */
-struct msgdma_desc_nonpf {
-       uint32_t src_addr;
-       uint32_t dst_addr;
+#if defined(ALTERA_MSGDMA_DESC_STD)
+
+/* Standard descriptor format with prefetcher disabled. */
+struct msgdma_desc {
+       uint32_t read_lo;
+       uint32_t write_lo;
        uint32_t length;
        uint32_t control;
 };
 
-/* Prefetcher-enabled descriptor format. */
+#elif defined(ALTERA_MSGDMA_DESC_EXT)
+
+/* Extended descriptor format with prefetcher disabled. */
 struct msgdma_desc {
        uint32_t read_lo;
        uint32_t write_lo;
        uint32_t length;
+       uint8_t write_burst;
+       uint8_t read_burst;
+       uint16_t seq_num;
+       uint16_t write_stride;
+       uint16_t read_stride;
+       uint32_t read_hi;
+       uint32_t write_hi;
+       uint32_t control;
+};
+
+#elif defined(ALTERA_MSGDMA_DESC_PF_STD)
+
+/* Standard descriptor format with prefetcher enabled. */
+struct msgdma_desc {
+       uint32_t read_lo;
+       uint32_t write_lo;
+       uint32_t length;
        uint32_t next;
        uint32_t transferred;
        uint32_t status;
        uint32_t reserved;
        uint32_t control;
 };
+
+#elif defined(ALTERA_MSGDMA_DESC_PF_EXT)
+
+/* Extended descriptor format with prefetcher enabled. */
+struct msgdma_desc {
+       uint32_t read_lo;
+       uint32_t write_lo;
+       uint32_t length;
+       uint32_t next;
+       uint32_t transferred;
+       uint32_t status;
+       uint32_t reserved;
+       uint8_t write_burst;
+       uint8_t read_burst;
+       uint16_t seq_num;
+       uint16_t write_stride;
+       uint16_t read_stride;
+       uint32_t read_hi;
+       uint32_t write_hi;
+       uint32_t next_hi;
+       uint32_t reserved1;
+       uint32_t reserved2;
+       uint32_t reserved3;
+       uint32_t control;
+};
+
+#else
+
+#error "mSGDMA descriptor format (kernel option) is not set."
+
+#endif

Modified: head/sys/mips/conf/BERI_DE4_BASE
==============================================================================
--- head/sys/mips/conf/BERI_DE4_BASE    Thu Jun 27 17:59:15 2019        
(r349465)
+++ head/sys/mips/conf/BERI_DE4_BASE    Thu Jun 27 18:08:18 2019        
(r349466)
@@ -44,6 +44,7 @@ options       DEVICE_POLLING
 #
 # DMA support
 #
+options                ALTERA_MSGDMA_DESC_PF_STD
 device         xdma
 device         altera_softdma
 device         altera_msgdma
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to