From: David Woodhouse <dwmw2@infradead.org>
To: netdev@vger.kernel.org
Subject: [PATCH 14/30] solos: First attempt at DMA support
Date: Tue, 17 Mar 2009 21:29:26 +0000 [thread overview]
Message-ID: <1237325366.27681.343.camel@macbook.infradead.org> (raw)
In-Reply-To: <1237310370.27681.314.camel@macbook.infradead.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
drivers/atm/solos-pci.c | 118 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 90 insertions(+), 28 deletions(-)
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index b7d4af3..63c9ad0 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -55,6 +55,8 @@
#define FLASH_BUSY 0x60
#define FPGA_MODE 0x5C
#define FLASH_MODE 0x58
+#define TX_DMA_ADDR(port) (0x40 + (4 * (port)))
+#define RX_DMA_ADDR(port) (0x30 + (4 * (port)))
#define DATA_RAM_SIZE 32768
#define BUF_SIZE 4096
@@ -78,6 +80,14 @@ struct pkt_hdr {
__le16 type;
};
+struct solos_skb_cb {
+ struct atm_vcc *vcc;
+ uint32_t dma_addr;
+};
+
+
+#define SKB_CB(skb) ((struct solos_skb_cb *)skb->cb)
+
#define PKT_DATA 0
#define PKT_COMMAND 1
#define PKT_POPEN 3
@@ -98,8 +108,11 @@ struct solos_card {
struct list_head param_queue;
struct sk_buff_head tx_queue[4];
struct sk_buff_head cli_queue[4];
+ struct sk_buff *tx_skb[4];
+ struct sk_buff *rx_skb[4];
wait_queue_head_t param_wq;
wait_queue_head_t fw_wq;
+ int using_dma;
};
@@ -588,44 +601,64 @@ void solos_bh(unsigned long card_arg)
for (port = 0; port < card->nr_ports; port++) {
if (card_flags & (0x10 << port)) {
- struct pkt_hdr header;
+ struct pkt_hdr _hdr, *header;
struct sk_buff *skb;
struct atm_vcc *vcc;
int size;
- rx_done |= 0x10 << port;
+ if (card->using_dma) {
+ skb = card->rx_skb[port];
+ pci_unmap_single(card->dev, SKB_CB(skb)->dma_addr, skb->len,
+ PCI_DMA_FROMDEVICE);
+
+ card->rx_skb[port] = alloc_skb(2048, GFP_ATOMIC);
+ if (card->rx_skb[port]) {
+ SKB_CB(card->rx_skb[port])->dma_addr =
+ pci_map_single(card->dev, skb->data, skb->len,
+ PCI_DMA_FROMDEVICE);
+ iowrite32(SKB_CB(card->rx_skb[port])->dma_addr,
+ card->config_regs + RX_DMA_ADDR(port));
+ }
+ header = (void *)skb->data;
+ size = le16_to_cpu(header->size);
+ skb_put(skb, size + sizeof(*header));
+ skb_pull(skb, sizeof(*header));
+ } else {
+ header = &_hdr;
- memcpy_fromio(&header, RX_BUF(card, port), sizeof(header));
+ rx_done |= 0x10 << port;
- size = le16_to_cpu(header.size);
+ memcpy_fromio(header, RX_BUF(card, port), sizeof(*header));
- skb = alloc_skb(size + 1, GFP_ATOMIC);
- if (!skb) {
- if (net_ratelimit())
- dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
- continue;
- }
+ size = le16_to_cpu(header->size);
- memcpy_fromio(skb_put(skb, size),
- RX_BUF(card, port) + sizeof(header),
- size);
+ skb = alloc_skb(size + 1, GFP_ATOMIC);
+ if (!skb) {
+ if (net_ratelimit())
+ dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
+ continue;
+ }
+ memcpy_fromio(skb_put(skb, size),
+ RX_BUF(card, port) + sizeof(*header),
+ size);
+ }
if (atmdebug) {
dev_info(&card->dev->dev, "Received: device %d\n", port);
dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n",
- size, le16_to_cpu(header.vpi),
- le16_to_cpu(header.vci));
+ size, le16_to_cpu(header->vpi),
+ le16_to_cpu(header->vci));
print_buffer(skb);
}
- switch (le16_to_cpu(header.type)) {
+ switch (le16_to_cpu(header->type)) {
case PKT_DATA:
- vcc = find_vcc(card->atmdev[port], le16_to_cpu(header.vpi),
- le16_to_cpu(header.vci));
+ vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi),
+ le16_to_cpu(header->vci));
if (!vcc) {
if (net_ratelimit())
dev_warn(&card->dev->dev, "Received packet for unknown VCI.VPI %d.%d on port %d\n",
- le16_to_cpu(header.vci), le16_to_cpu(header.vpi),
+ le16_to_cpu(header->vci), le16_to_cpu(header->vpi),
port);
continue;
}
@@ -839,7 +872,7 @@ static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
{
int old_len;
- *(void **)skb->cb = vcc;
+ SKB_CB(skb)->vcc = vcc;
spin_lock(&card->tx_queue_lock);
old_len = skb_queue_len(&card->tx_queue[port]);
@@ -881,17 +914,37 @@ static int fpga_tx(struct solos_card *card)
port);
print_buffer(skb);
}
- memcpy_toio(TX_BUF(card, port), skb->data, skb->len);
+ if (card->using_dma) {
+ if (card->tx_skb[port]) {
+ struct sk_buff *oldskb = card->tx_skb[port];
- vcc = *(void **)skb->cb;
+ pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr,
+ oldskb->len, PCI_DMA_TODEVICE);
- if (vcc) {
- atomic_inc(&vcc->stats->tx);
- solos_pop(vcc, skb);
- } else
- dev_kfree_skb_irq(skb);
+ vcc = SKB_CB(oldskb)->vcc;
- tx_started |= 1 << port; //Set TX full flag
+ if (vcc) {
+ atomic_inc(&vcc->stats->tx);
+ solos_pop(vcc, oldskb);
+ } else
+ dev_kfree_skb_irq(oldskb);
+ }
+
+ SKB_CB(skb)->dma_addr = pci_map_single(card->dev, skb->data,
+ skb->len, PCI_DMA_TODEVICE);
+ iowrite32(SKB_CB(skb)->dma_addr, card->config_regs + TX_DMA_ADDR(port));
+ } else {
+ memcpy_toio(TX_BUF(card, port), skb->data, skb->len);
+ tx_started |= 1 << port; //Set TX full flag
+
+ vcc = SKB_CB(skb)->vcc;
+
+ if (vcc) {
+ atomic_inc(&vcc->stats->tx);
+ solos_pop(vcc, skb);
+ } else
+ dev_kfree_skb_irq(skb);
+ }
}
}
if (tx_started)
@@ -999,6 +1052,12 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
goto out;
}
+ err = pci_set_dma_mask(dev, DMA_32BIT_MASK);
+ if (err) {
+ dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n");
+ goto out;
+ }
+
err = pci_request_regions(dev, "solos");
if (err) {
dev_warn(&dev->dev, "Failed to request regions\n");
@@ -1035,6 +1094,9 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n",
major_ver, minor_ver, fpga_ver);
+ if (fpga_ver > 27)
+ card->using_dma = 1;
+
card->nr_ports = 2; /* FIXME: Detect daughterboard */
pci_set_drvdata(dev, card);
--
1.6.0.6
next prev parent reply other threads:[~2009-03-17 21:29 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 17:19 [GIT *] Solos PCI ADSL card update David Woodhouse
2009-03-17 19:23 ` David Miller
2009-03-17 20:41 ` Stephen Hemminger
2009-03-17 21:36 ` David Woodhouse
2009-03-17 21:33 ` David Woodhouse
2009-03-17 21:29 ` [PATCH 01/30] solos: Fix length header in FPGA transfers David Woodhouse
2009-03-17 21:29 ` [PATCH 02/30] solos: Slight debugging improvements David Woodhouse
2009-03-17 21:29 ` [PATCH 03/30] solos: FPGA and firmware update support David Woodhouse
2009-03-17 21:29 ` [PATCH 04/30] solos: Clean up firmware loading code David Woodhouse
2009-03-17 21:29 ` [PATCH 05/30] solos: Kill global 'opens' count David Woodhouse
2009-03-17 21:29 ` [PATCH 06/30] solos: Handle attribute show/store in kernel more sanely David Woodhouse
2009-03-17 22:44 ` Stephen Hemminger
2009-03-17 22:49 ` David Woodhouse
2009-03-21 20:22 ` David Miller
2009-03-17 21:29 ` [PATCH 08/30] solos: Handle new line status change packets, hook up to ATM layer info David Woodhouse
2009-03-17 21:29 ` [PATCH 07/30] solos: Add initial list of parameters David Woodhouse
2009-03-17 21:29 ` [PATCH 09/30] solos: Kill existing connections on link down event David Woodhouse
2009-03-17 21:29 ` [PATCH 10/30] solos: Reject non-AAL5 connections.... for now David Woodhouse
2009-03-17 21:29 ` [PATCH 11/30] solos: Add SNR and Attn to status packet, fix oops on load David Woodhouse
2009-03-17 21:29 ` [PATCH 12/30] solos: Fix under-allocation of skb size for get/set parameters David Woodhouse
2009-03-17 21:29 ` [PATCH 13/30] solos: Remove parameter group from sysfs on ATM dev deregister David Woodhouse
2009-03-17 21:29 ` David Woodhouse [this message]
2009-03-17 21:29 ` [PATCH 15/30] solos: Tidy up DMA handling a little. Still untested David Woodhouse
2009-03-17 21:29 ` [PATCH 16/30] solos: Tidy up tx_mask handling for ports which need TX David Woodhouse
2009-03-17 21:29 ` [PATCH 18/30] solos: Remove IRQF_DISABLED, don't frob IRQ enable on the FPGA in solos_irq() David Woodhouse
2009-03-17 21:29 ` [PATCH 17/30] solos: Remove unused loopback debug stuff David Woodhouse
2009-03-17 21:29 ` [PATCH 19/30] solos: Remove superfluous wait_queue_head_t from struct solos_param David Woodhouse
2009-03-17 21:29 ` [PATCH 21/30] solos: Clean up handling of card->tx_mask a little David Woodhouse
2009-03-17 21:29 ` [PATCH 20/30] solos: Fix various bugs in status packet handling David Woodhouse
2009-03-17 21:29 ` [PATCH 23/30] solos: Add 'reset' module parameter to reset the DSL chips on load David Woodhouse
2009-03-17 21:29 ` [PATCH 22/30] solos: Remove debugging, commented-out test code David Woodhouse
2009-03-17 21:29 ` [PATCH 24/30] solos: Tidy up status interrupt handling, cope with 'ERROR' status David Woodhouse
2009-03-17 21:29 ` [PATCH 26/30] solos: Set RX empty flag at startup only for !dma mode David Woodhouse
2009-03-17 21:29 ` [PATCH 25/30] solos: Don't clear config registers at startup David Woodhouse
2009-03-17 21:29 ` [PATCH 27/30] solos: Swap upstream/downstream rates in status packet, clean up some more David Woodhouse
2009-03-17 21:29 ` [PATCH 28/30] solos: Reset device on unload, free pending skbs David Woodhouse
2009-03-17 21:29 ` [PATCH 29/30] solos: Automatically determine number of ports David Woodhouse
2009-03-17 21:29 ` [PATCH 30/30] solos: Disable DMA until we have an FPGA update with it actually implemented David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237325366.27681.343.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).