1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2008 Intel Corporation. */
4 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8 /* This is the only thing that needs to be changed to adjust the
9 * maximum number of ports that the driver can manage.
12 #define IXGB_MAX_NIC 8
14 #define OPTION_UNSET -1
15 #define OPTION_DISABLED 0
16 #define OPTION_ENABLED 1
18 /* All parameters are treated the same, as an integer array of values.
19 * This macro just reduces the need to repeat the same declaration code
20 * over and over (plus this helps to avoid typo bugs).
23 #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
24 #define IXGB_PARAM(X, desc) \
25 static int X[IXGB_MAX_NIC+1] \
27 static unsigned int num_##X = 0; \
28 module_param_array_named(X, X, int, &num_##X, 0); \
29 MODULE_PARM_DESC(X, desc);
31 /* Transmit Descriptor Count
33 * Valid Range: 64-4096
38 IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
40 /* Receive Descriptor Count
42 * Valid Range: 64-4096
47 IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
49 /* User Specified Flow Control Override
52 * - 0 - No Flow Control
53 * - 1 - Rx only, respond to PAUSE frames but do not generate them
54 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
55 * - 3 - Full Flow Control Support
57 * Default Value: 2 - Tx only (silicon bug avoidance)
60 IXGB_PARAM(FlowControl, "Flow Control setting");
62 /* XsumRX - Receive Checksum Offload Enable/Disable
65 * - 0 - disables all checksum offload
66 * - 1 - enables receive IP/TCP/UDP checksum offload
72 IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
74 /* Transmit Interrupt Delay in units of 0.8192 microseconds
76 * Valid Range: 0-65535
81 IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
83 /* Receive Interrupt Delay in units of 0.8192 microseconds
85 * Valid Range: 0-65535
90 IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
92 /* Receive Flow control high threshold (when we send a pause frame)
95 * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
97 * Default Value: 196,608 (0x30000)
100 IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
102 /* Receive Flow control low threshold (when we send a resume frame)
105 * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
106 * must be less than high threshold by at least 8 bytes
108 * Default Value: 163,840 (0x28000)
111 IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
113 /* Flow control request timeout (how long to pause the link partner's tx)
116 * Valid Range: 1 - 65535
118 * Default Value: 65535 (0xffff) (we'll send an xon if we recover)
121 IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
123 /* Interrupt Delay Enable
127 * - 0 - disables transmit interrupt delay
128 * - 1 - enables transmmit interrupt delay
133 IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
136 #define DEFAULT_TIDV 32
137 #define MAX_TIDV 0xFFFF
140 #define DEFAULT_RDTR 72
141 #define MAX_RDTR 0xFFFF
144 #define XSUMRX_DEFAULT OPTION_ENABLED
146 #define DEFAULT_FCRTL 0x28000
147 #define DEFAULT_FCRTH 0x30000
149 #define MAX_FCRTL 0x3FFE8
151 #define MAX_FCRTH 0x3FFF0
153 #define MIN_FCPAUSE 1
154 #define MAX_FCPAUSE 0xffff
155 #define DEFAULT_FCPAUSE 0xFFFF /* this may be too long */
158 enum { enable_option, range_option, list_option } type;
163 struct { /* range_option info */
167 struct { /* list_option info */
169 const struct ixgb_opt_list {
178 ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt)
180 if (*value == OPTION_UNSET) {
189 pr_info("%s Enabled\n", opt->name);
191 case OPTION_DISABLED:
192 pr_info("%s Disabled\n", opt->name);
197 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
198 pr_info("%s set to %i\n", opt->name, *value);
204 const struct ixgb_opt_list *ent;
206 for (i = 0; i < opt->arg.l.nr; i++) {
207 ent = &opt->arg.l.p[i];
208 if (*value == ent->i) {
209 if (ent->str[0] != '\0')
210 pr_info("%s\n", ent->str);
220 pr_info("Invalid %s specified (%i) %s\n", opt->name, *value, opt->err);
226 * ixgb_check_options - Range Checking for Command Line Parameters
227 * @adapter: board private structure
229 * This routine checks all command line parameters for valid user
230 * input. If an invalid value is given, or if no user specified
231 * value exists, a default value is used. The final value is stored
232 * in a variable in the adapter structure.
236 ixgb_check_options(struct ixgb_adapter *adapter)
238 int bd = adapter->bd_number;
239 if (bd >= IXGB_MAX_NIC) {
240 pr_notice("Warning: no configuration for board #%i\n", bd);
241 pr_notice("Using defaults for all values\n");
244 { /* Transmit Descriptor Count */
245 static const struct ixgb_option opt = {
246 .type = range_option,
247 .name = "Transmit Descriptors",
248 .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
250 .arg = { .r = { .min = MIN_TXD,
253 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
255 if (num_TxDescriptors > bd) {
256 tx_ring->count = TxDescriptors[bd];
257 ixgb_validate_option(&tx_ring->count, &opt);
259 tx_ring->count = opt.def;
261 tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
263 { /* Receive Descriptor Count */
264 static const struct ixgb_option opt = {
265 .type = range_option,
266 .name = "Receive Descriptors",
267 .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
269 .arg = { .r = { .min = MIN_RXD,
272 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
274 if (num_RxDescriptors > bd) {
275 rx_ring->count = RxDescriptors[bd];
276 ixgb_validate_option(&rx_ring->count, &opt);
278 rx_ring->count = opt.def;
280 rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
282 { /* Receive Checksum Offload Enable */
283 static const struct ixgb_option opt = {
284 .type = enable_option,
285 .name = "Receive Checksum Offload",
286 .err = "defaulting to Enabled",
287 .def = OPTION_ENABLED
290 if (num_XsumRX > bd) {
291 unsigned int rx_csum = XsumRX[bd];
292 ixgb_validate_option(&rx_csum, &opt);
293 adapter->rx_csum = rx_csum;
295 adapter->rx_csum = opt.def;
300 static const struct ixgb_opt_list fc_list[] = {
301 { ixgb_fc_none, "Flow Control Disabled" },
302 { ixgb_fc_rx_pause, "Flow Control Receive Only" },
303 { ixgb_fc_tx_pause, "Flow Control Transmit Only" },
304 { ixgb_fc_full, "Flow Control Enabled" },
305 { ixgb_fc_default, "Flow Control Hardware Default" }
308 static const struct ixgb_option opt = {
310 .name = "Flow Control",
311 .err = "reading default settings from EEPROM",
312 .def = ixgb_fc_tx_pause,
313 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
317 if (num_FlowControl > bd) {
318 unsigned int fc = FlowControl[bd];
319 ixgb_validate_option(&fc, &opt);
320 adapter->hw.fc.type = fc;
322 adapter->hw.fc.type = opt.def;
325 { /* Receive Flow Control High Threshold */
326 static const struct ixgb_option opt = {
327 .type = range_option,
328 .name = "Rx Flow Control High Threshold",
329 .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH),
330 .def = DEFAULT_FCRTH,
331 .arg = { .r = { .min = MIN_FCRTH,
335 if (num_RxFCHighThresh > bd) {
336 adapter->hw.fc.high_water = RxFCHighThresh[bd];
337 ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
339 adapter->hw.fc.high_water = opt.def;
341 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
342 pr_info("Ignoring RxFCHighThresh when no RxFC\n");
344 { /* Receive Flow Control Low Threshold */
345 static const struct ixgb_option opt = {
346 .type = range_option,
347 .name = "Rx Flow Control Low Threshold",
348 .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL),
349 .def = DEFAULT_FCRTL,
350 .arg = { .r = { .min = MIN_FCRTL,
354 if (num_RxFCLowThresh > bd) {
355 adapter->hw.fc.low_water = RxFCLowThresh[bd];
356 ixgb_validate_option(&adapter->hw.fc.low_water, &opt);
358 adapter->hw.fc.low_water = opt.def;
360 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
361 pr_info("Ignoring RxFCLowThresh when no RxFC\n");
363 { /* Flow Control Pause Time Request*/
364 static const struct ixgb_option opt = {
365 .type = range_option,
366 .name = "Flow Control Pause Time Request",
367 .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE),
368 .def = DEFAULT_FCPAUSE,
369 .arg = { .r = { .min = MIN_FCPAUSE,
373 if (num_FCReqTimeout > bd) {
374 unsigned int pause_time = FCReqTimeout[bd];
375 ixgb_validate_option(&pause_time, &opt);
376 adapter->hw.fc.pause_time = pause_time;
378 adapter->hw.fc.pause_time = opt.def;
380 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
381 pr_info("Ignoring FCReqTimeout when no RxFC\n");
383 /* high low and spacing check for rx flow control thresholds */
384 if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
385 /* high must be greater than low */
386 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
388 pr_info("RxFCHighThresh must be >= (RxFCLowThresh + 8), Using Defaults\n");
389 adapter->hw.fc.high_water = DEFAULT_FCRTH;
390 adapter->hw.fc.low_water = DEFAULT_FCRTL;
393 { /* Receive Interrupt Delay */
394 static const struct ixgb_option opt = {
395 .type = range_option,
396 .name = "Receive Interrupt Delay",
397 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
399 .arg = { .r = { .min = MIN_RDTR,
403 if (num_RxIntDelay > bd) {
404 adapter->rx_int_delay = RxIntDelay[bd];
405 ixgb_validate_option(&adapter->rx_int_delay, &opt);
407 adapter->rx_int_delay = opt.def;
410 { /* Transmit Interrupt Delay */
411 static const struct ixgb_option opt = {
412 .type = range_option,
413 .name = "Transmit Interrupt Delay",
414 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
416 .arg = { .r = { .min = MIN_TIDV,
420 if (num_TxIntDelay > bd) {
421 adapter->tx_int_delay = TxIntDelay[bd];
422 ixgb_validate_option(&adapter->tx_int_delay, &opt);
424 adapter->tx_int_delay = opt.def;
428 { /* Transmit Interrupt Delay Enable */
429 static const struct ixgb_option opt = {
430 .type = enable_option,
431 .name = "Tx Interrupt Delay Enable",
432 .err = "defaulting to Enabled",
433 .def = OPTION_ENABLED
436 if (num_IntDelayEnable > bd) {
437 unsigned int ide = IntDelayEnable[bd];
438 ixgb_validate_option(&ide, &opt);
439 adapter->tx_int_delay_enable = ide;
441 adapter->tx_int_delay_enable = opt.def;