* More updates to bcm63xx
@ 2009-06-02 23:47 Maxime Bizon
2009-06-02 23:47 ` [PATCH 1/3] bcm63xx: don't use BUS_ID_SIZE in bcm63xx_enet Maxime Bizon
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Maxime Bizon @ 2009-06-02 23:47 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: Florian Fainelli
Hi Ralf,
Could you please fold the following patches in the bcm63xx tree ?
Thanks,
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] bcm63xx: don't use BUS_ID_SIZE in bcm63xx_enet.
2009-06-02 23:47 More updates to bcm63xx Maxime Bizon
@ 2009-06-02 23:47 ` Maxime Bizon
2009-06-02 23:47 ` [PATCH 2/3] bcm63xx: make it possible to change MTU on bcm63xx_enet Maxime Bizon
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Maxime Bizon @ 2009-06-02 23:47 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: Florian Fainelli, Maxime Bizon
Networking recently got rid of BUS_ID_SIZE. Use MII_BUS_ID_SIZE
instead in bcm63xx_enet.
Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
drivers/net/bcm63xx_enet.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index 36324b3..af0114a 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -793,7 +793,7 @@ static int bcm_enet_open(struct net_device *dev)
struct phy_device *phydev;
int i, ret;
unsigned int size;
- char phy_id[BUS_ID_SIZE];
+ char phy_id[MII_BUS_ID_SIZE + 3];
void *p;
u32 val;
@@ -802,7 +802,7 @@ static int bcm_enet_open(struct net_device *dev)
if (priv->has_phy) {
/* connect to PHY */
- snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT,
+ snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
priv->mac_id ? "1" : "0", priv->phy_id);
phydev = phy_connect(dev, phy_id, &bcm_enet_adjust_phy_link, 0,
--
1.6.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] bcm63xx: make it possible to change MTU on bcm63xx_enet.
2009-06-02 23:47 More updates to bcm63xx Maxime Bizon
2009-06-02 23:47 ` [PATCH 1/3] bcm63xx: don't use BUS_ID_SIZE in bcm63xx_enet Maxime Bizon
@ 2009-06-02 23:47 ` Maxime Bizon
2009-06-02 23:47 ` [PATCH 3/3] bcm63xx: use NET_IP_ALIGN Maxime Bizon
2009-06-03 6:06 ` More updates to bcm63xx Ralf Baechle
3 siblings, 0 replies; 9+ messages in thread
From: Maxime Bizon @ 2009-06-02 23:47 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: Florian Fainelli, Maxime Bizon
bcm63xx integrated ethernet mac supports receiving and sending frames
bigger than 1500 bytes, this patch adds support for changing MTU.
This patch also fixes the reception of 802.1q frames for default MTU
which were reported as oversized.
Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
drivers/net/bcm63xx_enet.c | 71 +++++++++++++++++++++++++++++++++++++++-----
drivers/net/bcm63xx_enet.h | 15 +++++++--
2 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index af0114a..322ed03 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -27,6 +27,7 @@
#include <linux/err.h>
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>
+#include <linux/if_vlan.h>
#include <bcm63xx_dev_enet.h>
#include "bcm63xx_enet.h"
@@ -189,18 +190,18 @@ static int bcm_enet_refill_rx(struct net_device *dev)
desc = &priv->rx_desc_cpu[desc_idx];
if (!priv->rx_skb[desc_idx]) {
- skb = netdev_alloc_skb(dev, BCMENET_MAX_RX_SIZE);
+ skb = netdev_alloc_skb(dev, priv->rx_skb_size);
if (!skb)
break;
priv->rx_skb[desc_idx] = skb;
p = dma_map_single(&priv->pdev->dev, skb->data,
- BCMENET_MAX_RX_SIZE,
+ priv->rx_skb_size,
DMA_FROM_DEVICE);
desc->address = p;
}
- len_stat = BCMENET_MAX_RX_SIZE << DMADESC_LENGTH_SHIFT;
+ len_stat = priv->rx_skb_size << DMADESC_LENGTH_SHIFT;
len_stat |= DMADESC_OWNER_MASK;
if (priv->rx_dirty_desc == priv->rx_ring_size - 1) {
len_stat |= DMADESC_WRAP_MASK;
@@ -337,7 +338,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
skb = nskb;
} else {
dma_unmap_single(&priv->pdev->dev, desc->address,
- BCMENET_MAX_RX_SIZE, DMA_FROM_DEVICE);
+ priv->rx_skb_size, DMA_FROM_DEVICE);
priv->rx_skb[desc_idx] = NULL;
}
@@ -943,8 +944,8 @@ static int bcm_enet_open(struct net_device *dev)
enet_dma_writel(priv, 0, ENETDMA_SRAM4_REG(priv->tx_chan));
/* set max rx/tx length */
- enet_writel(priv, BCMENET_MAX_RX_SIZE, ENET_RXMAXLEN_REG);
- enet_writel(priv, BCMENET_MAX_TX_SIZE, ENET_TXMAXLEN_REG);
+ enet_writel(priv, priv->hw_mtu, ENET_RXMAXLEN_REG);
+ enet_writel(priv, priv->hw_mtu, ENET_TXMAXLEN_REG);
/* set dma maximum burst len */
enet_dma_writel(priv, BCMENET_DMA_MAXBURST,
@@ -1003,7 +1004,7 @@ out:
continue;
desc = &priv->rx_desc_cpu[i];
- dma_unmap_single(kdev, desc->address, BCMENET_MAX_RX_SIZE,
+ dma_unmap_single(kdev, desc->address, priv->rx_skb_size,
DMA_FROM_DEVICE);
kfree_skb(priv->rx_skb[i]);
}
@@ -1120,7 +1121,7 @@ static int bcm_enet_stop(struct net_device *dev)
continue;
desc = &priv->rx_desc_cpu[i];
- dma_unmap_single(kdev, desc->address, BCMENET_MAX_RX_SIZE,
+ dma_unmap_single(kdev, desc->address, priv->rx_skb_size,
DMA_FROM_DEVICE);
kfree_skb(priv->rx_skb[i]);
}
@@ -1510,6 +1511,55 @@ static int bcm_enet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
}
/*
+ * calculate actual hardware mtu
+ */
+static int compute_hw_mtu(struct bcm_enet_priv *priv, int mtu)
+{
+ int actual_mtu;
+
+ actual_mtu = mtu;
+
+ /* add ethernet header + vlan tag size */
+ actual_mtu += VLAN_ETH_HLEN;
+
+ if (actual_mtu < 64 || actual_mtu > BCMENET_MAX_MTU)
+ return -EINVAL;
+
+ /*
+ * setup maximum size before we get overflow mark in
+ * descriptor, note that this will not prevent reception of
+ * big frames, they will be split into multiple buffers
+ * anyway
+ */
+ priv->hw_mtu = actual_mtu;
+
+ /*
+ * align rx buffer size to dma burst len, account FCS since
+ * it's appended
+ */
+ priv->rx_skb_size = ALIGN(actual_mtu + ETH_FCS_LEN,
+ BCMENET_DMA_MAXBURST * 4);
+ return 0;
+}
+
+/*
+ * adjust mtu, can't be called while device is running
+ */
+static int bcm_enet_change_mtu(struct net_device *dev, int new_mtu)
+{
+ int ret;
+
+ if (netif_running(dev))
+ return -EBUSY;
+
+ ret = compute_hw_mtu(netdev_priv(dev), new_mtu);
+ if (ret)
+ return ret;
+ dev->mtu = new_mtu;
+ return 0;
+}
+
+/*
* preinit hardware to allow mii operation while device is down
*/
static void bcm_enet_hw_preinit(struct bcm_enet_priv *priv)
@@ -1559,6 +1609,7 @@ static const struct net_device_ops bcm_enet_ops = {
.ndo_set_mac_address = bcm_enet_set_mac_address,
.ndo_set_multicast_list = bcm_enet_set_multicast_list,
.ndo_do_ioctl = bcm_enet_ioctl,
+ .ndo_change_mtu = bcm_enet_change_mtu,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = bcm_enet_netpoll,
#endif
@@ -1597,6 +1648,10 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
priv = netdev_priv(dev);
memset(priv, 0, sizeof(*priv));
+ ret = compute_hw_mtu(priv, dev->mtu);
+ if (ret)
+ goto out;
+
iomem_size = res_mem->end - res_mem->start + 1;
if (!request_mem_region(res_mem->start, iomem_size, "bcm63xx_enet")) {
ret = -EBUSY;
diff --git a/drivers/net/bcm63xx_enet.h b/drivers/net/bcm63xx_enet.h
index 0da8973..bd3684d 100644
--- a/drivers/net/bcm63xx_enet.h
+++ b/drivers/net/bcm63xx_enet.h
@@ -23,9 +23,12 @@
* not overflow the fifo */
#define BCMENET_TX_FIFO_TRESH 32
-/* maximum rx/tx packet size */
-#define BCMENET_MAX_RX_SIZE (ETH_FRAME_LEN + 4)
-#define BCMENET_MAX_TX_SIZE (ETH_FRAME_LEN + 4)
+/*
+ * hardware maximum rx/tx packet size including FCS, max mtu is
+ * actually 2047, but if we set max rx size register to 2047 we won't
+ * get overflow information if packet size is 2048 or above
+ */
+#define BCMENET_MAX_MTU 2046
/*
* rx/tx dma descriptor
@@ -202,6 +205,9 @@ struct bcm_enet_priv {
/* next dirty rx descriptor to refill */
int rx_dirty_desc;
+ /* size of allocated rx skbs */
+ unsigned int rx_skb_size;
+
/* list of skb given to hw for rx */
struct sk_buff **rx_skb;
@@ -289,6 +295,9 @@ struct bcm_enet_priv {
/* platform device reference */
struct platform_device *pdev;
+
+ /* maximum hardware transmit/receive size */
+ unsigned int hw_mtu;
};
#endif /* ! BCM63XX_ENET_H_ */
--
1.6.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] bcm63xx: use NET_IP_ALIGN
2009-06-02 23:47 More updates to bcm63xx Maxime Bizon
2009-06-02 23:47 ` [PATCH 1/3] bcm63xx: don't use BUS_ID_SIZE in bcm63xx_enet Maxime Bizon
2009-06-02 23:47 ` [PATCH 2/3] bcm63xx: make it possible to change MTU on bcm63xx_enet Maxime Bizon
@ 2009-06-02 23:47 ` Maxime Bizon
2009-06-03 6:06 ` More updates to bcm63xx Ralf Baechle
3 siblings, 0 replies; 9+ messages in thread
From: Maxime Bizon @ 2009-06-02 23:47 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: Florian Fainelli, Maxime Bizon
Replace hardcoded 2 with NET_IP_ALIGN.
Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
drivers/net/bcm63xx_enet.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index 322ed03..660ffa2 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -320,7 +320,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
if (len < copybreak) {
struct sk_buff *nskb;
- nskb = netdev_alloc_skb(dev, len + 2);
+ nskb = netdev_alloc_skb(dev, len + NET_IP_ALIGN);
if (!nskb) {
/* forget packet, just rearm desc */
priv->stats.rx_dropped++;
--
1.6.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: More updates to bcm63xx
2009-06-02 23:47 More updates to bcm63xx Maxime Bizon
` (2 preceding siblings ...)
2009-06-02 23:47 ` [PATCH 3/3] bcm63xx: use NET_IP_ALIGN Maxime Bizon
@ 2009-06-03 6:06 ` Ralf Baechle
3 siblings, 0 replies; 9+ messages in thread
From: Ralf Baechle @ 2009-06-03 6:06 UTC (permalink / raw)
To: Maxime Bizon; +Cc: linux-mips, Florian Fainelli
On Wed, Jun 03, 2009 at 01:47:34AM +0200, Maxime Bizon wrote:
> Could you please fold the following patches in the bcm63xx tree ?
Thanks, all three folded into the bcm63xx tree.
Ralf
^ permalink raw reply [flat|nested] 9+ messages in thread
* More updates to bcm63xx
@ 2009-06-03 14:02 Maxime Bizon
2009-08-18 12:24 ` Ralf Baechle
0 siblings, 1 reply; 9+ messages in thread
From: Maxime Bizon @ 2009-06-03 14:02 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: Florian Fainelli
Hi Ralf,
Yet another list of cleanup and fixes for the bcm63xx tree, please
fold them into the existing patches.
Thanks !
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: More updates to bcm63xx
2009-06-03 14:02 Maxime Bizon
@ 2009-08-18 12:24 ` Ralf Baechle
2009-08-18 14:31 ` Maxime Bizon
0 siblings, 1 reply; 9+ messages in thread
From: Ralf Baechle @ 2009-08-18 12:24 UTC (permalink / raw)
To: Maxime Bizon; +Cc: linux-mips, Florian Fainelli
On Wed, Jun 03, 2009 at 04:02:19PM +0200, Maxime Bizon wrote:
> Yet another list of cleanup and fixes for the bcm63xx tree, please
> fold them into the existing patches.
I folded all 8 patches into the existing patches for the linux-bcm63xx tree.
Thanks!
Ralf
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: More updates to bcm63xx
2009-08-18 12:24 ` Ralf Baechle
@ 2009-08-18 14:31 ` Maxime Bizon
2009-08-18 14:37 ` Ralf Baechle
0 siblings, 1 reply; 9+ messages in thread
From: Maxime Bizon @ 2009-08-18 14:31 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Florian Fainelli
On Tue, 2009-08-18 at 13:24 +0100, Ralf Baechle wrote:
Hi Ralf,
> I folded all 8 patches into the existing patches for the linux-bcm63xx
> tree
The bcm63xx tree seems wrong.
The patch from Florian that adds support for 6338 & 6345 is merged with
commit BCM63XX: Add integrated ethernet mac support.
The final patch that adds the board code is gone.
--
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: More updates to bcm63xx
2009-08-18 14:31 ` Maxime Bizon
@ 2009-08-18 14:37 ` Ralf Baechle
0 siblings, 0 replies; 9+ messages in thread
From: Ralf Baechle @ 2009-08-18 14:37 UTC (permalink / raw)
To: Maxime Bizon; +Cc: linux-mips, Florian Fainelli
On Tue, Aug 18, 2009 at 04:31:27PM +0200, Maxime Bizon wrote:
> > I folded all 8 patches into the existing patches for the linux-bcm63xx
> > tree
>
> The bcm63xx tree seems wrong.
>
> The patch from Florian that adds support for 6338 & 6345 is merged with
> commit BCM63XX: Add integrated ethernet mac support.
>
> The final patch that adds the board code is gone.
I'm just folding some of the patches together. I'm aware something went
wrong with the ethernet support and I'm sorting that out now.
Ralf
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-08-18 14:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 23:47 More updates to bcm63xx Maxime Bizon
2009-06-02 23:47 ` [PATCH 1/3] bcm63xx: don't use BUS_ID_SIZE in bcm63xx_enet Maxime Bizon
2009-06-02 23:47 ` [PATCH 2/3] bcm63xx: make it possible to change MTU on bcm63xx_enet Maxime Bizon
2009-06-02 23:47 ` [PATCH 3/3] bcm63xx: use NET_IP_ALIGN Maxime Bizon
2009-06-03 6:06 ` More updates to bcm63xx Ralf Baechle
-- strict thread matches above, loose matches on Subject: below --
2009-06-03 14:02 Maxime Bizon
2009-08-18 12:24 ` Ralf Baechle
2009-08-18 14:31 ` Maxime Bizon
2009-08-18 14:37 ` Ralf Baechle
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).