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