22 #include <linux/module.h>
24 #define OPTION_UNSET -1
25 #define OPTION_DISABLED 0
26 #define OPTION_ENABLED 1
92 #define PHY_ADVERTISE_10_HALF 0x0001
93 #define PHY_ADVERTISE_10_FULL 0x0002
94 #define PHY_ADVERTISE_100_HALF 0x0004
95 #define PHY_ADVERTISE_100_FULL 0x0008
96 #define PHY_ADVERTISE_1000_HALF 0x0010
97 #define PHY_ADVERTISE_1000_FULL 0x0020
98 #define PCH_AUTONEG_ADVERTISE_DEFAULT 0x2F
124 #define PCH_GBE_DEFAULT_RX_CSUM true
137 #define PCH_GBE_DEFAULT_TX_CSUM true
158 const struct pch_gbe_opt_list {
int i;
char *
str; } *
p;
163 static const struct pch_gbe_opt_list speed_list[] = {
170 static const struct pch_gbe_opt_list dplx_list[] = {
176 static const struct pch_gbe_opt_list an_list[] =
177 #define AA "AutoNeg advertising "
178 {{ 0x01,
AA "10/HD" },
179 { 0x02,
AA "10/FD" },
180 { 0x03,
AA "10/FD, 10/HD" },
181 { 0x04,
AA "100/HD" },
182 { 0x05,
AA "100/HD, 10/HD" },
183 { 0x06,
AA "100/HD, 10/FD" },
184 { 0x07,
AA "100/HD, 10/FD, 10/HD" },
185 { 0x08,
AA "100/FD" },
186 { 0x09,
AA "100/FD, 10/HD" },
187 { 0x0a,
AA "100/FD, 10/FD" },
188 { 0x0b,
AA "100/FD, 10/FD, 10/HD" },
189 { 0x0c,
AA "100/FD, 100/HD" },
190 { 0x0d,
AA "100/FD, 100/HD, 10/HD" },
191 { 0x0e,
AA "100/FD, 100/HD, 10/FD" },
192 { 0x0f,
AA "100/FD, 100/HD, 10/FD, 10/HD" },
193 { 0x20,
AA "1000/FD" },
194 { 0x21,
AA "1000/FD, 10/HD" },
195 { 0x22,
AA "1000/FD, 10/FD" },
196 { 0x23,
AA "1000/FD, 10/FD, 10/HD" },
197 { 0x24,
AA "1000/FD, 100/HD" },
198 { 0x25,
AA "1000/FD, 100/HD, 10/HD" },
199 { 0x26,
AA "1000/FD, 100/HD, 10/FD" },
200 { 0x27,
AA "1000/FD, 100/HD, 10/FD, 10/HD" },
201 { 0x28,
AA "1000/FD, 100/FD" },
202 { 0x29,
AA "1000/FD, 100/FD, 10/HD" },
203 { 0x2a,
AA "1000/FD, 100/FD, 10/FD" },
204 { 0x2b,
AA "1000/FD, 100/FD, 10/FD, 10/HD" },
205 { 0x2c,
AA "1000/FD, 100/FD, 100/HD" },
206 { 0x2d,
AA "1000/FD, 100/FD, 100/HD, 10/HD" },
207 { 0x2e,
AA "1000/FD, 100/FD, 100/HD, 10/FD" },
208 { 0x2f,
AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }
211 static const struct pch_gbe_opt_list fc_list[] = {
227 static int pch_gbe_validate_option(
int *
value,
248 if (*value >= opt->
arg.
r.min && *value <= opt->
arg.r.max) {
255 const struct pch_gbe_opt_list *
ent;
257 for (i = 0; i < opt->
arg.
l.nr; i++) {
258 ent = &opt->
arg.
l.p[
i];
259 if (*value == ent->i) {
260 if (ent->str[0] !=
'\0')
271 pr_debug(
"Invalid %s value specified (%i) %s\n",
281 static void pch_gbe_check_copper_options(
struct pch_gbe_adapter *adapter)
290 .err =
"parameter ignored",
296 pch_gbe_validate_option(&speed, &opt, adapter);
302 .err =
"parameter ignored",
308 pch_gbe_validate_option(&dplx, &opt, adapter);
315 .err =
"parameter ignored",
321 pr_debug(
"AutoNeg specified along with Speed or Duplex, AutoNeg parameter ignored\n");
322 hw->
phy.autoneg_advertised = opt.
def;
326 pch_gbe_validate_option(&tmp, &opt, adapter);
327 hw->
phy.autoneg_advertised =
tmp;
331 switch (speed + dplx) {
333 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
335 pr_debug(
"Speed and duplex autonegotiation enabled\n");
340 pr_debug(
"Half Duplex specified without Speed\n");
341 pr_debug(
"Using Autonegotiation at Half Duplex only\n");
342 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
349 pr_debug(
"Full Duplex specified without Speed\n");
350 pr_debug(
"Using Autonegotiation at Full Duplex only\n");
351 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
359 pr_debug(
"10 Mbps Speed specified without Duplex\n");
360 pr_debug(
"Using Autonegotiation at 10 Mbps only\n");
361 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
368 pr_debug(
"Forcing to 10 Mbps Half Duplex\n");
369 hw->
mac.autoneg = hw->
mac.fc_autoneg = 0;
370 hw->
phy.autoneg_advertised = 0;
375 pr_debug(
"Forcing to 10 Mbps Full Duplex\n");
376 hw->
mac.autoneg = hw->
mac.fc_autoneg = 0;
377 hw->
phy.autoneg_advertised = 0;
382 pr_debug(
"100 Mbps Speed specified without Duplex\n");
383 pr_debug(
"Using Autonegotiation at 100 Mbps only\n");
384 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
391 pr_debug(
"Forcing to 100 Mbps Half Duplex\n");
392 hw->
mac.autoneg = hw->
mac.fc_autoneg = 0;
393 hw->
phy.autoneg_advertised = 0;
398 pr_debug(
"Forcing to 100 Mbps Full Duplex\n");
399 hw->
mac.autoneg = hw->
mac.fc_autoneg = 0;
400 hw->
phy.autoneg_advertised = 0;
405 pr_debug(
"1000 Mbps Speed specified without Duplex\n");
406 goto full_duplex_only;
408 pr_debug(
"Half Duplex is not supported at 1000 Mbps\n");
412 pr_debug(
"Using Autonegotiation at 1000 Mbps Full Duplex only\n");
413 hw->
mac.autoneg = hw->
mac.fc_autoneg = 1;
436 .name =
"Transmit Descriptors",
437 .err =
"using default of "
444 tx_ring->
count = TxDescriptors;
445 pch_gbe_validate_option(&tx_ring->
count, &opt, adapter);
452 .name =
"Receive Descriptors",
453 .err =
"using default of "
460 rx_ring->
count = RxDescriptors;
461 pch_gbe_validate_option(&rx_ring->
count, &opt, adapter);
468 .name =
"Checksum Offload",
469 .err =
"defaulting to Enabled",
473 pch_gbe_validate_option(&val, &opt, adapter);
480 .name =
"Checksum Offload",
481 .err =
"defaulting to Enabled",
485 pch_gbe_validate_option(&val, &opt, adapter);
492 .name =
"Flow Control",
493 .err =
"reading default settings from EEPROM",
500 pch_gbe_validate_option(&tmp, &opt, adapter);
504 pch_gbe_check_copper_options(adapter);