From: Govindarajulu Varadarajan <_govind@gmx.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: ssujith@cisco.com, benve@cisco.com,
Govindarajulu Varadarajan <_govind@gmx.com>
Subject: [PATCH net-next v3 2/2] enic: use netdev_dma_alloc
Date: Tue, 10 Mar 2015 23:13:04 +0530 [thread overview]
Message-ID: <1426009384-11544-3-git-send-email-_govind@gmx.com> (raw)
In-Reply-To: <1426009384-11544-1-git-send-email-_govind@gmx.com>
This patches uses dma cache skb allocator fot rx buffers.
netdev_dma_head is initialized per rq. All calls to netdev_dma_alloc_skb() and
netdev_dma_frag_unmap() happens in napi_poll and they are serialized.
Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
---
drivers/net/ethernet/cisco/enic/enic_main.c | 31 +++++++++--------------------
drivers/net/ethernet/cisco/enic/vnic_rq.c | 3 +++
drivers/net/ethernet/cisco/enic/vnic_rq.h | 3 +++
3 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 204bd182..3be5bc12 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -952,13 +952,9 @@ nla_put_failure:
static void enic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
{
- struct enic *enic = vnic_dev_priv(rq->vdev);
-
if (!buf->os_buf)
return;
-
- pci_unmap_single(enic->pdev, buf->dma_addr,
- buf->len, PCI_DMA_FROMDEVICE);
+ netdev_dma_frag_unmap(&rq->nc_head, buf->nc);
dev_kfree_skb_any(buf->os_buf);
buf->os_buf = NULL;
}
@@ -979,17 +975,10 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq)
return 0;
}
- skb = netdev_alloc_skb_ip_align(netdev, len);
+ skb = netdev_dma_alloc_skb(&rq->nc_head, &buf->nc, &dma_addr, len);
if (!skb)
return -ENOMEM;
- dma_addr = pci_map_single(enic->pdev, skb->data, len,
- PCI_DMA_FROMDEVICE);
- if (unlikely(enic_dma_map_check(enic, dma_addr))) {
- dev_kfree_skb(skb);
- return -ENOMEM;
- }
-
enic_queue_rq_desc(rq, skb, os_buf_index,
dma_addr, len);
@@ -1016,8 +1005,6 @@ static bool enic_rxcopybreak(struct net_device *netdev, struct sk_buff **skb,
new_skb = netdev_alloc_skb_ip_align(netdev, len);
if (!new_skb)
return false;
- pci_dma_sync_single_for_cpu(enic->pdev, buf->dma_addr, len,
- DMA_FROM_DEVICE);
memcpy(new_skb->data, (*skb)->data, len);
*skb = new_skb;
@@ -1065,8 +1052,7 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
enic->rq_truncated_pkts++;
}
- pci_unmap_single(enic->pdev, buf->dma_addr, buf->len,
- PCI_DMA_FROMDEVICE);
+ netdev_dma_frag_unmap(&rq->nc_head, buf->nc);
dev_kfree_skb_any(skb);
buf->os_buf = NULL;
@@ -1078,10 +1064,11 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
/* Good receive
*/
+ pci_dma_sync_single_for_cpu(enic->pdev, buf->dma_addr,
+ bytes_written, DMA_FROM_DEVICE);
if (!enic_rxcopybreak(netdev, &skb, buf, bytes_written)) {
buf->os_buf = NULL;
- pci_unmap_single(enic->pdev, buf->dma_addr, buf->len,
- PCI_DMA_FROMDEVICE);
+ netdev_dma_frag_unmap(&rq->nc_head, buf->nc);
}
prefetch(skb->data - NET_IP_ALIGN);
@@ -1122,9 +1109,7 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
/* Buffer overflow
*/
-
- pci_unmap_single(enic->pdev, buf->dma_addr, buf->len,
- PCI_DMA_FROMDEVICE);
+ netdev_dma_frag_unmap(&rq->nc_head, buf->nc);
dev_kfree_skb_any(skb);
buf->os_buf = NULL;
}
@@ -1648,6 +1633,8 @@ static int enic_open(struct net_device *netdev)
}
for (i = 0; i < enic->rq_count; i++) {
+ netdev_dma_init(&enic->rq[i].nc_head, &enic->pdev->dev,
+ GFP_ATOMIC);
vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf);
/* Need at least one buffer on ring to get going */
if (vnic_rq_desc_used(&enic->rq[i]) == 0) {
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c b/drivers/net/ethernet/cisco/enic/vnic_rq.c
index 36a2ed6..afa1d71 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c
@@ -23,6 +23,7 @@
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/skbuff.h>
#include "vnic_dev.h"
#include "vnic_rq.h"
@@ -199,6 +200,8 @@ void vnic_rq_clean(struct vnic_rq *rq,
rq->ring.desc_avail++;
}
+ netdev_dma_destroy(&rq->nc_head);
+
/* Use current fetch_index as the ring starting point */
fetch_index = ioread32(&rq->ctrl->fetch_index);
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethernet/cisco/enic/vnic_rq.h
index 8111d52..d4ee963 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.h
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h
@@ -21,6 +21,7 @@
#define _VNIC_RQ_H_
#include <linux/pci.h>
+#include <linux/skbuff.h>
#include "vnic_dev.h"
#include "vnic_cq.h"
@@ -73,6 +74,7 @@ struct vnic_rq_buf {
unsigned int index;
void *desc;
uint64_t wr_id;
+ struct netdev_dma_node *nc;
};
struct vnic_rq {
@@ -100,6 +102,7 @@ struct vnic_rq {
unsigned int bpoll_state;
spinlock_t bpoll_lock;
#endif /* CONFIG_NET_RX_BUSY_POLL */
+ struct netdev_dma_head nc_head;
};
static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
--
2.3.2
next prev parent reply other threads:[~2015-03-10 17:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 17:43 [PATCH net-next v3 0/2] introduce dma frag allocation and reduce dma mapping Govindarajulu Varadarajan
2015-03-10 17:43 ` [PATCH net-next v3 1/2] net: implement dma cache skb allocator Govindarajulu Varadarajan
2015-03-10 20:33 ` Alexander Duyck
2015-03-11 8:57 ` Govindarajulu Varadarajan
2015-03-11 13:55 ` Alexander Duyck
2015-03-11 15:42 ` Eric Dumazet
2015-03-11 17:06 ` David Laight
2015-03-14 20:08 ` Ben Hutchings
2015-03-10 17:43 ` Govindarajulu Varadarajan [this message]
2015-03-10 20:14 ` [PATCH net-next v3 2/2] enic: use netdev_dma_alloc Alexander Duyck
2015-03-11 9:27 ` Govindarajulu Varadarajan
2015-03-11 14:00 ` Alexander Duyck
2015-03-11 17:34 ` David Laight
2015-03-11 17:51 ` Alexander Duyck
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=1426009384-11544-3-git-send-email-_govind@gmx.com \
--to=_govind@gmx.com \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=ssujith@cisco.com \
/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).