]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/kernel/linux/kni/ethtool/igb/igb_param.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / kernel / linux / kni / ethtool / igb / igb_param.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*******************************************************************************
3
4 Intel(R) Gigabit Ethernet Linux driver
5 Copyright(c) 2007-2013 Intel Corporation.
6
7 Contact Information:
8 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
9 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
10
11 *******************************************************************************/
12
13
14 #include <linux/netdevice.h>
15
16 #include "igb.h"
17
18 /* This is the only thing that needs to be changed to adjust the
19 * maximum number of ports that the driver can manage.
20 */
21
22 #define IGB_MAX_NIC 32
23
24 #define OPTION_UNSET -1
25 #define OPTION_DISABLED 0
26 #define OPTION_ENABLED 1
27 #define MAX_NUM_LIST_OPTS 15
28
29 /* All parameters are treated the same, as an integer array of values.
30 * This macro just reduces the need to repeat the same declaration code
31 * over and over (plus this helps to avoid typo bugs).
32 */
33
34 #define IGB_PARAM_INIT { [0 ... IGB_MAX_NIC] = OPTION_UNSET }
35 #ifndef module_param_array
36 /* Module Parameters are always initialized to -1, so that the driver
37 * can tell the difference between no user specified value or the
38 * user asking for the default value.
39 * The true default values are loaded in when igb_check_options is called.
40 *
41 * This is a GCC extension to ANSI C.
42 * See the item "Labeled Elements in Initializers" in the section
43 * "Extensions to the C Language Family" of the GCC documentation.
44 */
45
46 #define IGB_PARAM(X, desc) \
47 static const int X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
48 MODULE_PARM(X, "1-" __MODULE_STRING(IGB_MAX_NIC) "i"); \
49 MODULE_PARM_DESC(X, desc);
50 #else
51 #define IGB_PARAM(X, desc) \
52 static int X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
53 static unsigned int num_##X; \
54 module_param_array_named(X, X, int, &num_##X, 0); \
55 MODULE_PARM_DESC(X, desc);
56 #endif
57
58 /* Interrupt Throttle Rate (interrupts/sec)
59 *
60 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
61 */
62 IGB_PARAM(InterruptThrottleRate,
63 "Maximum interrupts per second, per vector, (max 100000), default 3=adaptive");
64 #define DEFAULT_ITR 3
65 #define MAX_ITR 100000
66 /* #define MIN_ITR 120 */
67 #define MIN_ITR 0
68 /* IntMode (Interrupt Mode)
69 *
70 * Valid Range: 0 - 2
71 *
72 * Default Value: 2 (MSI-X)
73 */
74 IGB_PARAM(IntMode, "Change Interrupt Mode (0=Legacy, 1=MSI, 2=MSI-X), default 2");
75 #define MAX_INTMODE IGB_INT_MODE_MSIX
76 #define MIN_INTMODE IGB_INT_MODE_LEGACY
77
78 IGB_PARAM(Node, "set the starting node to allocate memory on, default -1");
79
80 /* LLIPort (Low Latency Interrupt TCP Port)
81 *
82 * Valid Range: 0 - 65535
83 *
84 * Default Value: 0 (disabled)
85 */
86 IGB_PARAM(LLIPort, "Low Latency Interrupt TCP Port (0-65535), default 0=off");
87
88 #define DEFAULT_LLIPORT 0
89 #define MAX_LLIPORT 0xFFFF
90 #define MIN_LLIPORT 0
91
92 /* LLIPush (Low Latency Interrupt on TCP Push flag)
93 *
94 * Valid Range: 0, 1
95 *
96 * Default Value: 0 (disabled)
97 */
98 IGB_PARAM(LLIPush, "Low Latency Interrupt on TCP Push flag (0,1), default 0=off");
99
100 #define DEFAULT_LLIPUSH 0
101 #define MAX_LLIPUSH 1
102 #define MIN_LLIPUSH 0
103
104 /* LLISize (Low Latency Interrupt on Packet Size)
105 *
106 * Valid Range: 0 - 1500
107 *
108 * Default Value: 0 (disabled)
109 */
110 IGB_PARAM(LLISize, "Low Latency Interrupt on Packet Size (0-1500), default 0=off");
111
112 #define DEFAULT_LLISIZE 0
113 #define MAX_LLISIZE 1500
114 #define MIN_LLISIZE 0
115
116 /* RSS (Enable RSS multiqueue receive)
117 *
118 * Valid Range: 0 - 8
119 *
120 * Default Value: 1
121 */
122 IGB_PARAM(RSS, "Number of Receive-Side Scaling Descriptor Queues (0-8), default 1, 0=number of cpus");
123
124 #define DEFAULT_RSS 1
125 #define MAX_RSS 8
126 #define MIN_RSS 0
127
128 /* VMDQ (Enable VMDq multiqueue receive)
129 *
130 * Valid Range: 0 - 8
131 *
132 * Default Value: 0
133 */
134 IGB_PARAM(VMDQ, "Number of Virtual Machine Device Queues: 0-1 = disable, 2-8 enable, default 0");
135
136 #define DEFAULT_VMDQ 0
137 #define MAX_VMDQ MAX_RSS
138 #define MIN_VMDQ 0
139
140 /* max_vfs (Enable SR-IOV VF devices)
141 *
142 * Valid Range: 0 - 7
143 *
144 * Default Value: 0
145 */
146 IGB_PARAM(max_vfs, "Number of Virtual Functions: 0 = disable, 1-7 enable, default 0");
147
148 #define DEFAULT_SRIOV 0
149 #define MAX_SRIOV 7
150 #define MIN_SRIOV 0
151
152 /* MDD (Enable Malicious Driver Detection)
153 *
154 * Only available when SR-IOV is enabled - max_vfs is greater than 0
155 *
156 * Valid Range: 0, 1
157 *
158 * Default Value: 1
159 */
160 IGB_PARAM(MDD, "Malicious Driver Detection (0/1), default 1 = enabled. "
161 "Only available when max_vfs is greater than 0");
162
163 #ifdef DEBUG
164
165 /* Disable Hardware Reset on Tx Hang
166 *
167 * Valid Range: 0, 1
168 *
169 * Default Value: 0 (disabled, i.e. h/w will reset)
170 */
171 IGB_PARAM(DisableHwReset, "Disable reset of hardware on Tx hang");
172
173 /* Dump Transmit and Receive buffers
174 *
175 * Valid Range: 0, 1
176 *
177 * Default Value: 0
178 */
179 IGB_PARAM(DumpBuffers, "Dump Tx/Rx buffers on Tx hang or by request");
180
181 #endif /* DEBUG */
182
183 /* QueuePairs (Enable TX/RX queue pairs for interrupt handling)
184 *
185 * Valid Range: 0 - 1
186 *
187 * Default Value: 1
188 */
189 IGB_PARAM(QueuePairs, "Enable Tx/Rx queue pairs for interrupt handling (0,1), default 1=on");
190
191 #define DEFAULT_QUEUE_PAIRS 1
192 #define MAX_QUEUE_PAIRS 1
193 #define MIN_QUEUE_PAIRS 0
194
195 /* Enable/disable EEE (a.k.a. IEEE802.3az)
196 *
197 * Valid Range: 0, 1
198 *
199 * Default Value: 1
200 */
201 IGB_PARAM(EEE, "Enable/disable on parts that support the feature");
202
203 /* Enable/disable DMA Coalescing
204 *
205 * Valid Values: 0(off), 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000,
206 * 9000, 10000(msec), 250(usec), 500(usec)
207 *
208 * Default Value: 0
209 */
210 IGB_PARAM(DMAC, "Disable or set latency for DMA Coalescing ((0=off, 1000-10000(msec), 250, 500 (usec))");
211
212 #ifndef IGB_NO_LRO
213 /* Enable/disable Large Receive Offload
214 *
215 * Valid Values: 0(off), 1(on)
216 *
217 * Default Value: 0
218 */
219 IGB_PARAM(LRO, "Large Receive Offload (0,1), default 0=off");
220
221 #endif
222 struct igb_opt_list {
223 int i;
224 char *str;
225 };
226 struct igb_option {
227 enum { enable_option, range_option, list_option } type;
228 const char *name;
229 const char *err;
230 int def;
231 union {
232 struct { /* range_option info */
233 int min;
234 int max;
235 } r;
236 struct { /* list_option info */
237 int nr;
238 struct igb_opt_list *p;
239 } l;
240 } arg;
241 };
242
243 static int igb_validate_option(unsigned int *value,
244 struct igb_option *opt,
245 struct igb_adapter *adapter)
246 {
247 if (*value == OPTION_UNSET) {
248 *value = opt->def;
249 return 0;
250 }
251
252 switch (opt->type) {
253 case enable_option:
254 switch (*value) {
255 case OPTION_ENABLED:
256 DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
257 return 0;
258 case OPTION_DISABLED:
259 DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
260 return 0;
261 }
262 break;
263 case range_option:
264 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
265 DPRINTK(PROBE, INFO,
266 "%s set to %d\n", opt->name, *value);
267 return 0;
268 }
269 break;
270 case list_option: {
271 int i;
272 struct igb_opt_list *ent;
273
274 for (i = 0; i < opt->arg.l.nr; i++) {
275 ent = &opt->arg.l.p[i];
276 if (*value == ent->i) {
277 if (ent->str[0] != '\0')
278 DPRINTK(PROBE, INFO, "%s\n", ent->str);
279 return 0;
280 }
281 }
282 }
283 break;
284 default:
285 BUG();
286 }
287
288 DPRINTK(PROBE, INFO, "Invalid %s value specified (%d) %s\n",
289 opt->name, *value, opt->err);
290 *value = opt->def;
291 return -1;
292 }
293
294 /**
295 * igb_check_options - Range Checking for Command Line Parameters
296 * @adapter: board private structure
297 *
298 * This routine checks all command line parameters for valid user
299 * input. If an invalid value is given, or if no user specified
300 * value exists, a default value is used. The final value is stored
301 * in a variable in the adapter structure.
302 **/
303
304 void igb_check_options(struct igb_adapter *adapter)
305 {
306 int bd = adapter->bd_number;
307 struct e1000_hw *hw = &adapter->hw;
308
309 if (bd >= IGB_MAX_NIC) {
310 DPRINTK(PROBE, NOTICE,
311 "Warning: no configuration for board #%d\n", bd);
312 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
313 #ifndef module_param_array
314 bd = IGB_MAX_NIC;
315 #endif
316 }
317
318 { /* Interrupt Throttling Rate */
319 struct igb_option opt = {
320 .type = range_option,
321 .name = "Interrupt Throttling Rate (ints/sec)",
322 .err = "using default of " __MODULE_STRING(DEFAULT_ITR),
323 .def = DEFAULT_ITR,
324 .arg = { .r = { .min = MIN_ITR,
325 .max = MAX_ITR } }
326 };
327
328 #ifdef module_param_array
329 if (num_InterruptThrottleRate > bd) {
330 #endif
331 unsigned int itr = InterruptThrottleRate[bd];
332
333 switch (itr) {
334 case 0:
335 DPRINTK(PROBE, INFO, "%s turned off\n",
336 opt.name);
337 if (hw->mac.type >= e1000_i350)
338 adapter->dmac = IGB_DMAC_DISABLE;
339 adapter->rx_itr_setting = itr;
340 break;
341 case 1:
342 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
343 opt.name);
344 adapter->rx_itr_setting = itr;
345 break;
346 case 3:
347 DPRINTK(PROBE, INFO,
348 "%s set to dynamic conservative mode\n",
349 opt.name);
350 adapter->rx_itr_setting = itr;
351 break;
352 default:
353 igb_validate_option(&itr, &opt, adapter);
354 /* Save the setting, because the dynamic bits
355 * change itr. In case of invalid user value,
356 * default to conservative mode, else need to
357 * clear the lower two bits because they are
358 * used as control */
359 if (itr == 3) {
360 adapter->rx_itr_setting = itr;
361 } else {
362 adapter->rx_itr_setting = 1000000000 /
363 (itr * 256);
364 adapter->rx_itr_setting &= ~3;
365 }
366 break;
367 }
368 #ifdef module_param_array
369 } else {
370 adapter->rx_itr_setting = opt.def;
371 }
372 #endif
373 adapter->tx_itr_setting = adapter->rx_itr_setting;
374 }
375 { /* Interrupt Mode */
376 struct igb_option opt = {
377 .type = range_option,
378 .name = "Interrupt Mode",
379 .err = "defaulting to 2 (MSI-X)",
380 .def = IGB_INT_MODE_MSIX,
381 .arg = { .r = { .min = MIN_INTMODE,
382 .max = MAX_INTMODE } }
383 };
384
385 #ifdef module_param_array
386 if (num_IntMode > bd) {
387 #endif
388 unsigned int int_mode = IntMode[bd];
389 igb_validate_option(&int_mode, &opt, adapter);
390 adapter->int_mode = int_mode;
391 #ifdef module_param_array
392 } else {
393 adapter->int_mode = opt.def;
394 }
395 #endif
396 }
397 { /* Low Latency Interrupt TCP Port */
398 struct igb_option opt = {
399 .type = range_option,
400 .name = "Low Latency Interrupt TCP Port",
401 .err = "using default of " __MODULE_STRING(DEFAULT_LLIPORT),
402 .def = DEFAULT_LLIPORT,
403 .arg = { .r = { .min = MIN_LLIPORT,
404 .max = MAX_LLIPORT } }
405 };
406
407 #ifdef module_param_array
408 if (num_LLIPort > bd) {
409 #endif
410 adapter->lli_port = LLIPort[bd];
411 if (adapter->lli_port) {
412 igb_validate_option(&adapter->lli_port, &opt,
413 adapter);
414 } else {
415 DPRINTK(PROBE, INFO, "%s turned off\n",
416 opt.name);
417 }
418 #ifdef module_param_array
419 } else {
420 adapter->lli_port = opt.def;
421 }
422 #endif
423 }
424 { /* Low Latency Interrupt on Packet Size */
425 struct igb_option opt = {
426 .type = range_option,
427 .name = "Low Latency Interrupt on Packet Size",
428 .err = "using default of " __MODULE_STRING(DEFAULT_LLISIZE),
429 .def = DEFAULT_LLISIZE,
430 .arg = { .r = { .min = MIN_LLISIZE,
431 .max = MAX_LLISIZE } }
432 };
433
434 #ifdef module_param_array
435 if (num_LLISize > bd) {
436 #endif
437 adapter->lli_size = LLISize[bd];
438 if (adapter->lli_size) {
439 igb_validate_option(&adapter->lli_size, &opt,
440 adapter);
441 } else {
442 DPRINTK(PROBE, INFO, "%s turned off\n",
443 opt.name);
444 }
445 #ifdef module_param_array
446 } else {
447 adapter->lli_size = opt.def;
448 }
449 #endif
450 }
451 { /* Low Latency Interrupt on TCP Push flag */
452 struct igb_option opt = {
453 .type = enable_option,
454 .name = "Low Latency Interrupt on TCP Push flag",
455 .err = "defaulting to Disabled",
456 .def = OPTION_DISABLED
457 };
458
459 #ifdef module_param_array
460 if (num_LLIPush > bd) {
461 #endif
462 unsigned int lli_push = LLIPush[bd];
463 igb_validate_option(&lli_push, &opt, adapter);
464 adapter->flags |= lli_push ? IGB_FLAG_LLI_PUSH : 0;
465 #ifdef module_param_array
466 } else {
467 adapter->flags |= opt.def ? IGB_FLAG_LLI_PUSH : 0;
468 }
469 #endif
470 }
471 { /* SRIOV - Enable SR-IOV VF devices */
472 struct igb_option opt = {
473 .type = range_option,
474 .name = "max_vfs - SR-IOV VF devices",
475 .err = "using default of " __MODULE_STRING(DEFAULT_SRIOV),
476 .def = DEFAULT_SRIOV,
477 .arg = { .r = { .min = MIN_SRIOV,
478 .max = MAX_SRIOV } }
479 };
480
481 #ifdef module_param_array
482 if (num_max_vfs > bd) {
483 #endif
484 adapter->vfs_allocated_count = max_vfs[bd];
485 igb_validate_option(&adapter->vfs_allocated_count, &opt, adapter);
486
487 #ifdef module_param_array
488 } else {
489 adapter->vfs_allocated_count = opt.def;
490 }
491 #endif
492 if (adapter->vfs_allocated_count) {
493 switch (hw->mac.type) {
494 case e1000_82575:
495 case e1000_82580:
496 case e1000_i210:
497 case e1000_i211:
498 case e1000_i354:
499 adapter->vfs_allocated_count = 0;
500 DPRINTK(PROBE, INFO, "SR-IOV option max_vfs not supported.\n");
501 default:
502 break;
503 }
504 }
505 }
506 { /* VMDQ - Enable VMDq multiqueue receive */
507 struct igb_option opt = {
508 .type = range_option,
509 .name = "VMDQ - VMDq multiqueue queue count",
510 .err = "using default of " __MODULE_STRING(DEFAULT_VMDQ),
511 .def = DEFAULT_VMDQ,
512 .arg = { .r = { .min = MIN_VMDQ,
513 .max = (MAX_VMDQ - adapter->vfs_allocated_count) } }
514 };
515 if ((hw->mac.type != e1000_i210) ||
516 (hw->mac.type != e1000_i211)) {
517 #ifdef module_param_array
518 if (num_VMDQ > bd) {
519 #endif
520 adapter->vmdq_pools = (VMDQ[bd] == 1 ? 0 : VMDQ[bd]);
521 if (adapter->vfs_allocated_count && !adapter->vmdq_pools) {
522 DPRINTK(PROBE, INFO, "Enabling SR-IOV requires VMDq be set to at least 1\n");
523 adapter->vmdq_pools = 1;
524 }
525 igb_validate_option(&adapter->vmdq_pools, &opt, adapter);
526
527 #ifdef module_param_array
528 } else {
529 if (!adapter->vfs_allocated_count)
530 adapter->vmdq_pools = (opt.def == 1 ? 0 : opt.def);
531 else
532 adapter->vmdq_pools = 1;
533 }
534 #endif
535 #ifdef CONFIG_IGB_VMDQ_NETDEV
536 if (hw->mac.type == e1000_82575 && adapter->vmdq_pools) {
537 DPRINTK(PROBE, INFO, "VMDq not supported on this part.\n");
538 adapter->vmdq_pools = 0;
539 }
540 #endif
541
542 } else {
543 DPRINTK(PROBE, INFO, "VMDq option is not supported.\n");
544 adapter->vmdq_pools = opt.def;
545 }
546 }
547 { /* RSS - Enable RSS multiqueue receives */
548 struct igb_option opt = {
549 .type = range_option,
550 .name = "RSS - RSS multiqueue receive count",
551 .err = "using default of " __MODULE_STRING(DEFAULT_RSS),
552 .def = DEFAULT_RSS,
553 .arg = { .r = { .min = MIN_RSS,
554 .max = MAX_RSS } }
555 };
556
557 switch (hw->mac.type) {
558 case e1000_82575:
559 #ifndef CONFIG_IGB_VMDQ_NETDEV
560 if (!!adapter->vmdq_pools) {
561 if (adapter->vmdq_pools <= 2) {
562 if (adapter->vmdq_pools == 2)
563 opt.arg.r.max = 3;
564 } else {
565 opt.arg.r.max = 1;
566 }
567 } else {
568 opt.arg.r.max = 4;
569 }
570 #else
571 opt.arg.r.max = !!adapter->vmdq_pools ? 1 : 4;
572 #endif /* CONFIG_IGB_VMDQ_NETDEV */
573 break;
574 case e1000_i210:
575 opt.arg.r.max = 4;
576 break;
577 case e1000_i211:
578 opt.arg.r.max = 2;
579 break;
580 case e1000_82576:
581 #ifndef CONFIG_IGB_VMDQ_NETDEV
582 if (!!adapter->vmdq_pools)
583 opt.arg.r.max = 2;
584 break;
585 #endif /* CONFIG_IGB_VMDQ_NETDEV */
586 case e1000_82580:
587 case e1000_i350:
588 case e1000_i354:
589 default:
590 if (!!adapter->vmdq_pools)
591 opt.arg.r.max = 1;
592 break;
593 }
594
595 if (adapter->int_mode != IGB_INT_MODE_MSIX) {
596 DPRINTK(PROBE, INFO, "RSS is not supported when in MSI/Legacy Interrupt mode, %s\n",
597 opt.err);
598 opt.arg.r.max = 1;
599 }
600
601 #ifdef module_param_array
602 if (num_RSS > bd) {
603 #endif
604 adapter->rss_queues = RSS[bd];
605 switch (adapter->rss_queues) {
606 case 1:
607 break;
608 default:
609 igb_validate_option(&adapter->rss_queues, &opt, adapter);
610 if (adapter->rss_queues)
611 break;
612 case 0:
613 adapter->rss_queues = min_t(u32, opt.arg.r.max, num_online_cpus());
614 break;
615 }
616 #ifdef module_param_array
617 } else {
618 adapter->rss_queues = opt.def;
619 }
620 #endif
621 }
622 { /* QueuePairs - Enable Tx/Rx queue pairs for interrupt handling */
623 struct igb_option opt = {
624 .type = enable_option,
625 .name = "QueuePairs - Tx/Rx queue pairs for interrupt handling",
626 .err = "defaulting to Enabled",
627 .def = OPTION_ENABLED
628 };
629 #ifdef module_param_array
630 if (num_QueuePairs > bd) {
631 #endif
632 unsigned int qp = QueuePairs[bd];
633 /*
634 * We must enable queue pairs if the number of queues
635 * exceeds the number of available interrupts. We are
636 * limited to 10, or 3 per unallocated vf. On I210 and
637 * I211 devices, we are limited to 5 interrupts.
638 * However, since I211 only supports 2 queues, we do not
639 * need to check and override the user option.
640 */
641 if (qp == OPTION_DISABLED) {
642 if (adapter->rss_queues > 4)
643 qp = OPTION_ENABLED;
644
645 if (adapter->vmdq_pools > 4)
646 qp = OPTION_ENABLED;
647
648 if (adapter->rss_queues > 1 &&
649 (adapter->vmdq_pools > 3 ||
650 adapter->vfs_allocated_count > 6))
651 qp = OPTION_ENABLED;
652
653 if (hw->mac.type == e1000_i210 &&
654 adapter->rss_queues > 2)
655 qp = OPTION_ENABLED;
656
657 if (qp == OPTION_ENABLED)
658 DPRINTK(PROBE, INFO, "Number of queues exceeds available interrupts, %s\n",
659 opt.err);
660 }
661 igb_validate_option(&qp, &opt, adapter);
662 adapter->flags |= qp ? IGB_FLAG_QUEUE_PAIRS : 0;
663 #ifdef module_param_array
664 } else {
665 adapter->flags |= opt.def ? IGB_FLAG_QUEUE_PAIRS : 0;
666 }
667 #endif
668 }
669 { /* EEE - Enable EEE for capable adapters */
670
671 if (hw->mac.type >= e1000_i350) {
672 struct igb_option opt = {
673 .type = enable_option,
674 .name = "EEE Support",
675 .err = "defaulting to Enabled",
676 .def = OPTION_ENABLED
677 };
678 #ifdef module_param_array
679 if (num_EEE > bd) {
680 #endif
681 unsigned int eee = EEE[bd];
682 igb_validate_option(&eee, &opt, adapter);
683 adapter->flags |= eee ? IGB_FLAG_EEE : 0;
684 if (eee)
685 hw->dev_spec._82575.eee_disable = false;
686 else
687 hw->dev_spec._82575.eee_disable = true;
688
689 #ifdef module_param_array
690 } else {
691 adapter->flags |= opt.def ? IGB_FLAG_EEE : 0;
692 if (adapter->flags & IGB_FLAG_EEE)
693 hw->dev_spec._82575.eee_disable = false;
694 else
695 hw->dev_spec._82575.eee_disable = true;
696 }
697 #endif
698 }
699 }
700 { /* DMAC - Enable DMA Coalescing for capable adapters */
701
702 if (hw->mac.type >= e1000_i350) {
703 struct igb_opt_list list [] = {
704 { IGB_DMAC_DISABLE, "DMAC Disable"},
705 { IGB_DMAC_MIN, "DMAC 250 usec"},
706 { IGB_DMAC_500, "DMAC 500 usec"},
707 { IGB_DMAC_EN_DEFAULT, "DMAC 1000 usec"},
708 { IGB_DMAC_2000, "DMAC 2000 usec"},
709 { IGB_DMAC_3000, "DMAC 3000 usec"},
710 { IGB_DMAC_4000, "DMAC 4000 usec"},
711 { IGB_DMAC_5000, "DMAC 5000 usec"},
712 { IGB_DMAC_6000, "DMAC 6000 usec"},
713 { IGB_DMAC_7000, "DMAC 7000 usec"},
714 { IGB_DMAC_8000, "DMAC 8000 usec"},
715 { IGB_DMAC_9000, "DMAC 9000 usec"},
716 { IGB_DMAC_MAX, "DMAC 10000 usec"}
717 };
718 struct igb_option opt = {
719 .type = list_option,
720 .name = "DMA Coalescing",
721 .err = "using default of "__MODULE_STRING(IGB_DMAC_DISABLE),
722 .def = IGB_DMAC_DISABLE,
723 .arg = { .l = { .nr = 13,
724 .p = list
725 }
726 }
727 };
728 #ifdef module_param_array
729 if (num_DMAC > bd) {
730 #endif
731 unsigned int dmac = DMAC[bd];
732 if (adapter->rx_itr_setting == IGB_DMAC_DISABLE)
733 dmac = IGB_DMAC_DISABLE;
734 igb_validate_option(&dmac, &opt, adapter);
735 switch (dmac) {
736 case IGB_DMAC_DISABLE:
737 adapter->dmac = dmac;
738 break;
739 case IGB_DMAC_MIN:
740 adapter->dmac = dmac;
741 break;
742 case IGB_DMAC_500:
743 adapter->dmac = dmac;
744 break;
745 case IGB_DMAC_EN_DEFAULT:
746 adapter->dmac = dmac;
747 break;
748 case IGB_DMAC_2000:
749 adapter->dmac = dmac;
750 break;
751 case IGB_DMAC_3000:
752 adapter->dmac = dmac;
753 break;
754 case IGB_DMAC_4000:
755 adapter->dmac = dmac;
756 break;
757 case IGB_DMAC_5000:
758 adapter->dmac = dmac;
759 break;
760 case IGB_DMAC_6000:
761 adapter->dmac = dmac;
762 break;
763 case IGB_DMAC_7000:
764 adapter->dmac = dmac;
765 break;
766 case IGB_DMAC_8000:
767 adapter->dmac = dmac;
768 break;
769 case IGB_DMAC_9000:
770 adapter->dmac = dmac;
771 break;
772 case IGB_DMAC_MAX:
773 adapter->dmac = dmac;
774 break;
775 default:
776 adapter->dmac = opt.def;
777 DPRINTK(PROBE, INFO,
778 "Invalid DMAC setting, "
779 "resetting DMAC to %d\n", opt.def);
780 }
781 #ifdef module_param_array
782 } else
783 adapter->dmac = opt.def;
784 #endif
785 }
786 }
787 #ifndef IGB_NO_LRO
788 { /* LRO - Enable Large Receive Offload */
789 struct igb_option opt = {
790 .type = enable_option,
791 .name = "LRO - Large Receive Offload",
792 .err = "defaulting to Disabled",
793 .def = OPTION_DISABLED
794 };
795 struct net_device *netdev = adapter->netdev;
796 #ifdef module_param_array
797 if (num_LRO > bd) {
798 #endif
799 unsigned int lro = LRO[bd];
800 igb_validate_option(&lro, &opt, adapter);
801 netdev->features |= lro ? NETIF_F_LRO : 0;
802 #ifdef module_param_array
803 } else if (opt.def == OPTION_ENABLED) {
804 netdev->features |= NETIF_F_LRO;
805 }
806 #endif
807 }
808 #endif /* IGB_NO_LRO */
809 { /* MDD - Enable Malicious Driver Detection. Only available when
810 SR-IOV is enabled. */
811 struct igb_option opt = {
812 .type = enable_option,
813 .name = "Malicious Driver Detection",
814 .err = "defaulting to 1",
815 .def = OPTION_ENABLED,
816 .arg = { .r = { .min = OPTION_DISABLED,
817 .max = OPTION_ENABLED } }
818 };
819
820 #ifdef module_param_array
821 if (num_MDD > bd) {
822 #endif
823 adapter->mdd = MDD[bd];
824 igb_validate_option((uint *)&adapter->mdd, &opt,
825 adapter);
826 #ifdef module_param_array
827 } else {
828 adapter->mdd = opt.def;
829 }
830 #endif
831 }
832 }