[PATCH 4/5] macb: implement alloc_packet & free_packet
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Fri Mar 2 13:20:09 EST 2012
We need to have a non cached buffer.
Need when MMU enabled.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/net/macb.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index d79da72..9b54afa 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -50,6 +50,7 @@
#include <mach/board.h>
#include <linux/clk.h>
#include <linux/err.h>
+#include <asm/mmu.h>
#include "macb.h"
@@ -391,6 +392,16 @@ static int macb_set_ethaddr(struct eth_device *edev, unsigned char *adr)
return 0;
}
+static void *macb_alloc_packet(struct eth_device* edev)
+{
+ return dma_alloc_coherent(PKTSIZE);
+}
+
+static void macb_free_packet(struct eth_device* edev, void *packet)
+{
+ dma_free_coherent(packet, PKTSIZE);
+}
+
static int macb_probe(struct device_d *dev)
{
struct eth_device *edev;
@@ -420,6 +431,8 @@ static int macb_probe(struct device_d *dev)
edev->halt = macb_halt;
edev->get_ethaddr = pdata->get_ethaddr ? pdata->get_ethaddr : macb_get_ethaddr;
edev->set_ethaddr = macb_set_ethaddr;
+ edev->alloc_packet = macb_alloc_packet;
+ edev->free_packet = macb_free_packet;
edev->parent = dev;
macb->miidev.read = macb_phy_read;
@@ -431,9 +444,9 @@ static int macb_probe(struct device_d *dev)
macb->miidev.parent = dev;
macb->flags = pdata->flags;
- macb->rx_buffer = xmalloc(CFG_MACB_RX_BUFFER_SIZE);
- macb->rx_ring = xmalloc(CFG_MACB_RX_RING_SIZE * sizeof(struct macb_dma_desc));
- macb->tx_ring = xmalloc(sizeof(struct macb_dma_desc));
+ macb->rx_buffer = dma_alloc_coherent(CFG_MACB_RX_BUFFER_SIZE);
+ macb->rx_ring = dma_alloc_coherent(CFG_MACB_RX_RING_SIZE * sizeof(struct macb_dma_desc));
+ macb->tx_ring = dma_alloc_coherent(sizeof(struct macb_dma_desc));
macb->regs = dev_request_mem_region(dev, 0);
--
1.7.7
More information about the barebox
mailing list