ibm: emac: more cleanups
Subsystems (2)
v8 cover ibm: emac: more cleanups
Tested on Cisco MX60W.
v2: fixed build errors. Also added extra commits to clean the driver up further.
v3: Added tested message. Removed bad alloc_netdev_dummy commit.
v4: removed modules changes from patchset. Added fix for if MAC not found.
v5: added of_find_matching_node commit.
v6: resend after net-next merge.
v7: removed of_find_matching_node commit. Adjusted mutex_init patch.
v8: removed patch removing custom init/exit. Needs more work.
Rosen Penev (5):
net: ibm: emac: use netif_receive_skb_list
net: ibm: emac: use devm_platform_ioremap_resource
net: ibm: emac: use platform_get_irq
net: ibm: emac: use devm for mutex_init
net: ibm: emac: generate random MAC if not found
drivers/net/ethernet/ibm/emac/core.c | 42 +++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-)
Signature · 1 line
2.47.0
PATCH v8 1/5 net: ibm: emac: use netif_receive_skb_list
Small rx improvement. Would use napi_gro_receive instead but that's a lot more involved than netif_receive_skb_list because of how the function is implemented.
Before:
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 51556 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 559 MBytes 467 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 48228 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.03 sec 558 MBytes 467 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 47600 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 557 MBytes 466 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 37252 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 559 MBytes 467 Mbits/sec
After:
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 40786 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 572 MBytes 478 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 52482 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 571 MBytes 477 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 48370 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 572 MBytes 478 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 46086 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 571 MBytes 476 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 46062 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 572 MBytes 478 Mbits/sec
--- drivers/net/ethernet/ibm/emac/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +4 -2
@@ -1727,6 +1727,7 @@ static inline int emac_rx_sg_append(struct emac_instance *dev, int slot)/* NAPI poll context */ static int emac_poll_rx (void *param,int budget) { +LIST_HEAD (rx_list);struct emac_instance *dev = param;int slot = dev->rx_slot, received =0 ;
@@ -1783,8 +1784,7 @@ static int emac_poll_rx(void *param, int budget) skb->protocol =eth_type_trans (skb, dev->ndev);emac_rx_csum (dev, skb, ctrl); -if (unlikely (netif_receive_skb (skb) ==NET_RX_DROP )) - ++dev->estats.rx_dropped_stack; +list_add_tail (&skb->list, &rx_list); next: ++dev->stats.rx_packets; skip:
@@ -1828,6 +1828,8 @@ static int emac_poll_rx(void *param, int budget) goto next; } +netif_receive_skb_list (&rx_list); +if (received) {DBG2 (dev,"rx %d BDs" NL , received); dev->rx_slot = slot;
Signature · 1 line
2.47.0
PATCH v8 2/5 net: ibm: emac: use devm_platform_ioremap_resource
In reply to Rosen PenevNo need to have a struct resource. Gets rid of the TODO.
--- drivers/net/ethernet/ibm/emac/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +3 -5
@@ -3050,12 +3050,10 @@ static int emac_probe(struct platform_device *ofdev) ndev->irq = dev->emac_irq; -/* Map EMAC regs */ -// TODO : platform_get_resource() and devm_ioremap_resource() - dev->emacp =devm_of_iomap (&ofdev->dev, np,0 ,NULL ); -if (!dev->emacp) { + dev->emacp =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (dev->emacp)) {dev_err (&ofdev->dev,"can't map device registers" ); - err = -ENOMEM ; + err =PTR_ERR (dev->emacp); goto err_gone; }
Signature · 1 line
2.47.0
PATCH v8 3/5 net: ibm: emac: use platform_get_irq
In reply to Rosen PenevNo need for irq_of_parse_and_map since we have platform_device.
--- drivers/net/ethernet/ibm/emac/core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +1 -8
@@ -3031,15 +3031,8 @@ static int emac_probe(struct platform_device *ofdev)if (err) goto err_gone; -/* Get interrupts. EMAC irq is mandatory */ - dev->emac_irq =irq_of_parse_and_map (np,0 ); -if (!dev->emac_irq) { -printk (KERN_ERR "%pOF: Can't map main interrupt\n" , np); - err = -ENODEV ; - goto err_gone; - } -/* Setup error IRQ handler */ + dev->emac_irq =platform_get_irq (ofdev,0 ); err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , dev);if (err) {
Signature · 1 line
2.47.0
PATCH v8 4/5 net: ibm: emac: use devm for mutex_init
In reply to Rosen PenevIt seems since inception that mutex_destroy was never called for these in _remove. Instead of handling this manually, just use devm for simplicity.
--- drivers/net/ethernet/ibm/emac/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +8 -2
@@ -3021,8 +3021,14 @@ static int emac_probe(struct platform_device *ofdev)SET_NETDEV_DEV (ndev, &ofdev->dev);/* Initialize some embedded data structures */ -mutex_init (&dev->mdio_lock); -mutex_init (&dev->link_lock); + err =devm_mutex_init (&ofdev->dev, &dev->mdio_lock); +if (err) + goto err_gone; + + err =devm_mutex_init (&ofdev->dev, &dev->link_lock); +if (err) + goto err_gone; +spin_lock_init (&dev->lock);INIT_WORK (&dev->reset_work, emac_reset_work);
Signature · 1 line
2.47.0
PATCH v8 5/5 net: ibm: emac: generate random MAC if not found
In reply to Rosen PenevOn this Cisco MX60W, u-boot sets the local-mac-address property. Unfortunately by default, the MAC is wrong and is actually located on a UBI partition. Which means nvmem needs to be used to grab it.
In the case where that fails, EMAC fails to initialize instead of generating a random MAC as many other drivers do.
Match behavior with other drivers to have a working ethernet interface.
--- drivers/net/ethernet/ibm/emac/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +6 -3
@@ -2937,9 +2937,12 @@ static int emac_init_config(struct emac_instance *dev)/* Read MAC-address */ err =of_get_ethdev_address (np, dev->ndev); -if (err) -return dev_err_probe (&dev->ofdev->dev, err, -"Can't get valid [local-]mac-address from OF !\n" ); +if (err == -EPROBE_DEFER ) +return err; +if (err) { +dev_warn (&dev->ofdev->dev,"Can't get valid mac-address. Generating random." ); +eth_hw_addr_random (dev->ndev); + }/* IAHT and GAHT filter parameterization */ if (emac_has_feature (dev,EMAC_FTR_EMAC4SYNC )) {
Signature · 1 line
2.47.0
Quoted 20 lines · Rosen Penev
Tested on Cisco MX60W.
v2: fixed build errors. Also added extra commits to clean the driver up further.
v3: Added tested message. Removed badalloc_netdev_dummycommit.
v4: removed modules changes from patchset. Added fix for if MAC not found.
v5: addedof_find_matching_nodecommit.
v6: resend after net-next merge.
v7: removedof_find_matching_nodecommit. Adjustedmutex_initpatch.
v8: removed patch removing custom init/exit. Needs more work.Rosen Penev (5):
net: ibm: emac: usenetif_receive_skb_list
net: ibm: emac: usedevm_platform_ioremap_resource
net: ibm: emac: useplatform_get_irq
net: ibm: emac: use devm formutex_init
net: ibm: emac: generate random MAC if not found
Quoted 6 lines
drivers/net/ethernet/ibm/emac/core.c | 42 +++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-)--
2.47.0
These look reasonable - thanks.
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 12 lines · On Mon, 21 Oct 2024 17:22:40 -0700 you wrote:
Tested on Cisco MX60W.
v2: fixed build errors. Also added extra commits to clean the driver up further.
v3: Added tested message. Removed badalloc_netdev_dummycommit.
v4: removed modules changes from patchset. Added fix for if MAC not found.
v5: addedof_find_matching_nodecommit.
v6: resend after net-next merge.
v7: removedof_find_matching_nodecommit. Adjustedmutex_initpatch.
v8: removed patch removing custom init/exit. Needs more work.
Quoted 1 line
[...]
Here is the summary with links:
- [PATCHv8,net-next,1/5] net: ibm: emac: use netif_receive_skb_list
https://git.kernel.org/netdev/net-next/c/0a24488d93e8 - [PATCHv8,net-next,2/5] net: ibm: emac: use devm_platform_ioremap_resource https://git.kernel.org/netdev/net-next/c/c9bf90863df5 - [PATCHv8,net-next,3/5] net: ibm: emac: use platform_get_irq https://git.kernel.org/netdev/net-next/c/a598f66d9169 - [PATCHv8,net-next,4/5] net: ibm: emac: use devm for mutex_init https://git.kernel.org/netdev/net-next/c/af4698be49e8 - [PATCHv8,net-next,5/5] net: ibm: emac: generate random MAC if not found https://git.kernel.org/netdev/net-next/c/707f1c4b6a2c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html