diff options
author | Chris Snook <csnook@redhat.com> | 2008-04-18 21:51:53 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-25 02:08:52 -0400 |
commit | 8ec7226a93dcd4a314e2387d1033aef01145061b (patch) | |
tree | 1819ab7d6e62e6d97e83272e02d50a7fab28802e /drivers/net/atlx/atlx.c | |
parent | 3b49f0354561aefc5235b8dd6ee4ae779a26e06b (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/net/atlx/atlx.c')
-rw-r--r-- | drivers/net/atlx/atlx.c | 138 |
1 files changed, 0 insertions, 138 deletions
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 | */ | ||
275 | static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT; | ||
276 | static int num_int_mod_timer; | ||
277 | module_param_array_named(int_mod_timer, int_mod_timer, int, | ||
278 | &num_int_mod_timer, 0); | ||
279 | MODULE_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 | |||
285 | struct 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 | |||
305 | static 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 | */ | ||
366 | void __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 */ |