aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChris Snook <csnook@redhat.com>2008-04-18 21:51:53 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-25 02:08:52 -0400
commit8ec7226a93dcd4a314e2387d1033aef01145061b (patch)
tree1819ab7d6e62e6d97e83272e02d50a7fab28802e /drivers
parent3b49f0354561aefc5235b8dd6ee4ae779a26e06b (diff)
[netdrvr] atlx: code movement: move atl1 parameter parsing
Move some code from atlx.c to atl1.c to prevent build conflict with the upcoming atl2 code. No changes, just movement. Signed-off-by: Chris Snook <csnook@redhat.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/atlx/atl1.c138
-rw-r--r--drivers/net/atlx/atlx.c138
2 files changed, 138 insertions, 138 deletions
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 5586fc624688..0afe522b8f7b 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -91,6 +91,144 @@
91#include "atlx.c" 91#include "atlx.c"
92 92
93/* 93/*
94 * This is the only thing that needs to be changed to adjust the
95 * maximum number of ports that the driver can manage.
96 */
97#define ATL1_MAX_NIC 4
98
99#define OPTION_UNSET -1
100#define OPTION_DISABLED 0
101#define OPTION_ENABLED 1
102
103#define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET }
104
105/*
106 * Interrupt Moderate Timer in units of 2 us
107 *
108 * Valid Range: 10-65535
109 *
110 * Default Value: 100 (200us)
111 */
112static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
113static int num_int_mod_timer;
114module_param_array_named(int_mod_timer, int_mod_timer, int,
115 &num_int_mod_timer, 0);
116MODULE_PARM_DESC(int_mod_timer, "Interrupt moderator timer");
117
118#define DEFAULT_INT_MOD_CNT 100 /* 200us */
119#define MAX_INT_MOD_CNT 65000
120#define MIN_INT_MOD_CNT 50
121
122struct atl1_option {
123 enum { enable_option, range_option, list_option } type;
124 char *name;
125 char *err;
126 int def;
127 union {
128 struct { /* range_option info */
129 int min;
130 int max;
131 } r;
132 struct { /* list_option info */
133 int nr;
134 struct atl1_opt_list {
135 int i;
136 char *str;
137 } *p;
138 } l;
139 } arg;
140};
141
142static int __devinit atl1_validate_option(int *value, struct atl1_option *opt,
143 struct pci_dev *pdev)
144{
145 if (*value == OPTION_UNSET) {
146 *value = opt->def;
147 return 0;
148 }
149
150 switch (opt->type) {
151 case enable_option:
152 switch (*value) {
153 case OPTION_ENABLED:
154 dev_info(&pdev->dev, "%s enabled\n", opt->name);
155 return 0;
156 case OPTION_DISABLED:
157 dev_info(&pdev->dev, "%s disabled\n", opt->name);
158 return 0;
159 }
160 break;
161 case range_option:
162 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
163 dev_info(&pdev->dev, "%s set to %i\n", opt->name,
164 *value);
165 return 0;
166 }
167 break;
168 case list_option:{
169 int i;
170 struct atl1_opt_list *ent;
171
172 for (i = 0; i < opt->arg.l.nr; i++) {
173 ent = &opt->arg.l.p[i];
174 if (*value == ent->i) {
175 if (ent->str[0] != '\0')
176 dev_info(&pdev->dev, "%s\n",
177 ent->str);
178 return 0;
179 }
180 }
181 }
182 break;
183
184 default:
185 break;
186 }
187
188 dev_info(&pdev->dev, "invalid %s specified (%i) %s\n",
189 opt->name, *value, opt->err);
190 *value = opt->def;
191 return -1;
192}
193
194/*
195 * atl1_check_options - Range Checking for Command Line Parameters
196 * @adapter: board private structure
197 *
198 * This routine checks all command line parameters for valid user
199 * input. If an invalid value is given, or if no user specified
200 * value exists, a default value is used. The final value is stored
201 * in a variable in the adapter structure.
202 */
203void __devinit atl1_check_options(struct atl1_adapter *adapter)
204{
205 struct pci_dev *pdev = adapter->pdev;
206 int bd = adapter->bd_number;
207 if (bd >= ATL1_MAX_NIC) {
208 dev_notice(&pdev->dev, "no configuration for board#%i\n", bd);
209 dev_notice(&pdev->dev, "using defaults for all values\n");
210 }
211 { /* Interrupt Moderate Timer */
212 struct atl1_option opt = {
213 .type = range_option,
214 .name = "Interrupt Moderator Timer",
215 .err = "using default of "
216 __MODULE_STRING(DEFAULT_INT_MOD_CNT),
217 .def = DEFAULT_INT_MOD_CNT,
218 .arg = {.r = {.min = MIN_INT_MOD_CNT,
219 .max = MAX_INT_MOD_CNT} }
220 };
221 int val;
222 if (num_int_mod_timer > bd) {
223 val = int_mod_timer[bd];
224 atl1_validate_option(&val, &opt, pdev);
225 adapter->imt = (u16) val;
226 } else
227 adapter->imt = (u16) (opt.def);
228 }
229}
230
231/*
94 * atl1_pci_tbl - PCI Device ID Table 232 * atl1_pci_tbl - PCI Device ID Table
95 */ 233 */
96static const struct pci_device_id atl1_pci_tbl[] = { 234static const struct pci_device_id atl1_pci_tbl[] = {
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c
index b7bf70ef3b63..f06b854e2501 100644
--- a/drivers/net/atlx/atlx.c
+++ b/drivers/net/atlx/atlx.c
@@ -253,142 +253,4 @@ static void atlx_restore_vlan(struct atlx_adapter *adapter)
253 atlx_vlan_rx_register(adapter->netdev, adapter->vlgrp); 253 atlx_vlan_rx_register(adapter->netdev, adapter->vlgrp);
254} 254}
255 255
256/*
257 * This is the only thing that needs to be changed to adjust the
258 * maximum number of ports that the driver can manage.
259 */
260#define ATL1_MAX_NIC 4
261
262#define OPTION_UNSET -1
263#define OPTION_DISABLED 0
264#define OPTION_ENABLED 1
265
266#define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET }
267
268/*
269 * Interrupt Moderate Timer in units of 2 us
270 *
271 * Valid Range: 10-65535
272 *
273 * Default Value: 100 (200us)
274 */
275static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
276static int num_int_mod_timer;
277module_param_array_named(int_mod_timer, int_mod_timer, int,
278 &num_int_mod_timer, 0);
279MODULE_PARM_DESC(int_mod_timer, "Interrupt moderator timer");
280
281#define DEFAULT_INT_MOD_CNT 100 /* 200us */
282#define MAX_INT_MOD_CNT 65000
283#define MIN_INT_MOD_CNT 50
284
285struct atl1_option {
286 enum { enable_option, range_option, list_option } type;
287 char *name;
288 char *err;
289 int def;
290 union {
291 struct { /* range_option info */
292 int min;
293 int max;
294 } r;
295 struct { /* list_option info */
296 int nr;
297 struct atl1_opt_list {
298 int i;
299 char *str;
300 } *p;
301 } l;
302 } arg;
303};
304
305static int __devinit atl1_validate_option(int *value, struct atl1_option *opt,
306 struct pci_dev *pdev)
307{
308 if (*value == OPTION_UNSET) {
309 *value = opt->def;
310 return 0;
311 }
312
313 switch (opt->type) {
314 case enable_option:
315 switch (*value) {
316 case OPTION_ENABLED:
317 dev_info(&pdev->dev, "%s enabled\n", opt->name);
318 return 0;
319 case OPTION_DISABLED:
320 dev_info(&pdev->dev, "%s disabled\n", opt->name);
321 return 0;
322 }
323 break;
324 case range_option:
325 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
326 dev_info(&pdev->dev, "%s set to %i\n", opt->name,
327 *value);
328 return 0;
329 }
330 break;
331 case list_option:{
332 int i;
333 struct atl1_opt_list *ent;
334
335 for (i = 0; i < opt->arg.l.nr; i++) {
336 ent = &opt->arg.l.p[i];
337 if (*value == ent->i) {
338 if (ent->str[0] != '\0')
339 dev_info(&pdev->dev, "%s\n",
340 ent->str);
341 return 0;
342 }
343 }
344 }
345 break;
346
347 default:
348 break;
349 }
350
351 dev_info(&pdev->dev, "invalid %s specified (%i) %s\n",
352 opt->name, *value, opt->err);
353 *value = opt->def;
354 return -1;
355}
356
357/*
358 * atl1_check_options - Range Checking for Command Line Parameters
359 * @adapter: board private structure
360 *
361 * This routine checks all command line parameters for valid user
362 * input. If an invalid value is given, or if no user specified
363 * value exists, a default value is used. The final value is stored
364 * in a variable in the adapter structure.
365 */
366void __devinit atl1_check_options(struct atl1_adapter *adapter)
367{
368 struct pci_dev *pdev = adapter->pdev;
369 int bd = adapter->bd_number;
370 if (bd >= ATL1_MAX_NIC) {
371 dev_notice(&pdev->dev, "no configuration for board#%i\n", bd);
372 dev_notice(&pdev->dev, "using defaults for all values\n");
373 }
374 { /* Interrupt Moderate Timer */
375 struct atl1_option opt = {
376 .type = range_option,
377 .name = "Interrupt Moderator Timer",
378 .err = "using default of "
379 __MODULE_STRING(DEFAULT_INT_MOD_CNT),
380 .def = DEFAULT_INT_MOD_CNT,
381 .arg = {.r = {.min = MIN_INT_MOD_CNT,
382 .max = MAX_INT_MOD_CNT} }
383 };
384 int val;
385 if (num_int_mod_timer > bd) {
386 val = int_mod_timer[bd];
387 atl1_validate_option(&val, &opt, pdev);
388 adapter->imt = (u16) val;
389 } else
390 adapter->imt = (u16) (opt.def);
391 }
392}
393
394#endif /* ATLX_C */ 256#endif /* ATLX_C */