brcm63xx: fix typo and missing BCM6328 check in BCM6345 ethernet patch
[openwrt/staging/wigyori.git] / target / linux / mvebu / patches-3.8 / 004-net_mvneta_fix_driver_operations_smp.patch
1 From: Dmitri Epshtein <dima@marvell.com>
2
3 In order for the driver to behave properly in a SMP context, the same
4 transmit queue should be used by the kernel in dev_queue_xmit() and in
5 the driver's mvneta_tx() function. To achieve that, the driver now
6 implements the ->ndo_select_txq() operation.
7
8 For now, it always returns the same transmit queue, txq_def, until the
9 driver is expanded to properly take advantage of the multiqueue
10 capabilities of the hardware.
11
12 Without this patch, the network driver crashes the kernel almost
13 immediately on Armada XP platforms, if the network load is at least a
14 little bit parallel (i.e several threads).
15
16 [Thomas Petazzoni: reword commit message]
17 Signed-off-by: Dmitri Epshtein <dima@marvell.com>
18 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
19 ---
20 This is 3.8-rc material.
21 ---
22 drivers/net/ethernet/marvell/mvneta.c | 17 +++++++++++++++--
23 1 file changed, 15 insertions(+), 2 deletions(-)
24
25 --- a/drivers/net/ethernet/marvell/mvneta.c
26 +++ b/drivers/net/ethernet/marvell/mvneta.c
27 @@ -1310,6 +1310,17 @@ static u32 mvneta_skb_tx_csum(struct mvn
28 return MVNETA_TX_L4_CSUM_NOT;
29 }
30
31 +static u16 mvneta_tx_policy(struct mvneta_port *pp, struct sk_buff *skb)
32 +{
33 + return (u16)txq_def;
34 +}
35 +
36 +static u16 mvneta_select_txq(struct net_device *dev, struct sk_buff *skb)
37 +{
38 + struct mvneta_port *pp = netdev_priv(dev);
39 + return mvneta_tx_policy(pp, skb);
40 +}
41 +
42 /* Returns rx queue pointer (find last set bit) according to causeRxTx
43 * value
44 */
45 @@ -1476,7 +1487,8 @@ error:
46 static int mvneta_tx(struct sk_buff *skb, struct net_device *dev)
47 {
48 struct mvneta_port *pp = netdev_priv(dev);
49 - struct mvneta_tx_queue *txq = &pp->txqs[txq_def];
50 + u16 txq_id = mvneta_tx_policy(pp, skb);
51 + struct mvneta_tx_queue *txq = &pp->txqs[txq_id];
52 struct mvneta_tx_desc *tx_desc;
53 struct netdev_queue *nq;
54 int frags = 0;
55 @@ -1486,7 +1498,7 @@ static int mvneta_tx(struct sk_buff *skb
56 goto out;
57
58 frags = skb_shinfo(skb)->nr_frags + 1;
59 - nq = netdev_get_tx_queue(dev, txq_def);
60 + nq = netdev_get_tx_queue(dev, txq_id);
61
62 /* Get a descriptor for the first part of the packet */
63 tx_desc = mvneta_txq_next_desc_get(txq);
64 @@ -2550,6 +2562,7 @@ static const struct net_device_ops mvnet
65 .ndo_change_mtu = mvneta_change_mtu,
66 .ndo_tx_timeout = mvneta_tx_timeout,
67 .ndo_get_stats64 = mvneta_get_stats64,
68 + .ndo_select_queue = mvneta_select_txq,
69 };
70
71 const struct ethtool_ops mvneta_eth_tool_ops = {