Commit 2f2dee16 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-stmmac-clean-up-plat_dat-allocation-initialisation'

Russell King says:

====================
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:
  7 files changed, 53 insertions(+), 148 deletions(-)
====================

Link: https://patch.msgid.link/aRdKVMPHXlIn457m@shell.armlinux.org.uk


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7cf3ac8a 6409249c
Loading
Loading
Loading
Loading
+2 −41
Original line number Diff line number Diff line
@@ -569,26 +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;

	/* 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;

	/* 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;

	/* 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;
}

static struct phylink_pcs *intel_mgbe_select_pcs(struct stmmac_priv *priv,
@@ -629,22 +609,12 @@ 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;
		plat->rx_queues_cfg[i].chan = i;

		/* 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;
	}

	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;
@@ -706,15 +676,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;

	/* 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 */
@@ -1286,7 +1247,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;

+2 −20
Original line number Diff line number Diff line
@@ -95,28 +95,12 @@ 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 */
	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;

	/* Disable RX queues routing by default */
	plat->rx_queues_cfg[0].pkt_route = 0x0;

	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;

@@ -140,8 +124,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;
	}
}
@@ -559,7 +541,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
	struct 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;

+0 −1
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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;
+34 −0
Original line number Diff line number Diff line
@@ -7555,6 +7555,40 @@ 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;
	int i;

	plat_dat = devm_kzalloc(dev, sizeof(*plat_dat), GFP_KERNEL);
	if (!plat_dat)
		return NULL;

	/* Set the defaults:
	 * - phy autodetection
	 * - 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;

	/* Set the mtl defaults */
	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);

/**
 * stmmac_dvr_probe
 * @device: device pointer
Loading