net: stmmac: clean up plat_dat allocation/initialisation
Subsystems (5)
cover net: stmmac: clean up plat_dat allocation/initialisation
This series cleans up the plat_dat allocation and initialisation, moving common themes into the allocator.
This results in a nice saving:
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 43 +--------------- .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 22 +------- drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 34 ++++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 39 +------------- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 60 ++++------------------ 7 files changed, 53 insertions(+), 148 deletions(-)
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!
PATCH 1/11 net: stmmac: add stmmac_plat_dat_alloc()
Add a function to allocate and initialise the plat_stmmacenet_data structure with default values.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -1286,7 +1286,7 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,if (!intel_priv)return -ENOMEM ; - plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); + plat =stmmac_plat_dat_alloc (&pdev->dev);if (!plat)return -ENOMEM ;
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
@@ -559,7 +559,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idstruct loongson_data *ld;int ret; - plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); + plat =stmmac_plat_dat_alloc (&pdev->dev);if (!plat)return -ENOMEM ;
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -0
@@ -408,6 +408,8 @@ int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size);int stmmac_set_clk_tx_rate (void *bsp_priv,struct clk *clk_tx_i,phy_interface_t interface,int speed); +struct plat_stmmacenet_data *stmmac_plat_dat_alloc (struct device *dev); +static inline bool stmmac_xdp_is_enabled (struct stmmac_priv *priv) {return !!priv->xdp_prog;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +12 -0
@@ -7555,6 +7555,18 @@ static void stmmac_unregister_devlink(struct stmmac_priv *priv)devlink_free (priv->devlink); } +struct plat_stmmacenet_data *stmmac_plat_dat_alloc (struct device *dev) +{ +struct plat_stmmacenet_data *plat_dat; + + plat_dat =devm_kzalloc (dev,sizeof (*plat_dat),GFP_KERNEL ); +if (!plat_dat) +return NULL ; + +return plat_dat; +} +EXPORT_SYMBOL_GPL (stmmac_plat_dat_alloc); +/** * stmmac_dvr_probe * @device: device pointer
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +1 -1
@@ -191,7 +191,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,int ret;int i; - plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); + plat =stmmac_plat_dat_alloc (&pdev->dev);if (!plat)return -ENOMEM ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -1
@@ -436,7 +436,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)void *ret;int rc; - plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); + plat =stmmac_plat_dat_alloc (&pdev->dev);if (!plat)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.47.3
PATCH 2/11 net: stmmac: move initialisation of phy_addr to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->phy_addr to stmmac_plat_dat_alloc().
--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 3 --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -3
@@ -114,9 +114,6 @@ static void loongson_default_data(struct pci_dev *pdev, plat->clk_ref_rate =125000000 ; plat->clk_ptp_rate =125000000 ; -/* Default to phy auto-detection */ - plat->phy_addr =-1 ; - plat->dma_cfg->pbl =32 ; plat->dma_cfg->pblx8 = true;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
@@ -7563,6 +7563,11 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)if (!plat_dat)return NULL ; +/* Set the defaults: +* - phy autodetection +*/ + plat_dat->phy_addr =-1 ; +return plat_dat; }EXPORT_SYMBOL_GPL (stmmac_plat_dat_alloc);
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -1
@@ -112,7 +112,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, } plat->bus_id =1 ; - plat->phy_addr =-1 ; plat->phy_interface =PHY_INTERFACE_MODE_GMII ; plat->dma_cfg->pbl =32 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -2
@@ -480,8 +480,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->bus_id = ++bus_id; } -/* Default to phy auto-detection */ - plat->phy_addr =-1 ;/* Default to get clk_csr from stmmac_clk_csr_set(), * or get clk_csr from device tree.
Signature · 1 line
2.47.3
PATCH 3/11 net: stmmac: move initialisation of clk_csr to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->clk_csr to stmmac_plat_dat_alloc().
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -7565,8 +7565,10 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)/* Set the defaults: * - phy autodetection +* - determine GMII_Address CR field from CSR clock */ plat_dat->phy_addr =-1 ; + plat_dat->clk_csr =-1 ;return plat_dat; }
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -5
@@ -480,11 +480,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->bus_id = ++bus_id; } - -/* Default to get clk_csr from stmmac_clk_csr_set(), -* or get clk_csr from device tree. -*/ - plat->clk_csr =-1 ;if (of_property_read_u32 (np,"snps,clk-csr" , &plat->clk_csr))of_property_read_u32 (np,"clk_csr" , &plat->clk_csr);
Signature · 1 line
2.47.3
PATCH 4/11 net: stmmac: move initialisation of maxmtu to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->maxmtu to JUMBO_LEN to stmmac_plat_dat_alloc().
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 3 --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 5 files changed, 2 insertions(+), 20 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -6
@@ -576,9 +576,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat)/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ; -/* Set the maxmtu to a default of JUMBO_LEN */ - plat->maxmtu =JUMBO_LEN ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =1 ; plat->rx_queues_to_use =1 ;
@@ -712,9 +709,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ; -/* Set the maxmtu to a default of JUMBO_LEN */ - plat->maxmtu =JUMBO_LEN ; - plat->flags |=STMMAC_FLAG_VLAN_FAIL_Q_EN ;/* Use the last Rx queue */
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -3
@@ -101,9 +101,6 @@ static void loongson_default_data(struct pci_dev *pdev,/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ; -/* Set the maxmtu to a default of JUMBO_LEN */ - plat->maxmtu =JUMBO_LEN ; -/* Disable Priority config by default */ plat->tx_queues_cfg[0 ].use_prio = false; plat->rx_queues_cfg[0 ].use_prio = false;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -7566,9 +7566,11 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)/* Set the defaults: * - phy autodetection * - determine GMII_Address CR field from CSR clock +* - allow MTU up to JUMBO_LEN */ plat_dat->phy_addr =-1 ; plat_dat->clk_csr =-1 ; + plat_dat->maxmtu =JUMBO_LEN ;return plat_dat; }
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -6
@@ -34,9 +34,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat)/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ; -/* Set the maxmtu to a default of JUMBO_LEN */ - plat->maxmtu =JUMBO_LEN ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =1 ; plat->rx_queues_to_use =1 ;
@@ -87,9 +84,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev,/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ; -/* Set the maxmtu to a default of JUMBO_LEN */ - plat->maxmtu =JUMBO_LEN ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =4 ; plat->rx_queues_to_use =4 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -5
@@ -508,11 +508,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->flags |=STMMAC_FLAG_EN_TX_LPI_CLOCKGATING ; } -/* Set the maxmtu to a default of JUMBO_LEN in case the -* parameter is not present in the device tree. -*/ - plat->maxmtu =JUMBO_LEN ; -/* Set default value for multicast hash bins */ plat->multicast_filter_bins =HASH_TABLE_SIZE ;
Signature · 1 line
2.47.3
PATCH 5/11 net: stmmac: move initialisation of multicast_filter_bins to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->multicast_filter_bins to HASH_TABLE_SIZE to stmmac_plat_dat_alloc(). This means platform glue only needs to override this if different.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 --- 5 files changed, 3 insertions(+), 16 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -6
@@ -570,9 +570,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; -/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
@@ -703,9 +700,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config; -/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; -/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
@@ -95,7 +95,7 @@ static void loongson_default_data(struct pci_dev *pdev, plat->core_type =DWMAC_CORE_GMAC ; plat->force_sf_dma_mode =1 ; -/* Set default value for multicast hash bins */ +/* Increase the default value for multicast hash bins */ plat->multicast_filter_bins =256 ;/* Set default value for unicast filter entries */
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -7567,10 +7567,12 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)* - phy autodetection * - determine GMII_Address CR field from CSR clock * - allow MTU up to JUMBO_LEN +* - hash table size */ plat_dat->phy_addr =-1 ; plat_dat->clk_csr =-1 ; plat_dat->maxmtu =JUMBO_LEN ; + plat_dat->multicast_filter_bins =HASH_TABLE_SIZE ;return plat_dat; }
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -6
@@ -28,9 +28,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; -/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
@@ -78,9 +75,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->flags |=STMMAC_FLAG_TSO_EN ; plat->pmt =1 ; -/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; -/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -3
@@ -508,9 +508,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->flags |=STMMAC_FLAG_EN_TX_LPI_CLOCKGATING ; } -/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; -/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
Signature · 1 line
2.47.3
PATCH 6/11 net: stmmac: move initialisation of unicast_filter_entries to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->unicast_filter_entries to 1 to stmmac_plat_dat_alloc(). This means platform glue only needs to override this if different.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 3 --- drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 --- 6 files changed, 2 insertions(+), 19 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -6
@@ -570,9 +570,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =1 ; plat->rx_queues_to_use =1 ;
@@ -700,9 +697,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config; -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; - plat->flags |=STMMAC_FLAG_VLAN_FAIL_Q_EN ;/* Use the last Rx queue */
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -3
@@ -98,9 +98,6 @@ static void loongson_default_data(struct pci_dev *pdev,/* Increase the default value for multicast hash bins */ plat->multicast_filter_bins =256 ; -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; -/* Disable Priority config by default */ plat->tx_queues_cfg[0 ].use_prio = false; plat->rx_queues_cfg[0 ].use_prio = false;
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c +0 -1
@@ -24,7 +24,6 @@ static int sophgo_sg2044_dwmac_init(struct platform_device *pdev, plat_dat->flags |=STMMAC_FLAG_SPH_DISABLE ; plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate; plat_dat->multicast_filter_bins =0 ; - plat_dat->unicast_filter_entries =1 ;return 0 ; }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -7568,11 +7568,13 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)* - determine GMII_Address CR field from CSR clock * - allow MTU up to JUMBO_LEN * - hash table size +* - one unicast filter entry */ plat_dat->phy_addr =-1 ; plat_dat->clk_csr =-1 ; plat_dat->maxmtu =JUMBO_LEN ; plat_dat->multicast_filter_bins =HASH_TABLE_SIZE ; + plat_dat->unicast_filter_entries =1 ;return plat_dat; }
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -6
@@ -28,9 +28,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =1 ; plat->rx_queues_to_use =1 ;
@@ -75,9 +72,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->flags |=STMMAC_FLAG_TSO_EN ; plat->pmt =1 ; -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; -/* Set default number of RX and TX queues to use */ plat->tx_queues_to_use =4 ; plat->rx_queues_to_use =4 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -3
@@ -508,9 +508,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->flags |=STMMAC_FLAG_EN_TX_LPI_CLOCKGATING ; } -/* Set default value for unicast filter entries */ - plat->unicast_filter_entries =1 ; -/* * Currently only the properties needed on SPEAr600 * are provided. All other properties should be added
Signature · 1 line
2.47.3
PATCH 7/11 net: stmmac: move initialisation of queues_to_use to stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Move the default initialisation of plat_dat->tx_queues_to_use and plat_dat->rx_queues_to_use to 1 to stmmac_plat_dat_alloc(). This means platform glue only needs to override this if different.
--- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ---- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 2 -- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ---- .../ethernet/stmicro/stmmac/stmmac_platform.c | 17 ++++------------- 5 files changed, 8 insertions(+), 23 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -4
@@ -570,10 +570,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default number of RX and TX queues to use */ - plat->tx_queues_to_use =1 ; - plat->rx_queues_to_use =1 ; -/* Disable Priority config by default */ plat->tx_queues_cfg[0 ].use_prio = false; plat->rx_queues_cfg[0 ].use_prio = false;
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -2
@@ -131,8 +131,6 @@ static void loongson_default_data(struct pci_dev *pdev,break ;default : ld->multichan =0 ; - plat->tx_queues_to_use =1 ; - plat->rx_queues_to_use =1 ;break ; } }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -7576,6 +7576,10 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev) plat_dat->multicast_filter_bins =HASH_TABLE_SIZE ; plat_dat->unicast_filter_entries =1 ; +/* Set the mtl defaults */ + plat_dat->tx_queues_to_use =1 ; + plat_dat->rx_queues_to_use =1 ; +return plat_dat; }EXPORT_SYMBOL_GPL (stmmac_plat_dat_alloc);
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -4
@@ -28,10 +28,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Set default number of RX and TX queues to use */ - plat->tx_queues_to_use =1 ; - plat->rx_queues_to_use =1 ; -/* Disable Priority config by default */ plat->tx_queues_cfg[0 ].use_prio = false; plat->rx_queues_cfg[0 ].use_prio = false;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 -13
@@ -137,13 +137,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev,u8 queue =0 ;int ret =0 ; -/* For backwards-compatibility with device trees that don't have any -* snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back -* to one RX and TX queues each. -*/ - plat->rx_queues_to_use =1 ; - plat->tx_queues_to_use =1 ; -/* First Queue must always be in DCB mode. As MTL_QUEUE_DCB = 1 we need * to always set this, otherwise Queue will be classified as AVB * (because MTL_QUEUE_AVB = 0).
@@ -162,9 +155,8 @@ static int stmmac_mtl_setup(struct platform_device *pdev, }/* Processing RX queues common config */ -if (of_property_read_u32 (rx_node,"snps,rx-queues-to-use" , - &plat->rx_queues_to_use)) - plat->rx_queues_to_use =1 ; +of_property_read_u32 (rx_node,"snps,rx-queues-to-use" , + &plat->rx_queues_to_use);if (of_property_read_bool (rx_node,"snps,rx-sched-sp" )) plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ;
@@ -221,9 +213,8 @@ static int stmmac_mtl_setup(struct platform_device *pdev, }/* Processing TX queues common config */ -if (of_property_read_u32 (tx_node,"snps,tx-queues-to-use" , - &plat->tx_queues_to_use)) - plat->tx_queues_to_use =1 ; +of_property_read_u32 (tx_node,"snps,tx-queues-to-use" , + &plat->tx_queues_to_use);if (of_property_read_bool (tx_node,"snps,tx-sched-wrr" )) plat->tx_sched_algorithm =MTL_TX_ALGORITHM_WRR ;
Signature · 1 line
2.47.3
PATCH 8/11 net: stmmac: setup default RX channel map in stmmac_plat_dat_alloc()
In reply to Russell King (Oracle)Setup the default 1:1 RX channel map in stmmac_plat_dat_alloc() and remove 1:1 initialisations from platform glue drivers.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ++--- 4 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -1
@@ -618,7 +618,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,for (i =0 ; i < plat->rx_queues_to_use; i++) { plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; - plat->rx_queues_cfg[i].chan = i;/* Disable Priority config by default */ plat->rx_queues_cfg[i].use_prio = false;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
@@ -7558,6 +7558,7 @@ static void stmmac_unregister_devlink(struct stmmac_priv *priv)struct plat_stmmacenet_data *stmmac_plat_dat_alloc (struct device *dev) {struct plat_stmmacenet_data *plat_dat; +int i; plat_dat =devm_kzalloc (dev,sizeof (*plat_dat),GFP_KERNEL );if (!plat_dat)
@@ -7580,6 +7581,10 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev) plat_dat->tx_queues_to_use =1 ; plat_dat->rx_queues_to_use =1 ; +/* Setup the default RX queue channel map */ +for (i =0 ; i <ARRAY_SIZE (plat_dat->rx_queues_cfg); i++) + plat_dat->rx_queues_cfg[i].chan = i; +return plat_dat; }EXPORT_SYMBOL_GPL (stmmac_plat_dat_alloc);
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -1
@@ -86,7 +86,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->rx_queues_cfg[i].use_prio = false; plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; plat->rx_queues_cfg[i].pkt_route =0x0 ; - plat->rx_queues_cfg[i].chan = i; } plat->bus_id =1 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -3
@@ -177,9 +177,8 @@ static int stmmac_mtl_setup(struct platform_device *pdev,else plat->rx_queues_cfg[queue].mode_to_use =MTL_QUEUE_DCB ; -if (of_property_read_u32 (q_node,"snps,map-to-dma-channel" , - &plat->rx_queues_cfg[queue].chan)) - plat->rx_queues_cfg[queue].chan = queue; +of_property_read_u32 (q_node,"snps,map-to-dma-channel" , + &plat->rx_queues_cfg[queue].chan);/* TODO: Dynamic mapping to be included in the future */ if (of_property_read_u32(q_node, "snps,priority",
Signature · 1 line
2.47.3
PATCH 9/11 net: stmmac: remove unnecessary .use_prio queue initialisation
In reply to Russell King (Oracle)Several drivers (see below) explicitly set the queue .use_prio configuration to false. However, as this structure is allocated using devm_kzalloc(), all members default to zero unless otherwise explicitly initialised. .use_prio isn't, so defaults to false. Remove these unnecessary initialisations, leaving stmmac_platform.c as the only file that .use_prio is set true.
$ grep 'use_prio =' *.c dwmac-intel.c: plat->tx_queues_cfg[0].use_prio = false; dwmac-intel.c: plat->rx_queues_cfg[0].use_prio = false; dwmac-intel.c: plat->rx_queues_cfg[i].use_prio = false; dwmac-intel.c: plat->tx_queues_cfg[i].use_prio = false; dwmac-loongson.c: plat->tx_queues_cfg[0].use_prio = false; dwmac-loongson.c: plat->rx_queues_cfg[0].use_prio = false; stmmac_pci.c: plat->tx_queues_cfg[0].use_prio = false; stmmac_pci.c: plat->rx_queues_cfg[0].use_prio = false; stmmac_pci.c: plat->tx_queues_cfg[i].use_prio = false; stmmac_pci.c: plat->rx_queues_cfg[i].use_prio = false; stmmac_platform.c: plat->rx_queues_cfg[queue].use_prio = false; stmmac_platform.c: plat->rx_queues_cfg[queue].use_prio = true; stmmac_platform.c: plat->tx_queues_cfg[queue].use_prio = false; stmmac_platform.c: plat->tx_queues_cfg[queue].use_prio = true;
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 9 --------- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 4 ---- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 -- 4 files changed, 21 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -9
@@ -570,10 +570,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Disable Priority config by default */ - plat->tx_queues_cfg[0 ].use_prio = false; - plat->rx_queues_cfg[0 ].use_prio = false; -/* Disable RX queues routing by default */ plat->rx_queues_cfg[0 ].pkt_route =0x0 ; }
@@ -619,9 +615,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,for (i =0 ; i < plat->rx_queues_to_use; i++) { plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; -/* Disable Priority config by default */ - plat->rx_queues_cfg[i].use_prio = false; -/* Disable RX queues routing by default */ plat->rx_queues_cfg[i].pkt_route =0x0 ; }
@@ -629,8 +622,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,for (i =0 ; i < plat->tx_queues_to_use; i++) { plat->tx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; -/* Disable Priority config by default */ - plat->tx_queues_cfg[i].use_prio = false;/* Default TX Q0 to use TSO and rest TXQ for TBS */ if (i >0 ) plat->tx_queues_cfg[i].tbs_en =1 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -4
@@ -98,10 +98,6 @@ static void loongson_default_data(struct pci_dev *pdev,/* Increase the default value for multicast hash bins */ plat->multicast_filter_bins =256 ; -/* Disable Priority config by default */ - plat->tx_queues_cfg[0 ].use_prio = false; - plat->rx_queues_cfg[0 ].use_prio = false; -/* Disable RX queues routing by default */ plat->rx_queues_cfg[0 ].pkt_route =0x0 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -6
@@ -28,10 +28,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->mdio_bus_data->needs_reset = true; -/* Disable Priority config by default */ - plat->tx_queues_cfg[0 ].use_prio = false; - plat->rx_queues_cfg[0 ].use_prio = false; -/* Disable RX queues routing by default */ plat->rx_queues_cfg[0 ].pkt_route =0x0 ; }
@@ -74,7 +70,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->tx_sched_algorithm =MTL_TX_ALGORITHM_WRR ;for (i =0 ; i < plat->tx_queues_to_use; i++) { - plat->tx_queues_cfg[i].use_prio = false; plat->tx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; plat->tx_queues_cfg[i].weight =25 ;if (i >0 )
@@ -83,7 +78,6 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ;for (i =0 ; i < plat->rx_queues_to_use; i++) { - plat->rx_queues_cfg[i].use_prio = false; plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; plat->rx_queues_cfg[i].pkt_route =0x0 ; }
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -2
@@ -184,7 +184,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev,if (of_property_read_u32 (q_node,"snps,priority" , &plat->rx_queues_cfg[queue].prio)) { plat->rx_queues_cfg[queue].prio =0 ; - plat->rx_queues_cfg[queue].use_prio = false; }else { plat->rx_queues_cfg[queue].use_prio = true; }
@@ -261,7 +260,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev,if (of_property_read_u32 (q_node,"snps,priority" , &plat->tx_queues_cfg[queue].prio)) { plat->tx_queues_cfg[queue].prio =0 ; - plat->tx_queues_cfg[queue].use_prio = false; }else { plat->tx_queues_cfg[queue].use_prio = true; }
Signature · 1 line
2.47.3
PATCH 10/11 net: stmmac: remove unnecessary .prio queue initialisation
In reply to Russell King (Oracle)stmmac_platform.c explicitly sets .prio to zero if the snps,priority property is not present in DT for the queue. However, as the struct is allocated using devm_kzalloc(), all members default to zero unless explicitly initialised, and of_property_read_u32() will not write to its argument if the property is not found. Thus, explicitly setting these to zero is unnecessary. Remove these.
$ grep '\.prio =' *.c stmmac_platform.c: plat->rx_queues_cfg[queue].prio = 0; stmmac_platform.c: plat->tx_queues_cfg[queue].prio = 0;
--- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 -10
@@ -181,12 +181,9 @@ static int stmmac_mtl_setup(struct platform_device *pdev, &plat->rx_queues_cfg[queue].chan);/* TODO: Dynamic mapping to be included in the future */ -if (of_property_read_u32 (q_node,"snps,priority" , - &plat->rx_queues_cfg[queue].prio)) { - plat->rx_queues_cfg[queue].prio =0 ; - }else { +if (!of_property_read_u32 (q_node,"snps,priority" , + &plat->rx_queues_cfg[queue].prio)) plat->rx_queues_cfg[queue].use_prio = true; - }/* RX queue specific packet type routing */ if (of_property_read_bool (q_node,"snps,route-avcp" ))
@@ -257,12 +254,9 @@ static int stmmac_mtl_setup(struct platform_device *pdev, plat->tx_queues_cfg[queue].mode_to_use =MTL_QUEUE_DCB ; } -if (of_property_read_u32 (q_node,"snps,priority" , - &plat->tx_queues_cfg[queue].prio)) { - plat->tx_queues_cfg[queue].prio =0 ; - }else { +if (!of_property_read_u32 (q_node,"snps,priority" , + &plat->tx_queues_cfg[queue].prio)) plat->tx_queues_cfg[queue].use_prio = true; - } plat->tx_queues_cfg[queue].coe_unsupported =of_property_read_bool (q_node,"snps,coe-unsupported" );
Signature · 1 line
2.47.3
PATCH 11/11 net: stmmac: remove unnecessary .pkt_route queue initialisation
In reply to Russell King (Oracle)PCI drivers explicitly set .pkt_route to zero. However, as the struct is allocated using devm_kzalloc(), all members default to zero unless explicitly initialised. Thus, explicitly setting these to zero is unnecessary. Remove these. This leaves only stmmac_platform.c where this is explicitly initialised depending on DT properties.
$ grep '\.pkt_route =' *.c dwmac-intel.c: plat->rx_queues_cfg[0].pkt_route = 0x0; dwmac-intel.c: plat->rx_queues_cfg[i].pkt_route = 0x0; dwmac-loongson.c: plat->rx_queues_cfg[0].pkt_route = 0x0; stmmac_main.c: if (priv->plat->rx_queues_cfg[queue].pkt_route == 0x0) stmmac_pci.c: plat->rx_queues_cfg[0].pkt_route = 0x0; stmmac_pci.c: plat->rx_queues_cfg[i].pkt_route = 0x0; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = PACKET_AVCPQ; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = PACKET_PTPQ; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = PACKET_DCBCPQ; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = PACKET_UPQ; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = PACKET_MCBCQ; stmmac_platform.c: plat->rx_queues_cfg[queue].pkt_route = 0x0;
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 9 +-------- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 3 --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 7 +------ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 -- 4 files changed, 2 insertions(+), 19 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -8
@@ -569,9 +569,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->force_sf_dma_mode =1 ; plat->mdio_bus_data->needs_reset = true; - -/* Disable RX queues routing by default */ - plat->rx_queues_cfg[0 ].pkt_route =0x0 ; } static struct phylink_pcs *intel_mgbe_select_pcs(struct stmmac_priv *priv,
@@ -612,13 +609,9 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ; -for (i =0 ; i < plat->rx_queues_to_use; i++) { +for (i =0 ; i < plat->rx_queues_to_use; i++) plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; -/* Disable RX queues routing by default */ - plat->rx_queues_cfg[i].pkt_route =0x0 ; - } -for (i =0 ; i < plat->tx_queues_to_use; i++) { plat->tx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ;
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -3
@@ -98,9 +98,6 @@ static void loongson_default_data(struct pci_dev *pdev,/* Increase the default value for multicast hash bins */ plat->multicast_filter_bins =256 ; -/* Disable RX queues routing by default */ - plat->rx_queues_cfg[0 ].pkt_route =0x0 ; - plat->clk_ref_rate =125000000 ; plat->clk_ptp_rate =125000000 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +1 -6
@@ -27,9 +27,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->force_sf_dma_mode =1 ; plat->mdio_bus_data->needs_reset = true; - -/* Disable RX queues routing by default */ - plat->rx_queues_cfg[0 ].pkt_route =0x0 ; } static int stmmac_default_data(struct pci_dev *pdev,
@@ -77,10 +74,8 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, } plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ; -for (i =0 ; i < plat->rx_queues_to_use; i++) { +for (i =0 ; i < plat->rx_queues_to_use; i++) plat->rx_queues_cfg[i].mode_to_use =MTL_QUEUE_DCB ; - plat->rx_queues_cfg[i].pkt_route =0x0 ; - } plat->bus_id =1 ; plat->phy_interface =PHY_INTERFACE_MODE_GMII ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -2
@@ -196,8 +196,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev, plat->rx_queues_cfg[queue].pkt_route =PACKET_UPQ ; else if (of_property_read_bool(q_node, "snps,route-multi-broad")) plat->rx_queues_cfg[queue].pkt_route =PACKET_MCBCQ ; - else - plat->rx_queues_cfg[queue].pkt_route = 0x0; queue++; }
Signature · 1 line
2.47.3
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Fri, 14 Nov 2025 15:27:16 +0000 you wrote:
This series cleans up the
plat_datallocation and initialisation, moving common themes into the allocator.This results in a nice saving:
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 43 +--------------- .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 22 +------- drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c | 1 - drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 34 ++++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 39 +------------- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 60 ++++------------------ 7 files changed, 53 insertions(+), 148 deletions(-)
Here is the summary with links:
- [net-next,01/11] net: stmmac: add stmmac_plat_dat_alloc()
https://git.kernel.org/netdev/net-next/c/511171e47f8b - [net-next,02/11] net: stmmac: move initialisation of phy_addr to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/99e6ddaabdb4 - [net-next,03/11] net: stmmac: move initialisation of clk_csr to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/ae4f29712bf3 - [net-next,04/11] net: stmmac: move initialisation of maxmtu to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/528478a746a5 - [net-next,05/11] net: stmmac: move initialisation of multicast_filter_bins to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/07cedb9eed41 - [net-next,06/11] net: stmmac: move initialisation of unicast_filter_entries to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/bcb145c69690 - [net-next,07/11] net: stmmac: move initialisation of queues_to_use to stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/d5e788e86fe3 - [net-next,08/11] net: stmmac: setup default RX channel map in stmmac_plat_dat_alloc() https://git.kernel.org/netdev/net-next/c/b6d013b3260b - [net-next,09/11] net: stmmac: remove unnecessary .use_prio queue initialisation https://git.kernel.org/netdev/net-next/c/c03101cb1bf0 - [net-next,10/11] net: stmmac: remove unnecessary .prio queue initialisation https://git.kernel.org/netdev/net-next/c/0a20999ed452 - [net-next,11/11] net: stmmac: remove unnecessary .pkt_route queue initialisation https://git.kernel.org/netdev/net-next/c/6409249ccc15
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html