Commit 78a55412 authored by Ganesh Venkatesan's avatar Ganesh Venkatesan Committed by Jeff Garzik

[PATCH] ixgb: Support for 2.6.x style module parameters

Signed-off-by: default avatarGanesh Venkatesan <ganesh.venkatesan@intel.com>
parent ed14df08
...@@ -34,31 +34,21 @@ ...@@ -34,31 +34,21 @@
#define IXGB_MAX_NIC 8 #define IXGB_MAX_NIC 8
#define OPTION_UNSET -1 #define OPTION_UNSET -1
#define OPTION_DISABLED 0 #define OPTION_DISABLED 0
#define OPTION_ENABLED 1 #define OPTION_ENABLED 1
/* Module Parameters are always initialized to -1, so that the driver
* can tell the difference between no user specified value or the
* user asking for the default value.
* The true default values are loaded in when ixgb_check_options is called.
*
* This is a GCC extension to ANSI C.
* See the item "Labeled Elements in Initializers" in the section
* "Extensions to the C Language Family" of the GCC documentation.
*/
#define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
/* All parameters are treated the same, as an integer array of values. /* All parameters are treated the same, as an integer array of values.
* This macro just reduces the need to repeat the same declaration code * This macro just reduces the need to repeat the same declaration code
* over and over (plus this helps to avoid typo bugs). * over and over (plus this helps to avoid typo bugs).
*/ */
#define IXGB_PARAM(X, S) \ #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
static const int __devinitdata X[IXGB_MAX_NIC + 1] = IXGB_PARAM_INIT; \ #define IXGB_PARAM(X, desc) \
MODULE_PARM(X, "1-" __MODULE_STRING(IXGB_MAX_NIC) "i"); \ static int __devinitdata X[IXGB_MAX_NIC+1] = IXGB_PARAM_INIT; \
MODULE_PARM_DESC(X, S); static int num_##X = 0; \
module_param_array_named(X, X, int, &num_##X, 0); \
MODULE_PARM_DESC(X, desc);
/* Transmit Descriptor Count /* Transmit Descriptor Count
* *
...@@ -290,8 +280,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -290,8 +280,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
}; };
struct ixgb_desc_ring *tx_ring = &adapter->tx_ring; struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
tx_ring->count = TxDescriptors[bd]; if(num_TxDescriptors > bd) {
ixgb_validate_option(&tx_ring->count, &opt); tx_ring->count = TxDescriptors[bd];
ixgb_validate_option(&tx_ring->count, &opt);
} else {
tx_ring->count = opt.def;
}
IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
} }
{ /* Receive Descriptor Count */ { /* Receive Descriptor Count */
...@@ -305,8 +299,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -305,8 +299,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
}; };
struct ixgb_desc_ring *rx_ring = &adapter->rx_ring; struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
rx_ring->count = RxDescriptors[bd]; if(num_RxDescriptors > bd) {
ixgb_validate_option(&rx_ring->count, &opt); rx_ring->count = RxDescriptors[bd];
ixgb_validate_option(&rx_ring->count, &opt);
} else {
rx_ring->count = opt.def;
}
IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
} }
{ /* Receive Checksum Offload Enable */ { /* Receive Checksum Offload Enable */
...@@ -317,9 +315,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -317,9 +315,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
int rx_csum = XsumRX[bd]; if(num_XsumRX > bd) {
ixgb_validate_option(&rx_csum, &opt); int rx_csum = XsumRX[bd];
adapter->rx_csum = rx_csum; ixgb_validate_option(&rx_csum, &opt);
adapter->rx_csum = rx_csum;
} else {
adapter->rx_csum = opt.def;
}
} }
{ /* Flow Control */ { /* Flow Control */
...@@ -340,9 +342,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -340,9 +342,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.p = fc_list}} .p = fc_list}}
}; };
int fc = FlowControl[bd]; if(num_FlowControl > bd) {
ixgb_validate_option(&fc, &opt); int fc = FlowControl[bd];
adapter->hw.fc.type = fc; ixgb_validate_option(&fc, &opt);
adapter->hw.fc.type = fc;
} else {
adapter->hw.fc.type = opt.def;
}
} }
{ /* Receive Flow Control High Threshold */ { /* Receive Flow Control High Threshold */
struct ixgb_option opt = { struct ixgb_option opt = {
...@@ -355,11 +361,15 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -355,11 +361,15 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.max = MAX_FCRTH}} .max = MAX_FCRTH}}
}; };
adapter->hw.fc.high_water = RxFCHighThresh[bd]; if(num_RxFCHighThresh > bd) {
ixgb_validate_option(&adapter->hw.fc.high_water, &opt); adapter->hw.fc.high_water = RxFCHighThresh[bd];
if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
printk(KERN_INFO } else {
"Ignoring RxFCHighThresh when no RxFC\n"); adapter->hw.fc.high_water = opt.def;
}
if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
printk (KERN_INFO
"Ignoring RxFCHighThresh when no RxFC\n");
} }
{ /* Receive Flow Control Low Threshold */ { /* Receive Flow Control Low Threshold */
struct ixgb_option opt = { struct ixgb_option opt = {
...@@ -372,11 +382,15 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -372,11 +382,15 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.max = MAX_FCRTL}} .max = MAX_FCRTL}}
}; };
adapter->hw.fc.low_water = RxFCLowThresh[bd]; if(num_RxFCLowThresh > bd) {
ixgb_validate_option(&adapter->hw.fc.low_water, &opt); adapter->hw.fc.low_water = RxFCLowThresh[bd];
if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) ixgb_validate_option(&adapter->hw.fc.low_water, &opt);
printk(KERN_INFO } else {
"Ignoring RxFCLowThresh when no RxFC\n"); adapter->hw.fc.low_water = opt.def;
}
if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
printk (KERN_INFO
"Ignoring RxFCLowThresh when no RxFC\n");
} }
{ /* Flow Control Pause Time Request */ { /* Flow Control Pause Time Request */
struct ixgb_option opt = { struct ixgb_option opt = {
...@@ -390,13 +404,16 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -390,13 +404,16 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.max = MAX_FCPAUSE}} .max = MAX_FCPAUSE}}
}; };
int pause_time = FCReqTimeout[bd]; if(num_FCReqTimeout > bd) {
int pause_time = FCReqTimeout[bd];
ixgb_validate_option(&pause_time, &opt); ixgb_validate_option(&pause_time, &opt);
if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) adapter->hw.fc.pause_time = pause_time;
printk(KERN_INFO } else {
"Ignoring FCReqTimeout when no RxFC\n"); adapter->hw.fc.pause_time = opt.def;
adapter->hw.fc.pause_time = pause_time; }
if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
printk (KERN_INFO
"Ignoring FCReqTimeout when no RxFC\n");
} }
/* high low and spacing check for rx flow control thresholds */ /* high low and spacing check for rx flow control thresholds */
if (adapter->hw.fc.type & ixgb_fc_rx_pause) { if (adapter->hw.fc.type & ixgb_fc_rx_pause) {
...@@ -421,8 +438,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -421,8 +438,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.max = MAX_RDTR}} .max = MAX_RDTR}}
}; };
adapter->rx_int_delay = RxIntDelay[bd]; if(num_RxIntDelay > bd) {
ixgb_validate_option(&adapter->rx_int_delay, &opt); adapter->rx_int_delay = RxIntDelay[bd];
ixgb_validate_option(&adapter->rx_int_delay, &opt);
} else {
adapter->rx_int_delay = opt.def;
}
} }
{ /* Transmit Interrupt Delay */ { /* Transmit Interrupt Delay */
struct ixgb_option opt = { struct ixgb_option opt = {
...@@ -435,8 +456,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -435,8 +456,12 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.max = MAX_TIDV}} .max = MAX_TIDV}}
}; };
adapter->tx_int_delay = TxIntDelay[bd]; if(num_TxIntDelay > bd) {
ixgb_validate_option(&adapter->tx_int_delay, &opt); adapter->tx_int_delay = TxIntDelay[bd];
ixgb_validate_option(&adapter->tx_int_delay, &opt);
} else {
adapter->tx_int_delay = opt.def;
}
} }
{ /* Transmit Interrupt Delay Enable */ { /* Transmit Interrupt Delay Enable */
...@@ -446,9 +471,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter) ...@@ -446,9 +471,13 @@ void __devinit ixgb_check_options(struct ixgb_adapter *adapter)
.err = "defaulting to Enabled", .err = "defaulting to Enabled",
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
int ide = IntDelayEnable[bd];
ixgb_validate_option(&ide, &opt); if(num_IntDelayEnable > bd) {
adapter->tx_int_delay_enable = ide; int ide = IntDelayEnable[bd];
ixgb_validate_option(&ide, &opt);
adapter->tx_int_delay_enable = ide;
} else {
adapter->tx_int_delay_enable = opt.def;
}
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment