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