summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/files
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-05-06 21:19:14 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-05-06 21:19:14 +0000
commit0ff3c396d39e762cb0230eb84b9bd1d29dddc520 (patch)
tree25a23535641b48d2b83e90e007c977404cade1b7 /target/linux/ar71xx/files
parentc3f0b757a3bd952f8d85753cd975618a3008ab36 (diff)
downloadmtk-20170518-0ff3c396d39e762cb0230eb84b9bd1d29dddc520.zip
mtk-20170518-0ff3c396d39e762cb0230eb84b9bd1d29dddc520.tar.gz
mtk-20170518-0ff3c396d39e762cb0230eb84b9bd1d29dddc520.tar.bz2
kernel: rewrite the phy packet hook, put it in the network stack to avoid having to keep non-upstream ethernet driver changes
SVN-Revision: 31637
Diffstat (limited to 'target/linux/ar71xx/files')
-rw-r--r--target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 4687e20..6d1aff7 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -196,28 +196,24 @@ static void ag71xx_ring_rx_clean(struct ag71xx *ag)
}
}
-static int ag71xx_rx_reserve(struct ag71xx *ag)
+struct sk_buff *ag71xx_rx_alloc(struct ag71xx *ag)
{
- int reserve = 0;
-
- if (ag71xx_get_pdata(ag)->is_ar724x) {
- if (!ag71xx_has_ar8216(ag))
- reserve = 2;
-
- if (ag->phy_dev)
- reserve += 4 - (ag->phy_dev->pkt_align % 4);
-
- reserve %= 4;
- }
+ /*
+ * On AR71xx/AR91xx packets must be 4-byte aligned.
+ *
+ * When using builtin AR8216 support, hardware adds a 2-byte header,
+ * so we don't need any extra alignment in that case.
+ */
+ if (!ag71xx_get_pdata(ag)->is_ar724x || ag71xx_has_ar8216(ag))
+ return netdev_alloc_skb(ag->dev, AG71XX_RX_PKT_SIZE);
- return reserve + AG71XX_RX_PKT_RESERVE;
+ return netdev_alloc_skb_ip_align(ag->dev, AG71XX_RX_PKT_SIZE);
}
static int ag71xx_ring_rx_init(struct ag71xx *ag)
{
struct ag71xx_ring *ring = &ag->rx_ring;
- unsigned int reserve = ag71xx_rx_reserve(ag);
unsigned int i;
int ret;
@@ -235,15 +231,13 @@ static int ag71xx_ring_rx_init(struct ag71xx *ag)
struct sk_buff *skb;
dma_addr_t dma_addr;
- skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE + reserve);
+ skb = ag71xx_rx_alloc(ag);
if (!skb) {
ret = -ENOMEM;
break;
}
skb->dev = ag->dev;
- skb_reserve(skb, reserve);
-
dma_addr = dma_map_single(&ag->dev->dev, skb->data,
AG71XX_RX_PKT_SIZE,
DMA_FROM_DEVICE);
@@ -265,7 +259,6 @@ static int ag71xx_ring_rx_init(struct ag71xx *ag)
static int ag71xx_ring_rx_refill(struct ag71xx *ag)
{
struct ag71xx_ring *ring = &ag->rx_ring;
- unsigned int reserve = ag71xx_rx_reserve(ag);
unsigned int count;
count = 0;
@@ -278,11 +271,10 @@ static int ag71xx_ring_rx_refill(struct ag71xx *ag)
dma_addr_t dma_addr;
struct sk_buff *skb;
- skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE + reserve);
+ skb = ag71xx_rx_alloc(ag);
if (skb == NULL)
break;
- skb_reserve(skb, reserve);
skb->dev = ag->dev;
dma_addr = dma_map_single(&ag->dev->dev, skb->data,
@@ -914,12 +906,8 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
} else {
skb->dev = dev;
skb->ip_summed = CHECKSUM_NONE;
- if (ag->phy_dev) {
- ag->phy_dev->netif_receive_skb(skb);
- } else {
- skb->protocol = eth_type_trans(skb, dev);
- netif_receive_skb(skb);
- }
+ skb->protocol = eth_type_trans(skb, dev);
+ netif_receive_skb(skb);
}
ring->buf[i].skb = NULL;