1 /*******************************************************************************
4 Copyright(c) 1999 - 2005 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 /* All parameters are treated the same, as an integer array of values.
42 * This macro just reduces the need to repeat the same declaration code
43 * over and over (plus this helps to avoid typo bugs).
46 #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
47 #define IXGB_PARAM(X, desc) \
48 static int __devinitdata X[IXGB_MAX_NIC+1] = IXGB_PARAM_INIT; \
49 static int num_##X = 0; \
50 module_param_array_named(X, X, int, &num_##X, 0); \
51 MODULE_PARM_DESC(X, desc);
53 /* Transmit Descriptor Count
55 * Valid Range: 64-4096
60 IXGB_PARAM(TxDescriptors
, "Number of transmit descriptors");
62 /* Receive Descriptor Count
64 * Valid Range: 64-4096
69 IXGB_PARAM(RxDescriptors
, "Number of receive descriptors");
71 /* User Specified Flow Control Override
74 * - 0 - No Flow Control
75 * - 1 - Rx only, respond to PAUSE frames but do not generate them
76 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
77 * - 3 - Full Flow Control Support
79 * Default Value: Read flow control settings from the EEPROM
82 IXGB_PARAM(FlowControl
, "Flow Control setting");
84 /* XsumRX - Receive Checksum Offload Enable/Disable
87 * - 0 - disables all checksum offload
88 * - 1 - enables receive IP/TCP/UDP checksum offload
94 IXGB_PARAM(XsumRX
, "Disable or enable Receive Checksum offload");
96 /* Transmit Interrupt Delay in units of 0.8192 microseconds
98 * Valid Range: 0-65535
103 IXGB_PARAM(TxIntDelay
, "Transmit Interrupt Delay");
105 /* Receive Interrupt Delay in units of 0.8192 microseconds
107 * Valid Range: 0-65535
112 IXGB_PARAM(RxIntDelay
, "Receive Interrupt Delay");
114 /* Receive Flow control high threshold (when we send a pause frame)
117 * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
119 * Default Value: 196,608 (0x30000)
122 IXGB_PARAM(RxFCHighThresh
, "Receive Flow Control High Threshold");
124 /* Receive Flow control low threshold (when we send a resume frame)
127 * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
128 * must be less than high threshold by at least 8 bytes
130 * Default Value: 163,840 (0x28000)
133 IXGB_PARAM(RxFCLowThresh
, "Receive Flow Control Low Threshold");
135 /* Flow control request timeout (how long to pause the link partner's tx)
138 * Valid Range: 1 - 65535
140 * Default Value: 256 (0x100)
143 IXGB_PARAM(FCReqTimeout
, "Flow Control Request Timeout");
145 /* Interrupt Delay Enable
149 * - 0 - disables transmit interrupt delay
150 * - 1 - enables transmmit interrupt delay
155 IXGB_PARAM(IntDelayEnable
, "Transmit Interrupt Delay Enable");
158 #define DEFAULT_TIDV 32
159 #define MAX_TIDV 0xFFFF
162 #define DEFAULT_RDTR 72
163 #define MAX_RDTR 0xFFFF
166 #define XSUMRX_DEFAULT OPTION_ENABLED
168 #define FLOW_CONTROL_FULL ixgb_fc_full
169 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
170 #define DEFAULT_FCRTL 0x28000
171 #define DEFAULT_FCRTH 0x30000
173 #define MAX_FCRTL 0x3FFE8
175 #define MAX_FCRTH 0x3FFF0
177 #define DEFAULT_FCPAUSE 0x100 /* this may be too long */
178 #define MIN_FCPAUSE 1
179 #define MAX_FCPAUSE 0xffff
182 enum { enable_option
, range_option
, list_option
} type
;
187 struct { /* range_option info */
191 struct { /* list_option info */
193 struct ixgb_opt_list
{
202 ixgb_validate_option(int *value
, struct ixgb_option
*opt
)
204 if(*value
== OPTION_UNSET
) {
213 printk(KERN_INFO
"%s Enabled\n", opt
->name
);
215 case OPTION_DISABLED
:
216 printk(KERN_INFO
"%s Disabled\n", opt
->name
);
221 if(*value
>= opt
->arg
.r
.min
&& *value
<= opt
->arg
.r
.max
) {
222 printk(KERN_INFO
"%s set to %i\n", opt
->name
, *value
);
228 struct ixgb_opt_list
*ent
;
230 for(i
= 0; i
< opt
->arg
.l
.nr
; i
++) {
231 ent
= &opt
->arg
.l
.p
[i
];
232 if(*value
== ent
->i
) {
233 if(ent
->str
[0] != '\0')
234 printk(KERN_INFO
"%s\n", ent
->str
);
244 printk(KERN_INFO
"Invalid %s specified (%i) %s\n",
245 opt
->name
, *value
, opt
->err
);
250 #define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
253 * ixgb_check_options - Range Checking for Command Line Parameters
254 * @adapter: board private structure
256 * This routine checks all command line parameters for valid user
257 * input. If an invalid value is given, or if no user specified
258 * value exists, a default value is used. The final value is stored
259 * in a variable in the adapter structure.
263 ixgb_check_options(struct ixgb_adapter
*adapter
)
265 int bd
= adapter
->bd_number
;
266 if(bd
>= IXGB_MAX_NIC
) {
268 "Warning: no configuration for board #%i\n", bd
);
269 printk(KERN_NOTICE
"Using defaults for all values\n");
272 { /* Transmit Descriptor Count */
273 struct ixgb_option opt
= {
274 .type
= range_option
,
275 .name
= "Transmit Descriptors",
276 .err
= "using default of " __MODULE_STRING(DEFAULT_TXD
),
278 .arg
= { .r
= { .min
= MIN_TXD
,
281 struct ixgb_desc_ring
*tx_ring
= &adapter
->tx_ring
;
283 if(num_TxDescriptors
> bd
) {
284 tx_ring
->count
= TxDescriptors
[bd
];
285 ixgb_validate_option(&tx_ring
->count
, &opt
);
287 tx_ring
->count
= opt
.def
;
289 IXGB_ROUNDUP(tx_ring
->count
, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE
);
291 { /* Receive Descriptor Count */
292 struct ixgb_option opt
= {
293 .type
= range_option
,
294 .name
= "Receive Descriptors",
295 .err
= "using default of " __MODULE_STRING(DEFAULT_RXD
),
297 .arg
= { .r
= { .min
= MIN_RXD
,
300 struct ixgb_desc_ring
*rx_ring
= &adapter
->rx_ring
;
302 if(num_RxDescriptors
> bd
) {
303 rx_ring
->count
= RxDescriptors
[bd
];
304 ixgb_validate_option(&rx_ring
->count
, &opt
);
306 rx_ring
->count
= opt
.def
;
308 IXGB_ROUNDUP(rx_ring
->count
, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE
);
310 { /* Receive Checksum Offload Enable */
311 struct ixgb_option opt
= {
312 .type
= enable_option
,
313 .name
= "Receive Checksum Offload",
314 .err
= "defaulting to Enabled",
315 .def
= OPTION_ENABLED
318 if(num_XsumRX
> bd
) {
319 int rx_csum
= XsumRX
[bd
];
320 ixgb_validate_option(&rx_csum
, &opt
);
321 adapter
->rx_csum
= rx_csum
;
323 adapter
->rx_csum
= opt
.def
;
328 struct ixgb_opt_list fc_list
[] =
329 {{ ixgb_fc_none
, "Flow Control Disabled" },
330 { ixgb_fc_rx_pause
,"Flow Control Receive Only" },
331 { ixgb_fc_tx_pause
,"Flow Control Transmit Only" },
332 { ixgb_fc_full
, "Flow Control Enabled" },
333 { ixgb_fc_default
, "Flow Control Hardware Default" }};
335 struct ixgb_option opt
= {
337 .name
= "Flow Control",
338 .err
= "reading default settings from EEPROM",
340 .arg
= { .l
= { .nr
= LIST_LEN(fc_list
),
344 if(num_FlowControl
> bd
) {
345 int fc
= FlowControl
[bd
];
346 ixgb_validate_option(&fc
, &opt
);
347 adapter
->hw
.fc
.type
= fc
;
349 adapter
->hw
.fc
.type
= opt
.def
;
352 { /* Receive Flow Control High Threshold */
353 struct ixgb_option opt
= {
354 .type
= range_option
,
355 .name
= "Rx Flow Control High Threshold",
356 .err
= "using default of " __MODULE_STRING(DEFAULT_FCRTH
),
357 .def
= DEFAULT_FCRTH
,
358 .arg
= { .r
= { .min
= MIN_FCRTH
,
362 if(num_RxFCHighThresh
> bd
) {
363 adapter
->hw
.fc
.high_water
= RxFCHighThresh
[bd
];
364 ixgb_validate_option(&adapter
->hw
.fc
.high_water
, &opt
);
366 adapter
->hw
.fc
.high_water
= opt
.def
;
368 if(!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
) )
370 "Ignoring RxFCHighThresh when no RxFC\n");
372 { /* Receive Flow Control Low Threshold */
373 struct ixgb_option opt
= {
374 .type
= range_option
,
375 .name
= "Rx Flow Control Low Threshold",
376 .err
= "using default of " __MODULE_STRING(DEFAULT_FCRTL
),
377 .def
= DEFAULT_FCRTL
,
378 .arg
= { .r
= { .min
= MIN_FCRTL
,
382 if(num_RxFCLowThresh
> bd
) {
383 adapter
->hw
.fc
.low_water
= RxFCLowThresh
[bd
];
384 ixgb_validate_option(&adapter
->hw
.fc
.low_water
, &opt
);
386 adapter
->hw
.fc
.low_water
= opt
.def
;
388 if(!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
) )
390 "Ignoring RxFCLowThresh when no RxFC\n");
392 { /* Flow Control Pause Time Request*/
393 struct ixgb_option opt
= {
394 .type
= range_option
,
395 .name
= "Flow Control Pause Time Request",
396 .err
= "using default of "__MODULE_STRING(DEFAULT_FCPAUSE
),
397 .def
= DEFAULT_FCPAUSE
,
398 .arg
= { .r
= { .min
= MIN_FCPAUSE
,
402 if(num_FCReqTimeout
> bd
) {
403 int pause_time
= FCReqTimeout
[bd
];
404 ixgb_validate_option(&pause_time
, &opt
);
405 adapter
->hw
.fc
.pause_time
= pause_time
;
407 adapter
->hw
.fc
.pause_time
= opt
.def
;
409 if(!(adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
) )
411 "Ignoring FCReqTimeout when no RxFC\n");
413 /* high low and spacing check for rx flow control thresholds */
414 if (adapter
->hw
.fc
.type
& ixgb_fc_rx_pause
) {
415 /* high must be greater than low */
416 if (adapter
->hw
.fc
.high_water
< (adapter
->hw
.fc
.low_water
+ 8)) {
419 "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
421 adapter
->hw
.fc
.high_water
= DEFAULT_FCRTH
;
422 adapter
->hw
.fc
.low_water
= DEFAULT_FCRTL
;
425 { /* Receive Interrupt Delay */
426 struct ixgb_option opt
= {
427 .type
= range_option
,
428 .name
= "Receive Interrupt Delay",
429 .err
= "using default of " __MODULE_STRING(DEFAULT_RDTR
),
431 .arg
= { .r
= { .min
= MIN_RDTR
,
435 if(num_RxIntDelay
> bd
) {
436 adapter
->rx_int_delay
= RxIntDelay
[bd
];
437 ixgb_validate_option(&adapter
->rx_int_delay
, &opt
);
439 adapter
->rx_int_delay
= opt
.def
;
442 { /* Transmit Interrupt Delay */
443 struct ixgb_option opt
= {
444 .type
= range_option
,
445 .name
= "Transmit Interrupt Delay",
446 .err
= "using default of " __MODULE_STRING(DEFAULT_TIDV
),
448 .arg
= { .r
= { .min
= MIN_TIDV
,
452 if(num_TxIntDelay
> bd
) {
453 adapter
->tx_int_delay
= TxIntDelay
[bd
];
454 ixgb_validate_option(&adapter
->tx_int_delay
, &opt
);
456 adapter
->tx_int_delay
= opt
.def
;
460 { /* Transmit Interrupt Delay Enable */
461 struct ixgb_option opt
= {
462 .type
= enable_option
,
463 .name
= "Tx Interrupt Delay Enable",
464 .err
= "defaulting to Enabled",
465 .def
= OPTION_ENABLED
468 if(num_IntDelayEnable
> bd
) {
469 int ide
= IntDelayEnable
[bd
];
470 ixgb_validate_option(&ide
, &opt
);
471 adapter
->tx_int_delay_enable
= ide
;
473 adapter
->tx_int_delay_enable
= opt
.def
;