Skip to content

Commit 610a5cc

Browse files
FreeFlyingSheepchenhuacai
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 5fabfe4 commit 610a5cc

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)
@@ -2372,8 +2373,8 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
23722373
txfifosz /= tx_channels_count;
23732374

23742375
if (priv->plat->force_thresh_dma_mode) {
2375-
txmode = tc;
2376-
rxmode = tc;
2376+
txmode = stmmac_tc;
2377+
rxmode = stmmac_tc;
23772378
} else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) {
23782379
/*
23792380
* In case of GMAC, SF mode can be enabled
@@ -2386,7 +2387,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
23862387
rxmode = SF_DMA_MODE;
23872388
priv->xstats.threshold = SF_DMA_MODE;
23882389
} else {
2389-
txmode = tc;
2390+
txmode = stmmac_tc;
23902391
rxmode = SF_DMA_MODE;
23912392
}
23922393

@@ -2517,16 +2518,16 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
25172518

25182519
static void stmmac_bump_dma_threshold(struct stmmac_priv *priv, u32 chan)
25192520
{
2520-
if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && tc <= 256) {
2521-
tc += 64;
2521+
if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && stmmac_tc <= 256) {
2522+
stmmac_tc += 64;
25222523

25232524
if (priv->plat->force_thresh_dma_mode)
2524-
stmmac_set_dma_operation_mode(priv, tc, tc, chan);
2525+
stmmac_set_dma_operation_mode(priv, stmmac_tc, stmmac_tc, chan);
25252526
else
2526-
stmmac_set_dma_operation_mode(priv, tc, SF_DMA_MODE,
2527+
stmmac_set_dma_operation_mode(priv, stmmac_tc, SF_DMA_MODE,
25272528
chan);
25282529

2529-
priv->xstats.threshold = tc;
2530+
priv->xstats.threshold = stmmac_tc;
25302531
}
25312532
}
25322533

@@ -3371,7 +3372,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
33713372

33723373
/* Convert the timer from msec to usec */
33733374
if (!priv->tx_lpi_timer)
3374-
priv->tx_lpi_timer = eee_timer * 1000;
3375+
priv->tx_lpi_timer = stmmac_eee_timer * 1000;
33753376

33763377
if (priv->use_riwt) {
33773378
u32 queue;
@@ -3825,11 +3826,11 @@ static int __stmmac_open(struct net_device *dev,
38253826

38263827
/* Extra statistics */
38273828
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
3828-
priv->xstats.threshold = tc;
3829+
priv->xstats.threshold = stmmac_tc;
38293830

38303831
priv->rx_copybreak = STMMAC_RX_COPYBREAK;
38313832

3832-
buf_sz = dma_conf->dma_buf_sz;
3833+
stmmac_buf_sz = dma_conf->dma_buf_sz;
38333834
memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));
38343835

38353836
stmmac_reset_queues_param(priv);
@@ -6852,8 +6853,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
68526853

68536854
/* dwmac-sun8i only work in chain mode */
68546855
if (priv->plat->has_sun8i)
6855-
chain_mode = 1;
6856-
priv->chain_mode = chain_mode;
6856+
stmmac_chain_mode = 1;
6857+
priv->chain_mode = stmmac_chain_mode;
68576858

68586859
/* Initialize HW Interface */
68596860
ret = stmmac_hwif_init(priv);
@@ -7157,7 +7158,7 @@ int stmmac_dvr_probe(struct device *device,
71577158
priv->dev = ndev;
71587159

71597160
stmmac_set_ethtool_ops(ndev);
7160-
priv->pause = pause;
7161+
priv->pause = stmmac_pause;
71617162
priv->plat = plat_dat;
71627163
priv->ioaddr = res->addr;
71637164
priv->dev->base_addr = (unsigned long)res->addr;
@@ -7201,8 +7202,8 @@ int stmmac_dvr_probe(struct device *device,
72017202
/* Override with kernel parameters if supplied XXX CRS XXX
72027203
* this needs to have multiple instances
72037204
*/
7204-
if ((phyaddr >= 0) && (phyaddr <= 31))
7205-
priv->plat->phy_addr = phyaddr;
7205+
if ((stmmac_phyaddr >= 0) && (stmmac_phyaddr <= 31))
7206+
priv->plat->phy_addr = stmmac_phyaddr;
72067207

72077208
if (priv->plat->stmmac_rst) {
72087209
ret = reset_control_assert(priv->plat->stmmac_rst);
@@ -7295,7 +7296,7 @@ int stmmac_dvr_probe(struct device *device,
72957296
}
72967297

72977298
ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA;
7298-
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
7299+
ndev->watchdog_timeo = msecs_to_jiffies(stmmac_watchdog);
72997300
#ifdef STMMAC_VLAN_TAG_USED
73007301
/* Both mac100 and gmac support receive VLAN tag detection */
73017302
ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
@@ -7309,7 +7310,7 @@ int stmmac_dvr_probe(struct device *device,
73097310
ndev->features |= NETIF_F_HW_VLAN_STAG_TX;
73107311
}
73117312
#endif
7312-
priv->msg_enable = netif_msg_init(debug, default_msg_level);
7313+
priv->msg_enable = netif_msg_init(stmmac_debug, default_msg_level);
73137314

73147315
/* Initialize RSS */
73157316
rxq = priv->plat->rx_queues_to_use;
@@ -7343,7 +7344,7 @@ int stmmac_dvr_probe(struct device *device,
73437344
"%s: warning: maxmtu having invalid value (%d)\n",
73447345
__func__, priv->plat->maxmtu);
73457346

7346-
if (flow_ctrl)
7347+
if (stmmac_flow_ctrl)
73477348
priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */
73487349

73497350
ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
@@ -7676,31 +7677,31 @@ static int __init stmmac_cmdline_opt(char *str)
76767677
return 1;
76777678
while ((opt = strsep(&str, ",")) != NULL) {
76787679
if (!strncmp(opt, "debug:", 6)) {
7679-
if (kstrtoint(opt + 6, 0, &debug))
7680+
if (kstrtoint(opt + 6, 0, &stmmac_debug))
76807681
goto err;
76817682
} else if (!strncmp(opt, "phyaddr:", 8)) {
7682-
if (kstrtoint(opt + 8, 0, &phyaddr))
7683+
if (kstrtoint(opt + 8, 0, &stmmac_phyaddr))
76837684
goto err;
76847685
} else if (!strncmp(opt, "buf_sz:", 7)) {
7685-
if (kstrtoint(opt + 7, 0, &buf_sz))
7686+
if (kstrtoint(opt + 7, 0, &stmmac_buf_sz))
76867687
goto err;
76877688
} else if (!strncmp(opt, "tc:", 3)) {
7688-
if (kstrtoint(opt + 3, 0, &tc))
7689+
if (kstrtoint(opt + 3, 0, &stmmac_tc))
76897690
goto err;
76907691
} else if (!strncmp(opt, "watchdog:", 9)) {
7691-
if (kstrtoint(opt + 9, 0, &watchdog))
7692+
if (kstrtoint(opt + 9, 0, &stmmac_watchdog))
76927693
goto err;
76937694
} else if (!strncmp(opt, "flow_ctrl:", 10)) {
7694-
if (kstrtoint(opt + 10, 0, &flow_ctrl))
7695+
if (kstrtoint(opt + 10, 0, &stmmac_flow_ctrl))
76957696
goto err;
76967697
} else if (!strncmp(opt, "pause:", 6)) {
7697-
if (kstrtoint(opt + 6, 0, &pause))
7698+
if (kstrtoint(opt + 6, 0, &stmmac_pause))
76987699
goto err;
76997700
} else if (!strncmp(opt, "eee_timer:", 10)) {
7700-
if (kstrtoint(opt + 10, 0, &eee_timer))
7701+
if (kstrtoint(opt + 10, 0, &stmmac_eee_timer))
77017702
goto err;
77027703
} else if (!strncmp(opt, "chain_mode:", 11)) {
7703-
if (kstrtoint(opt + 11, 0, &chain_mode))
7704+
if (kstrtoint(opt + 11, 0, &stmmac_chain_mode))
77047705
goto err;
77057706
}
77067707
}

0 commit comments

Comments
 (0)