提交 1db2740d 编写于 作者: A Auke Kok 提交者: Auke Kok

e1000: Use module param array code

Use module param array code to distinguish between defaults and user
specified values.
Signed-off-by: NAuke Kok <auke-jan.h.kok@intel.com>
上级 e7b44117
...@@ -324,7 +324,6 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -324,7 +324,6 @@ e1000_check_options(struct e1000_adapter *adapter)
DPRINTK(PROBE, NOTICE, DPRINTK(PROBE, NOTICE,
"Warning: no configuration for board #%i\n", bd); "Warning: no configuration for board #%i\n", bd);
DPRINTK(PROBE, NOTICE, "Using defaults for all values\n"); DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
bd = E1000_MAX_NIC;
} }
{ /* Transmit Descriptor Count */ { /* Transmit Descriptor Count */
...@@ -342,9 +341,14 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -342,9 +341,14 @@ e1000_check_options(struct e1000_adapter *adapter)
opt.arg.r.max = mac_type < e1000_82544 ? opt.arg.r.max = mac_type < e1000_82544 ?
E1000_MAX_TXD : E1000_MAX_82544_TXD; E1000_MAX_TXD : E1000_MAX_82544_TXD;
if (num_TxDescriptors > bd) {
tx_ring->count = TxDescriptors[bd]; tx_ring->count = TxDescriptors[bd];
e1000_validate_option(&tx_ring->count, &opt, adapter); e1000_validate_option(&tx_ring->count, &opt, adapter);
E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE); E1000_ROUNDUP(tx_ring->count,
REQ_TX_DESCRIPTOR_MULTIPLE);
} else {
tx_ring->count = opt.def;
}
for (i = 0; i < adapter->num_tx_queues; i++) for (i = 0; i < adapter->num_tx_queues; i++)
tx_ring[i].count = tx_ring->count; tx_ring[i].count = tx_ring->count;
} }
...@@ -363,9 +367,14 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -363,9 +367,14 @@ e1000_check_options(struct e1000_adapter *adapter)
opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
E1000_MAX_82544_RXD; E1000_MAX_82544_RXD;
if (num_RxDescriptors > bd) {
rx_ring->count = RxDescriptors[bd]; rx_ring->count = RxDescriptors[bd];
e1000_validate_option(&rx_ring->count, &opt, adapter); e1000_validate_option(&rx_ring->count, &opt, adapter);
E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); E1000_ROUNDUP(rx_ring->count,
REQ_RX_DESCRIPTOR_MULTIPLE);
} else {
rx_ring->count = opt.def;
}
for (i = 0; i < adapter->num_rx_queues; i++) for (i = 0; i < adapter->num_rx_queues; i++)
rx_ring[i].count = rx_ring->count; rx_ring[i].count = rx_ring->count;
} }
...@@ -377,9 +386,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -377,9 +386,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
if (num_XsumRX > bd) {
int rx_csum = XsumRX[bd]; int rx_csum = XsumRX[bd];
e1000_validate_option(&rx_csum, &opt, adapter); e1000_validate_option(&rx_csum, &opt, adapter);
adapter->rx_csum = rx_csum; adapter->rx_csum = rx_csum;
} else {
adapter->rx_csum = opt.def;
}
} }
{ /* Flow Control */ { /* Flow Control */
...@@ -399,9 +412,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -399,9 +412,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.p = fc_list }} .p = fc_list }}
}; };
if (num_FlowControl > bd) {
int fc = FlowControl[bd]; int fc = FlowControl[bd];
e1000_validate_option(&fc, &opt, adapter); e1000_validate_option(&fc, &opt, adapter);
adapter->hw.fc = adapter->hw.original_fc = fc; adapter->hw.fc = adapter->hw.original_fc = fc;
} else {
adapter->hw.fc = adapter->hw.original_fc = opt.def;
}
} }
{ /* Transmit Interrupt Delay */ { /* Transmit Interrupt Delay */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -413,8 +430,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -413,8 +430,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.max = MAX_TXDELAY }} .max = MAX_TXDELAY }}
}; };
if (num_TxIntDelay > bd) {
adapter->tx_int_delay = TxIntDelay[bd]; adapter->tx_int_delay = TxIntDelay[bd];
e1000_validate_option(&adapter->tx_int_delay, &opt, adapter); e1000_validate_option(&adapter->tx_int_delay, &opt,
adapter);
} else {
adapter->tx_int_delay = opt.def;
}
} }
{ /* Transmit Absolute Interrupt Delay */ { /* Transmit Absolute Interrupt Delay */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -426,9 +448,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -426,9 +448,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.max = MAX_TXABSDELAY }} .max = MAX_TXABSDELAY }}
}; };
if (num_TxAbsIntDelay > bd) {
adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
e1000_validate_option(&adapter->tx_abs_int_delay, &opt, e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
adapter); adapter);
} else {
adapter->tx_abs_int_delay = opt.def;
}
} }
{ /* Receive Interrupt Delay */ { /* Receive Interrupt Delay */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -440,8 +466,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -440,8 +466,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.max = MAX_RXDELAY }} .max = MAX_RXDELAY }}
}; };
if (num_RxIntDelay > bd) {
adapter->rx_int_delay = RxIntDelay[bd]; adapter->rx_int_delay = RxIntDelay[bd];
e1000_validate_option(&adapter->rx_int_delay, &opt, adapter); e1000_validate_option(&adapter->rx_int_delay, &opt,
adapter);
} else {
adapter->rx_int_delay = opt.def;
}
} }
{ /* Receive Absolute Interrupt Delay */ { /* Receive Absolute Interrupt Delay */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -453,9 +484,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -453,9 +484,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.max = MAX_RXABSDELAY }} .max = MAX_RXABSDELAY }}
}; };
if (num_RxAbsIntDelay > bd) {
adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
e1000_validate_option(&adapter->rx_abs_int_delay, &opt, e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
adapter); adapter);
} else {
adapter->rx_abs_int_delay = opt.def;
}
} }
{ /* Interrupt Throttling Rate */ { /* Interrupt Throttling Rate */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -467,19 +502,25 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -467,19 +502,25 @@ e1000_check_options(struct e1000_adapter *adapter)
.max = MAX_ITR }} .max = MAX_ITR }}
}; };
if (num_InterruptThrottleRate > bd) {
adapter->itr = InterruptThrottleRate[bd]; adapter->itr = InterruptThrottleRate[bd];
switch (adapter->itr) { switch (adapter->itr) {
case 0: case 0:
DPRINTK(PROBE, INFO, "%s turned off\n", opt.name); DPRINTK(PROBE, INFO, "%s turned off\n",
opt.name);
break; break;
case 1: case 1:
DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
opt.name); opt.name);
break; break;
default: default:
e1000_validate_option(&adapter->itr, &opt, adapter); e1000_validate_option(&adapter->itr, &opt,
adapter);
break; break;
} }
} else {
adapter->itr = opt.def;
}
} }
{ /* Smart Power Down */ { /* Smart Power Down */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -489,9 +530,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -489,9 +530,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.def = OPTION_DISABLED .def = OPTION_DISABLED
}; };
if (num_SmartPowerDownEnable > bd) {
int spd = SmartPowerDownEnable[bd]; int spd = SmartPowerDownEnable[bd];
e1000_validate_option(&spd, &opt, adapter); e1000_validate_option(&spd, &opt, adapter);
adapter->smart_power_down = spd; adapter->smart_power_down = spd;
} else {
adapter->smart_power_down = opt.def;
}
} }
{ /* Kumeran Lock Loss Workaround */ { /* Kumeran Lock Loss Workaround */
struct e1000_option opt = { struct e1000_option opt = {
...@@ -501,9 +546,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -501,9 +546,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
if (num_KumeranLockLoss > bd) {
int kmrn_lock_loss = KumeranLockLoss[bd]; int kmrn_lock_loss = KumeranLockLoss[bd];
e1000_validate_option(&kmrn_lock_loss, &opt, adapter); e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss;
} else {
adapter->hw.kmrn_lock_loss_workaround_disabled = !opt.def;
}
} }
switch (adapter->hw.media_type) { switch (adapter->hw.media_type) {
...@@ -530,18 +579,17 @@ static void __devinit ...@@ -530,18 +579,17 @@ static void __devinit
e1000_check_fiber_options(struct e1000_adapter *adapter) e1000_check_fiber_options(struct e1000_adapter *adapter)
{ {
int bd = adapter->bd_number; int bd = adapter->bd_number;
bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd; if (num_Speed > bd) {
if ((Speed[bd] != OPTION_UNSET)) {
DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, " DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
"parameter ignored\n"); "parameter ignored\n");
} }
if ((Duplex[bd] != OPTION_UNSET)) { if (num_Duplex > bd) {
DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, " DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
"parameter ignored\n"); "parameter ignored\n");
} }
if ((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) { if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is " DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
"not valid for fiber adapters, " "not valid for fiber adapters, "
"parameter ignored\n"); "parameter ignored\n");
...@@ -560,7 +608,6 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -560,7 +608,6 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
{ {
int speed, dplx, an; int speed, dplx, an;
int bd = adapter->bd_number; int bd = adapter->bd_number;
bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
{ /* Speed */ { /* Speed */
struct e1000_opt_list speed_list[] = {{ 0, "" }, struct e1000_opt_list speed_list[] = {{ 0, "" },
...@@ -577,8 +624,12 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -577,8 +624,12 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
.p = speed_list }} .p = speed_list }}
}; };
if (num_Speed > bd) {
speed = Speed[bd]; speed = Speed[bd];
e1000_validate_option(&speed, &opt, adapter); e1000_validate_option(&speed, &opt, adapter);
} else {
speed = opt.def;
}
} }
{ /* Duplex */ { /* Duplex */
struct e1000_opt_list dplx_list[] = {{ 0, "" }, struct e1000_opt_list dplx_list[] = {{ 0, "" },
...@@ -600,11 +651,15 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -600,11 +651,15 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
"Speed/Duplex/AutoNeg parameter ignored.\n"); "Speed/Duplex/AutoNeg parameter ignored.\n");
return; return;
} }
if (num_Duplex > bd) {
dplx = Duplex[bd]; dplx = Duplex[bd];
e1000_validate_option(&dplx, &opt, adapter); e1000_validate_option(&dplx, &opt, adapter);
} else {
dplx = opt.def;
}
} }
if (AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) { if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
DPRINTK(PROBE, INFO, DPRINTK(PROBE, INFO,
"AutoNeg specified along with Speed or Duplex, " "AutoNeg specified along with Speed or Duplex, "
"parameter ignored\n"); "parameter ignored\n");
...@@ -653,15 +708,19 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -653,15 +708,19 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
.p = an_list }} .p = an_list }}
}; };
if (num_AutoNeg > bd) {
an = AutoNeg[bd]; an = AutoNeg[bd];
e1000_validate_option(&an, &opt, adapter); e1000_validate_option(&an, &opt, adapter);
} else {
an = opt.def;
}
adapter->hw.autoneg_advertised = an; adapter->hw.autoneg_advertised = an;
} }
switch (speed + dplx) { switch (speed + dplx) {
case 0: case 0:
adapter->hw.autoneg = adapter->fc_autoneg = 1; adapter->hw.autoneg = adapter->fc_autoneg = 1;
if (Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET) if ((num_Speed > bd) && (speed != 0 || dplx != 0))
DPRINTK(PROBE, INFO, DPRINTK(PROBE, INFO,
"Speed and duplex autonegotiation enabled\n"); "Speed and duplex autonegotiation enabled\n");
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册