net: ethernet: stmmac: Add config option for full driver

Add this config option to reduce memory usage, if it was not necessary.

./ksize.sh drivers/net/ethernet/stmicro/

before size: 109539 Bytes
after  size: 70125 Bytes
save   size: 39414 Bytes

Change-Id: I5f6b4573d7358c3b6f046e960c7ddf7d53541b14
Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
David Wu
2021-09-18 16:39:41 +08:00
committed by Tao Huang
parent 541323a247
commit 2f2111686d
4 changed files with 37 additions and 8 deletions

View File

@@ -31,6 +31,13 @@ config STMMAC_ETHTOOL
help
This selects the ethtool function, default is Y.
config STMMAC_FULL
bool "Support full driver for STMMAC"
default STMMAC_ETH
help
This selects the full function, default is Y, full-featured version
includes 4.10 and other versions, if it is N, only 4.10 core working.
config STMMAC_PLATFORM
tristate "STMMAC Platform bus support"
depends on STMMAC_ETH

View File

@@ -1,13 +1,17 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_STMMAC_ETH) += stmmac.o
stmmac-objs:= stmmac_main.o stmmac_mdio.o ring_mode.o \
chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \
dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
stmmac-objs:= stmmac_main.o stmmac_mdio.o dwmac_lib.o \
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o \
dwmac4_descs.o dwmac4_dma.o \
dwmac4_lib.o dwmac4_core.o hwif.o \
$(stmmac-y)
stmmac-$(CONFIG_STMMAC_FULL) += ring_mode.o chain_mode.o dwmac1000_core.o \
dwmac1000_dma.o dwmac100_core.o dwmac100_dma.o \
enh_desc.o norm_desc.o dwmac5.o stmmac_tc.o \
dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
stmmac-$(CONFIG_STMMAC_ETHTOOL) += stmmac_ethtool.o

View File

@@ -1143,6 +1143,7 @@ static int dwmac4_config_l4_filter(struct mac_device_info *hw, u32 filter_no,
return 0;
}
#ifdef CONFIG_STMMAC_FULL
const struct stmmac_ops dwmac4_ops = {
.core_init = dwmac4_core_init,
.set_mac = stmmac_set_mac,
@@ -1183,6 +1184,7 @@ const struct stmmac_ops dwmac4_ops = {
.del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr,
.restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr,
};
#endif
const struct stmmac_ops dwmac410_ops = {
.core_init = dwmac4_core_init,
@@ -1213,7 +1215,9 @@ const struct stmmac_ops dwmac410_ops = {
.pcs_get_adv_lp = dwmac4_get_adv_lp,
.debug = dwmac4_debug,
.set_filter = dwmac4_set_filter,
#ifdef CONFIG_STMMAC_FULL
.flex_pps_config = dwmac5_flex_pps_config,
#endif
.set_mac_loopback = dwmac4_set_mac_loopback,
.update_vlan_hash = dwmac4_update_vlan_hash,
.sarc_configure = dwmac4_sarc_configure,
@@ -1221,13 +1225,16 @@ const struct stmmac_ops dwmac410_ops = {
.set_arp_offload = dwmac4_set_arp_offload,
.config_l3_filter = dwmac4_config_l3_filter,
.config_l4_filter = dwmac4_config_l4_filter,
#ifdef CONFIG_STMMAC_FULL
.est_configure = dwmac5_est_configure,
.fpe_configure = dwmac5_fpe_configure,
#endif
.add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr,
.del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr,
.restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr,
};
#ifdef CONFIG_STMMAC_FULL
const struct stmmac_ops dwmac510_ops = {
.core_init = dwmac4_core_init,
.set_mac = stmmac_dwmac4_set_mac,
@@ -1275,6 +1282,7 @@ const struct stmmac_ops dwmac510_ops = {
.del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr,
.restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr,
};
#endif
static u32 dwmac4_get_num_vlan(void __iomem *ioaddr)
{

View File

@@ -35,6 +35,7 @@ static u32 stmmac_get_dev_id(struct stmmac_priv *priv, u32 id_reg)
return (reg & GENMASK(15, 8)) >> 8;
}
#ifdef CONFIG_STMMAC_FULL
static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv)
{
struct mac_device_info *mac = priv->hw;
@@ -86,6 +87,7 @@ static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv)
priv->hw->xlgmac = true;
return 0;
}
#endif
static const struct stmmac_hwif_entry {
bool gmac;
@@ -105,6 +107,7 @@ static const struct stmmac_hwif_entry {
int (*quirks)(struct stmmac_priv *priv);
} stmmac_hw[] = {
/* NOTE: New HW versions shall go to the end of this table */
#ifdef CONFIG_STMMAC_FULL
{
.gmac = false,
.gmac4 = false,
@@ -177,7 +180,9 @@ static const struct stmmac_hwif_entry {
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup,
.quirks = NULL,
}, {
},
#endif /* CONFIG_STMMAC_FULL */
{
.gmac = false,
.gmac4 = true,
.xgmac = false,
@@ -191,11 +196,15 @@ static const struct stmmac_hwif_entry {
.mac = &dwmac410_ops,
.hwtimestamp = &stmmac_ptp,
.mode = &dwmac4_ring_mode_ops,
#ifdef CONFIG_STMMAC_FULL
.tc = &dwmac510_tc_ops,
#endif
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup,
.quirks = NULL,
}, {
},
#ifdef CONFIG_STMMAC_FULL
{
.gmac = false,
.gmac4 = true,
.xgmac = false,
@@ -252,6 +261,7 @@ static const struct stmmac_hwif_entry {
.setup = dwxlgmac2_setup,
.quirks = stmmac_dwxlgmac_quirks,
},
#endif
};
int stmmac_hwif_init(struct stmmac_priv *priv)