Skip to content

Commit 7c19085

Browse files
committed
Merge branch 'at91-4.19-trunk/base_net' into linux-4.19-at91
2 parents 09d0c18 + 92c329d commit 7c19085

3 files changed

Lines changed: 69 additions & 20 deletions

File tree

drivers/net/ethernet/cadence/macb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,8 @@ struct macb_or_gem_ops {
10631063
int (*mog_alloc_rx_buffers)(struct macb *bp);
10641064
void (*mog_free_rx_buffers)(struct macb *bp);
10651065
void (*mog_init_rings)(struct macb *bp);
1066-
int (*mog_rx)(struct macb_queue *queue, int budget);
1066+
int (*mog_rx)(struct macb_queue *queue, struct napi_struct *napi,
1067+
int budget);
10671068
};
10681069

10691070
/* MACB-PTP interface: adapt to platform needs. */

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ static void discard_partial_frame(struct macb_queue *queue, unsigned int begin,
10181018
*/
10191019
}
10201020

1021-
static int gem_rx(struct macb_queue *queue, int budget)
1021+
static int gem_rx(struct macb_queue *queue, struct napi_struct *napi,
1022+
int budget)
10221023
{
10231024
struct macb *bp = queue->bp;
10241025
unsigned int len;
@@ -1100,16 +1101,16 @@ static int gem_rx(struct macb_queue *queue, int budget)
11001101
skb->data, 32, true);
11011102
#endif
11021103

1103-
netif_receive_skb(skb);
1104+
napi_gro_receive(napi, skb);
11041105
}
11051106

11061107
gem_rx_refill(queue);
11071108

11081109
return count;
11091110
}
11101111

1111-
static int macb_rx_frame(struct macb_queue *queue, unsigned int first_frag,
1112-
unsigned int last_frag)
1112+
static int macb_rx_frame(struct macb_queue *queue, struct napi_struct *napi,
1113+
unsigned int first_frag, unsigned int last_frag)
11131114
{
11141115
unsigned int len;
11151116
unsigned int frag;
@@ -1185,7 +1186,7 @@ static int macb_rx_frame(struct macb_queue *queue, unsigned int first_frag,
11851186
bp->dev->stats.rx_bytes += skb->len;
11861187
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
11871188
skb->len, skb->csum);
1188-
netif_receive_skb(skb);
1189+
napi_gro_receive(napi, skb);
11891190

11901191
return 0;
11911192
}
@@ -1208,7 +1209,8 @@ static inline void macb_init_rx_ring(struct macb_queue *queue)
12081209
queue->rx_tail = 0;
12091210
}
12101211

1211-
static int macb_rx(struct macb_queue *queue, int budget)
1212+
static int macb_rx(struct macb_queue *queue, struct napi_struct *napi,
1213+
int budget)
12121214
{
12131215
struct macb *bp = queue->bp;
12141216
bool reset_rx_queue = false;
@@ -1245,7 +1247,7 @@ static int macb_rx(struct macb_queue *queue, int budget)
12451247
continue;
12461248
}
12471249

1248-
dropped = macb_rx_frame(queue, first_frag, tail);
1250+
dropped = macb_rx_frame(queue, napi, first_frag, tail);
12491251
first_frag = -1;
12501252
if (unlikely(dropped < 0)) {
12511253
reset_rx_queue = true;
@@ -1299,7 +1301,7 @@ static int macb_poll(struct napi_struct *napi, int budget)
12991301
netdev_vdbg(bp->dev, "poll: status = %08lx, budget = %d\n",
13001302
(unsigned long)status, budget);
13011303

1302-
work_done = bp->macbgem_ops.mog_rx(queue, budget);
1304+
work_done = bp->macbgem_ops.mog_rx(queue, napi, budget);
13031305
if (work_done < budget) {
13041306
napi_complete_done(napi, work_done);
13051307

@@ -3514,7 +3516,7 @@ static int macb_init(struct platform_device *pdev)
35143516

35153517
queue = &bp->queues[q];
35163518
queue->bp = bp;
3517-
netif_napi_add(dev, &queue->napi, macb_poll, 64);
3519+
netif_napi_add(dev, &queue->napi, macb_poll, NAPI_POLL_WEIGHT);
35183520
if (hw_q) {
35193521
queue->ISR = GEM_ISR(hw_q - 1);
35203522
queue->IER = GEM_IER(hw_q - 1);
@@ -4206,15 +4208,13 @@ static int macb_probe(struct platform_device *pdev)
42064208
bp->rx_intr_mask |= MACB_BIT(RXUBR);
42074209

42084210
mac = of_get_mac_address(np);
4209-
if (mac) {
4211+
if (PTR_ERR(mac) == -EPROBE_DEFER) {
4212+
err = -EPROBE_DEFER;
4213+
goto err_out_free_netdev;
4214+
} else if (!IS_ERR_OR_NULL(mac)) {
42104215
ether_addr_copy(bp->dev->dev_addr, mac);
42114216
} else {
4212-
err = nvmem_get_mac_address(&pdev->dev, bp->dev->dev_addr);
4213-
if (err) {
4214-
if (err == -EPROBE_DEFER)
4215-
goto err_out_free_netdev;
4216-
macb_get_hwaddr(bp);
4217-
}
4217+
macb_get_hwaddr(bp);
42184218
}
42194219

42204220
err = of_get_phy_mode(np);

drivers/of/of_net.c

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#include <linux/kernel.h>
1010
#include <linux/nvmem-consumer.h>
1111
#include <linux/of_net.h>
12+
#include <linux/of_platform.h>
1213
#include <linux/phy.h>
1314
#include <linux/export.h>
15+
#include <linux/device.h>
1416

1517
/**
1618
* of_get_phy_mode - Get phy mode for given device_node
@@ -48,12 +50,52 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name)
4850
return NULL;
4951
}
5052

53+
static const void *of_get_mac_addr_nvmem(struct device_node *np)
54+
{
55+
int ret;
56+
u8 mac[ETH_ALEN];
57+
struct property *pp;
58+
struct platform_device *pdev = of_find_device_by_node(np);
59+
60+
if (!pdev)
61+
return ERR_PTR(-ENODEV);
62+
63+
ret = nvmem_get_mac_address(&pdev->dev, &mac);
64+
if (ret)
65+
return ERR_PTR(ret);
66+
67+
pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL);
68+
if (!pp)
69+
return ERR_PTR(-ENOMEM);
70+
71+
pp->name = "nvmem-mac-address";
72+
pp->length = ETH_ALEN;
73+
pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
74+
if (!pp->value) {
75+
ret = -ENOMEM;
76+
goto free;
77+
}
78+
79+
ret = of_add_property(np, pp);
80+
if (ret)
81+
goto free;
82+
83+
return pp->value;
84+
free:
85+
devm_kfree(&pdev->dev, pp->value);
86+
devm_kfree(&pdev->dev, pp);
87+
88+
return ERR_PTR(ret);
89+
}
90+
5191
/**
5292
* Search the device tree for the best MAC address to use. 'mac-address' is
5393
* checked first, because that is supposed to contain to "most recent" MAC
5494
* address. If that isn't set, then 'local-mac-address' is checked next,
55-
* because that is the default address. If that isn't set, then the obsolete
56-
* 'address' is checked, just in case we're using an old device tree.
95+
* because that is the default address. If that isn't set, then the obsolete
96+
* 'address' is checked, just in case we're using an old device tree. If any
97+
* of the above isn't set, then try to get MAC address from nvmem cell named
98+
* 'mac-address'.
5799
*
58100
* Note that the 'address' property is supposed to contain a virtual address of
59101
* the register set, but some DTS files have redefined that property to be the
@@ -65,6 +107,8 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name)
65107
* addresses. Some older U-Boots only initialized 'local-mac-address'. In
66108
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
67109
* but is all zeros.
110+
*
111+
* Return: Will be a valid pointer on success and ERR_PTR in case of error.
68112
*/
69113
const void *of_get_mac_address(struct device_node *np)
70114
{
@@ -78,7 +122,11 @@ const void *of_get_mac_address(struct device_node *np)
78122
if (addr)
79123
return addr;
80124

81-
return of_get_mac_addr(np, "address");
125+
addr = of_get_mac_addr(np, "address");
126+
if (addr)
127+
return addr;
128+
129+
return of_get_mac_addr_nvmem(np);
82130
}
83131
EXPORT_SYMBOL(of_get_mac_address);
84132

0 commit comments

Comments
 (0)