1 /*******************************************************************************
4 Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
30 /* This is the only thing that needs to be changed to adjust the
31 * maximum number of ports that the driver can manage.
34 #define IXGB_MAX_NIC 8
36 #define OPTION_UNSET -1
37 #define OPTION_DISABLED 0
38 #define OPTION_ENABLED 1
40 /* Module Parameters are always initialized to -1, so that the driver
41 * can tell the difference between no user specified value or the
42 * user asking for the default value.
43 * The true default values are loaded in when ixgb_check_options is called.
45 * This is a GCC extension to ANSI C.
46 * See the item "Labeled Elements in Initializers" in the section
47 * "Extensions to the C Language Family" of the GCC documentation.
50 #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
52 /* All parameters are treated the same, as an integer array of values.
53 * This macro just reduces the need to repeat the same declaration code
54 * over and over (plus this helps to avoid typo bugs).
57 #define IXGB_PARAM(X, S) \
58 static const int __devinitdata X[IXGB_MAX_NIC + 1] = IXGB_PARAM_INIT; \
59 MODULE_PARM(X, "1-" __MODULE_STRING(IXGB_MAX_NIC) "i"); \
60 MODULE_PARM_DESC(X, S);
62 /* Transmit Descriptor Count
64 * Valid Range: 64-4096
69 IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
71 /* Receive Descriptor Count
73 * Valid Range: 64-4096
78 IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
80 /* User Specified Flow Control Override
83 * - 0 - No Flow Control
84 * - 1 - Rx only, respond to PAUSE frames but do not generate them
85 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
86 * - 3 - Full Flow Control Support
88 * Default Value: Read flow control settings from the EEPROM
91 IXGB_PARAM(FlowControl, "Flow Control setting");
93 /* XsumRX - Receive Checksum Offload Enable/Disable
96 * - 0 - disables all checksum offload
97 * - 1 - enables receive IP/TCP/UDP checksum offload
103 IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
105 /* XsumTX - Transmit Checksum Offload Enable/Disable
108 * - 0 - disables all checksum offload
109 * - 1 - enables transmmit IP/TCP/UDP checksum offload
110 * on 82597 based NICs
115 IXGB_PARAM(XsumTX, "Disable or enable Transmit Checksum offload");
117 /* Receive Interrupt Delay in units of 0.8192 microseconds
119 * Valid Range: 0-65535
124 IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
126 /* Receive Interrupt Moderation enable (uses RxIntDelay too)
133 IXGB_PARAM(RAIDC, "Disable or enable Receive Interrupt Moderation");
135 /* Receive Flow control high threshold (when we send a pause frame)
138 * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
140 * Default Value: 196,608 (0x30000)
143 IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
145 /* Receive Flow control low threshold (when we send a resume frame)
148 * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
149 * must be less than high threshold by at least 8 bytes
151 * Default Value: 163,840 (0x28000)
154 IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
156 /* Flow control request timeout (how long to pause the link partner's tx)
159 * Valid Range: 1 - 65535
161 * Default Value: 256 (0x100)
164 IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
166 /* Transmit Interrupt Delay in units of 0.8192 microseconds
168 * Valid Range: 0-65535
173 IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
175 /* Interrupt Delay Enable
179 * - 0 - disables transmit interrupt delay
180 * - 1 - enables transmmit interrupt delay
185 IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
187 #define DEFAULT_TXD 256
190 #define DEFAULT_RXD 1024
193 #define DEFAULT_TIDV 32
194 #define MAX_TIDV 0xFFFF
196 #define DEFAULT_RDTR 72
197 #define MAX_RDTR 0xFFFF
199 #define XSUMRX_DEFAULT OPTION_ENABLED
200 #define FLOW_CONTROL_FULL ixgb_fc_full
201 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
202 #define DEFAULT_FCRTL 0x28000
203 #define DEFAULT_FCRTH 0x30000
205 #define MAX_FCRTL 0x3FFE8
207 #define MAX_FCRTH 0x3FFF0
208 #define DEFAULT_FCPAUSE 0x100
209 #define MIN_FCPAUSE 1
210 #define MAX_FCPAUSE 0xffff
213 enum { enable_option, range_option, list_option } type;
218 struct { /* range option information */
222 struct { /* list option information */
224 struct ixgb_opt_list {
233 ixgb_validate_option(int *value, struct ixgb_option *opt)
235 if (*value == OPTION_UNSET) {
244 printk(KERN_INFO "%s Enabled\n", opt->name);
246 case OPTION_DISABLED:
247 printk(KERN_INFO "%s Disabled\n", opt->name);
252 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
253 printk(KERN_INFO "%s set to %i\n", opt->name, *value);
260 struct ixgb_opt_list *ent;
262 for (i = 0; i < opt->arg.l.nr; i++) {
263 ent = &opt->arg.l.p[i];
264 if (*value == ent->i) {
265 if (ent->str[0] != '\0')
266 printk(KERN_INFO "%s",
277 printk(KERN_INFO "Invalid %s specified (%i) %s\n", opt->name, *value,
283 #define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
286 * ixgb_check_options - Range Checking for Command Line Parameters
287 * @adapter: board private structure
289 * This routine checks all command line paramters for valid user
290 * input. If an invalid value is given, or if no user specified
291 * value exists, a default value is used. The final value is stored
292 * in a variable in the adapter structure.
296 ixgb_check_options(struct ixgb_adapter *adapter)
298 int board = adapter->bd_number;
300 IXGB_DBG("ixgb_check_options\n");
302 if (board >= IXGB_MAX_NIC) {
303 printk(KERN_NOTICE "Warning: no configuration for board #%i\n",
305 printk(KERN_NOTICE "Using defaults for all values\n");
306 board = IXGB_MAX_NIC;
309 { /* Transmit Descriptor Count */
310 struct ixgb_option opt = {
311 .type = range_option,
312 .name = "Transmit Descriptors",
313 .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
315 .arg = {.r = {.min = MIN_TXD,.max = MAX_TXD}}
317 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
319 tx_ring->count = TxDescriptors[board];
320 ixgb_validate_option(&tx_ring->count, &opt);
321 IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
324 { /* Receive Descriptor Count */
325 struct ixgb_option opt = {
326 .type = range_option,
327 .name = "Receive Descriptors",
328 .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
330 .arg = {.r = {.min = MIN_RXD,.max = MAX_RXD}}
332 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
334 rx_ring->count = RxDescriptors[board];
335 ixgb_validate_option(&rx_ring->count, &opt);
336 IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
339 { /* Receive Checksum Offload Enable */
340 struct ixgb_option opt = {
341 .type = enable_option,
342 .name = "Receive Checksum Offload",
343 .err = "defaulting to Enabled",
344 .def = OPTION_ENABLED,
346 int rx_csum = XsumRX[board];
348 ixgb_validate_option(&rx_csum, &opt);
349 adapter->rx_csum = rx_csum;
352 { /* Transmit Checksum Offload Enable */
353 struct ixgb_option opt = {
354 .type = enable_option,
355 .name = "Transmit Checksum Offload",
356 .err = "defaulting to Enabled",
357 .def = OPTION_ENABLED,
359 int tx_csum = XsumTX[board];
361 ixgb_validate_option(&tx_csum, &opt);
362 adapter->tx_csum = tx_csum;
366 struct ixgb_opt_list fc_list[] = {
367 {ixgb_fc_none, "Flow Control Disabled\n"},
368 {ixgb_fc_rx_pause, "Flow Control Receive Only\n"},
369 {ixgb_fc_tx_pause, "Flow Control Transmit Only\n"},
370 {ixgb_fc_full, "Flow Control Enabled\n"},
371 {ixgb_fc_default, "Flow Control Hardware Default\n"}
374 struct ixgb_option opt = {
376 .name = "Flow Control",
377 .err = "reading default settings from EEPROM",
379 .arg = {.l = {.nr = LIST_LEN(fc_list),.p = fc_list}}
382 int fc = FlowControl[board];
384 ixgb_validate_option(&fc, &opt);
385 adapter->hw.fc.type = fc;
387 { /* Receive Flow Control High Threshold */
388 struct ixgb_option fcrth = {
389 .type = range_option,
390 .name = "Rx Flow Control High Threshold",
392 "using default of " __MODULE_STRING(DEFAULT_FCRTH),
393 .def = DEFAULT_FCRTH,
394 .arg = {.r = {.min = MIN_FCRTH,.max = MAX_FCRTH}}
397 adapter->hw.fc.high_water = RxFCHighThresh[board];
398 ixgb_validate_option(&adapter->hw.fc.high_water, &fcrth);
399 if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
401 "Ignoring RxFCHighThresh when no RxFC\n");
403 { /* Receive Flow Control Low Threshold */
404 struct ixgb_option fcrtl = {
405 .type = range_option,
406 .name = "Rx Flow Control Low Threshold",
408 "using default of " __MODULE_STRING(DEFAULT_FCRTL),
409 .def = DEFAULT_FCRTL,
410 .arg = {.r = {.min = MIN_FCRTL,.max = MAX_FCRTL}}
413 adapter->hw.fc.low_water = RxFCLowThresh[board];
414 ixgb_validate_option(&adapter->hw.fc.low_water, &fcrtl);
415 if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
417 "Ignoring RxFCLowThresh when no RxFC\n");
419 { /* Flow Control Pause Time Request */
420 struct ixgb_option fcpap = {
421 .type = range_option,
422 .name = "Flow Control Pause Time Request",
425 __MODULE_STRING(DEFAULT_FCPAUSE),
426 .def = DEFAULT_FCPAUSE,
427 .arg = {.r = {.min = MIN_FCPAUSE,.max = MAX_FCPAUSE}}
430 int pause_time = FCReqTimeout[board];
432 ixgb_validate_option(&pause_time, &fcpap);
433 if (!(adapter->hw.fc.type & ixgb_fc_rx_pause))
435 "Ignoring FCReqTimeout when no RxFC\n");
436 adapter->hw.fc.pause_time = pause_time;
438 /* high low and spacing check for rx flow control thresholds */
439 if (adapter->hw.fc.type & ixgb_fc_rx_pause) {
440 /* high must be greater than low */
441 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
444 "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
446 adapter->hw.fc.high_water = DEFAULT_FCRTH;
447 adapter->hw.fc.low_water = DEFAULT_FCRTL;
450 { /* Receive Interrupt Delay */
451 struct ixgb_option opt = {
452 .type = range_option,
453 .name = "Receive Interrupt Delay",
455 "using default of " __MODULE_STRING(DEFAULT_RDTR),
457 .arg = {.r = {.min = MIN_RDTR,.max = MAX_RDTR}}
460 adapter->rx_int_delay = RxIntDelay[board];
461 ixgb_validate_option(&adapter->rx_int_delay, &opt);
463 { /* Receive Interrupt Moderation */
464 struct ixgb_option opt = {
465 .type = enable_option,
466 .name = "Advanced Receive Interrupt Moderation",
467 .err = "defaulting to Enabled",
468 .def = OPTION_ENABLED,
470 int raidc = RAIDC[board];
472 ixgb_validate_option(&raidc, &opt);
473 adapter->raidc = raidc;
476 { /* Transmit Interrupt Delay */
477 struct ixgb_option opt = {
478 .type = range_option,
479 .name = "Transmit Interrupt Delay",
481 "using default of " __MODULE_STRING(DEFAULT_TIDV),
483 .arg = {.r = {.min = MIN_TIDV,.max = MAX_TIDV}}
486 adapter->tx_int_delay = TxIntDelay[board];
487 ixgb_validate_option(&adapter->tx_int_delay, &opt);
490 { /* Transmit Interrupt Delay Enable */
491 struct ixgb_option opt = {
492 .type = enable_option,
493 .name = "Tx Interrupt Delay Enable",
494 .err = "defaulting to Enabled",
495 .def = OPTION_ENABLED,
497 int ide = IntDelayEnable[board];
499 ixgb_validate_option(&ide, &opt);
500 adapter->tx_int_delay_enable = ide;