Skip to content

Commit a661d3c

Browse files
FreeFlyingSheepheiher
authored andcommitted
stmmac: Expose module parameters
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. Signed-off-by: Feiyang Chen <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent aef89b7 commit a661d3c

File tree

2 files changed

+70
-58
lines changed

2 files changed

+70
-58
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,17 @@ enum stmmac_state {
339339
STMMAC_SERVICE_SCHED,
340340
};
341341

342+
/* Module parameters */
343+
extern int stmmac_watchdog;
344+
extern int stmmac_debug;
345+
extern int stmmac_phyaddr;
346+
extern int stmmac_flow_ctrl;
347+
extern int stmmac_pause;
348+
extern int stmmac_tc;
349+
extern int stmmac_buf_sz;
350+
extern int stmmac_eee_timer;
351+
extern unsigned int stmmac_chain_mode;
352+
342353
int stmmac_mdio_unregister(struct net_device *ndev);
343354
int stmmac_mdio_register(struct net_device *ndev);
344355
int stmmac_mdio_reset(struct mii_bus *mii);

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@
6262

6363
/* Module parameters */
6464
#define TX_TIMEO 5000
65-
static int watchdog = TX_TIMEO;
66-
module_param(watchdog, int, 0644);
65+
int stmmac_watchdog = TX_TIMEO;
66+
module_param_named(watchdog, stmmac_watchdog, int, 0644);
6767
MODULE_PARM_DESC(watchdog, "Transmit timeout in milliseconds (default 5s)");
6868

69-
static int debug = -1;
70-
module_param(debug, int, 0644);
69+
int stmmac_debug = -1;
70+
module_param_named(debug, stmmac_debug, int, 0644);
7171
MODULE_PARM_DESC(debug, "Message Level (-1: default, 0: no output, 16: all)");
7272

73-
static int phyaddr = -1;
74-
module_param(phyaddr, int, 0444);
73+
int stmmac_phyaddr = -1;
74+
module_param_named(phyaddr, stmmac_phyaddr, int, 0444);
7575
MODULE_PARM_DESC(phyaddr, "Physical device address");
7676

7777
#define STMMAC_TX_THRESH(x) ((x)->dma_conf.dma_tx_size / 4)
@@ -87,22 +87,22 @@ MODULE_PARM_DESC(phyaddr, "Physical device address");
8787
#define STMMAC_XDP_TX BIT(1)
8888
#define STMMAC_XDP_REDIRECT BIT(2)
8989

90-
static int flow_ctrl = FLOW_AUTO;
91-
module_param(flow_ctrl, int, 0644);
90+
int stmmac_flow_ctrl = FLOW_AUTO;
91+
module_param_named(flow_ctrl, stmmac_flow_ctrl, int, 0644);
9292
MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]");
9393

94-
static int pause = PAUSE_TIME;
95-
module_param(pause, int, 0644);
94+
int stmmac_pause = PAUSE_TIME;
95+
module_param_named(pause, stmmac_pause, int, 0644);
9696
MODULE_PARM_DESC(pause, "Flow Control Pause Time");
9797

9898
#define TC_DEFAULT 64
99-
static int tc = TC_DEFAULT;
100-
module_param(tc, int, 0644);
99+
int stmmac_tc = TC_DEFAULT;
100+
module_param_named(tc, stmmac_tc, int, 0644);
101101
MODULE_PARM_DESC(tc, "DMA threshold control value");
102102

103103
#define DEFAULT_BUFSIZE 1536
104-
static int buf_sz = DEFAULT_BUFSIZE;
105-
module_param(buf_sz, int, 0644);
104+
int stmmac_buf_sz = DEFAULT_BUFSIZE;
105+
module_param_named(buf_sz, stmmac_buf_sz, int, 0644);
106106
MODULE_PARM_DESC(buf_sz, "DMA buffer size");
107107

108108
#define STMMAC_RX_COPYBREAK 256
@@ -112,16 +112,16 @@ static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
112112
NETIF_MSG_IFDOWN | NETIF_MSG_TIMER);
113113

114114
#define STMMAC_DEFAULT_LPI_TIMER 1000
115-
static int eee_timer = STMMAC_DEFAULT_LPI_TIMER;
116-
module_param(eee_timer, int, 0644);
115+
int stmmac_eee_timer = STMMAC_DEFAULT_LPI_TIMER;
116+
module_param_named(eee_timer, stmmac_eee_timer, int, 0644);
117117
MODULE_PARM_DESC(eee_timer, "LPI tx expiration time in msec");
118118
#define STMMAC_LPI_T(x) (jiffies + usecs_to_jiffies(x))
119119

120120
/* By default the driver will use the ring mode to manage tx and rx descriptors,
121121
* but allow user to force to use the chain instead of the ring
122122
*/
123-
static unsigned int chain_mode;
124-
module_param(chain_mode, int, 0444);
123+
unsigned int stmmac_chain_mode;
124+
module_param_named(chain_mode, stmmac_chain_mode, int, 0444);
125125
MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode");
126126

127127
static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
@@ -185,18 +185,19 @@ EXPORT_SYMBOL_GPL(stmmac_bus_clks_config);
185185
*/
186186
static void stmmac_verify_args(void)
187187
{
188-
if (unlikely(watchdog < 0))
189-
watchdog = TX_TIMEO;
190-
if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB)))
191-
buf_sz = DEFAULT_BUFSIZE;
192-
if (unlikely(flow_ctrl > 1))
193-
flow_ctrl = FLOW_AUTO;
194-
else if (likely(flow_ctrl < 0))
195-
flow_ctrl = FLOW_OFF;
196-
if (unlikely((pause < 0) || (pause > 0xffff)))
197-
pause = PAUSE_TIME;
198-
if (eee_timer < 0)
199-
eee_timer = STMMAC_DEFAULT_LPI_TIMER;
188+
if (unlikely(stmmac_watchdog < 0))
189+
stmmac_watchdog = TX_TIMEO;
190+
if (unlikely((stmmac_buf_sz < DEFAULT_BUFSIZE) ||
191+
(stmmac_buf_sz > BUF_SIZE_16KiB)))
192+
stmmac_buf_sz = DEFAULT_BUFSIZE;
193+
if (unlikely(stmmac_flow_ctrl > 1))
194+
stmmac_flow_ctrl = FLOW_AUTO;
195+
else if (likely(stmmac_flow_ctrl < 0))
196+
stmmac_flow_ctrl = FLOW_OFF;
197+
if (unlikely((stmmac_pause < 0) || (stmmac_pause > 0xffff)))
198+
stmmac_pause = PAUSE_TIME;
199+
if (stmmac_eee_timer < 0)
200+
stmmac_eee_timer = STMMAC_DEFAULT_LPI_TIMER;
200201
}
201202

202203
static void __stmmac_disable_all_queues(struct stmmac_priv *priv)
@@ -2375,8 +2376,8 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
23752376
txfifosz /= tx_channels_count;
23762377

23772378
if (priv->plat->force_thresh_dma_mode) {
2378-
txmode = tc;
2379-
rxmode = tc;
2379+
txmode = stmmac_tc;
2380+
rxmode = stmmac_tc;
23802381
} else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) {
23812382
/*
23822383
* In case of GMAC, SF mode can be enabled
@@ -2389,7 +2390,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
23892390
rxmode = SF_DMA_MODE;
23902391
priv->xstats.threshold = SF_DMA_MODE;
23912392
} else {
2392-
txmode = tc;
2393+
txmode = stmmac_tc;
23932394
rxmode = SF_DMA_MODE;
23942395
}
23952396

@@ -2520,16 +2521,16 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
25202521

25212522
static void stmmac_bump_dma_threshold(struct stmmac_priv *priv, u32 chan)
25222523
{
2523-
if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && tc <= 256) {
2524-
tc += 64;
2524+
if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && stmmac_tc <= 256) {
2525+
stmmac_tc += 64;
25252526

25262527
if (priv->plat->force_thresh_dma_mode)
2527-
stmmac_set_dma_operation_mode(priv, tc, tc, chan);
2528+
stmmac_set_dma_operation_mode(priv, stmmac_tc, stmmac_tc, chan);
25282529
else
2529-
stmmac_set_dma_operation_mode(priv, tc, SF_DMA_MODE,
2530+
stmmac_set_dma_operation_mode(priv, stmmac_tc, SF_DMA_MODE,
25302531
chan);
25312532

2532-
priv->xstats.threshold = tc;
2533+
priv->xstats.threshold = stmmac_tc;
25332534
}
25342535
}
25352536

@@ -3374,7 +3375,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
33743375

33753376
/* Convert the timer from msec to usec */
33763377
if (!priv->tx_lpi_timer)
3377-
priv->tx_lpi_timer = eee_timer * 1000;
3378+
priv->tx_lpi_timer = stmmac_eee_timer * 1000;
33783379

33793380
if (priv->use_riwt) {
33803381
u32 queue;
@@ -3829,11 +3830,11 @@ static int __stmmac_open(struct net_device *dev,
38293830

38303831
/* Extra statistics */
38313832
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
3832-
priv->xstats.threshold = tc;
3833+
priv->xstats.threshold = stmmac_tc;
38333834

38343835
priv->rx_copybreak = STMMAC_RX_COPYBREAK;
38353836

3836-
buf_sz = dma_conf->dma_buf_sz;
3837+
stmmac_buf_sz = dma_conf->dma_buf_sz;
38373838
memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));
38383839

38393840
stmmac_reset_queues_param(priv);
@@ -6856,8 +6857,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
68566857

68576858
/* dwmac-sun8i only work in chain mode */
68586859
if (priv->plat->has_sun8i)
6859-
chain_mode = 1;
6860-
priv->chain_mode = chain_mode;
6860+
stmmac_chain_mode = 1;
6861+
priv->chain_mode = stmmac_chain_mode;
68616862

68626863
/* Initialize HW Interface */
68636864
ret = stmmac_hwif_init(priv);
@@ -7161,7 +7162,7 @@ int stmmac_dvr_probe(struct device *device,
71617162
priv->dev = ndev;
71627163

71637164
stmmac_set_ethtool_ops(ndev);
7164-
priv->pause = pause;
7165+
priv->pause = stmmac_pause;
71657166
priv->plat = plat_dat;
71667167
priv->ioaddr = res->addr;
71677168
priv->dev->base_addr = (unsigned long)res->addr;
@@ -7205,8 +7206,8 @@ int stmmac_dvr_probe(struct device *device,
72057206
/* Override with kernel parameters if supplied XXX CRS XXX
72067207
* this needs to have multiple instances
72077208
*/
7208-
if ((phyaddr >= 0) && (phyaddr <= 31))
7209-
priv->plat->phy_addr = phyaddr;
7209+
if ((stmmac_phyaddr >= 0) && (stmmac_phyaddr <= 31))
7210+
priv->plat->phy_addr = stmmac_phyaddr;
72107211

72117212
if (priv->plat->stmmac_rst) {
72127213
ret = reset_control_assert(priv->plat->stmmac_rst);
@@ -7299,7 +7300,7 @@ int stmmac_dvr_probe(struct device *device,
72997300
}
73007301

73017302
ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA;
7302-
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
7303+
ndev->watchdog_timeo = msecs_to_jiffies(stmmac_watchdog);
73037304
#ifdef STMMAC_VLAN_TAG_USED
73047305
/* Both mac100 and gmac support receive VLAN tag detection */
73057306
ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
@@ -7313,7 +7314,7 @@ int stmmac_dvr_probe(struct device *device,
73137314
ndev->features |= NETIF_F_HW_VLAN_STAG_TX;
73147315
}
73157316
#endif
7316-
priv->msg_enable = netif_msg_init(debug, default_msg_level);
7317+
priv->msg_enable = netif_msg_init(stmmac_debug, default_msg_level);
73177318

73187319
/* Initialize RSS */
73197320
rxq = priv->plat->rx_queues_to_use;
@@ -7347,7 +7348,7 @@ int stmmac_dvr_probe(struct device *device,
73477348
"%s: warning: maxmtu having invalid value (%d)\n",
73487349
__func__, priv->plat->maxmtu);
73497350

7350-
if (flow_ctrl)
7351+
if (stmmac_flow_ctrl)
73517352
priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */
73527353

73537354
ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
@@ -7674,31 +7675,31 @@ static int __init stmmac_cmdline_opt(char *str)
76747675
return 1;
76757676
while ((opt = strsep(&str, ",")) != NULL) {
76767677
if (!strncmp(opt, "debug:", 6)) {
7677-
if (kstrtoint(opt + 6, 0, &debug))
7678+
if (kstrtoint(opt + 6, 0, &stmmac_debug))
76787679
goto err;
76797680
} else if (!strncmp(opt, "phyaddr:", 8)) {
7680-
if (kstrtoint(opt + 8, 0, &phyaddr))
7681+
if (kstrtoint(opt + 8, 0, &stmmac_phyaddr))
76817682
goto err;
76827683
} else if (!strncmp(opt, "buf_sz:", 7)) {
7683-
if (kstrtoint(opt + 7, 0, &buf_sz))
7684+
if (kstrtoint(opt + 7, 0, &stmmac_buf_sz))
76847685
goto err;
76857686
} else if (!strncmp(opt, "tc:", 3)) {
7686-
if (kstrtoint(opt + 3, 0, &tc))
7687+
if (kstrtoint(opt + 3, 0, &stmmac_tc))
76877688
goto err;
76887689
} else if (!strncmp(opt, "watchdog:", 9)) {
7689-
if (kstrtoint(opt + 9, 0, &watchdog))
7690+
if (kstrtoint(opt + 9, 0, &stmmac_watchdog))
76907691
goto err;
76917692
} else if (!strncmp(opt, "flow_ctrl:", 10)) {
7692-
if (kstrtoint(opt + 10, 0, &flow_ctrl))
7693+
if (kstrtoint(opt + 10, 0, &stmmac_flow_ctrl))
76937694
goto err;
76947695
} else if (!strncmp(opt, "pause:", 6)) {
7695-
if (kstrtoint(opt + 6, 0, &pause))
7696+
if (kstrtoint(opt + 6, 0, &stmmac_pause))
76967697
goto err;
76977698
} else if (!strncmp(opt, "eee_timer:", 10)) {
7698-
if (kstrtoint(opt + 10, 0, &eee_timer))
7699+
if (kstrtoint(opt + 10, 0, &stmmac_eee_timer))
76997700
goto err;
77007701
} else if (!strncmp(opt, "chain_mode:", 11)) {
7701-
if (kstrtoint(opt + 11, 0, &chain_mode))
7702+
if (kstrtoint(opt + 11, 0, &stmmac_chain_mode))
77027703
goto err;
77037704
}
77047705
}

0 commit comments

Comments
 (0)