Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright(c) 1999 - 2006 Intel Corporation. */
0003 
0004 #include "e1000.h"
0005 
0006 /* This is the only thing that needs to be changed to adjust the
0007  * maximum number of ports that the driver can manage.
0008  */
0009 
0010 #define E1000_MAX_NIC 32
0011 
0012 #define OPTION_UNSET   -1
0013 #define OPTION_DISABLED 0
0014 #define OPTION_ENABLED  1
0015 
0016 /* All parameters are treated the same, as an integer array of values.
0017  * This macro just reduces the need to repeat the same declaration code
0018  * over and over (plus this helps to avoid typo bugs).
0019  */
0020 
0021 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
0022 #define E1000_PARAM(X, desc) \
0023     static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
0024     static unsigned int num_##X; \
0025     module_param_array_named(X, X, int, &num_##X, 0); \
0026     MODULE_PARM_DESC(X, desc);
0027 
0028 /* Transmit Descriptor Count
0029  *
0030  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
0031  * Valid Range: 80-4096 for 82544 and newer
0032  *
0033  * Default Value: 256
0034  */
0035 E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
0036 
0037 /* Receive Descriptor Count
0038  *
0039  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
0040  * Valid Range: 80-4096 for 82544 and newer
0041  *
0042  * Default Value: 256
0043  */
0044 E1000_PARAM(RxDescriptors, "Number of receive descriptors");
0045 
0046 /* User Specified Speed Override
0047  *
0048  * Valid Range: 0, 10, 100, 1000
0049  *  - 0    - auto-negotiate at all supported speeds
0050  *  - 10   - only link at 10 Mbps
0051  *  - 100  - only link at 100 Mbps
0052  *  - 1000 - only link at 1000 Mbps
0053  *
0054  * Default Value: 0
0055  */
0056 E1000_PARAM(Speed, "Speed setting");
0057 
0058 /* User Specified Duplex Override
0059  *
0060  * Valid Range: 0-2
0061  *  - 0 - auto-negotiate for duplex
0062  *  - 1 - only link at half duplex
0063  *  - 2 - only link at full duplex
0064  *
0065  * Default Value: 0
0066  */
0067 E1000_PARAM(Duplex, "Duplex setting");
0068 
0069 /* Auto-negotiation Advertisement Override
0070  *
0071  * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
0072  *
0073  * The AutoNeg value is a bit mask describing which speed and duplex
0074  * combinations should be advertised during auto-negotiation.
0075  * The supported speed and duplex modes are listed below
0076  *
0077  * Bit           7     6     5      4      3     2     1      0
0078  * Speed (Mbps)  N/A   N/A   1000   N/A    100   100   10     10
0079  * Duplex                    Full          Full  Half  Full   Half
0080  *
0081  * Default Value: 0x2F (copper); 0x20 (fiber)
0082  */
0083 E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
0084 #define AUTONEG_ADV_DEFAULT  0x2F
0085 
0086 /* User Specified Flow Control Override
0087  *
0088  * Valid Range: 0-3
0089  *  - 0 - No Flow Control
0090  *  - 1 - Rx only, respond to PAUSE frames but do not generate them
0091  *  - 2 - Tx only, generate PAUSE frames but ignore them on receive
0092  *  - 3 - Full Flow Control Support
0093  *
0094  * Default Value: Read flow control settings from the EEPROM
0095  */
0096 E1000_PARAM(FlowControl, "Flow Control setting");
0097 
0098 /* XsumRX - Receive Checksum Offload Enable/Disable
0099  *
0100  * Valid Range: 0, 1
0101  *  - 0 - disables all checksum offload
0102  *  - 1 - enables receive IP/TCP/UDP checksum offload
0103  *        on 82543 and newer -based NICs
0104  *
0105  * Default Value: 1
0106  */
0107 E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
0108 
0109 /* Transmit Interrupt Delay in units of 1.024 microseconds
0110  *  Tx interrupt delay needs to typically be set to something non zero
0111  *
0112  * Valid Range: 0-65535
0113  */
0114 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
0115 #define DEFAULT_TIDV                   8
0116 #define MAX_TXDELAY               0xFFFF
0117 #define MIN_TXDELAY                    0
0118 
0119 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
0120  *
0121  * Valid Range: 0-65535
0122  */
0123 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
0124 #define DEFAULT_TADV                  32
0125 #define MAX_TXABSDELAY            0xFFFF
0126 #define MIN_TXABSDELAY                 0
0127 
0128 /* Receive Interrupt Delay in units of 1.024 microseconds
0129  *   hardware will likely hang if you set this to anything but zero.
0130  *
0131  * Valid Range: 0-65535
0132  */
0133 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
0134 #define DEFAULT_RDTR                   0
0135 #define MAX_RXDELAY               0xFFFF
0136 #define MIN_RXDELAY                    0
0137 
0138 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
0139  *
0140  * Valid Range: 0-65535
0141  */
0142 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
0143 #define DEFAULT_RADV                   8
0144 #define MAX_RXABSDELAY            0xFFFF
0145 #define MIN_RXABSDELAY                 0
0146 
0147 /* Interrupt Throttle Rate (interrupts/sec)
0148  *
0149  * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
0150  */
0151 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
0152 #define DEFAULT_ITR                    3
0153 #define MAX_ITR                   100000
0154 #define MIN_ITR                      100
0155 
0156 /* Enable Smart Power Down of the PHY
0157  *
0158  * Valid Range: 0, 1
0159  *
0160  * Default Value: 0 (disabled)
0161  */
0162 E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
0163 
0164 struct e1000_option {
0165     enum { enable_option, range_option, list_option } type;
0166     const char *name;
0167     const char *err;
0168     int def;
0169     union {
0170         struct { /* range_option info */
0171             int min;
0172             int max;
0173         } r;
0174         struct { /* list_option info */
0175             int nr;
0176             const struct e1000_opt_list { int i; char *str; } *p;
0177         } l;
0178     } arg;
0179 };
0180 
0181 static int e1000_validate_option(unsigned int *value,
0182                  const struct e1000_option *opt,
0183                  struct e1000_adapter *adapter)
0184 {
0185     if (*value == OPTION_UNSET) {
0186         *value = opt->def;
0187         return 0;
0188     }
0189 
0190     switch (opt->type) {
0191     case enable_option:
0192         switch (*value) {
0193         case OPTION_ENABLED:
0194             e_dev_info("%s Enabled\n", opt->name);
0195             return 0;
0196         case OPTION_DISABLED:
0197             e_dev_info("%s Disabled\n", opt->name);
0198             return 0;
0199         }
0200         break;
0201     case range_option:
0202         if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
0203             e_dev_info("%s set to %i\n", opt->name, *value);
0204             return 0;
0205         }
0206         break;
0207     case list_option: {
0208         int i;
0209         const struct e1000_opt_list *ent;
0210 
0211         for (i = 0; i < opt->arg.l.nr; i++) {
0212             ent = &opt->arg.l.p[i];
0213             if (*value == ent->i) {
0214                 if (ent->str[0] != '\0')
0215                     e_dev_info("%s\n", ent->str);
0216                 return 0;
0217             }
0218         }
0219     }
0220         break;
0221     default:
0222         BUG();
0223     }
0224 
0225     e_dev_info("Invalid %s value specified (%i) %s\n",
0226            opt->name, *value, opt->err);
0227     *value = opt->def;
0228     return -1;
0229 }
0230 
0231 static void e1000_check_fiber_options(struct e1000_adapter *adapter);
0232 static void e1000_check_copper_options(struct e1000_adapter *adapter);
0233 
0234 /**
0235  * e1000_check_options - Range Checking for Command Line Parameters
0236  * @adapter: board private structure
0237  *
0238  * This routine checks all command line parameters for valid user
0239  * input.  If an invalid value is given, or if no user specified
0240  * value exists, a default value is used.  The final value is stored
0241  * in a variable in the adapter structure.
0242  **/
0243 void e1000_check_options(struct e1000_adapter *adapter)
0244 {
0245     struct e1000_option opt;
0246     int bd = adapter->bd_number;
0247 
0248     if (bd >= E1000_MAX_NIC) {
0249         e_dev_warn("Warning: no configuration for board #%i "
0250                "using defaults for all values\n", bd);
0251     }
0252 
0253     { /* Transmit Descriptor Count */
0254         struct e1000_tx_ring *tx_ring = adapter->tx_ring;
0255         int i;
0256         e1000_mac_type mac_type = adapter->hw.mac_type;
0257 
0258         opt = (struct e1000_option) {
0259             .type = range_option,
0260             .name = "Transmit Descriptors",
0261             .err  = "using default of "
0262                 __MODULE_STRING(E1000_DEFAULT_TXD),
0263             .def  = E1000_DEFAULT_TXD,
0264             .arg  = { .r = {
0265                 .min = E1000_MIN_TXD,
0266                 .max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD
0267                 }}
0268         };
0269 
0270         if (num_TxDescriptors > bd) {
0271             tx_ring->count = TxDescriptors[bd];
0272             e1000_validate_option(&tx_ring->count, &opt, adapter);
0273             tx_ring->count = ALIGN(tx_ring->count,
0274                         REQ_TX_DESCRIPTOR_MULTIPLE);
0275         } else {
0276             tx_ring->count = opt.def;
0277         }
0278         for (i = 0; i < adapter->num_tx_queues; i++)
0279             tx_ring[i].count = tx_ring->count;
0280     }
0281     { /* Receive Descriptor Count */
0282         struct e1000_rx_ring *rx_ring = adapter->rx_ring;
0283         int i;
0284         e1000_mac_type mac_type = adapter->hw.mac_type;
0285 
0286         opt = (struct e1000_option) {
0287             .type = range_option,
0288             .name = "Receive Descriptors",
0289             .err  = "using default of "
0290                 __MODULE_STRING(E1000_DEFAULT_RXD),
0291             .def  = E1000_DEFAULT_RXD,
0292             .arg  = { .r = {
0293                 .min = E1000_MIN_RXD,
0294                 .max = mac_type < e1000_82544 ? E1000_MAX_RXD :
0295                        E1000_MAX_82544_RXD
0296             }}
0297         };
0298 
0299         if (num_RxDescriptors > bd) {
0300             rx_ring->count = RxDescriptors[bd];
0301             e1000_validate_option(&rx_ring->count, &opt, adapter);
0302             rx_ring->count = ALIGN(rx_ring->count,
0303                         REQ_RX_DESCRIPTOR_MULTIPLE);
0304         } else {
0305             rx_ring->count = opt.def;
0306         }
0307         for (i = 0; i < adapter->num_rx_queues; i++)
0308             rx_ring[i].count = rx_ring->count;
0309     }
0310     { /* Checksum Offload Enable/Disable */
0311         opt = (struct e1000_option) {
0312             .type = enable_option,
0313             .name = "Checksum Offload",
0314             .err  = "defaulting to Enabled",
0315             .def  = OPTION_ENABLED
0316         };
0317 
0318         if (num_XsumRX > bd) {
0319             unsigned int rx_csum = XsumRX[bd];
0320             e1000_validate_option(&rx_csum, &opt, adapter);
0321             adapter->rx_csum = rx_csum;
0322         } else {
0323             adapter->rx_csum = opt.def;
0324         }
0325     }
0326     { /* Flow Control */
0327 
0328         static const struct e1000_opt_list fc_list[] = {
0329                { E1000_FC_NONE, "Flow Control Disabled" },
0330                { E1000_FC_RX_PAUSE, "Flow Control Receive Only" },
0331                { E1000_FC_TX_PAUSE, "Flow Control Transmit Only" },
0332                { E1000_FC_FULL, "Flow Control Enabled" },
0333                { E1000_FC_DEFAULT, "Flow Control Hardware Default" }
0334         };
0335 
0336         opt = (struct e1000_option) {
0337             .type = list_option,
0338             .name = "Flow Control",
0339             .err  = "reading default settings from EEPROM",
0340             .def  = E1000_FC_DEFAULT,
0341             .arg  = { .l = { .nr = ARRAY_SIZE(fc_list),
0342                      .p = fc_list }}
0343         };
0344 
0345         if (num_FlowControl > bd) {
0346             unsigned int fc = FlowControl[bd];
0347             e1000_validate_option(&fc, &opt, adapter);
0348             adapter->hw.fc = adapter->hw.original_fc = fc;
0349         } else {
0350             adapter->hw.fc = adapter->hw.original_fc = opt.def;
0351         }
0352     }
0353     { /* Transmit Interrupt Delay */
0354         opt = (struct e1000_option) {
0355             .type = range_option,
0356             .name = "Transmit Interrupt Delay",
0357             .err  = "using default of " __MODULE_STRING(DEFAULT_TIDV),
0358             .def  = DEFAULT_TIDV,
0359             .arg  = { .r = { .min = MIN_TXDELAY,
0360                      .max = MAX_TXDELAY }}
0361         };
0362 
0363         if (num_TxIntDelay > bd) {
0364             adapter->tx_int_delay = TxIntDelay[bd];
0365             e1000_validate_option(&adapter->tx_int_delay, &opt,
0366                                   adapter);
0367         } else {
0368             adapter->tx_int_delay = opt.def;
0369         }
0370     }
0371     { /* Transmit Absolute Interrupt Delay */
0372         opt = (struct e1000_option) {
0373             .type = range_option,
0374             .name = "Transmit Absolute Interrupt Delay",
0375             .err  = "using default of " __MODULE_STRING(DEFAULT_TADV),
0376             .def  = DEFAULT_TADV,
0377             .arg  = { .r = { .min = MIN_TXABSDELAY,
0378                      .max = MAX_TXABSDELAY }}
0379         };
0380 
0381         if (num_TxAbsIntDelay > bd) {
0382             adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
0383             e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
0384                           adapter);
0385         } else {
0386             adapter->tx_abs_int_delay = opt.def;
0387         }
0388     }
0389     { /* Receive Interrupt Delay */
0390         opt = (struct e1000_option) {
0391             .type = range_option,
0392             .name = "Receive Interrupt Delay",
0393             .err  = "using default of " __MODULE_STRING(DEFAULT_RDTR),
0394             .def  = DEFAULT_RDTR,
0395             .arg  = { .r = { .min = MIN_RXDELAY,
0396                      .max = MAX_RXDELAY }}
0397         };
0398 
0399         if (num_RxIntDelay > bd) {
0400             adapter->rx_int_delay = RxIntDelay[bd];
0401             e1000_validate_option(&adapter->rx_int_delay, &opt,
0402                           adapter);
0403         } else {
0404             adapter->rx_int_delay = opt.def;
0405         }
0406     }
0407     { /* Receive Absolute Interrupt Delay */
0408         opt = (struct e1000_option) {
0409             .type = range_option,
0410             .name = "Receive Absolute Interrupt Delay",
0411             .err  = "using default of " __MODULE_STRING(DEFAULT_RADV),
0412             .def  = DEFAULT_RADV,
0413             .arg  = { .r = { .min = MIN_RXABSDELAY,
0414                      .max = MAX_RXABSDELAY }}
0415         };
0416 
0417         if (num_RxAbsIntDelay > bd) {
0418             adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
0419             e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
0420                           adapter);
0421         } else {
0422             adapter->rx_abs_int_delay = opt.def;
0423         }
0424     }
0425     { /* Interrupt Throttling Rate */
0426         opt = (struct e1000_option) {
0427             .type = range_option,
0428             .name = "Interrupt Throttling Rate (ints/sec)",
0429             .err  = "using default of " __MODULE_STRING(DEFAULT_ITR),
0430             .def  = DEFAULT_ITR,
0431             .arg  = { .r = { .min = MIN_ITR,
0432                      .max = MAX_ITR }}
0433         };
0434 
0435         if (num_InterruptThrottleRate > bd) {
0436             adapter->itr = InterruptThrottleRate[bd];
0437             switch (adapter->itr) {
0438             case 0:
0439                 e_dev_info("%s turned off\n", opt.name);
0440                 break;
0441             case 1:
0442                 e_dev_info("%s set to dynamic mode\n",
0443                        opt.name);
0444                 adapter->itr_setting = adapter->itr;
0445                 adapter->itr = 20000;
0446                 break;
0447             case 3:
0448                 e_dev_info("%s set to dynamic conservative "
0449                        "mode\n", opt.name);
0450                 adapter->itr_setting = adapter->itr;
0451                 adapter->itr = 20000;
0452                 break;
0453             case 4:
0454                 e_dev_info("%s set to simplified "
0455                        "(2000-8000) ints mode\n", opt.name);
0456                 adapter->itr_setting = adapter->itr;
0457                 break;
0458             default:
0459                 e1000_validate_option(&adapter->itr, &opt,
0460                               adapter);
0461                 /* save the setting, because the dynamic bits
0462                  * change itr.
0463                  * clear the lower two bits because they are
0464                  * used as control
0465                  */
0466                 adapter->itr_setting = adapter->itr & ~3;
0467                 break;
0468             }
0469         } else {
0470             adapter->itr_setting = opt.def;
0471             adapter->itr = 20000;
0472         }
0473     }
0474     { /* Smart Power Down */
0475         opt = (struct e1000_option) {
0476             .type = enable_option,
0477             .name = "PHY Smart Power Down",
0478             .err  = "defaulting to Disabled",
0479             .def  = OPTION_DISABLED
0480         };
0481 
0482         if (num_SmartPowerDownEnable > bd) {
0483             unsigned int spd = SmartPowerDownEnable[bd];
0484             e1000_validate_option(&spd, &opt, adapter);
0485             adapter->smart_power_down = spd;
0486         } else {
0487             adapter->smart_power_down = opt.def;
0488         }
0489     }
0490 
0491     switch (adapter->hw.media_type) {
0492     case e1000_media_type_fiber:
0493     case e1000_media_type_internal_serdes:
0494         e1000_check_fiber_options(adapter);
0495         break;
0496     case e1000_media_type_copper:
0497         e1000_check_copper_options(adapter);
0498         break;
0499     default:
0500         BUG();
0501     }
0502 }
0503 
0504 /**
0505  * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
0506  * @adapter: board private structure
0507  *
0508  * Handles speed and duplex options on fiber adapters
0509  **/
0510 static void e1000_check_fiber_options(struct e1000_adapter *adapter)
0511 {
0512     int bd = adapter->bd_number;
0513     if (num_Speed > bd) {
0514         e_dev_info("Speed not valid for fiber adapters, parameter "
0515                "ignored\n");
0516     }
0517 
0518     if (num_Duplex > bd) {
0519         e_dev_info("Duplex not valid for fiber adapters, parameter "
0520                "ignored\n");
0521     }
0522 
0523     if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
0524         e_dev_info("AutoNeg other than 1000/Full is not valid for fiber"
0525                "adapters, parameter ignored\n");
0526     }
0527 }
0528 
0529 /**
0530  * e1000_check_copper_options - Range Checking for Link Options, Copper Version
0531  * @adapter: board private structure
0532  *
0533  * Handles speed and duplex options on copper adapters
0534  **/
0535 static void e1000_check_copper_options(struct e1000_adapter *adapter)
0536 {
0537     struct e1000_option opt;
0538     unsigned int speed, dplx, an;
0539     int bd = adapter->bd_number;
0540 
0541     { /* Speed */
0542         static const struct e1000_opt_list speed_list[] = {
0543             {          0, "" },
0544             {   SPEED_10, "" },
0545             {  SPEED_100, "" },
0546             { SPEED_1000, "" }};
0547 
0548         opt = (struct e1000_option) {
0549             .type = list_option,
0550             .name = "Speed",
0551             .err  = "parameter ignored",
0552             .def  = 0,
0553             .arg  = { .l = { .nr = ARRAY_SIZE(speed_list),
0554                      .p = speed_list }}
0555         };
0556 
0557         if (num_Speed > bd) {
0558             speed = Speed[bd];
0559             e1000_validate_option(&speed, &opt, adapter);
0560         } else {
0561             speed = opt.def;
0562         }
0563     }
0564     { /* Duplex */
0565         static const struct e1000_opt_list dplx_list[] = {
0566             {           0, "" },
0567             { HALF_DUPLEX, "" },
0568             { FULL_DUPLEX, "" }};
0569 
0570         opt = (struct e1000_option) {
0571             .type = list_option,
0572             .name = "Duplex",
0573             .err  = "parameter ignored",
0574             .def  = 0,
0575             .arg  = { .l = { .nr = ARRAY_SIZE(dplx_list),
0576                      .p = dplx_list }}
0577         };
0578 
0579         if (num_Duplex > bd) {
0580             dplx = Duplex[bd];
0581             e1000_validate_option(&dplx, &opt, adapter);
0582         } else {
0583             dplx = opt.def;
0584         }
0585     }
0586 
0587     if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
0588         e_dev_info("AutoNeg specified along with Speed or Duplex, "
0589                "parameter ignored\n");
0590         adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
0591     } else { /* Autoneg */
0592         static const struct e1000_opt_list an_list[] =
0593             #define AA "AutoNeg advertising "
0594             {{ 0x01, AA "10/HD" },
0595              { 0x02, AA "10/FD" },
0596              { 0x03, AA "10/FD, 10/HD" },
0597              { 0x04, AA "100/HD" },
0598              { 0x05, AA "100/HD, 10/HD" },
0599              { 0x06, AA "100/HD, 10/FD" },
0600              { 0x07, AA "100/HD, 10/FD, 10/HD" },
0601              { 0x08, AA "100/FD" },
0602              { 0x09, AA "100/FD, 10/HD" },
0603              { 0x0a, AA "100/FD, 10/FD" },
0604              { 0x0b, AA "100/FD, 10/FD, 10/HD" },
0605              { 0x0c, AA "100/FD, 100/HD" },
0606              { 0x0d, AA "100/FD, 100/HD, 10/HD" },
0607              { 0x0e, AA "100/FD, 100/HD, 10/FD" },
0608              { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
0609              { 0x20, AA "1000/FD" },
0610              { 0x21, AA "1000/FD, 10/HD" },
0611              { 0x22, AA "1000/FD, 10/FD" },
0612              { 0x23, AA "1000/FD, 10/FD, 10/HD" },
0613              { 0x24, AA "1000/FD, 100/HD" },
0614              { 0x25, AA "1000/FD, 100/HD, 10/HD" },
0615              { 0x26, AA "1000/FD, 100/HD, 10/FD" },
0616              { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
0617              { 0x28, AA "1000/FD, 100/FD" },
0618              { 0x29, AA "1000/FD, 100/FD, 10/HD" },
0619              { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
0620              { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
0621              { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
0622              { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
0623              { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
0624              { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
0625 
0626         opt = (struct e1000_option) {
0627             .type = list_option,
0628             .name = "AutoNeg",
0629             .err  = "parameter ignored",
0630             .def  = AUTONEG_ADV_DEFAULT,
0631             .arg  = { .l = { .nr = ARRAY_SIZE(an_list),
0632                      .p = an_list }}
0633         };
0634 
0635         if (num_AutoNeg > bd) {
0636             an = AutoNeg[bd];
0637             e1000_validate_option(&an, &opt, adapter);
0638         } else {
0639             an = opt.def;
0640         }
0641         adapter->hw.autoneg_advertised = an;
0642     }
0643 
0644     switch (speed + dplx) {
0645     case 0:
0646         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0647         if ((num_Speed > bd) && (speed != 0 || dplx != 0))
0648             e_dev_info("Speed and duplex autonegotiation "
0649                    "enabled\n");
0650         break;
0651     case HALF_DUPLEX:
0652         e_dev_info("Half Duplex specified without Speed\n");
0653         e_dev_info("Using Autonegotiation at Half Duplex only\n");
0654         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0655         adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
0656                          ADVERTISE_100_HALF;
0657         break;
0658     case FULL_DUPLEX:
0659         e_dev_info("Full Duplex specified without Speed\n");
0660         e_dev_info("Using Autonegotiation at Full Duplex only\n");
0661         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0662         adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
0663                          ADVERTISE_100_FULL |
0664                          ADVERTISE_1000_FULL;
0665         break;
0666     case SPEED_10:
0667         e_dev_info("10 Mbps Speed specified without Duplex\n");
0668         e_dev_info("Using Autonegotiation at 10 Mbps only\n");
0669         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0670         adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
0671                          ADVERTISE_10_FULL;
0672         break;
0673     case SPEED_10 + HALF_DUPLEX:
0674         e_dev_info("Forcing to 10 Mbps Half Duplex\n");
0675         adapter->hw.autoneg = adapter->fc_autoneg = 0;
0676         adapter->hw.forced_speed_duplex = e1000_10_half;
0677         adapter->hw.autoneg_advertised = 0;
0678         break;
0679     case SPEED_10 + FULL_DUPLEX:
0680         e_dev_info("Forcing to 10 Mbps Full Duplex\n");
0681         adapter->hw.autoneg = adapter->fc_autoneg = 0;
0682         adapter->hw.forced_speed_duplex = e1000_10_full;
0683         adapter->hw.autoneg_advertised = 0;
0684         break;
0685     case SPEED_100:
0686         e_dev_info("100 Mbps Speed specified without Duplex\n");
0687         e_dev_info("Using Autonegotiation at 100 Mbps only\n");
0688         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0689         adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
0690                          ADVERTISE_100_FULL;
0691         break;
0692     case SPEED_100 + HALF_DUPLEX:
0693         e_dev_info("Forcing to 100 Mbps Half Duplex\n");
0694         adapter->hw.autoneg = adapter->fc_autoneg = 0;
0695         adapter->hw.forced_speed_duplex = e1000_100_half;
0696         adapter->hw.autoneg_advertised = 0;
0697         break;
0698     case SPEED_100 + FULL_DUPLEX:
0699         e_dev_info("Forcing to 100 Mbps Full Duplex\n");
0700         adapter->hw.autoneg = adapter->fc_autoneg = 0;
0701         adapter->hw.forced_speed_duplex = e1000_100_full;
0702         adapter->hw.autoneg_advertised = 0;
0703         break;
0704     case SPEED_1000:
0705         e_dev_info("1000 Mbps Speed specified without Duplex\n");
0706         goto full_duplex_only;
0707     case SPEED_1000 + HALF_DUPLEX:
0708         e_dev_info("Half Duplex is not supported at 1000 Mbps\n");
0709         fallthrough;
0710     case SPEED_1000 + FULL_DUPLEX:
0711 full_duplex_only:
0712         e_dev_info("Using Autonegotiation at 1000 Mbps Full Duplex "
0713                "only\n");
0714         adapter->hw.autoneg = adapter->fc_autoneg = 1;
0715         adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
0716         break;
0717     default:
0718         BUG();
0719     }
0720 
0721     /* Speed, AutoNeg and MDI/MDI-X must all play nice */
0722     if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
0723         e_dev_info("Speed, AutoNeg and MDI-X specs are incompatible. "
0724                "Setting MDI-X to a compatible value.\n");
0725     }
0726 }
0727