1 /*******************************************************************************
4 Copyright(c) 1999 - 2004 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
27 *******************************************************************************/
31 /* This is the only thing that needs to be changed to adjust the
32 * maximum number of ports that the driver can manage.
35 #define IXGB_MAX_NIC 8
37 #define OPTION_UNSET -1
38 #define OPTION_DISABLED 0
39 #define OPTION_ENABLED 1
41 /* Module Parameters are always initialized to -1, so that the driver
42 * can tell the difference between no user specified value or the
43 * user asking for the default value.
44 * The true default values are loaded in when ixgb_check_options is called.
46 * This is a GCC extension to ANSI C.
47 * See the item "Labeled Elements in Initializers" in the section
48 * "Extensions to the C Language Family" of the GCC documentation.
51 #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
53 /* All parameters are treated the same, as an integer array of values.
54 * This macro just reduces the need to repeat the same declaration code
55 * over and over (plus this helps to avoid typo bugs).
58 #define IXGB_PARAM(X, S) \
59 static const int __devinitdata X[IXGB_MAX_NIC + 1] = IXGB_PARAM_INIT; \
60 MODULE_PARM(X, "1-" __MODULE_STRING(IXGB_MAX_NIC) "i"); \
61 MODULE_PARM_DESC(X, S);
63 /* Transmit Descriptor Count
65 * Valid Range: 64-4096
70 IXGB_PARAM(TxDescriptors
, "Number of transmit descriptors");
72 /* Receive Descriptor Count
74 * Valid Range: 64-4096
79 IXGB_PARAM(RxDescriptors
, "Number of receive descriptors");
81 /* User Specified Flow Control Override
84 * - 0 - No Flow Control
85 * - 1 - Rx only, respond to PAUSE frames but do not generate them
86 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
87 * - 3 - Full Flow Control Support
89 * Default Value: Read flow control settings from the EEPROM
92 IXGB_PARAM(FlowControl
, "Flow Control setting");
94 /* XsumRX - Receive Checksum Offload Enable/Disable
97 * - 0 - disables all checksum offload
98 * - 1 - enables receive IP/TCP/UDP checksum offload
104 IXGB_PARAM(XsumRX
, "Disable or enable Receive Checksum offload");
106 /* Transmit Interrupt Delay in units of 0.8192 microseconds
108 * Valid Range: 0-65535
113 IXGB_PARAM(TxIntDelay
, "Transmit Interrupt Delay");
115 /* Receive Interrupt Delay in units of 0.8192 microseconds
117 * Valid Range: 0-65535
122 IXGB_PARAM(RxIntDelay
, "Receive Interrupt Delay");
124 /* Receive Interrupt Moderation enable (uses RxIntDelay too)
131 IXGB_PARAM(RAIDC
, "Disable or enable Receive Interrupt Moderation");
133 /* Receive Flow control high threshold (when we send a pause frame)
136 * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
138 * Default Value: 196,608 (0x30000)
141 IXGB_PARAM(RxFCHighThresh
, "Receive Flow Control High Threshold");
143 /* Receive Flow control low threshold (when we send a resume frame)
146 * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
147 * must be less than high threshold by at least 8 bytes
149 * Default Value: 163,840 (0x28000)
152 IXGB_PARAM(RxFCLowThresh
, "Receive Flow Control Low Threshold");
154 /* Flow control request timeout (how long to pause the link partner's tx)
157 * Valid Range: 1 - 65535
159 * Default Value: 256 (0x100)
162 IXGB_PARAM(FCReqTimeout
, "Flow Control Request Timeout");
164 /* Interrupt Delay Enable
168 * - 0 - disables transmit interrupt delay
169 * - 1 - enables transmmit interrupt delay
174 IXGB_PARAM(IntDelayEnable
, "Transmit Interrupt Delay Enable");
176 #define DEFAULT_TXD 256
180 #define DEFAULT_RXD 1024
184 #define DEFAULT_TIDV 32
185 #define MAX_TIDV 0xFFFF
188 #define DEFAULT_RDTR 72
189 #define MAX_RDTR 0xFFFF
192 #define XSUMRX_DEFAULT OPTION_ENABLED
194 #define FLOW_CONTROL_FULL ixgb_fc_full
195 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
196 #define DEFAULT_FCRTL 0x28000
197 #define DEFAULT_FCRTH 0x30000
199 #define MAX_FCRTL 0x3FFE8
201 #define MAX_FCRTH 0x3FFF0
203 #define DEFAULT_FCPAUSE 0x100 /* this may be too long */
204 #define MIN_FCPAUSE 1
205 #define MAX_FCPAUSE 0xffff
208 enum { enable_option
, range_option
, list_option
} type
;
213 struct { /* range_option info */
217 struct { /* list_option info */
219 struct ixgb_opt_list
{
227 static int __devinit
ixgb_validate_option(int *value
, struct ixgb_option
*opt
)
229 if (*value
== OPTION_UNSET
) {
238 printk(KERN_INFO
"%s Enabled\n", opt
->name
);
240 case OPTION_DISABLED
:
241 printk(KERN_INFO
"%s Disabled\n", opt
->name
);
246 if (*value
>= opt
->arg
.r
.min
&& *value
<= opt
->arg
.r
.max
) {
247 printk(KERN_INFO
"%s set to %i\n", opt
->name
, *value
);
253 struct ixgb_opt_list
*ent
;
255 for (i
= 0; i
< opt
->arg
.l
.nr
; i
++) {
256 ent
= &opt
->arg
.l
.p
[i
];
257 if (*value
== ent
->i
) {
258 if (ent
->str
[0] != '\0')
259 printk(KERN_INFO
"%s\n",
270 printk(KERN_INFO
"Invalid %s specified (%i) %s\n",
271 opt
->name
, *value
, opt
->err
);
276 #define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
279 * ixgb_check_options - Range Checking for Command Line Parameters
280 * @adapter: board private structure
282 * This routine checks all command line parameters for valid user
283 * input. If an invalid value is given, or if no user specified
284 * value exists, a default value is used. The final value is stored
285 * in a variable in the adapter structure.
288 void __devinit
ixgb_check_options(struct ixgb_adapter
*adapter
)
290 int bd
= adapter
->bd_number
;
291 if (bd
>= IXGB_MAX_NIC
) {
293 "Warning: no configuration for board #%i\n", bd
);
294 printk(KERN_NOTICE
"Using defaults for all values\n");
298 { /* Transmit Descriptor Count */
299 struct ixgb_option opt
= {
300 .type
= range_option
,
301 .name
= "Transmit Descriptors",
302 .err
= "using default of " __MODULE_STRING(DEFAULT_TXD
),
304 .arg
= {.r
= {.min
= MIN_TXD
,
307 struct ixgb_desc_ring
*tx_ring
= &adapter
->tx_ring
;
309 tx_ring
->count
= TxDescriptors
[bd
];
310 ixgb_validate_option(&tx_ring
->count
, &opt
);
311 IXGB_ROUNDUP(tx_ring
->count
, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE
);
313 { /* Receive Descriptor Count */
314 struct ixgb_option opt
= {
315 .type
= range_option
,
316 .name
= "Receive Descriptors",
317 .err
= "using default of " __MODULE_STRING(DEFAULT_RXD
),
319 .arg
= {.r
= {.min
= MIN_RXD
,
322 struct ixgb_desc_ring
*rx_ring
= &adapter
->rx_ring
;
324 rx_ring
->count
= RxDescriptors
[bd
];
325 ixgb_validate_option(&rx_ring
->count
, &opt
);
326 IXGB_ROUNDUP(rx_ring
->count
, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE
);
328 { /* Receive Checksum Offload Enable */
329 struct ixgb_option opt
= {
330 .type
= enable_option
,
331 .name
= "Receive Checksum Offload",
332 .err
= "defaulting to Enabled",
333 .def
= OPTION_ENABLED
336 int rx_csum
= XsumRX
[bd
];
337 ixgb_validate_option(&rx_csum
, &opt
);
338 adapter
->rx_csum
= rx_csum
;
342 struct ixgb_opt_list fc_list
[] =
343 { {ixgb_fc_none
, "Flow Control Disabled"},
344 {ixgb_fc_rx_pause
, "Flow Control Receive Only"},
345 {ixgb_fc_tx_pause
, "Flow Control Transmit Only"},
346 {ixgb_fc_full
, "Flow Control Enabled"},
347 {ixgb_fc_default
, "Flow Control Hardware Default"}
350 struct ixgb_option opt
= {
352 .name
= "Flow Control",
353 .err
= "reading default settings from EEPROM",
355 .arg
= {.l
= {.nr
= LIST_LEN(fc_list
),
359 int fc
= FlowControl
[bd
];
360 ixgb_validate_option(&fc
, &opt
);
361 adapter
->hw
.fc
.type
= fc
;
363 { /* Receive Flow Control High Threshold */
364 struct ixgb_option opt
= {
365 .type
= range_option
,
366 .name
= "Rx Flow Control High Threshold",
368 "using default of " __MODULE_STRING(DEFAULT_FCRTH
),
369 .def
= DEFAULT_FCRTH
,
370 .arg
= {.r
= {.min
= MIN_FCRTH
,
374 adapter
->hw
.fc
.high_water
= RxFCHighThresh
[bd
];
375 ixgb_validate_option(&adapter
->hw
.fc
.high_water
, &opt
);
376 if (!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
))
378 "Ignoring RxFCHighThresh when no RxFC\n");
380 { /* Receive Flow Control Low Threshold */
381 struct ixgb_option opt
= {
382 .type
= range_option
,
383 .name
= "Rx Flow Control Low Threshold",
385 "using default of " __MODULE_STRING(DEFAULT_FCRTL
),
386 .def
= DEFAULT_FCRTL
,
387 .arg
= {.r
= {.min
= MIN_FCRTL
,
391 adapter
->hw
.fc
.low_water
= RxFCLowThresh
[bd
];
392 ixgb_validate_option(&adapter
->hw
.fc
.low_water
, &opt
);
393 if (!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
))
395 "Ignoring RxFCLowThresh when no RxFC\n");
397 { /* Flow Control Pause Time Request */
398 struct ixgb_option opt
= {
399 .type
= range_option
,
400 .name
= "Flow Control Pause Time Request",
403 __MODULE_STRING(DEFAULT_FCPAUSE
),
404 .def
= DEFAULT_FCPAUSE
,
405 .arg
= {.r
= {.min
= MIN_FCPAUSE
,
409 int pause_time
= FCReqTimeout
[bd
];
411 ixgb_validate_option(&pause_time
, &opt
);
412 if (!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
))
414 "Ignoring FCReqTimeout when no RxFC\n");
415 adapter
->hw
.fc
.pause_time
= pause_time
;
417 /* high low and spacing check for rx flow control thresholds */
418 if (adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
) {
419 /* high must be greater than low */
420 if (adapter
->hw
.fc
.high_water
< (adapter
->hw
.fc
.low_water
+ 8)) {
423 "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
425 adapter
->hw
.fc
.high_water
= DEFAULT_FCRTH
;
426 adapter
->hw
.fc
.low_water
= DEFAULT_FCRTL
;
429 { /* Receive Interrupt Delay */
430 struct ixgb_option opt
= {
431 .type
= range_option
,
432 .name
= "Receive Interrupt Delay",
434 "using default of " __MODULE_STRING(DEFAULT_RDTR
),
436 .arg
= {.r
= {.min
= MIN_RDTR
,
440 adapter
->rx_int_delay
= RxIntDelay
[bd
];
441 ixgb_validate_option(&adapter
->rx_int_delay
, &opt
);
443 { /* Receive Interrupt Moderation */
444 struct ixgb_option opt
= {
445 .type
= enable_option
,
446 .name
= "Advanced Receive Interrupt Moderation",
447 .err
= "defaulting to Enabled",
448 .def
= OPTION_ENABLED
450 int raidc
= RAIDC
[bd
];
452 ixgb_validate_option(&raidc
, &opt
);
453 adapter
->raidc
= raidc
;
455 { /* Transmit Interrupt Delay */
456 struct ixgb_option opt
= {
457 .type
= range_option
,
458 .name
= "Transmit Interrupt Delay",
460 "using default of " __MODULE_STRING(DEFAULT_TIDV
),
462 .arg
= {.r
= {.min
= MIN_TIDV
,
466 adapter
->tx_int_delay
= TxIntDelay
[bd
];
467 ixgb_validate_option(&adapter
->tx_int_delay
, &opt
);
470 { /* Transmit Interrupt Delay Enable */
471 struct ixgb_option opt
= {
472 .type
= enable_option
,
473 .name
= "Tx Interrupt Delay Enable",
474 .err
= "defaulting to Enabled",
475 .def
= OPTION_ENABLED
477 int ide
= IntDelayEnable
[bd
];
479 ixgb_validate_option(&ide
, &opt
);
480 adapter
->tx_int_delay_enable
= ide
;