Probing cleanup for the Felix DSA driver
Subsystems (5)
Vladimir Oltean
maintainercover Probing cleanup for the Felix DSA driver
This is a follow-up to Russell King's request for code consolidation among felix_vsc9959, seville_vsc9953 and ocelot_ext, stated here:
https://lore.kernel.org/all/[email protected]/
Details are in individual patches. Testing was done on NXP LS1028A (felix_vsc9959).
Vladimir Oltean (8):
net: dsa: ocelot: use devres in ocelot_ext_probe()
net: dsa: ocelot: use devres in seville_probe()
net: dsa: ocelot: delete open coded status = "disabled" parsing
net: dsa: ocelot: consistently use devres in felix_pci_probe()
net: dsa: ocelot: move devm_request_threaded_irq() to felix_setup()
net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models
net: dsa: ocelot: common probing code
net: dsa: ocelot: unexport felix_phylink_mac_ops and felix_switch_ops
drivers/net/dsa/ocelot/felix.c | 62 ++++++++++++- drivers/net/dsa/ocelot/felix.h | 10 +- drivers/net/dsa/ocelot/felix_vsc9959.c | 113 +++++++---------------- drivers/net/dsa/ocelot/ocelot_ext.c | 55 +---------- drivers/net/dsa/ocelot/seville_vsc9953.c | 61 ++---------- 5 files changed, 106 insertions(+), 195 deletions(-)
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerPATCH 1/8 net: dsa: ocelot: use devres in ocelot_ext_probe()
Russell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.
[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the ocelot_ext driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.
--- drivers/net/dsa/ocelot/ocelot_ext.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
drivers/net/dsa/ocelot/ocelot_ext.c +5 -19
@@ -71,7 +71,7 @@ static int ocelot_ext_probe(struct platform_device *pdev)struct felix *felix;int err; - felix =kzalloc (sizeof (*felix),GFP_KERNEL ); + felix =devm_kzalloc (dev,sizeof (*felix),GFP_KERNEL );if (!felix)return -ENOMEM ;
@@ -84,12 +84,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->info = &vsc7512_info; - ds =kzalloc (sizeof (*ds),GFP_KERNEL ); -if (!ds) { - err = -ENOMEM ; -dev_err_probe (dev, err,"Failed to allocate DSA switch\n" ); - goto err_free_felix; - } + ds =devm_kzalloc (dev,sizeof (*ds),GFP_KERNEL ); +if (!ds) +return -ENOMEM ; ds->dev = dev; ds->num_ports = felix->info->num_ports;
@@ -102,17 +99,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->tag_proto =DSA_TAG_PROTO_OCELOT ; err =dsa_register_switch (ds); -if (err) { +if (err)dev_err_probe (dev, err,"Failed to register DSA switch\n" ); - goto err_free_ds; - } - -return 0 ; -err_free_ds: -kfree (ds); -err_free_felix: -kfree (felix);return err; }
@@ -124,9 +113,6 @@ static void ocelot_ext_remove(struct platform_device *pdev)return ;dsa_unregister_switch (felix->ds); - -kfree (felix->ds); -kfree (felix); }static void ocelot_ext_shutdown (struct platform_device *pdev)
Signature · 1 line
2.34.1
Re: [PATCH net-next 1/8] net: dsa: ocelot: use devres in ocelot_ext_probe()
Quoted 80 lines · Vladimir Oltean
Russell King suggested that
felix_vsc9959,seville_vsc9953andocelot_exthave a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the
ocelot_extdriver, by allocating the data structures using devres and deleting thekfree()calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.Suggested-by "Russell King (Oracle)" <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/ocelot_ext.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)drivers/net/dsa/ocelot/ocelot_ext.c +5
-19@@ -71,7 +71,7 @@ static int ocelot_ext_probe(struct platform_device *pdev)struct felix *felix;int err; - felix =kzalloc (sizeof (*felix),GFP_KERNEL ); + felix =devm_kzalloc (dev,sizeof (*felix),GFP_KERNEL );if (!felix)return -ENOMEM ;@@ -84,12 +84,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->info = &vsc7512_info; - ds =kzalloc (sizeof (*ds),GFP_KERNEL ); -if (!ds) { - err = -ENOMEM ; -dev_err_probe (dev, err,"Failed to allocate DSA switch\n" ); - goto err_free_felix; - } + ds =devm_kzalloc (dev,sizeof (*ds),GFP_KERNEL ); +if (!ds) +return -ENOMEM ; ds->dev = dev; ds->num_ports = felix->info->num_ports;@@ -102,17 +99,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->tag_proto =DSA_TAG_PROTO_OCELOT ; err =dsa_register_switch (ds); -if (err) { +if (err)dev_err_probe (dev, err,"Failed to register DSA switch\n" ); - goto err_free_ds; - } - -return 0 ; -err_free_ds: -kfree (ds); -err_free_felix: -kfree (felix);return err; }@@ -124,9 +113,6 @@ static void ocelot_ext_remove(struct platform_device *pdev)return ;dsa_unregister_switch (felix->ds); - -kfree (felix->ds); -kfree (felix); }static void ocelot_ext_shutdown (struct platform_device *pdev)Signature · 1 line
2.34.1
Re: [PATCH net-next 1/8] net: dsa: ocelot: use devres in ocelot_ext_probe()
In reply to Vladimir Olteandrivers/net/dsa/ocelot/ocelot_ext.c
Quoted 23 lines · Vladimir Oltean
Russell King suggested that
felix_vsc9959,seville_vsc9953andocelot_exthave a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the
ocelot_extdriver, by allocating the data structures using devres and deleting thekfree()calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.Suggested-by "Russell King (Oracle)" <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/ocelot_ext.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)drivers/net/dsa/ocelot/ocelot_ext.c +0
-0
I found my issue and was able to test the series.
Vladimir Oltean
maintainerRe: [PATCH net-next 1/8] net: dsa: ocelot: use devres in ocelot_ext_probe()
Quoted 20 lines · Colin Foster
Quoted 19 lines · Vladimir Oltean
Russell King suggested that
felix_vsc9959,seville_vsc9953andocelot_exthave a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the
ocelot_extdriver, by allocating the data structures using devres and deleting thekfree()calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.Suggested-by "Russell King (Oracle)" <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/ocelot_ext.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
Quoted 8 lines
drivers/net/dsa/ocelot/ocelot_ext.c
Quoted 4 lines
drivers/net/dsa/ocelot/ocelot_ext.c +0
-0I found my issue and was able to test the series.
Tested-by Colin Foster <[email protected]>
Thanks for testing, Colin.
Vladimir Oltean
maintainerPATCH 2/8 net: dsa: ocelot: use devres in seville_probe()
In reply to Vladimir OlteanRussell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.
[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the seville_vsc9953 driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 44 +++++++----------------- 1 file changed, 13 insertions(+), 31 deletions(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +13 -31
@@ -971,42 +971,36 @@ static const struct felix_info seville_info_vsc9953 = {static int seville_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct dsa_switch *ds;struct ocelot *ocelot;struct resource *res;struct felix *felix;int err; - felix =kzalloc (sizeof (struct felix ),GFP_KERNEL ); -if (!felix) { - err = -ENOMEM ; -dev_err (&pdev->dev,"Failed to allocate driver memory\n" ); - goto err_alloc_felix; - } + felix =devm_kzalloc (dev,sizeof (struct felix ),GFP_KERNEL ); +if (!felix) +return -ENOMEM ;platform_set_drvdata (pdev, felix); ocelot = &felix->ocelot; - ocelot->dev = &pdev->dev; + ocelot->dev = dev; ocelot->num_flooding_pgids =1 ; felix->info = &seville_info_vsc9953; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) { - err = -EINVAL ; -dev_err (&pdev->dev,"Invalid resource\n" ); - goto err_alloc_felix; +dev_err (dev,"Invalid resource\n" ); +return -EINVAL ; } felix->switch_base = res->start; - ds =kzalloc (sizeof (struct dsa_switch ),GFP_KERNEL ); -if (!ds) { - err = -ENOMEM ; -dev_err (&pdev->dev,"Failed to allocate DSA switch\n" ); - goto err_alloc_ds; - } + ds =devm_kzalloc (dev,sizeof (struct dsa_switch ),GFP_KERNEL ); +if (!ds) +return -ENOMEM ; - ds->dev = &pdev->dev; + ds->dev = dev; ds->num_ports = felix->info->num_ports; ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops;
@@ -1015,18 +1009,9 @@ static int seville_probe(struct platform_device *pdev) felix->tag_proto =DSA_TAG_PROTO_SEVILLE ; err =dsa_register_switch (ds); -if (err) { -dev_err (&pdev->dev,"Failed to register DSA switch: %d\n" , err); - goto err_register_ds; - } +if (err) +dev_err (dev,"Failed to register DSA switch: %d\n" , err); -return 0 ; - -err_register_ds: -kfree (ds); -err_alloc_ds: -err_alloc_felix: -kfree (felix);return err; }
@@ -1038,9 +1023,6 @@ static void seville_remove(struct platform_device *pdev)return ;dsa_unregister_switch (felix->ds); - -kfree (felix->ds); -kfree (felix); }static void seville_shutdown (struct platform_device *pdev)
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerPATCH 3/8 net: dsa: ocelot: delete open coded status = "disabled" parsing
In reply to Vladimir OlteanSince commit 6fffbc7ae137 ("PCI: Honor firmware's device disabled status"), PCI device drivers with OF bindings no longer need this check.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +0 -5
@@ -2668,11 +2668,6 @@ static int felix_pci_probe(struct pci_dev *pdev,struct felix *felix;int err; -if (pdev->dev.of_node && !of_device_is_available (pdev->dev.of_node)) { -dev_info (&pdev->dev,"device is disabled, skipping\n" ); -return -ENODEV ; - } - err =pci_enable_device (pdev);if (err) {dev_err (&pdev->dev,"device enable failed\n" );
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerPATCH 4/8 net: dsa: ocelot: consistently use devres in felix_pci_probe()
In reply to Vladimir OlteanRussell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently.
[1] https://lore.kernel.org/all/[email protected]/
Prepare the ground in the felix_vsc9959 driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 40 ++++++++++---------------- 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +15 -25
@@ -2663,6 +2663,7 @@ static irqreturn_t felix_irq_handler(int irq, void *data)static int felix_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +struct device *dev = &pdev->dev;struct dsa_switch *ds;struct ocelot *ocelot;struct felix *felix;
@@ -2670,45 +2671,43 @@ static int felix_pci_probe(struct pci_dev *pdev, err =pci_enable_device (pdev);if (err) { -dev_err (&pdev->dev,"device enable failed\n" ); - goto err_pci_enable; +dev_err (dev,"device enable failed: %pe\n" ,ERR_PTR (err)); +return err; } - felix =kzalloc (sizeof (struct felix ),GFP_KERNEL ); + felix =devm_kzalloc (dev,sizeof (struct felix ),GFP_KERNEL );if (!felix) { err = -ENOMEM ; -dev_err (&pdev->dev,"Failed to allocate driver memory\n" ); - goto err_alloc_felix; + goto out_disable; }pci_set_drvdata (pdev, felix); ocelot = &felix->ocelot; - ocelot->dev = &pdev->dev; + ocelot->dev = dev; ocelot->num_flooding_pgids =OCELOT_NUM_TC ; felix->info = &felix_info_vsc9959; felix->switch_base =pci_resource_start (pdev,VSC9959_SWITCH_PCI_BAR );pci_set_master (pdev); - err =devm_request_threaded_irq (&pdev->dev, pdev->irq,NULL , + err =devm_request_threaded_irq (dev, pdev->irq,NULL , &felix_irq_handler,IRQF_ONESHOT ,"felix-intb" , ocelot);if (err) { -dev_err (&pdev->dev,"Failed to request irq\n" ); - goto err_alloc_irq; +dev_err (dev,"Failed to request irq: %pe\n" ,ERR_PTR (err)); + goto out_disable; } ocelot->ptp =1 ; ocelot->mm_supported = true; - ds =kzalloc (sizeof (struct dsa_switch ),GFP_KERNEL ); + ds =devm_kzalloc (dev,sizeof (struct dsa_switch ),GFP_KERNEL );if (!ds) { err = -ENOMEM ; -dev_err (&pdev->dev,"Failed to allocate DSA switch\n" ); - goto err_alloc_ds; + goto out_disable; } - ds->dev = &pdev->dev; + ds->dev = dev; ds->num_ports = felix->info->num_ports; ds->num_tx_queues = felix->info->num_tx_queues; ds->ops = &felix_switch_ops;
@@ -2719,20 +2718,14 @@ static int felix_pci_probe(struct pci_dev *pdev, err =dsa_register_switch (ds);if (err) { -dev_err_probe (&pdev->dev, err,"Failed to register DSA switch\n" ); - goto err_register_ds; +dev_err_probe (dev, err,"Failed to register DSA switch\n" ); + goto out_disable; }return 0 ; -err_register_ds: -kfree (ds); -err_alloc_ds: -err_alloc_irq: -kfree (felix); -err_alloc_felix: +out_disable:pci_disable_device (pdev); -err_pci_enable:return err; }
@@ -2745,9 +2738,6 @@ static void felix_pci_remove(struct pci_dev *pdev)dsa_unregister_switch (felix->ds); -kfree (felix->ds); -kfree (felix); -pci_disable_device (pdev); }
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerPATCH 5/8 net: dsa: ocelot: move devm_request_threaded_irq() to felix_setup()
In reply to Vladimir OlteanThe current placement of devm_request_threaded_irq() is inconvenient. It is between the allocation of the "felix" structure and dsa_register_switch(), both of which we'd like to refactor into a function that's common for all switches. But the IRQ is specific to felix_vsc9959.
A closer inspection of the felix_irq_handler() code suggests that it does things that depend on the data structures having been fully initialized. For example, ocelot_get_txtstamp() takes &port->tx_skbs.lock, which has only been initialized in ocelot_init_port() which has not run yet.
It is not one of those IRQF_SHARED IRQs, so CONFIG_DEBUG_SHIRQ_FIXME shouldn't apply here, and thus, it doesn't really matter, because in practice, the IRQ will not be triggered so early. Nonetheless, it is a good practice for the driver to be prepared for it to fire as soon as it is requested.
Create a new felix->info method for running custom code for vsc9959 from within felix_setup(), and move the request_irq() call there. The ocelot_ext should have an IRQ as well, so this should be a step in the right direction for that model (VSC7512) as well.
Some minor changes are made while moving the code. Casts from void * aren't necessary, so drop them, and rename felix_irq_handler() to the more specific vsc9959_irq_handler().
--- drivers/net/dsa/ocelot/felix.c | 9 ++++++ drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_vsc9959.c | 44 ++++++++++++++------------ 3 files changed, 33 insertions(+), 21 deletions(-)
drivers/net/dsa/ocelot/felix.c +9 -0
@@ -1597,6 +1597,15 @@ static int felix_setup(struct dsa_switch *ds)felix_port_qos_map_init (ocelot, dp->index); } +if (felix->info->request_irq) { + err = felix->info->request_irq (ocelot); +if (err) { +dev_err (ocelot->dev,"Failed to request IRQ: %pe\n" , +ERR_PTR (err)); + goto out_deinit_ports; + } + } + err =ocelot_devlink_sb_register (ocelot);if (err) goto out_deinit_ports;
drivers/net/dsa/ocelot/felix.h +1 -0
@@ -64,6 +64,7 @@ struct felix_info { const struct phylink_link_state *state);int (*configure_serdes)(struct ocelot *ocelot,int port,struct device_node *portnp); +int (*request_irq)(struct ocelot *ocelot); };/* Methods for initializing the hardware resources specific to a tagging
drivers/net/dsa/ocelot/felix_vsc9959.c +23 -21
64 lines not on this page · raw message
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerPATCH 6/8 net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models
In reply to Vladimir OlteanRussell King points out that seville_vsc9953 populates felix->info->num_tx_queues = 8, but this doesn't make it all the way into ds->num_tx_queues (which is how the user interface netdev queues get allocated) [1].
[1]: https://lore.kernel.org/all/20240415160150.yejcazpjqvn7vhxu@skbuf/
When num_tx_queues=0 for seville, this is implicitly converted to 1 by dsa_user_create(), and this is good enough for basic operation for a switch port. The tc qdisc offload layer works with netdev TX queues, so for QoS offload we need to pretend we have multiple TX queues. The VSC9953, like ocelot_ext, doesn't export QoS offload, so it doesn't really matter. But we can definitely set num_tx_queues=8 for all switches.
The felix->info->num_tx_queues construct itself seems unnecessary. It was introduced by commit de143c0e274b ("net: dsa: felix: Configure Time-Aware Scheduler via taprio offload") at a time when vsc9959 (LS1028A) was the only switch supported by the driver.
8 traffic classes, and 1 queue per traffic class, is a common architectural feature of all switches in the family. So they could all just set OCELOT_NUM_TC and be fine.
--- drivers/net/dsa/ocelot/felix.h | 1 - drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/ocelot/ocelot_ext.c | 3 +-- drivers/net/dsa/ocelot/seville_vsc9953.c | 3 ++- 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/dsa/ocelot/felix.h +0 -1
@@ -32,7 +32,6 @@ struct felix_info {const u32 *port_modes;int num_mact_rows;int num_ports; -int num_tx_queues;struct vcap_props *vcap;u16 vcap_pol_base;u16 vcap_pol_max;
drivers/net/dsa/ocelot/felix_vsc9959.c +2 -2
@@ -2658,7 +2658,6 @@ static const struct felix_info felix_info_vsc9959 = { .vcap_pol_max2 = 0, .num_mact_rows = 2048, .num_ports = VSC9959_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .quirks = FELIX_MAC_QUIRKS, .quirk_no_xtr_irq = true, .ptp_caps = &vsc9959_ptp_caps,
@@ -2711,7 +2710,8 @@ static int felix_pci_probe(struct pci_dev *pdev, ds->dev = dev; ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = felix->info->num_tx_queues; + ds->num_tx_queues =OCELOT_NUM_TC ; + ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; ds->priv = ocelot;
drivers/net/dsa/ocelot/ocelot_ext.c +1 -2
@@ -57,7 +57,6 @@ static const struct felix_info vsc7512_info = { .vcap = vsc7514_vcap_props, .num_mact_rows = 1024, .num_ports = VSC7514_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .port_modes = vsc7512_port_modes, .phylink_mac_config = ocelot_phylink_mac_config, .configure_serdes = ocelot_port_configure_serdes,
@@ -90,7 +89,7 @@ static int ocelot_ext_probe(struct platform_device *pdev) ds->dev = dev; ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = felix->info->num_tx_queues; + ds->num_tx_queues =OCELOT_NUM_TC ; ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops;
drivers/net/dsa/ocelot/seville_vsc9953.c +2 -1
@@ -963,7 +963,6 @@ static const struct felix_info seville_info_vsc9953 = { .quirks = FELIX_MAC_QUIRKS, .num_mact_rows = 2048, .num_ports = VSC9953_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .mdio_bus_alloc = vsc9953_mdio_bus_alloc, .mdio_bus_free = vsc9953_mdio_bus_free, .port_modes = vsc9953_port_modes,
@@ -1002,6 +1001,8 @@ static int seville_probe(struct platform_device *pdev) ds->dev = dev; ds->num_ports = felix->info->num_ports; + ds->num_tx_queues =OCELOT_NUM_TC ; + ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; ds->priv = ocelot;
Signature · 1 line
2.34.1
Re: [PATCH net-next 6/8] net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models
Quoted 40 lines · Vladimir Oltean
Russell King points out that
seville_vsc9953populatesfelix->info->num_tx_queues= 8, but this doesn't make it all the way intods->num_tx_queues(which is how the user interface netdev queues get allocated) [1].[1]: https://lore.kernel.org/all/20240415160150.yejcazpjqvn7vhxu@skbuf/
When num_tx_queues=0 for seville, this is implicitly converted to 1 by
dsa_user_create(), and this is good enough for basic operation for a switch port. The tc qdisc offload layer works with netdev TX queues, so for QoS offload we need to pretend we have multiple TX queues. The VSC9953, likeocelot_ext, doesn't export QoS offload, so it doesn't really matter. But we can definitely set num_tx_queues=8 for all switches.The
felix->info->num_tx_queuesconstruct itself seems unnecessary. It was introduced by commitde143c0e274b("net: dsa: felix: Configure Time-Aware Scheduler via taprio offload") at a time when vsc9959 (LS1028A) was the only switch supported by the driver.8 traffic classes, and 1 queue per traffic class, is a common architectural feature of all switches in the family. So they could all just set
OCELOT_NUM_TCand be fine.Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/felix.h | 1 - drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/ocelot/ocelot_ext.c | 3 +--drivers/net/dsa/ocelot/ocelot_ext.c +0
-1@@ -57,7 +57,6 @@ static const struct felix_info vsc7512_info = { .vcap = vsc7514_vcap_props, .num_mact_rows = 1024, .num_ports = VSC7514_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .port_modes = vsc7512_port_modes, .phylink_mac_config = ocelot_phylink_mac_config, .configure_serdes = ocelot_port_configure_serdes,
drivers/net/dsa/ocelot/ocelot_ext.c static int ocelot_ext_probe(struct platform_device *pdev) · line 95
Quoted 8 lines
drivers/net/dsa/ocelot/ocelot_ext.c +1
-1@@ -90,7 +89,7 @@ static int ocelot_ext_probe(struct platform_device *pdev) ds->dev = dev; ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = felix->info->num_tx_queues; + ds->num_tx_queues =OCELOT_NUM_TC ; ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops;
For ocelot_ext
Re: [PATCH net-next 6/8] net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models
In reply to Vladimir OlteanQuoted 24 lines · Vladimir Oltean
Russell King points out that
seville_vsc9953populatesfelix->info->num_tx_queues= 8, but this doesn't make it all the way intods->num_tx_queues(which is how the user interface netdev queues get allocated) [1].[1]: https://lore.kernel.org/all/20240415160150.yejcazpjqvn7vhxu@skbuf/
When num_tx_queues=0 for seville, this is implicitly converted to 1 by
dsa_user_create(), and this is good enough for basic operation for a switch port. The tc qdisc offload layer works with netdev TX queues, so for QoS offload we need to pretend we have multiple TX queues. The VSC9953, likeocelot_ext, doesn't export QoS offload, so it doesn't really matter. But we can definitely set num_tx_queues=8 for all switches.The
felix->info->num_tx_queuesconstruct itself seems unnecessary. It was introduced by commitde143c0e274b("net: dsa: felix: Configure Time-Aware Scheduler via taprio offload") at a time when vsc9959 (LS1028A) was the only switch supported by the driver.8 traffic classes, and 1 queue per traffic class, is a common architectural feature of all switches in the family. So they could all just set
OCELOT_NUM_TCand be fine.
Quoted 5 lines
Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/felix.h | 1 - drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/ocelot/ocelot_ext.c | 3 +--
Vladimir Oltean
maintainerPATCH 7/8 net: dsa: ocelot: common probing code
In reply to Vladimir OlteanRussell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init code, which could be made common [1].
[1]: https://lore.kernel.org/all/[email protected]/
Here, we take the following common steps:
- "felix" and "ds" structure allocation
- "felix", "ocelot" and "ds" basic structure initialization
- dsa_register_switch() call
and we make a common function out of them.
For every driver except felix_vsc9959, this is also the entire probing procedure. For felix_vsc9959, we also need to do some PCI-specific stuff, which can easily be reordered to be done before, and unwound on failure.
We also have to convert the bus-specific platform_set_drvdata() and pci_set_drvdata() calls into dev_set_drvdata(). But this should have no impact on the behavior.
--- drivers/net/dsa/ocelot/felix.c | 47 ++++++++++++++++++++++++ drivers/net/dsa/ocelot/felix.h | 5 +++ drivers/net/dsa/ocelot/felix_vsc9959.c | 44 +++------------------- drivers/net/dsa/ocelot/ocelot_ext.c | 40 +------------------- drivers/net/dsa/ocelot/seville_vsc9953.c | 38 ++----------------- 5 files changed, 63 insertions(+), 111 deletions(-)
drivers/net/dsa/ocelot/felix.c +47 -0
@@ -2195,6 +2195,53 @@ const struct dsa_switch_ops felix_switch_ops = { };EXPORT_SYMBOL_GPL (felix_switch_ops); +int felix_register_switch (struct device *dev,resource_size_t switch_base, +int num_flooding_pgids,bool ptp, +bool mm_supported, +enum dsa_tag_protocol init_tag_proto, +const struct felix_info *info) +{ +struct dsa_switch *ds; +struct ocelot *ocelot; +struct felix *felix; +int err; + + felix =devm_kzalloc (dev,sizeof (*felix),GFP_KERNEL ); +if (!felix) +return -ENOMEM ; + + ds =devm_kzalloc (dev,sizeof (*ds),GFP_KERNEL ); +if (!ds) +return -ENOMEM ; + +dev_set_drvdata (dev, felix); + + ocelot = &felix->ocelot; + ocelot->dev = dev; + ocelot->num_flooding_pgids = num_flooding_pgids; + ocelot->ptp = ptp; + ocelot->mm_supported = mm_supported; + + felix->info = info; + felix->switch_base = switch_base; + felix->ds = ds; + felix->tag_proto = init_tag_proto; + + ds->dev = dev; + ds->num_ports = info->num_ports; + ds->num_tx_queues =OCELOT_NUM_TC ; + ds->ops = &felix_switch_ops; + ds->phylink_mac_ops = &felix_phylink_mac_ops; + ds->priv = ocelot; + + err =dsa_register_switch (ds); +if (err) +dev_err_probe (dev, err,"Failed to register DSA switch\n" ); + +return err; +} +EXPORT_SYMBOL_GPL (felix_register_switch); +struct net_device *felix_port_to_netdev (struct ocelot *ocelot,int port) {struct felix *felix =ocelot_to_felix (ocelot);
drivers/net/dsa/ocelot/felix.h +5 -0
@@ -100,6 +100,11 @@ struct felix {unsigned long host_flood_mc_mask; }; +int felix_register_switch (struct device *dev,resource_size_t switch_base, +int num_flooding_pgids,bool ptp, +bool mm_supported, +enum dsa_tag_protocol init_tag_proto, +const struct felix_info *info);struct net_device *felix_port_to_netdev (struct ocelot *ocelot,int port);int felix_netdev_to_port (struct net_device *dev);
drivers/net/dsa/ocelot/felix_vsc9959.c +6 -38
60 lines not on this page · raw message
drivers/net/dsa/ocelot/ocelot_ext.c +2 -38
@@ -64,44 +64,8 @@ static const struct felix_info vsc7512_info = {static int ocelot_ext_probe (struct platform_device *pdev) { -struct device *dev = &pdev->dev; -struct dsa_switch *ds; -struct ocelot *ocelot; -struct felix *felix; -int err; - - felix =devm_kzalloc (dev,sizeof (*felix),GFP_KERNEL ); -if (!felix) -return -ENOMEM ; - -dev_set_drvdata (dev, felix); - - ocelot = &felix->ocelot; - ocelot->dev = dev; - - ocelot->num_flooding_pgids =1 ; - - felix->info = &vsc7512_info; - - ds =devm_kzalloc (dev,sizeof (*ds),GFP_KERNEL ); -if (!ds) -return -ENOMEM ; - - ds->dev = dev; - ds->num_ports = felix->info->num_ports; - ds->num_tx_queues =OCELOT_NUM_TC ; - - ds->ops = &felix_switch_ops; - ds->phylink_mac_ops = &felix_phylink_mac_ops; - ds->priv = ocelot; - felix->ds = ds; - felix->tag_proto =DSA_TAG_PROTO_OCELOT ; - - err =dsa_register_switch (ds); -if (err) -dev_err_probe (dev, err,"Failed to register DSA switch\n" ); - -return err; +return felix_register_switch (&pdev->dev,0 ,1 , false, false, +DSA_TAG_PROTO_OCELOT , &vsc7512_info); }static void ocelot_ext_remove (struct platform_device *pdev)
drivers/net/dsa/ocelot/seville_vsc9953.c +3 -35
@@ -971,49 +971,17 @@ static const struct felix_info seville_info_vsc9953 = {static int seville_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct dsa_switch *ds; -struct ocelot *ocelot;struct resource *res; -struct felix *felix; -int err; - - felix =devm_kzalloc (dev,sizeof (struct felix ),GFP_KERNEL ); -if (!felix) -return -ENOMEM ; - -platform_set_drvdata (pdev, felix); - - ocelot = &felix->ocelot; - ocelot->dev = dev; - ocelot->num_flooding_pgids =1 ; - felix->info = &seville_info_vsc9953; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {dev_err (dev,"Invalid resource\n" );return -EINVAL ; } - felix->switch_base = res->start; - - ds =devm_kzalloc (dev,sizeof (struct dsa_switch ),GFP_KERNEL ); -if (!ds) -return -ENOMEM ; - - ds->dev = dev; - ds->num_ports = felix->info->num_ports; - ds->num_tx_queues =OCELOT_NUM_TC ; - - ds->ops = &felix_switch_ops; - ds->phylink_mac_ops = &felix_phylink_mac_ops; - ds->priv = ocelot; - felix->ds = ds; - felix->tag_proto =DSA_TAG_PROTO_SEVILLE ; - - err =dsa_register_switch (ds); -if (err) -dev_err (dev,"Failed to register DSA switch: %d\n" , err); -return err; +return felix_register_switch (dev, res->start,1 , false, false, +DSA_TAG_PROTO_SEVILLE , + &seville_info_vsc9953); }static void seville_remove (struct platform_device *pdev)
Signature · 1 line
2.34.1
Re: [PATCH net-next 7/8] net: dsa: ocelot: common probing code
Quoted 22 lines · Vladimir Oltean
Russell King suggested that
felix_vsc9959,seville_vsc9953andocelot_exthave a large portion of duplicated init code, which could be made common [1].[1]: https://lore.kernel.org/all/[email protected]/
Here, we take the following common steps:
- "felix" and "ds" structure allocation
- "felix", "ocelot" and "ds" basic structure initialization
-dsa_register_switch()calland we make a common function out of them.
For every driver except
felix_vsc9959, this is also the entire probing procedure. Forfelix_vsc9959, we also need to do some PCI-specific stuff, which can easily be reordered to be done before, and unwound on failure.We also have to convert the bus-specific
platform_set_drvdata()andpci_set_drvdata()calls intodev_set_drvdata(). But this should have no impact on the behavior.
Quoted 8 lines
Suggested-by "Russell King (Oracle)" <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/felix.c | 47 ++++++++++++++++++++++++ drivers/net/dsa/ocelot/felix.h | 5 +++ drivers/net/dsa/ocelot/felix_vsc9959.c | 44 +++------------------- drivers/net/dsa/ocelot/ocelot_ext.c | 40 +------------------- drivers/net/dsa/ocelot/seville_vsc9953.c | 38 ++-----------------
Vladimir Oltean
maintainerPATCH 8/8 net: dsa: ocelot: unexport felix_phylink_mac_ops and felix_switch_ops
In reply to Vladimir OlteanNow that the common felix_register_switch() from the umbrella driver is the only entity that accesses these data structures, we can remove them from the list of the exported symbols.
--- drivers/net/dsa/ocelot/felix.c | 6 ++---- drivers/net/dsa/ocelot/felix.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/net/dsa/ocelot/felix.c +2 -4
@@ -2106,15 +2106,14 @@ static void felix_get_mm_stats(struct dsa_switch *ds, int port,ocelot_port_get_mm_stats (ocelot, port, stats); } -const struct phylink_mac_ops felix_phylink_mac_ops = { +static const struct phylink_mac_ops felix_phylink_mac_ops = { .mac_select_pcs = felix_phylink_mac_select_pcs, .mac_config = felix_phylink_mac_config, .mac_link_down = felix_phylink_mac_link_down, .mac_link_up = felix_phylink_mac_link_up, }; -EXPORT_SYMBOL_GPL (felix_phylink_mac_ops); -const struct dsa_switch_ops felix_switch_ops = { +static const struct dsa_switch_ops felix_switch_ops = { .get_tag_protocol = felix_get_tag_protocol, .change_tag_protocol = felix_change_tag_protocol, .connect_tag_protocol = felix_connect_tag_protocol,
@@ -2193,7 +2192,6 @@ const struct dsa_switch_ops felix_switch_ops = { .port_set_host_flood = felix_port_set_host_flood, .port_change_conduit = felix_port_change_conduit, }; -EXPORT_SYMBOL_GPL (felix_switch_ops); int felix_register_switch(struct device *dev, resource_size_t switch_base, int num_flooding_pgids, bool ptp,
drivers/net/dsa/ocelot/felix.h +0 -3
@@ -82,9 +82,6 @@ struct felix_tag_proto_ops { struct netlink_ext_ack *extack); }; -extern const struct phylink_mac_ops felix_phylink_mac_ops; -extern const struct dsa_switch_ops felix_switch_ops; -/* DSA glue / front-end for struct ocelot */ struct felix {struct dsa_switch *ds;
Signature · 1 line
2.34.1
RE: [PATCH net-next 8/8] net: dsa: ocelot: unexport felix_phylink_mac_ops and felix_switch_ops
Quoted 66 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Thursday, May 30, 2024 10:04 PM
To: [email protected]
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Claudiu Manoil <[email protected]>; Alexandre Belloni <[email protected]>; [email protected]; Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; Colin Foster <colin.foster@in- advantage.com>; Russell King <[email protected]>
Subject: [PATCH net-next 8/8] net: dsa: ocelot: unexportfelix_phylink_mac_opsandfelix_switch_opsNow that the common
felix_register_switch()from the umbrella driver is the only entity that accesses these data structures, we can remove them from the list of the exported symbols.Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/felix.c | 6 ++---- drivers/net/dsa/ocelot/felix.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)drivers/net/dsa/ocelot/felix.c index renamed from drivers/net/dsa/ocelot/felix.c +0
-0
accf737f7b69..d12c4e85baa7100644drivers/net/dsa/ocelot/felix.c +2
-4@@ -2106,15 +2106,14 @@ static void felix_get_mm_stats(struct dsa_switch *ds, int port,ocelot_port_get_mm_stats (ocelot, port, stats); } -const struct phylink_mac_ops felix_phylink_mac_ops = { +static const struct phylink_mac_ops felix_phylink_mac_ops = { .mac_select_pcs = felix_phylink_mac_select_pcs, .mac_config = felix_phylink_mac_config, .mac_link_down = felix_phylink_mac_link_down, .mac_link_up = felix_phylink_mac_link_up, }; -EXPORT_SYMBOL_GPL (felix_phylink_mac_ops); -const struct dsa_switch_ops felix_switch_ops = { +static const struct dsa_switch_ops felix_switch_ops = { .get_tag_protocol = felix_get_tag_protocol, .change_tag_protocol = felix_change_tag_protocol, .connect_tag_protocol = felix_connect_tag_protocol,@@ -2193,7 +2192,6 @@ const struct dsa_switch_ops felix_switch_ops = { .port_set_host_flood = felix_port_set_host_flood, .port_change_conduit = felix_port_change_conduit, }; -EXPORT_SYMBOL_GPL (felix_switch_ops); int felix_register_switch(struct device *dev, resource_size_t switch_base, int num_flooding_pgids, bool ptp,drivers/net/dsa/ocelot/felix.h +0
-3@@ -82,9 +82,6 @@ struct felix_tag_proto_ops { struct netlink_ext_ack *extack); }; -extern const struct phylink_mac_ops felix_phylink_mac_ops; -extern conststruct dsa_switch_ops felix_switch_ops; -/* DSA glue / front-end for struct ocelot */ struct felix {struct dsa_switch *ds; --
Quoted 2 lines
2.34.1
Colin Foster
maintainerHi Vladimir,
Quoted 17 lines · Vladimir Oltean
This is a follow-up to Russell King's request for code consolidation among
felix_vsc9959,seville_vsc9953andocelot_ext, stated here:
https://lore.kernel.org/all/[email protected]/Details are in individual patches. Testing was done on NXP LS1028A (
felix_vsc9959).Vladimir Oltean (8):
net: dsa: ocelot: use devres inocelot_ext_probe()
net: dsa: ocelot: use devres inseville_probe()
net: dsa: ocelot: delete open coded status = "disabled" parsing
net: dsa: ocelot: consistently use devres infelix_pci_probe()
net: dsa: ocelot: movedevm_request_threaded_irq()tofelix_setup()
net: dsa: ocelot: useds->num_tx_queues=OCELOT_NUM_TCfor all models
net: dsa: ocelot: common probing code
net: dsa: ocelot: unexportfelix_phylink_mac_opsandfelix_switch_ops
Quoted 4 lines
drivers/net/dsa/ocelot/felix.c | 62 ++++++++++++- drivers/net/dsa/ocelot/felix.h | 10 +- drivers/net/dsa/ocelot/felix_vsc9959.c | 113 +++++++---------------- drivers/net/dsa/ocelot/ocelot_ext.c | 55 +----------
Just FYI I tried testing this but hit an unrelated regression in 6.10, and a git b4 on 6.9.3 has conflicts. So I'm still alive, but probably won't get to testing this tonight. Looks good though.
Colin Foster
Quoted 20 lines · Colin Foster
Hi Vladimir,
Quoted 17 lines · Vladimir Oltean
This is a follow-up to Russell King's request for code consolidation among
felix_vsc9959,seville_vsc9953andocelot_ext, stated here:
https://lore.kernel.org/all/[email protected]/Details are in individual patches. Testing was done on NXP LS1028A (
felix_vsc9959).Vladimir Oltean (8):
net: dsa: ocelot: use devres inocelot_ext_probe()
net: dsa: ocelot: use devres inseville_probe()
net: dsa: ocelot: delete open coded status = "disabled" parsing
net: dsa: ocelot: consistently use devres infelix_pci_probe()
net: dsa: ocelot: movedevm_request_threaded_irq()tofelix_setup()
net: dsa: ocelot: useds->num_tx_queues=OCELOT_NUM_TCfor all models
net: dsa: ocelot: common probing code
net: dsa: ocelot: unexportfelix_phylink_mac_opsandfelix_switch_ops
Quoted 8 lines
Quoted 4 lines
drivers/net/dsa/ocelot/felix.c | 62 ++++++++++++- drivers/net/dsa/ocelot/felix.h | 10 +- drivers/net/dsa/ocelot/felix_vsc9959.c | 113 +++++++---------------- drivers/net/dsa/ocelot/ocelot_ext.c | 55 +----------Just FYI I tried testing this but hit an unrelated regression in 6.10, and a
git b4on 6.9.3 has conflicts. So I'm still alive, but probably won't get to testing this tonight. Looks good though.
You will need... the net-next tree because it's dependent on a patch I submitted earlier this week.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 8 lines · On Thu, 30 May 2024 19:33:25 +0300 you wrote:
This is a follow-up to Russell King's request for code consolidation among
felix_vsc9959,seville_vsc9953andocelot_ext, stated here:
https://lore.kernel.org/all/[email protected]/Details are in individual patches. Testing was done on NXP LS1028A (
felix_vsc9959).[...]
Here is the summary with links:
- [net-next,1/8] net: dsa: ocelot: use devres in ocelot_ext_probe()
https://git.kernel.org/netdev/net-next/c/454cfffe8dc1 - [net-next,2/8] net: dsa: ocelot: use devres in seville_probe() https://git.kernel.org/netdev/net-next/c/90ee9a5b49ce - [net-next,3/8] net: dsa: ocelot: delete open coded status = "disabled" parsing https://git.kernel.org/netdev/net-next/c/cc711c523da7 - [net-next,4/8] net: dsa: ocelot: consistently use devres in felix_pci_probe() https://git.kernel.org/netdev/net-next/c/4510bbd38cbe - [net-next,5/8] net: dsa: ocelot: move devm_request_threaded_irq() to felix_setup() https://git.kernel.org/netdev/net-next/c/0367a1775933 - [net-next,6/8] net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models https://git.kernel.org/netdev/net-next/c/4ca54dd96eca - [net-next,7/8] net: dsa: ocelot: common probing code https://git.kernel.org/netdev/net-next/c/efdbee7d0791 - [net-next,8/8] net: dsa: ocelot: unexport felix_phylink_mac_ops and felix_switch_ops https://git.kernel.org/netdev/net-next/c/a4303941c6f3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html