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#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
31#include "ixgb.h"
32
33
34
35
36
37#define IXGB_MAX_NIC 8
38
39#define OPTION_UNSET -1
40#define OPTION_DISABLED 0
41#define OPTION_ENABLED 1
42
43
44
45
46
47
48#define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
49#define IXGB_PARAM(X, desc) \
50 static int __devinitdata X[IXGB_MAX_NIC+1] \
51 = IXGB_PARAM_INIT; \
52 static unsigned int num_##X = 0; \
53 module_param_array_named(X, X, int, &num_##X, 0); \
54 MODULE_PARM_DESC(X, desc);
55
56
57
58
59
60
61
62
63IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
64
65
66
67
68
69
70
71
72IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
73
74
75
76
77
78
79
80
81
82
83
84
85IXGB_PARAM(FlowControl, "Flow Control setting");
86
87
88
89
90
91
92
93
94
95
96
97IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
98
99
100
101
102
103
104
105
106IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
107
108
109
110
111
112
113
114
115IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
116
117
118
119
120
121
122
123
124
125IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
126
127
128
129
130
131
132
133
134
135
136IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
137
138
139
140
141
142
143
144
145
146IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
147
148
149
150
151
152
153
154
155
156
157
158IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
159
160
161#define DEFAULT_TIDV 32
162#define MAX_TIDV 0xFFFF
163#define MIN_TIDV 0
164
165#define DEFAULT_RDTR 72
166#define MAX_RDTR 0xFFFF
167#define MIN_RDTR 0
168
169#define XSUMRX_DEFAULT OPTION_ENABLED
170
171#define DEFAULT_FCRTL 0x28000
172#define DEFAULT_FCRTH 0x30000
173#define MIN_FCRTL 0
174#define MAX_FCRTL 0x3FFE8
175#define MIN_FCRTH 8
176#define MAX_FCRTH 0x3FFF0
177
178#define MIN_FCPAUSE 1
179#define MAX_FCPAUSE 0xffff
180#define DEFAULT_FCPAUSE 0xFFFF
181
182struct ixgb_option {
183 enum { enable_option, range_option, list_option } type;
184 const char *name;
185 const char *err;
186 int def;
187 union {
188 struct {
189 int min;
190 int max;
191 } r;
192 struct {
193 int nr;
194 const struct ixgb_opt_list {
195 int i;
196 const char *str;
197 } *p;
198 } l;
199 } arg;
200};
201
202static int __devinit
203ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt)
204{
205 if (*value == OPTION_UNSET) {
206 *value = opt->def;
207 return 0;
208 }
209
210 switch (opt->type) {
211 case enable_option:
212 switch (*value) {
213 case OPTION_ENABLED:
214 pr_info("%s Enabled\n", opt->name);
215 return 0;
216 case OPTION_DISABLED:
217 pr_info("%s Disabled\n", opt->name);
218 return 0;
219 }
220 break;
221 case range_option:
222 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
223 pr_info("%s set to %i\n", opt->name, *value);
224 return 0;
225 }
226 break;
227 case list_option: {
228 int i;
229 const struct ixgb_opt_list *ent;
230
231 for (i = 0; i < opt->arg.l.nr; i++) {
232 ent = &opt->arg.l.p[i];
233 if (*value == ent->i) {
234 if (ent->str[0] != '\0')
235 pr_info("%s\n", ent->str);
236 return 0;
237 }
238 }
239 }
240 break;
241 default:
242 BUG();
243 }
244
245 pr_info("Invalid %s specified (%i) %s\n", opt->name, *value, opt->err);
246 *value = opt->def;
247 return -1;
248}
249
250
251
252
253
254
255
256
257
258
259
260void __devinit
261ixgb_check_options(struct ixgb_adapter *adapter)
262{
263 int bd = adapter->bd_number;
264 if (bd >= IXGB_MAX_NIC) {
265 pr_notice("Warning: no configuration for board #%i\n", bd);
266 pr_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 static const 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
333 static const struct ixgb_option opt = {
334 .type = list_option,
335 .name = "Flow Control",
336 .err = "reading default settings from EEPROM",
337 .def = ixgb_fc_tx_pause,
338 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
339 .p = fc_list }}
340 };
341
342 if (num_FlowControl > bd) {
343 unsigned int fc = FlowControl[bd];
344 ixgb_validate_option(&fc, &opt);
345 adapter->hw.fc.type = fc;
346 } else {
347 adapter->hw.fc.type = opt.def;
348 }
349 }
350 {
351 const struct ixgb_option opt = {
352 .type = range_option,
353 .name = "Rx Flow Control High Threshold",
354 .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH),
355 .def = DEFAULT_FCRTH,
356 .arg = { .r = { .min = MIN_FCRTH,
357 .max = MAX_FCRTH}}
358 };
359
360 if (num_RxFCHighThresh > bd) {
361 adapter->hw.fc.high_water = RxFCHighThresh[bd];
362 ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
363 } else {
364 adapter->hw.fc.high_water = opt.def;
365 }
366 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
367 pr_info("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 pr_info("Ignoring RxFCLowThresh when no RxFC\n");
387 }
388 {
389 const struct ixgb_option opt = {
390 .type = range_option,
391 .name = "Flow Control Pause Time Request",
392 .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE),
393 .def = DEFAULT_FCPAUSE,
394 .arg = { .r = { .min = MIN_FCPAUSE,
395 .max = MAX_FCPAUSE}}
396 };
397
398 if (num_FCReqTimeout > bd) {
399 unsigned int pause_time = FCReqTimeout[bd];
400 ixgb_validate_option(&pause_time, &opt);
401 adapter->hw.fc.pause_time = pause_time;
402 } else {
403 adapter->hw.fc.pause_time = opt.def;
404 }
405 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
406 pr_info("Ignoring FCReqTimeout when no RxFC\n");
407 }
408
409 if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
410
411 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
412
413 pr_info("RxFCHighThresh must be >= (RxFCLowThresh + 8), Using Defaults\n");
414 adapter->hw.fc.high_water = DEFAULT_FCRTH;
415 adapter->hw.fc.low_water = DEFAULT_FCRTL;
416 }
417 }
418 {
419 const struct ixgb_option opt = {
420 .type = range_option,
421 .name = "Receive Interrupt Delay",
422 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
423 .def = DEFAULT_RDTR,
424 .arg = { .r = { .min = MIN_RDTR,
425 .max = MAX_RDTR}}
426 };
427
428 if (num_RxIntDelay > bd) {
429 adapter->rx_int_delay = RxIntDelay[bd];
430 ixgb_validate_option(&adapter->rx_int_delay, &opt);
431 } else {
432 adapter->rx_int_delay = opt.def;
433 }
434 }
435 {
436 const struct ixgb_option opt = {
437 .type = range_option,
438 .name = "Transmit Interrupt Delay",
439 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
440 .def = DEFAULT_TIDV,
441 .arg = { .r = { .min = MIN_TIDV,
442 .max = MAX_TIDV}}
443 };
444
445 if (num_TxIntDelay > bd) {
446 adapter->tx_int_delay = TxIntDelay[bd];
447 ixgb_validate_option(&adapter->tx_int_delay, &opt);
448 } else {
449 adapter->tx_int_delay = opt.def;
450 }
451 }
452
453 {
454 const struct ixgb_option opt = {
455 .type = enable_option,
456 .name = "Tx Interrupt Delay Enable",
457 .err = "defaulting to Enabled",
458 .def = OPTION_ENABLED
459 };
460
461 if (num_IntDelayEnable > bd) {
462 unsigned int ide = IntDelayEnable[bd];
463 ixgb_validate_option(&ide, &opt);
464 adapter->tx_int_delay_enable = ide;
465 } else {
466 adapter->tx_int_delay_enable = opt.def;
467 }
468 }
469}
470