stmmac: Expose module parameters
Subsystems (5)
PATCH v2 1/2 stmmac: Expose module parameters
In reply to a message not in the archiveFrom: Feiyang Chen <[email protected]>
Expose module parameters so that we can use them in specific device configurations. Add the 'stmmac_' prefix for them to avoid conflicts.
Meanwhile, there was a 'buf_sz' local variable in stmmac_rx() with the same name as the global variable, and now we can distinguish them.
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 11 ++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 117 +++++++++--------- 2 files changed, 70 insertions(+), 58 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +11 -0
@@ -332,6 +332,17 @@ enum stmmac_state { STMMAC_SERVICE_SCHED, }; +/* Module parameters */ +extern int stmmac_watchdog; +extern int stmmac_debug; +extern int stmmac_phyaddr; +extern int stmmac_flow_ctrl; +extern int stmmac_pause; +extern int stmmac_tc; +extern int stmmac_buf_sz; +extern int stmmac_eee_timer; +extern unsigned int stmmac_chain_mode; +int stmmac_mdio_unregister (struct net_device *ndev);int stmmac_mdio_register (struct net_device *ndev);int stmmac_mdio_reset (struct mii_bus *mii);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +59 -58
255 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v2 2/2 stmmac: pci: Add LS7A support for dwmac-loongson
In reply to a message not in the archiveFrom: Feiyang Chen <[email protected]>
Current dwmac-loongson only support LS2K in the "probed with PCI and configured with DT" manner. We add LS7A support on which the devices are fully PCI (non-DT).
--- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 177 ++++++++++++------ 1 file changed, 124 insertions(+), 53 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +124 -53
@@ -9,14 +9,22 @@#include <linux/of_irq.h> #include "stmmac.h" -static int loongson_default_data (struct plat_stmmacenet_data *plat) +struct stmmac_pci_info { +int (*setup)(struct pci_dev *pdev,struct plat_stmmacenet_data *plat); +}; + +static void common_default_data (struct pci_dev *pdev, +struct plat_stmmacenet_data *plat) { + plat->bus_id =PCI_DEVID (pdev->bus->number, pdev->devfn); + plat->interface =PHY_INTERFACE_MODE_GMII ; + plat->clk_csr =2 ;/* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ plat->has_gmac =1 ; plat->force_sf_dma_mode =1 ;/* Set default value for multicast hash bins */ - plat->multicast_filter_bins =HASH_TABLE_SIZE ; + plat->multicast_filter_bins =256 ;/* Set default value for unicast filter entries */ plat->unicast_filter_entries =1 ;
@@ -35,32 +43,81 @@ static int loongson_default_data(struct plat_stmmacenet_data *plat)/* Disable RX queues routing by default */ plat->rx_queues_cfg[0 ].pkt_route =0x0 ; -/* Default to phy auto-detection */ - plat->phy_addr =-1 ; - plat->dma_cfg->pbl =32 ; plat->dma_cfg->pblx8 = true; - plat->multicast_filter_bins =256 ; + plat->clk_ref_rate =125000000 ; + plat->clk_ptp_rate =125000000 ; +} + +static int loongson_gmac_data (struct pci_dev *pdev, +struct plat_stmmacenet_data *plat) +{ +common_default_data (pdev, plat); + + plat->mdio_bus_data->phy_mask =0 ; + + plat->phy_addr =-1 ; + plat->phy_interface =PHY_INTERFACE_MODE_RGMII_ID ; + + stmmac_flow_ctrl =FLOW_OFF ; +return 0 ; } -static int loongson_dwmac_probe (struct pci_dev *pdev,const struct pci_device_id *id) +static struct stmmac_pci_info loongson_gmac_pci_info = { + .setup = loongson_gmac_data, +}; + +static void loongson_gnet_fix_speed (void *priv,unsigned int speed) +{ +struct net_device *ndev = (struct net_device *)(*(unsigned long *)priv); +struct stmmac_priv *ptr =netdev_priv (ndev); + +if (speed ==SPEED_1000 ) { +if (readl (ptr->ioaddr +MAC_CTRL_REG ) & (1 <<15 )/* PS */ ) { +/* reset phy */ +phy_set_bits (ndev->phydev,0 /*MII_BMCR*/ , +0x200 /*BMCR_ANRESTART*/ ); + } + } +} + +static int loongson_gnet_data (struct pci_dev *pdev, +struct plat_stmmacenet_data *plat) +{ +common_default_data (pdev, plat); + + plat->mdio_bus_data->phy_mask =0xfffffffb ; + + plat->phy_addr =2 ; + plat->phy_interface =PHY_INTERFACE_MODE_GMII ; + +/* GNET 1000M speed need workaround */ + plat->fix_mac_speed = loongson_gnet_fix_speed; + +/* Get netdev pointer address */ + plat->bsp_priv = &(pdev->dev.driver_data); + +return 0 ; +} + +static struct stmmac_pci_info loongson_gnet_pci_info = { + .setup = loongson_gnet_data, +}; + +static int loongson_dwmac_probe (struct pci_dev *pdev, +const struct pci_device_id *id) {struct plat_stmmacenet_data *plat; +struct stmmac_pci_info *info;struct stmmac_resources res;struct device_node *np; -int ret, i, phy_mode; +int ret, i, bus_id, phy_mode;bool mdio = false; np =dev_of_node (&pdev->dev); - -if (!np) { -pr_info ("dwmac_loongson_pci: No OF node\n" ); -return -ENODEV ; - } - -if (!of_device_is_compatible (np,"loongson, pci-gmac" )) { +if (np && !of_device_is_compatible (np,"loongson, pci-gmac" )) {pr_info ("dwmac_loongson_pci: Incompatible OF node\n" );return -ENODEV ; }
@@ -74,14 +131,14 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id mdio = true; } -if (mdio) { - plat->mdio_bus_data =devm_kzalloc (&pdev->dev, -sizeof (*plat->mdio_bus_data), -GFP_KERNEL ); -if (!plat->mdio_bus_data) -return -ENOMEM ; + plat->mdio_bus_data =devm_kzalloc (&pdev->dev, +sizeof (*plat->mdio_bus_data), +GFP_KERNEL ); +if (!plat->mdio_bus_data) +return -ENOMEM ; + +if (mdio) plat->mdio_bus_data->needs_reset = true; - } plat->dma_cfg =devm_kzalloc (&pdev->dev,sizeof (*plat->dma_cfg),GFP_KERNEL );if (!plat->dma_cfg)
@@ -104,42 +161,52 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idbreak ; } - plat->bus_id =of_alias_get_id (np,"ethernet" ); -if (plat->bus_id <0 ) - plat->bus_id =pci_dev_id (pdev); - - phy_mode =device_get_phy_mode (&pdev->dev); -if (phy_mode <0 ) { -dev_err (&pdev->dev,"phy_mode not found\n" ); -return phy_mode; - } - - plat->phy_interface = phy_mode; - plat->interface =PHY_INTERFACE_MODE_GMII ; -pci_set_master (pdev); -loongson_default_data (plat); -pci_enable_msi (pdev); -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[0 ]; + info = (struct stmmac_pci_info *)id->driver_data; + ret = info->setup (pdev, plat); +if (ret) +return ret; - res.irq =of_irq_get_byname (np,"macirq" ); -if (res.irq <0 ) { -dev_err (&pdev->dev,"IRQ macirq not found\n" ); - ret = -ENODEV ; +if (np) { + bus_id =of_alias_get_id (np,"ethernet" ); +if (bus_id >=0 ) + plat->bus_id = bus_id; + + phy_mode =device_get_phy_mode (&pdev->dev); +if (phy_mode <0 ) { +dev_err (&pdev->dev,"phy_mode not found\n" ); +return phy_mode; + } + plat->phy_interface = phy_mode; } - res.wol_irq =of_irq_get_byname (np,"eth_wake_irq" ); -if (res.wol_irq <0 ) { -dev_info (&pdev->dev,"IRQ eth_wake_irq not found, using macirq\n" ); - res.wol_irq = res.irq; - } +pci_enable_msi (pdev); - res.lpi_irq =of_irq_get_byname (np,"eth_lpi" ); -if (res.lpi_irq <0 ) { -dev_err (&pdev->dev,"IRQ eth_lpi not found\n" ); - ret = -ENODEV ; +memset (&res,0 ,sizeof (res)); + res.addr =pcim_iomap_table (pdev)[0 ]; +if (np) { + res.irq =of_irq_get_byname (np,"macirq" ); +if (res.irq <0 ) { +dev_err (&pdev->dev,"IRQ macirq not found\n" ); + ret = -ENODEV ; + } + + res.wol_irq =of_irq_get_byname (np,"eth_wake_irq" ); +if (res.wol_irq <0 ) { +dev_info (&pdev->dev, +"IRQ eth_wake_irq not found, using macirq\n" ); + res.wol_irq = res.irq; + } + + res.lpi_irq =of_irq_get_byname (np,"eth_lpi" ); +if (res.lpi_irq <0 ) { +dev_err (&pdev->dev,"IRQ eth_lpi not found\n" ); + ret = -ENODEV ; + } + }else { + res.irq = pdev->irq; + res.wol_irq = pdev->irq; }return stmmac_dvr_probe (&pdev->dev, plat, &res);
@@ -199,8 +266,12 @@ static int __maybe_unused loongson_dwmac_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend, loongson_dwmac_resume); +#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 +#define PCI_DEVICE_ID_LOONGSON_GNET 0x7a13 +static const struct pci_device_id loongson_dwmac_id_table[] = { - {PCI_VDEVICE (LOONGSON ,0x7a03 ) }, + {PCI_DEVICE_DATA (LOONGSON ,GMAC , &loongson_gmac_pci_info) }, + {PCI_DEVICE_DATA (LOONGSON ,GNET , &loongson_gnet_pci_info) }, {} };MODULE_DEVICE_TABLE (pci, loongson_dwmac_id_table);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerQuoted 5 lines · On Wed, 17 Aug 2022 15:29:18 +0800 [email protected] wrote:
Expose module parameters so that we can use them in specific device configurations. Add the '
stmmac_' prefix for them to avoid conflicts.Meanwhile, there was a '
buf_sz' local variable instmmac_rx()with the same name as the global variable, and now we can distinguish them.
Can you provide more information on the 'why'?
Quoted 9 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 17 Aug 2022 15:29:18 +0800 [email protected] wrote:
Expose module parameters so that we can use them in specific device configurations. Add the '
stmmac_' prefix for them to avoid conflicts.Meanwhile, there was a '
buf_sz' local variable instmmac_rx()with the same name as the global variable, and now we can distinguish them.Can you provide more information on the 'why'?
Hi, Jakub,
We would like to be able to change these properties when configuring the device data. For example, Loongson GMAC does not support Flow Control feature, and exposing these parameters allows us to ensure that flow control is off in the Loongson GMAC device.
Thanks,
Feiyang
Quoted 9 lines · Feiyang Chen
Quoted 8 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 17 Aug 2022 15:29:18 +0800 [email protected] wrote:
Expose module parameters so that we can use them in specific device configurations. Add the '
stmmac_' prefix for them to avoid conflicts.Meanwhile, there was a '
buf_sz' local variable instmmac_rx()with the same name as the global variable, and now we can distinguish them.
Quoted 8 lines
Quoted 1 line
Can you provide more information on the 'why'?
Hi, Jakub,
We would like to be able to change these properties when configuring the device data. For example, Loongson GMAC does not support Flow Control feature, and exposing these parameters allows us to ensure that flow control is off in the Loongson GMAC device.
Two comments:
One patch should do one thing, with a commit message which explains why.
The MAC needs to tell phylib about what it can do in terms of
pause. The MAC would normally call phy_set_sym_pause(phydev, False, False) and then the PHY will not auto-get any pause, and as a result, the MAC will never to asked to enable any sort of flow control.
Andrew