1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include "ixgb.h"
30
31
32
33
34
35#define IXGB_MAX_NIC 8
36
37#define OPTION_UNSET -1
38#define OPTION_DISABLED 0
39#define OPTION_ENABLED 1
40
41
42
43
44
45
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] \
49 = IXGB_PARAM_INIT; \
50 static unsigned int num_##X = 0; \
51 module_param_array_named(X, X, int, &num_##X, 0); \
52 MODULE_PARM_DESC(X, desc);
53
54
55
56
57
58
59
60
61IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
62
63
64
65
66
67
68
69
70IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
71
72
73
74
75
76
77
78
79
80
81
82
83IXGB_PARAM(FlowControl, "Flow Control setting");
84
85
86
87
88
89
90
91
92
93
94
95IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
96
97
98
99
100
101
102
103
104IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
105
106
107
108
109
110
111
112
113IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
114
115
116
117
118
119
120
121
122
123IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
124
125
126
127
128
129
130
131
132
133
134IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
135
136
137
138
139
140
141
142
143
144IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
145
146
147
148
149
150
151
152
153
154
155
156IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
157
158
159#define DEFAULT_TIDV 32
160#define MAX_TIDV 0xFFFF
161#define MIN_TIDV 0
162
163#define DEFAULT_RDTR 72
164#define MAX_RDTR 0xFFFF
165#define MIN_RDTR 0
166
167#define XSUMRX_DEFAULT OPTION_ENABLED
168
169#define DEFAULT_FCRTL 0x28000
170#define DEFAULT_FCRTH 0x30000
171#define MIN_FCRTL 0
172#define MAX_FCRTL 0x3FFE8
173#define MIN_FCRTH 8
174#define MAX_FCRTH 0x3FFF0
175
176#define MIN_FCPAUSE 1
177#define MAX_FCPAUSE 0xffff
178#define DEFAULT_FCPAUSE 0xFFFF
179
180struct ixgb_option {
181 enum { enable_option, range_option, list_option } type;
182 const char *name;
183 const char *err;
184 int def;
185 union {
186 struct {
187 int min;
188 int max;
189 } r;
190 struct {
191 int nr;
192 struct ixgb_opt_list {
193 int i;
194 char *str;
195 } *p;
196 } l;
197 } arg;
198};
199
200static int __devinit
201ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt)
202{
203 if(*value == OPTION_UNSET) {
204 *value = opt->def;
205 return 0;
206 }
207
208 switch (opt->type) {
209 case enable_option:
210 switch (*value) {
211 case OPTION_ENABLED:
212 printk(KERN_INFO "%s Enabled\n", opt->name);
213 return 0;
214 case OPTION_DISABLED:
215 printk(KERN_INFO "%s Disabled\n", opt->name);
216 return 0;
217 }
218 break;
219 case range_option:
220 if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
221 printk(KERN_INFO "%s set to %i\n", opt->name, *value);
222 return 0;
223 }
224 break;
225 case list_option: {
226 int i;
227 struct ixgb_opt_list *ent;
228
229 for(i = 0; i < opt->arg.l.nr; i++) {
230 ent = &opt->arg.l.p[i];
231 if(*value == ent->i) {
232 if(ent->str[0] != '\0')
233 printk(KERN_INFO "%s\n", ent->str);
234 return 0;
235 }
236 }
237 }
238 break;
239 default:
240 BUG();
241 }
242
243 printk(KERN_INFO "Invalid %s specified (%i) %s\n",
244 opt->name, *value, opt->err);
245 *value = opt->def;
246 return -1;
247}
248
249
250
251
252
253
254
255
256
257
258
259void __devinit
260ixgb_check_options(struct ixgb_adapter *adapter)
261{
262 int bd = adapter->bd_number;
263 if(bd >= IXGB_MAX_NIC) {
264 printk(KERN_NOTICE
265 "Warning: no configuration for board #%i\n", bd);
266 printk(KERN_NOTICE "Using defaults for all values\n");
267 }
268
269 {
270 const struct ixgb_option opt = {
271 .type = range_option,
272 .name = "Transmit Descriptors",
273 .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
274 .def = DEFAULT_TXD,
275 .arg = { .r = { .min = MIN_TXD,
276 .max = MAX_TXD}}
277 };
278 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
279
280 if(num_TxDescriptors > bd) {
281 tx_ring->count = TxDescriptors[bd];
282 ixgb_validate_option(&tx_ring->count, &opt);
283 } else {
284 tx_ring->count = opt.def;
285 }
286 tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
287 }
288 {
289 const struct ixgb_option opt = {
290 .type = range_option,
291 .name = "Receive Descriptors",
292 .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
293 .def = DEFAULT_RXD,
294 .arg = { .r = { .min = MIN_RXD,
295 .max = MAX_RXD}}
296 };
297 struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
298
299 if(num_RxDescriptors > bd) {
300 rx_ring->count = RxDescriptors[bd];
301 ixgb_validate_option(&rx_ring->count, &opt);
302 } else {
303 rx_ring->count = opt.def;
304 }
305 rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
306 }
307 {
308 const struct ixgb_option opt = {
309 .type = enable_option,
310 .name = "Receive Checksum Offload",
311 .err = "defaulting to Enabled",
312 .def = OPTION_ENABLED
313 };
314
315 if(num_XsumRX > bd) {
316 unsigned int rx_csum = XsumRX[bd];
317 ixgb_validate_option(&rx_csum, &opt);
318 adapter->rx_csum = rx_csum;
319 } else {
320 adapter->rx_csum = opt.def;
321 }
322 }
323 {
324
325 struct ixgb_opt_list fc_list[] =
326 {{ ixgb_fc_none, "Flow Control Disabled" },
327 { ixgb_fc_rx_pause,"Flow Control Receive Only" },
328 { ixgb_fc_tx_pause,"Flow Control Transmit Only" },
329 { ixgb_fc_full, "Flow Control Enabled" },
330 { ixgb_fc_default, "Flow Control Hardware Default" }};
331
332 const struct ixgb_option opt = {
333 .type = list_option,
334 .name = "Flow Control",
335 .err = "reading default settings from EEPROM",
336 .def = ixgb_fc_tx_pause,
337 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
338 .p = fc_list }}
339 };
340
341 if(num_FlowControl > bd) {
342 unsigned int fc = FlowControl[bd];
343 ixgb_validate_option(&fc, &opt);
344 adapter->hw.fc.type = fc;
345 } else {
346 adapter->hw.fc.type = opt.def;
347 }
348 }
349 {
350 const struct ixgb_option opt = {
351 .type = range_option,
352 .name = "Rx Flow Control High Threshold",
353 .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH),
354 .def = DEFAULT_FCRTH,
355 .arg = { .r = { .min = MIN_FCRTH,
356 .max = MAX_FCRTH}}
357 };
358
359 if(num_RxFCHighThresh > bd) {
360 adapter->hw.fc.high_water = RxFCHighThresh[bd];
361 ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
362 } else {
363 adapter->hw.fc.high_water = opt.def;
364 }
365 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
366 printk (KERN_INFO
367 "Ignoring RxFCHighThresh when no RxFC\n");
368 }
369 {
370 const struct ixgb_option opt = {
371 .type = range_option,
372 .name = "Rx Flow Control Low Threshold",
373 .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL),
374 .def = DEFAULT_FCRTL,
375 .arg = { .r = { .min = MIN_FCRTL,
376 .max = MAX_FCRTL}}
377 };
378
379 if(num_RxFCLowThresh > bd) {
380 adapter->hw.fc.low_water = RxFCLowThresh[bd];
381 ixgb_validate_option(&adapter->hw.fc.low_water, &opt);
382 } else {
383 adapter->hw.fc.low_water = opt.def;
384 }
385 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
386 printk (KERN_INFO
387 "Ignoring RxFCLowThresh when no RxFC\n");
388 }
389 {
390 const struct ixgb_option opt = {
391 .type = range_option,
392 .name = "Flow Control Pause Time Request",
393 .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE),
394 .def = DEFAULT_FCPAUSE,
395 .arg = { .r = { .min = MIN_FCPAUSE,
396 .max = MAX_FCPAUSE}}
397 };
398
399 if(num_FCReqTimeout > bd) {
400 unsigned int pause_time = FCReqTimeout[bd];
401 ixgb_validate_option(&pause_time, &opt);
402 adapter->hw.fc.pause_time = pause_time;
403 } else {
404 adapter->hw.fc.pause_time = opt.def;
405 }
406 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
407 printk (KERN_INFO
408 "Ignoring FCReqTimeout when no RxFC\n");
409 }
410
411 if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
412
413 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
414
415 printk (KERN_INFO
416 "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
417 "Using Defaults\n");
418 adapter->hw.fc.high_water = DEFAULT_FCRTH;
419 adapter->hw.fc.low_water = DEFAULT_FCRTL;
420 }
421 }
422 {
423 const struct ixgb_option opt = {
424 .type = range_option,
425 .name = "Receive Interrupt Delay",
426 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
427 .def = DEFAULT_RDTR,
428 .arg = { .r = { .min = MIN_RDTR,
429 .max = MAX_RDTR}}
430 };
431
432 if(num_RxIntDelay > bd) {
433 adapter->rx_int_delay = RxIntDelay[bd];
434 ixgb_validate_option(&adapter->rx_int_delay, &opt);
435 } else {
436 adapter->rx_int_delay = opt.def;
437 }
438 }
439 {
440 const struct ixgb_option opt = {
441 .type = range_option,
442 .name = "Transmit Interrupt Delay",
443 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
444 .def = DEFAULT_TIDV,
445 .arg = { .r = { .min = MIN_TIDV,
446 .max = MAX_TIDV}}
447 };
448
449 if(num_TxIntDelay > bd) {
450 adapter->tx_int_delay = TxIntDelay[bd];
451 ixgb_validate_option(&adapter->tx_int_delay, &opt);
452 } else {
453 adapter->tx_int_delay = opt.def;
454 }
455 }
456
457 {
458 const struct ixgb_option opt = {
459 .type = enable_option,
460 .name = "Tx Interrupt Delay Enable",
461 .err = "defaulting to Enabled",
462 .def = OPTION_ENABLED
463 };
464
465 if(num_IntDelayEnable > bd) {
466 unsigned int ide = IntDelayEnable[bd];
467 ixgb_validate_option(&ide, &opt);
468 adapter->tx_int_delay_enable = ide;
469 } else {
470 adapter->tx_int_delay_enable = opt.def;
471 }
472 }
473}
474