net: stmmac: replace boolean fields in plat_stmmacenet_data with flags
Subsystems (8)
v2 cover net: stmmac: replace boolean fields in plat_stmmacenet_data with flags
From: Bartosz Golaszewski <[email protected]>
As suggested by Jose Abreu: let's drop all 12 boolean fields in plat_stmmacenet_data and replace them with a common bitfield.
v1 -> v2:
- fix build on intel platforms
Bartosz Golaszewski (12):
net: stmmac: replace the has_integrated_pcs field with a flag
net: stmmac: replace the sph_disable field with a flag
net: stmmac: replace the use_phy_wol field with a flag
net: stmmac: replace the has_sun8i field with a flag
net: stmmac: replace the tso_en field with a flag
net: stmmac: replace the serdes_up_after_phy_linkup field with a flag
net: stmmac: replace the vlan_fail_q_en field with a flag
net: stmmac: replace the multi_msi_en field with a flag
net: stmmac: replace the ext_snapshot_en field with a flag
net: stmmac: replace the int_snapshot_en field with a flag
net: stmmac: replace the rx_clk_runs_in_lpi field with a flag
net: stmmac: replace the en_tx_lpi_clockgating field with a flag
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 +- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 23 +++++------ .../ethernet/stmicro/stmmac/dwmac-mediatek.c | 5 ++- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 8 ++-- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 4 +- .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++++++-------- .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- .../ethernet/stmicro/stmmac/stmmac_platform.c | 10 +++-- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++- include/linux/stmmac.h | 26 ++++++------ 12 files changed, 76 insertions(+), 57 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/12 net: stmmac: replace the has_integrated_pcs field with a flag
From: Bartosz Golaszewski <[email protected]>
struct plat_stmmacenet_data contains several boolean fields that could be easily replaced with a common integer 'flags' bitfield and bit defines.
Start the process with the has_integrated_pcs field.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/linux/stmmac.h | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2 -1
@@ -790,7 +790,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat->tso_en =of_property_read_bool (np,"snps,tso" );if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; - plat_dat->has_integrated_pcs = data->has_integrated_pcs; +if (data->has_integrated_pcs) + plat_dat->flags |=STMMAC_FLAG_HAS_INTEGRATED_PCS ;if (ethqos->serdes_phy) { plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -5798,7 +5798,8 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) }/* PCS link status */ -if (priv->hw->pcs && !priv->plat->has_integrated_pcs) { +if (priv->hw->pcs && + !(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS )) {if (priv->xstats.pcs_link)netif_carrier_on (priv->dev);else
include/linux/stmmac.h +3 -1
@@ -204,6 +204,8 @@ struct dwmac4_addrs {u32 mtl_low_cred_offset; }; +#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0) +struct plat_stmmacenet_data {int bus_id;int phy_addr;
@@ -293,6 +295,6 @@ struct plat_stmmacenet_data {bool sph_disable;bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs; - bool has_integrated_pcs; + unsigned int flags; };#endif
Signature · 1 line
2.39.2
PATCH v2 2/12 net: stmmac: replace the sph_disable field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/linux/stmmac.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +1 -1
@@ -359,7 +359,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, data->fix_mac_speed = tegra_eqos_fix_speed; data->init = tegra_eqos_init; data->bsp_priv = eqos; - data->sph_disable =1 ; + data->flags |=STMMAC_FLAG_SPH_DISABLE ; err =tegra_eqos_init (pdev, eqos);if (err <0 )
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -459,7 +459,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->has_gmac4 =1 ; plat->force_sf_dma_mode =0 ; plat->tso_en =1 ; - plat->sph_disable =1 ; + data->flags |=STMMAC_FLAG_SPH_DISABLE ;/* Multiplying factor to the clk_eee_i clock time * period to make it closer to 100 ns. This value
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -7258,7 +7258,8 @@ int stmmac_dvr_probe(struct device *device,dev_info (priv->device,"TSO feature enabled\n" ); } -if (priv->dma_cap.sphen && !priv->plat->sph_disable) { +if (priv->dma_cap.sphen && + !(priv->plat->flags &STMMAC_FLAG_SPH_DISABLE )) { ndev->hw_features |=NETIF_F_GRO ; priv->sph_cap = true; priv->sph = priv->sph_cap;
include/linux/stmmac.h +1 -1
@@ -205,6 +205,7 @@ struct dwmac4_addrs { };#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0) +#define STMMAC_FLAG_SPH_DISABLE BIT(1)struct plat_stmmacenet_data {int bus_id;
@@ -292,7 +293,6 @@ struct plat_stmmacenet_data {int msi_rx_base_vec;int msi_tx_base_vec;bool use_phy_wol; -bool sph_disable;bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs;unsigned int flags;
Signature · 1 line
2.39.2
Re: [PATCH net-next v2 02/12] net: stmmac: replace the sph_disable field with a flag
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the
plat_stmmacenet_datastructure in favor of a simple bitfield flag.Signed-off-by Bartosz Golaszewski <[email protected]>
...
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c static int intel_mgbe_common_data(struct pci_dev *pdev, · line 462
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1
-1@@ -459,7 +459,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->has_gmac4 =1 ; plat->force_sf_dma_mode =0 ; plat->tso_en =1 ; - plat->sph_disable =1 ; + data->flags |=STMMAC_FLAG_SPH_DISABLE ;
Hi Bartosz,
I think something must have got mixed-up here.
An x86_64 allmodconfig reports that data is undeclared here.
...
Signature · 1 line
pw-bot: changes-requested
Re: [PATCH net-next v2 02/12] net: stmmac: replace the sph_disable field with a flag
Quoted 24 lines · Simon Horman
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the
plat_stmmacenet_datastructure in favor of a simple bitfield flag.Signed-off-by Bartosz Golaszewski <[email protected]>...
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c static int intel_mgbe_common_data(struct pci_dev *pdev, · line 462
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1
-1@@ -459,7 +459,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->has_gmac4 =1 ; plat->force_sf_dma_mode =0 ; plat->tso_en =1 ; - plat->sph_disable =1 ; + data->flags |=STMMAC_FLAG_SPH_DISABLE ;Hi Bartosz,
Quoted 3 lines
I think something must have got mixed-up here.
Anx86_64allmodconfig reports that data is undeclared here.
Cr*p, I thought I build-tested everything...
My bad, I'll resend a v3 after the merge window.
Bart
Quoted 5 lines
...
--
pw-bot: changes-requested
Re: [PATCH net-next v2 02/12] net: stmmac: replace the sph_disable field with a flag
Quoted 25 lines · Bartosz Golaszewski
Quoted 24 lines · Simon Horman
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the
plat_stmmacenet_datastructure in favor of a simple bitfield flag.Signed-off-by Bartosz Golaszewski <[email protected]>...
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c static int intel_mgbe_common_data(struct pci_dev *pdev, · line 462
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1
-1@@ -459,7 +459,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->has_gmac4 =1 ; plat->force_sf_dma_mode =0 ; plat->tso_en =1 ; - plat->sph_disable =1 ; + data->flags |=STMMAC_FLAG_SPH_DISABLE ;Hi Bartosz,
Quoted 7 lines
Quoted 3 lines
I think something must have got mixed-up here.
Anx86_64allmodconfig reports that data is undeclared here.Cr*p, I thought I build-tested everything...
My bad, I'll resend a v3 after the merge window.
Sorry to have been the bearer of bad news :(
PATCH v2 3/12 net: stmmac: replace the use_phy_wol field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 5 ++++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- include/linux/stmmac.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -628,7 +628,7 @@ static int ehl_common_data(struct pci_dev *pdev, { plat->rx_queues_to_use =8 ; plat->tx_queues_to_use =8 ; - plat->use_phy_wol =1 ; + plat->flags |=STMMAC_FLAG_USE_PHY_WOL ; plat->safety_feat_cfg->tsoee =1 ; plat->safety_feat_cfg->mrxpee =1 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c +4 -1
@@ -588,7 +588,10 @@ static int mediatek_dwmac_common_data(struct platform_device *pdev,int i; plat->interface = priv_plat->phy_mode; - plat->use_phy_wol = priv_plat->mac_wol ?0 :1 ; +if (priv_plat->mac_wol) + plat->flags |=STMMAC_FLAG_USE_PHY_WOL ; +else + plat->flags &= ~STMMAC_FLAG_USE_PHY_WOL ; plat->riwt_off =1 ; plat->maxmtu =ETH_DATA_LEN ; plat->host_dma_width = priv_plat->variant->dma_bit_mask;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -6877,7 +6877,7 @@ static int stmmac_hw_init(struct stmmac_priv *priv)*/ priv->plat->enh_desc = priv->dma_cap.enh_desc; priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up && - !priv->plat->use_phy_wol; + !(priv->plat->flags &STMMAC_FLAG_USE_PHY_WOL ); priv->hw->pmt = priv->plat->pmt;if (priv->dma_cap.hash_tb_sz) { priv->hw->multicast_filter_bins =
include/linux/stmmac.h +1 -1
@@ -206,6 +206,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0)#define STMMAC_FLAG_SPH_DISABLE BIT(1) +#define STMMAC_FLAG_USE_PHY_WOL BIT(2)struct plat_stmmacenet_data {int bus_id;
@@ -292,7 +293,6 @@ struct plat_stmmacenet_data {int msi_sfty_ue_vec;int msi_rx_base_vec;int msi_tx_base_vec; -bool use_phy_wol;bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs;unsigned int flags;
Signature · 1 line
2.39.2
PATCH v2 4/12 net: stmmac: replace the has_sun8i field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- include/linux/stmmac.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +1 -1
@@ -1227,7 +1227,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev) plat_dat->interface = interface; plat_dat->rx_coe =STMMAC_RX_COE_TYPE2 ; plat_dat->tx_coe =1 ; - plat_dat->has_sun8i = true; + plat_dat->flags |=STMMAC_FLAG_HAS_SUN8I ; plat_dat->bsp_priv = gmac; plat_dat->init = sun8i_dwmac_init; plat_dat->exit = sun8i_dwmac_exit;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -325,7 +325,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) priv->clk_csr =STMMAC_CSR_250_300M ; } -if (priv->plat->has_sun8i) { +if (priv->plat->flags &STMMAC_FLAG_HAS_SUN8I ) {if (clk_rate >160000000 ) priv->clk_csr =0x03 ;else if (clk_rate >80000000 )
@@ -6856,7 +6856,7 @@ static int stmmac_hw_init(struct stmmac_priv *priv)int ret;/* dwmac-sun8i only work in chain mode */ -if (priv->plat->has_sun8i) +if (priv->plat->flags &STMMAC_FLAG_HAS_SUN8I ) chain_mode =1 ; priv->chain_mode = chain_mode;
include/linux/stmmac.h +1 -1
@@ -207,6 +207,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0)#define STMMAC_FLAG_SPH_DISABLE BIT(1)#define STMMAC_FLAG_USE_PHY_WOL BIT(2) +#define STMMAC_FLAG_HAS_SUN8I BIT(3)struct plat_stmmacenet_data {int bus_id;
@@ -270,7 +271,6 @@ struct plat_stmmacenet_data {struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4; -bool has_sun8i;bool tso_en;int rss_en;int mac_port_sel_speed;
Signature · 1 line
2.39.2
PATCH v2 5/12 net: stmmac: replace the tso_en field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 3 +-- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++++-- include/linux/stmmac.h | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +1 -1
@@ -113,7 +113,7 @@ static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,/* dwc-qos needs GMAC4, AAL, TSO and PMT */ plat_dat->has_gmac4 =1 ; plat_dat->dma_cfg->aal =1 ; - plat_dat->tso_en =1 ; + plat_dat->flags |=STMMAC_FLAG_TSO_EN ; plat_dat->pmt =1 ;return 0 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -2
@@ -458,8 +458,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->has_gmac =0 ; plat->has_gmac4 =1 ; plat->force_sf_dma_mode =0 ; - plat->tso_en =1 ; - data->flags |=STMMAC_FLAG_SPH_DISABLE ; + plat->flags |= (STMMAC_FLAG_TSO_EN |STMMAC_FLAG_SPH_DISABLE );/* Multiplying factor to the clk_eee_i clock time * period to make it closer to 100 ns. This value
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2 -1
@@ -787,7 +787,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ethqos->has_emac_ge_3) plat_dat->dwmac4_addrs = &data->dwmac4_addrs; plat_dat->pmt =1 ; - plat_dat->tso_en =of_property_read_bool (np,"snps,tso" ); +if (of_property_read_bool (np,"snps,tso" )) + plat_dat->flags |=STMMAC_FLAG_TSO_EN ;if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ;if (data->has_integrated_pcs)
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c +1 -1
@@ -290,7 +290,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev) } plat->has_xgmac =1 ; - plat->tso_en =1 ; + plat->flags |=STMMAC_FLAG_TSO_EN ; plat->pmt =1 ; plat->bsp_priv = mgbe;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -5677,7 +5677,7 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, features &= ~NETIF_F_CSUM_MASK ;/* Disable tso if asked by ethtool */ -if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) { +if ((priv->plat->flags &STMMAC_FLAG_TSO_EN ) && (priv->dma_cap.tsoen)) {if (features &NETIF_F_TSO ) priv->tso = true;else
@@ -7250,7 +7250,7 @@ int stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_HW_TC ; } -if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) { +if ((priv->plat->flags &STMMAC_FLAG_TSO_EN ) && (priv->dma_cap.tsoen)) { ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->has_gmac4) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +1 -1
@@ -77,7 +77,7 @@ static int snps_gmac5_default_data(struct pci_dev *pdev, plat->clk_csr =5 ; plat->has_gmac4 =1 ; plat->force_sf_dma_mode =1 ; - plat->tso_en =1 ; + plat->flags |=STMMAC_FLAG_TSO_EN ; plat->pmt =1 ;/* Set default value for multicast hash bins */
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 -2
@@ -524,7 +524,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->has_gmac4 =1 ; plat->has_gmac =0 ; plat->pmt =1 ; - plat->tso_en =of_property_read_bool (np,"snps,tso" ); +if (of_property_read_bool (np,"snps,tso" )) + plat->flags |=STMMAC_FLAG_TSO_EN ; } if (of_device_is_compatible(np, "snps,dwmac-3.610") ||
@@ -537,7 +538,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)if (of_device_is_compatible (np,"snps,dwxgmac" )) { plat->has_xgmac =1 ; plat->pmt =1 ; - plat->tso_en =of_property_read_bool (np,"snps,tso" ); +if (of_property_read_bool (np,"snps,tso" )) + plat->flags |=STMMAC_FLAG_TSO_EN ; } dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
include/linux/stmmac.h +1 -1
@@ -208,6 +208,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_SPH_DISABLE BIT(1)#define STMMAC_FLAG_USE_PHY_WOL BIT(2)#define STMMAC_FLAG_HAS_SUN8I BIT(3) +#define STMMAC_FLAG_TSO_EN BIT(4)struct plat_stmmacenet_data {int bus_id;
@@ -271,7 +272,6 @@ struct plat_stmmacenet_data {struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4; -bool tso_en;int rss_en;int mac_port_sel_speed;bool en_tx_lpi_clockgating;
Signature · 1 line
2.39.2
PATCH v2 6/12 net: stmmac: replace the serdes_up_after_phy_linkup field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++--- include/linux/stmmac.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c +1 -1
@@ -337,7 +337,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev)/* Program SID */ writel (MGBE_SID , mgbe->hv +MGBE_WRAP_AXI_ASID0_CTRL ); - plat->serdes_up_after_phy_linkup =1 ; + plat->flags |=STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP ; err =stmmac_dvr_probe (&pdev->dev, plat, &res);if (err <0 )
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -3
@@ -991,7 +991,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev));u32 old_ctrl, ctrl; -if (priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) +if ((priv->plat->flags &STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP ) && + priv->plat->serdes_powerup) priv->plat->serdes_powerup (priv->dev, priv->plat->bsp_priv); old_ctrl =readl (priv->ioaddr +MAC_CTRL_REG );
@@ -3838,7 +3839,8 @@ static int __stmmac_open(struct net_device *dev,stmmac_reset_queues_param (priv); -if (!priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) { +if (!(priv->plat->flags &STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP ) && + priv->plat->serdes_powerup) { ret = priv->plat->serdes_powerup (dev, priv->plat->bsp_priv);if (ret <0 ) { netdev_err(priv->dev, "%s: Serdes powerup failed\n",
@@ -7623,7 +7625,8 @@ int stmmac_resume(struct device *dev)stmmac_mdio_reset (priv->mii); } -if (!priv->plat->serdes_up_after_phy_linkup && priv->plat->serdes_powerup) { +if (!(priv->plat->flags &STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP ) && + priv->plat->serdes_powerup) { ret = priv->plat->serdes_powerup (ndev, priv->plat->bsp_priv);
include/linux/stmmac.h +1 -1
@@ -209,6 +209,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_USE_PHY_WOL BIT(2)#define STMMAC_FLAG_HAS_SUN8I BIT(3)#define STMMAC_FLAG_TSO_EN BIT(4) +#define STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP BIT(5)struct plat_stmmacenet_data {int bus_id;
@@ -293,7 +294,6 @@ struct plat_stmmacenet_data {int msi_sfty_ue_vec;int msi_rx_base_vec;int msi_tx_base_vec; -bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs;unsigned int flags; };
Signature · 1 line
2.39.2
PATCH v2 7/12 net: stmmac: replace the vlan_fail_q_en field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/linux/stmmac.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -560,7 +560,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,/* Set the maxmtu to a default of JUMBO_LEN */ plat->maxmtu =JUMBO_LEN ; - plat->vlan_fail_q_en = true; + plat->flags |=STMMAC_FLAG_VLAN_FAIL_Q_EN ;/* Use the last Rx queue */ plat->vlan_fail_q = plat->rx_queues_to_use -1 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -6923,7 +6923,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv)if (priv->dma_cap.tsoen)dev_info (priv->device,"TSO supported\n" ); - priv->hw->vlan_fail_q_en = priv->plat->vlan_fail_q_en; + priv->hw->vlan_fail_q_en = + (priv->plat->flags &STMMAC_FLAG_VLAN_FAIL_Q_EN ); priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;/* Run HW quirks, if any */
include/linux/stmmac.h +1 -1
@@ -210,6 +210,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_HAS_SUN8I BIT(3)#define STMMAC_FLAG_TSO_EN BIT(4)#define STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP BIT(5) +#define STMMAC_FLAG_VLAN_FAIL_Q_EN BIT(6)struct plat_stmmacenet_data {int bus_id;
@@ -278,7 +279,6 @@ struct plat_stmmacenet_data {bool en_tx_lpi_clockgating;bool rx_clk_runs_in_lpi;int has_xgmac; -bool vlan_fail_q_en;u8 vlan_fail_q;unsigned int eee_usecs_rate;struct pci_dev *pdev;
Signature · 1 line
2.39.2
PATCH v2 8/12 net: stmmac: replace the multi_msi_en field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++--- include/linux/stmmac.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +2 -2
@@ -953,7 +953,7 @@ static int stmmac_config_single_msi(struct pci_dev *pdev, res->irq =pci_irq_vector (pdev,0 ); res->wol_irq = res->irq; - plat->multi_msi_en =0 ; + plat->flags &= ~STMMAC_FLAG_MULTI_MSI_EN ;dev_info (&pdev->dev,"%s: Single IRQ enablement successful\n" , __func__);
@@ -1005,7 +1005,7 @@ static int stmmac_config_multi_msi(struct pci_dev *pdev,if (plat->msi_sfty_ue_vec <STMMAC_MSI_VEC_MAX ) res->sfty_ue_irq =pci_irq_vector (pdev, plat->msi_sfty_ue_vec); - plat->multi_msi_en =1 ; + plat->flags |=STMMAC_FLAG_MULTI_MSI_EN ;dev_info (&pdev->dev,"%s: multi MSI enablement successful\n" , __func__);return 0 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -3
@@ -3711,7 +3711,7 @@ static int stmmac_request_irq(struct net_device *dev)int ret;/* Request the IRQ lines */ -if (priv->plat->multi_msi_en) +if (priv->plat->flags &STMMAC_FLAG_MULTI_MSI_EN ) ret =stmmac_request_irq_multi_msi (dev);else ret =stmmac_request_irq_single (dev);
@@ -5954,7 +5954,7 @@ static void stmmac_poll_controller(struct net_device *dev)if (test_bit (STMMAC_DOWN , &priv->state))return ; -if (priv->plat->multi_msi_en) { +if (priv->plat->flags &STMMAC_FLAG_MULTI_MSI_EN ) {for (i =0 ; i < priv->plat->rx_queues_to_use; i++)stmmac_msi_intr_rx (0 , &priv->dma_conf.rx_queue[i]);
@@ -7169,7 +7169,8 @@ int stmmac_dvr_probe(struct device *device, priv->plat = plat_dat; priv->ioaddr = res->addr; priv->dev->base_addr = (unsigned long )res->addr; - priv->plat->dma_cfg->multi_msi_en = priv->plat->multi_msi_en; + priv->plat->dma_cfg->multi_msi_en = + (priv->plat->flags &STMMAC_FLAG_MULTI_MSI_EN ); priv->dev->irq = res->irq; priv->wol_irq = res->wol_irq;
include/linux/stmmac.h +1 -1
@@ -211,6 +211,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_TSO_EN BIT(4)#define STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP BIT(5)#define STMMAC_FLAG_VLAN_FAIL_Q_EN BIT(6) +#define STMMAC_FLAG_MULTI_MSI_EN BIT(7)struct plat_stmmacenet_data {int bus_id;
@@ -286,7 +287,6 @@ struct plat_stmmacenet_data {int ext_snapshot_num;bool int_snapshot_en;bool ext_snapshot_en; -bool multi_msi_en;int msi_mac_vec;int msi_wol_vec;int msi_lpi_vec;
Signature · 1 line
2.39.2
PATCH v2 9/12 net: stmmac: replace the ext_snapshot_en field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++++- include/linux/stmmac.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -326,7 +326,7 @@ static int intel_crosststamp(ktime_t *device,/* Both internal crosstimestamping and external triggered event * timestamping cannot be run concurrently. */ -if (priv->plat->ext_snapshot_en) +if (priv->plat->flags &STMMAC_FLAG_EXT_SNAPSHOT_EN )return -EBUSY ; priv->plat->int_snapshot_en =1 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +1 -1
@@ -195,7 +195,7 @@ static void timestamp_interrupt(struct stmmac_priv *priv)*/ ts_status =readl (priv->ioaddr +GMAC_TIMESTAMP_STATUS ); -if (!priv->plat->ext_snapshot_en) +if (priv->plat->flags &STMMAC_FLAG_EXT_SNAPSHOT_EN )return ; num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >>
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +4 -1
@@ -192,7 +192,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp,write_unlock_irqrestore (&priv->ptp_lock, flags);break ;case PTP_CLK_REQ_EXTTS : - priv->plat->ext_snapshot_en = on; +if (on) + priv->plat->flags |=STMMAC_FLAG_EXT_SNAPSHOT_EN ; +else + priv->plat->flags &= ~STMMAC_FLAG_EXT_SNAPSHOT_EN ;mutex_lock (&priv->aux_ts_lock); acr_value =readl (ptpaddr +PTP_ACR ); acr_value &= ~PTP_ACR_MASK ;
include/linux/stmmac.h +1 -1
@@ -212,6 +212,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP BIT(5)#define STMMAC_FLAG_VLAN_FAIL_Q_EN BIT(6)#define STMMAC_FLAG_MULTI_MSI_EN BIT(7) +#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8)struct plat_stmmacenet_data {int bus_id;
@@ -286,7 +287,6 @@ struct plat_stmmacenet_data {int int_snapshot_num;int ext_snapshot_num;bool int_snapshot_en; -bool ext_snapshot_en;int msi_mac_vec;int msi_wol_vec;int msi_lpi_vec;
Signature · 1 line
2.39.2
PATCH v2 10/12 net: stmmac: replace the int_snapshot_en field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 10 +++++----- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 2 +- include/linux/stmmac.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +5 -5
@@ -329,7 +329,7 @@ static int intel_crosststamp(ktime_t *device,if (priv->plat->flags &STMMAC_FLAG_EXT_SNAPSHOT_EN )return -EBUSY ; - priv->plat->int_snapshot_en =1 ; + priv->plat->flags |=STMMAC_FLAG_INT_SNAPSHOT_EN ;mutex_lock (&priv->aux_ts_lock);/* Enable Internal snapshot trigger */
@@ -350,7 +350,7 @@ static int intel_crosststamp(ktime_t *device,break ;default :mutex_unlock (&priv->aux_ts_lock); - priv->plat->int_snapshot_en =0 ; + priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN ;return -EINVAL ; }writel (acr_value, ptpaddr +PTP_ACR );
@@ -376,7 +376,7 @@ static int intel_crosststamp(ktime_t *device,if (!wait_event_interruptible_timeout (priv->tstamp_busy_wait,stmmac_cross_ts_isr (priv),HZ /100 )) { - priv->plat->int_snapshot_en =0 ; + priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN ;return -ETIMEDOUT ; }
@@ -395,7 +395,7 @@ static int intel_crosststamp(ktime_t *device, } system->cycles *= intel_priv->crossts_adj; - priv->plat->int_snapshot_en =0 ; + priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN ;return 0 ; }
@@ -609,7 +609,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->ext_snapshot_num =AUX_SNAPSHOT0 ; plat->crosststamp = intel_crosststamp; - plat->int_snapshot_en =0 ; + plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN ;/* Setup MSI vector offset specific to Intel mGbE controller */ plat->msi_mac_vec =29 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +1 -1
@@ -180,7 +180,7 @@ static void timestamp_interrupt(struct stmmac_priv *priv)u64 ptp_time;int i; -if (priv->plat->int_snapshot_en) { +if (priv->plat->flags &STMMAC_FLAG_INT_SNAPSHOT_EN ) {wake_up (&priv->tstamp_busy_wait);return ; }
include/linux/stmmac.h +1 -1
@@ -213,6 +213,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_VLAN_FAIL_Q_EN BIT(6)#define STMMAC_FLAG_MULTI_MSI_EN BIT(7)#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8) +#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9)struct plat_stmmacenet_data {int bus_id;
@@ -286,7 +287,6 @@ struct plat_stmmacenet_data {struct pci_dev *pdev;int int_snapshot_num;int ext_snapshot_num; -bool int_snapshot_en;int msi_mac_vec;int msi_wol_vec;int msi_lpi_vec;
Signature · 1 line
2.39.2
PATCH v2 11/12 net: stmmac: replace the rx_clk_runs_in_lpi field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/linux/stmmac.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -1
@@ -790,7 +790,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (of_property_read_bool (np,"snps,tso" )) plat_dat->flags |=STMMAC_FLAG_TSO_EN ;if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) - plat_dat->rx_clk_runs_in_lpi =1 ; + plat_dat->flags |=STMMAC_FLAG_RX_CLK_RUNS_IN_LPI ;if (data->has_integrated_pcs) plat_dat->flags |=STMMAC_FLAG_HAS_INTEGRATED_PCS ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -1085,7 +1085,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,stmmac_mac_set (priv, priv->ioaddr, true);if (phy && priv->dma_cap.eee) { priv->eee_active = -phy_init_eee (phy, !priv->plat->rx_clk_runs_in_lpi) >=0 ; +phy_init_eee (phy, !(priv->plat->flags & +STMMAC_FLAG_RX_CLK_RUNS_IN_LPI )) >=0 ; priv->eee_enabled =stmmac_eee_init (priv); priv->tx_lpi_enabled = priv->eee_enabled;stmmac_set_eee_pls (priv, priv->hw, true);
include/linux/stmmac.h +1 -1
@@ -214,6 +214,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_MULTI_MSI_EN BIT(7)#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8)#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9) +#define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10)struct plat_stmmacenet_data {int bus_id;
@@ -280,7 +281,6 @@ struct plat_stmmacenet_data {int rss_en;int mac_port_sel_speed;bool en_tx_lpi_clockgating; -bool rx_clk_runs_in_lpi;int has_xgmac;u8 vlan_fail_q;unsigned int eee_usecs_rate;
Signature · 1 line
2.39.2
PATCH v2 12/12 net: stmmac: replace the en_tx_lpi_clockgating field with a flag
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a simple bitfield flag.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 4 ++-- include/linux/stmmac.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -421,7 +421,7 @@ static int stmmac_enable_eee_mode(struct stmmac_priv *priv)/* Check and enter in LPI mode */ if (!priv->tx_path_in_lpi_mode)stmmac_set_eee_mode (priv, priv->hw, - priv->plat->en_tx_lpi_clockgating); + priv->plat->flags &STMMAC_FLAG_EN_TX_LPI_CLOCKGATING );return 0 ; }
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -2
@@ -465,8 +465,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->force_sf_dma_mode =of_property_read_bool (np,"snps,force_sf_dma_mode" ); - plat->en_tx_lpi_clockgating = -of_property_read_bool (np,"snps,en-tx-lpi-clockgating" ); +if (of_property_read_bool (np,"snps,en-tx-lpi-clockgating" )) + 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.
include/linux/stmmac.h +1 -1
@@ -215,6 +215,7 @@ struct dwmac4_addrs {#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8)#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9)#define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10) +#define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING BIT(11)struct plat_stmmacenet_data {int bus_id;
@@ -280,7 +281,6 @@ struct plat_stmmacenet_data {int has_gmac4;int rss_en;int mac_port_sel_speed; -bool en_tx_lpi_clockgating;int has_xgmac;u8 vlan_fail_q;unsigned int eee_usecs_rate;
Signature · 1 line
2.39.2
Quoted 22 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
As suggested by Jose Abreu: let's drop all 12 boolean fields in
plat_stmmacenet_dataand replace them with a common bitfield.v1 -> v2:
- fix build on intel platformsBartosz Golaszewski (12):
net: stmmac: replace thehas_integrated_pcsfield with a flag
net: stmmac: replace thesph_disablefield with a flag
net: stmmac: replace theuse_phy_wolfield with a flag
net: stmmac: replace thehas_sun8ifield with a flag
net: stmmac: replace thetso_enfield with a flag
net: stmmac: replace theserdes_up_after_phy_linkupfield with a flag
net: stmmac: replace thevlan_fail_q_enfield with a flag
net: stmmac: replace themulti_msi_enfield with a flag
net: stmmac: replace theext_snapshot_enfield with a flag
net: stmmac: replace theint_snapshot_enfield with a flag
net: stmmac: replace therx_clk_runs_in_lpifield with a flag
net: stmmac: replace theen_tx_lpi_clockgatingfield with a flag
Quoted 17 lines
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 +- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 23 +++++------ .../ethernet/stmicro/stmmac/dwmac-mediatek.c | 5 ++- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 8 ++-- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 4 +- .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++++++-------- .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- .../ethernet/stmicro/stmmac/stmmac_platform.c | 10 +++-- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++- include/linux/stmmac.h | 26 ++++++------ 12 files changed, 76 insertions(+), 57 deletions(-)Signature · 1 line
2.39.2
The series looks proper to me: