3be47abc8aeacea7b9151de5f0b4d12b24ce9335
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.4 / 032-net-mvneta-Make-the-default-queue-related-for-each-p.patch
1 From: Gregory CLEMENT <gregory.clement@free-electrons.com>
2 Date: Wed, 9 Dec 2015 18:23:48 +0100
3 Subject: [PATCH] net: mvneta: Make the default queue related for each port
4
5 Instead of using the same default queue for all the port. Move it in the
6 port struct. It will allow have a different default queue for each port.
7
8 Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
9 Signed-off-by: David S. Miller <davem@davemloft.net>
10 ---
11
12 --- a/drivers/net/ethernet/marvell/mvneta.c
13 +++ b/drivers/net/ethernet/marvell/mvneta.c
14 @@ -356,6 +356,7 @@ struct mvneta_port {
15 struct mvneta_tx_queue *txqs;
16 struct net_device *dev;
17 struct notifier_block cpu_notifier;
18 + int rxq_def;
19
20 /* Core clock */
21 struct clk *clk;
22 @@ -819,7 +820,7 @@ static void mvneta_port_up(struct mvneta
23 mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
24
25 /* Enable all initialized RXQs. */
26 - mvreg_write(pp, MVNETA_RXQ_CMD, BIT(rxq_def));
27 + mvreg_write(pp, MVNETA_RXQ_CMD, BIT(pp->rxq_def));
28 }
29
30 /* Stop the Ethernet port activity */
31 @@ -1071,7 +1072,7 @@ static void mvneta_defaults_set(struct m
32 mvreg_write(pp, MVNETA_ACC_MODE, val);
33
34 /* Update val of portCfg register accordingly with all RxQueue types */
35 - val = MVNETA_PORT_CONFIG_DEFL_VALUE(rxq_def);
36 + val = MVNETA_PORT_CONFIG_DEFL_VALUE(pp->rxq_def);
37 mvreg_write(pp, MVNETA_PORT_CONFIG, val);
38
39 val = 0;
40 @@ -2105,19 +2106,19 @@ static void mvneta_set_rx_mode(struct ne
41 if (dev->flags & IFF_PROMISC) {
42 /* Accept all: Multicast + Unicast */
43 mvneta_rx_unicast_promisc_set(pp, 1);
44 - mvneta_set_ucast_table(pp, rxq_def);
45 - mvneta_set_special_mcast_table(pp, rxq_def);
46 - mvneta_set_other_mcast_table(pp, rxq_def);
47 + mvneta_set_ucast_table(pp, pp->rxq_def);
48 + mvneta_set_special_mcast_table(pp, pp->rxq_def);
49 + mvneta_set_other_mcast_table(pp, pp->rxq_def);
50 } else {
51 /* Accept single Unicast */
52 mvneta_rx_unicast_promisc_set(pp, 0);
53 mvneta_set_ucast_table(pp, -1);
54 - mvneta_mac_addr_set(pp, dev->dev_addr, rxq_def);
55 + mvneta_mac_addr_set(pp, dev->dev_addr, pp->rxq_def);
56
57 if (dev->flags & IFF_ALLMULTI) {
58 /* Accept all multicast */
59 - mvneta_set_special_mcast_table(pp, rxq_def);
60 - mvneta_set_other_mcast_table(pp, rxq_def);
61 + mvneta_set_special_mcast_table(pp, pp->rxq_def);
62 + mvneta_set_other_mcast_table(pp, pp->rxq_def);
63 } else {
64 /* Accept only initialized multicast */
65 mvneta_set_special_mcast_table(pp, -1);
66 @@ -2126,7 +2127,7 @@ static void mvneta_set_rx_mode(struct ne
67 if (!netdev_mc_empty(dev)) {
68 netdev_for_each_mc_addr(ha, dev) {
69 mvneta_mcast_addr_set(pp, ha->addr,
70 - rxq_def);
71 + pp->rxq_def);
72 }
73 }
74 }
75 @@ -2209,7 +2210,7 @@ static int mvneta_poll(struct napi_struc
76 * RX packets
77 */
78 cause_rx_tx |= port->cause_rx_tx;
79 - rx_done = mvneta_rx(pp, budget, &pp->rxqs[rxq_def]);
80 + rx_done = mvneta_rx(pp, budget, &pp->rxqs[pp->rxq_def]);
81 budget -= rx_done;
82
83 if (budget > 0) {
84 @@ -2422,17 +2423,17 @@ static void mvneta_cleanup_txqs(struct m
85 /* Cleanup all Rx queues */
86 static void mvneta_cleanup_rxqs(struct mvneta_port *pp)
87 {
88 - mvneta_rxq_deinit(pp, &pp->rxqs[rxq_def]);
89 + mvneta_rxq_deinit(pp, &pp->rxqs[pp->rxq_def]);
90 }
91
92
93 /* Init all Rx queues */
94 static int mvneta_setup_rxqs(struct mvneta_port *pp)
95 {
96 - int err = mvneta_rxq_init(pp, &pp->rxqs[rxq_def]);
97 + int err = mvneta_rxq_init(pp, &pp->rxqs[pp->rxq_def]);
98 if (err) {
99 netdev_err(pp->dev, "%s: can't create rxq=%d\n",
100 - __func__, rxq_def);
101 + __func__, pp->rxq_def);
102 mvneta_cleanup_rxqs(pp);
103 return err;
104 }
105 @@ -2638,7 +2639,7 @@ static int mvneta_set_mac_addr(struct ne
106 mvneta_mac_addr_set(pp, dev->dev_addr, -1);
107
108 /* Set new addr in hw */
109 - mvneta_mac_addr_set(pp, sockaddr->sa_data, rxq_def);
110 + mvneta_mac_addr_set(pp, sockaddr->sa_data, pp->rxq_def);
111
112 eth_commit_mac_addr_change(dev, addr);
113 return 0;
114 @@ -2757,7 +2758,7 @@ static void mvneta_percpu_elect(struct m
115 {
116 int online_cpu_idx, cpu, i = 0;
117
118 - online_cpu_idx = rxq_def % num_online_cpus();
119 + online_cpu_idx = pp->rxq_def % num_online_cpus();
120
121 for_each_online_cpu(cpu) {
122 if (i == online_cpu_idx)
123 @@ -3365,6 +3366,8 @@ static int mvneta_probe(struct platform_
124 strcmp(managed, "in-band-status") == 0);
125 pp->cpu_notifier.notifier_call = mvneta_percpu_notifier;
126
127 + pp->rxq_def = rxq_def;
128 +
129 pp->clk = devm_clk_get(&pdev->dev, NULL);
130 if (IS_ERR(pp->clk)) {
131 err = PTR_ERR(pp->clk);