aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas/main.c')
-rw-r--r--drivers/net/wireless/libertas/main.c144
1 files changed, 82 insertions, 62 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 8f3e661db986..84fb49ca0fae 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -388,6 +388,8 @@ static int lbs_dev_open(struct net_device *dev)
388 struct lbs_private *priv = (struct lbs_private *) dev->priv ; 388 struct lbs_private *priv = (struct lbs_private *) dev->priv ;
389 int ret = 0; 389 int ret = 0;
390 390
391 lbs_deb_enter(LBS_DEB_NET);
392
391 spin_lock_irq(&priv->driver_lock); 393 spin_lock_irq(&priv->driver_lock);
392 394
393 if (priv->monitormode != LBS_MONITOR_OFF) { 395 if (priv->monitormode != LBS_MONITOR_OFF) {
@@ -413,6 +415,7 @@ static int lbs_dev_open(struct net_device *dev)
413 out: 415 out:
414 416
415 spin_unlock_irq(&priv->driver_lock); 417 spin_unlock_irq(&priv->driver_lock);
418 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
416 return ret; 419 return ret;
417} 420}
418 421
@@ -426,6 +429,7 @@ static int lbs_mesh_stop(struct net_device *dev)
426{ 429{
427 struct lbs_private *priv = (struct lbs_private *) (dev->priv); 430 struct lbs_private *priv = (struct lbs_private *) (dev->priv);
428 431
432 lbs_deb_enter(LBS_DEB_MESH);
429 spin_lock_irq(&priv->driver_lock); 433 spin_lock_irq(&priv->driver_lock);
430 434
431 priv->mesh_open = 0; 435 priv->mesh_open = 0;
@@ -435,6 +439,8 @@ static int lbs_mesh_stop(struct net_device *dev)
435 netif_carrier_off(dev); 439 netif_carrier_off(dev);
436 440
437 spin_unlock_irq(&priv->driver_lock); 441 spin_unlock_irq(&priv->driver_lock);
442
443 lbs_deb_leave(LBS_DEB_MESH);
438 return 0; 444 return 0;
439} 445}
440 446
@@ -448,13 +454,14 @@ static int lbs_eth_stop(struct net_device *dev)
448{ 454{
449 struct lbs_private *priv = (struct lbs_private *) dev->priv; 455 struct lbs_private *priv = (struct lbs_private *) dev->priv;
450 456
451 spin_lock_irq(&priv->driver_lock); 457 lbs_deb_enter(LBS_DEB_NET);
452 458
459 spin_lock_irq(&priv->driver_lock);
453 priv->infra_open = 0; 460 priv->infra_open = 0;
454
455 netif_stop_queue(dev); 461 netif_stop_queue(dev);
456
457 spin_unlock_irq(&priv->driver_lock); 462 spin_unlock_irq(&priv->driver_lock);
463
464 lbs_deb_leave(LBS_DEB_NET);
458 return 0; 465 return 0;
459} 466}
460 467
@@ -490,6 +497,8 @@ void lbs_host_to_card_done(struct lbs_private *priv)
490{ 497{
491 unsigned long flags; 498 unsigned long flags;
492 499
500 lbs_deb_enter(LBS_DEB_THREAD);
501
493 spin_lock_irqsave(&priv->driver_lock, flags); 502 spin_lock_irqsave(&priv->driver_lock, flags);
494 503
495 priv->dnld_sent = DNLD_RES_RECEIVED; 504 priv->dnld_sent = DNLD_RES_RECEIVED;
@@ -499,6 +508,7 @@ void lbs_host_to_card_done(struct lbs_private *priv)
499 wake_up_interruptible(&priv->waitq); 508 wake_up_interruptible(&priv->waitq);
500 509
501 spin_unlock_irqrestore(&priv->driver_lock, flags); 510 spin_unlock_irqrestore(&priv->driver_lock, flags);
511 lbs_deb_leave(LBS_DEB_THREAD);
502} 512}
503EXPORT_SYMBOL_GPL(lbs_host_to_card_done); 513EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
504 514
@@ -512,6 +522,7 @@ static struct net_device_stats *lbs_get_stats(struct net_device *dev)
512{ 522{
513 struct lbs_private *priv = (struct lbs_private *) dev->priv; 523 struct lbs_private *priv = (struct lbs_private *) dev->priv;
514 524
525 lbs_deb_enter(LBS_DEB_NET);
515 return &priv->stats; 526 return &priv->stats;
516} 527}
517 528
@@ -564,9 +575,7 @@ static int lbs_copy_multicast_address(struct lbs_private *priv,
564 memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN); 575 memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN);
565 mcptr = mcptr->next; 576 mcptr = mcptr->next;
566 } 577 }
567
568 return i; 578 return i;
569
570} 579}
571 580
572static void lbs_set_multicast_list(struct net_device *dev) 581static void lbs_set_multicast_list(struct net_device *dev)
@@ -620,7 +629,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
620 dev->mc_count); 629 dev->mc_count);
621 630
622 for (i = 0; i < dev->mc_count; i++) { 631 for (i = 0; i < dev->mc_count; i++) {
623 lbs_deb_net("Multicast address %d:%s\n", 632 lbs_deb_net("Multicast address %d: %s\n",
624 i, print_mac(mac, 633 i, print_mac(mac,
625 priv->multicastlist[i])); 634 priv->multicastlist[i]));
626 } 635 }
@@ -857,22 +866,24 @@ static int lbs_thread(void *data)
857static int lbs_suspend_callback(struct lbs_private *priv, unsigned long dummy, 866static int lbs_suspend_callback(struct lbs_private *priv, unsigned long dummy,
858 struct cmd_header *cmd) 867 struct cmd_header *cmd)
859{ 868{
860 lbs_deb_fw("HOST_SLEEP_ACTIVATE succeeded\n"); 869 lbs_deb_enter(LBS_DEB_FW);
861 870
862 netif_device_detach(priv->dev); 871 netif_device_detach(priv->dev);
863 if (priv->mesh_dev) 872 if (priv->mesh_dev)
864 netif_device_detach(priv->mesh_dev); 873 netif_device_detach(priv->mesh_dev);
865 874
866 priv->fw_ready = 0; 875 priv->fw_ready = 0;
876 lbs_deb_leave(LBS_DEB_FW);
867 return 0; 877 return 0;
868} 878}
869 879
870
871int lbs_suspend(struct lbs_private *priv) 880int lbs_suspend(struct lbs_private *priv)
872{ 881{
873 struct cmd_header cmd; 882 struct cmd_header cmd;
874 int ret; 883 int ret;
875 884
885 lbs_deb_enter(LBS_DEB_FW);
886
876 if (priv->wol_criteria == 0xffffffff) { 887 if (priv->wol_criteria == 0xffffffff) {
877 lbs_pr_info("Suspend attempt without configuring wake params!\n"); 888 lbs_pr_info("Suspend attempt without configuring wake params!\n");
878 return -EINVAL; 889 return -EINVAL;
@@ -885,12 +896,15 @@ int lbs_suspend(struct lbs_private *priv)
885 if (ret) 896 if (ret)
886 lbs_pr_info("HOST_SLEEP_ACTIVATE failed: %d\n", ret); 897 lbs_pr_info("HOST_SLEEP_ACTIVATE failed: %d\n", ret);
887 898
899 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
888 return ret; 900 return ret;
889} 901}
890EXPORT_SYMBOL_GPL(lbs_suspend); 902EXPORT_SYMBOL_GPL(lbs_suspend);
891 903
892int lbs_resume(struct lbs_private *priv) 904int lbs_resume(struct lbs_private *priv)
893{ 905{
906 lbs_deb_enter(LBS_DEB_FW);
907
894 priv->fw_ready = 1; 908 priv->fw_ready = 1;
895 909
896 /* Firmware doesn't seem to give us RX packets any more 910 /* Firmware doesn't seem to give us RX packets any more
@@ -902,6 +916,7 @@ int lbs_resume(struct lbs_private *priv)
902 if (priv->mesh_dev) 916 if (priv->mesh_dev)
903 netif_device_attach(priv->mesh_dev); 917 netif_device_attach(priv->mesh_dev);
904 918
919 lbs_deb_leave(LBS_DEB_FW);
905 return 0; 920 return 0;
906} 921}
907EXPORT_SYMBOL_GPL(lbs_resume); 922EXPORT_SYMBOL_GPL(lbs_resume);
@@ -953,6 +968,7 @@ static void command_timer_fn(unsigned long data)
953 struct lbs_private *priv = (struct lbs_private *)data; 968 struct lbs_private *priv = (struct lbs_private *)data;
954 unsigned long flags; 969 unsigned long flags;
955 970
971 lbs_deb_enter(LBS_DEB_CMD);
956 spin_lock_irqsave(&priv->driver_lock, flags); 972 spin_lock_irqsave(&priv->driver_lock, flags);
957 973
958 if (!priv->cur_cmd) { 974 if (!priv->cur_cmd) {
@@ -964,8 +980,9 @@ static void command_timer_fn(unsigned long data)
964 980
965 priv->cmd_timed_out = 1; 981 priv->cmd_timed_out = 1;
966 wake_up_interruptible(&priv->waitq); 982 wake_up_interruptible(&priv->waitq);
967 out: 983out:
968 spin_unlock_irqrestore(&priv->driver_lock, flags); 984 spin_unlock_irqrestore(&priv->driver_lock, flags);
985 lbs_deb_leave(LBS_DEB_CMD);
969} 986}
970 987
971static int lbs_init_adapter(struct lbs_private *priv) 988static int lbs_init_adapter(struct lbs_private *priv)
@@ -973,6 +990,8 @@ static int lbs_init_adapter(struct lbs_private *priv)
973 size_t bufsize; 990 size_t bufsize;
974 int i, ret = 0; 991 int i, ret = 0;
975 992
993 lbs_deb_enter(LBS_DEB_MAIN);
994
976 /* Allocate buffer to store the BSSID list */ 995 /* Allocate buffer to store the BSSID list */
977 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor); 996 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
978 priv->networks = kzalloc(bufsize, GFP_KERNEL); 997 priv->networks = kzalloc(bufsize, GFP_KERNEL);
@@ -1015,7 +1034,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
1015 mutex_init(&priv->lock); 1034 mutex_init(&priv->lock);
1016 1035
1017 setup_timer(&priv->command_timer, command_timer_fn, 1036 setup_timer(&priv->command_timer, command_timer_fn,
1018 (unsigned long)priv); 1037 (unsigned long)priv);
1019 1038
1020 INIT_LIST_HEAD(&priv->cmdfreeq); 1039 INIT_LIST_HEAD(&priv->cmdfreeq);
1021 INIT_LIST_HEAD(&priv->cmdpendingq); 1040 INIT_LIST_HEAD(&priv->cmdpendingq);
@@ -1030,20 +1049,21 @@ static int lbs_init_adapter(struct lbs_private *priv)
1030 } 1049 }
1031 1050
1032out: 1051out:
1052 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1053
1033 return ret; 1054 return ret;
1034} 1055}
1035 1056
1036static void lbs_free_adapter(struct lbs_private *priv) 1057static void lbs_free_adapter(struct lbs_private *priv)
1037{ 1058{
1038 lbs_deb_fw("free command buffer\n"); 1059 lbs_deb_enter(LBS_DEB_MAIN);
1039 lbs_free_cmd_buffer(priv);
1040 1060
1041 lbs_deb_fw("free command_timer\n"); 1061 lbs_free_cmd_buffer(priv);
1042 del_timer(&priv->command_timer); 1062 del_timer(&priv->command_timer);
1043
1044 lbs_deb_fw("free scan results table\n");
1045 kfree(priv->networks); 1063 kfree(priv->networks);
1046 priv->networks = NULL; 1064 priv->networks = NULL;
1065
1066 lbs_deb_leave(LBS_DEB_MAIN);
1047} 1067}
1048 1068
1049/** 1069/**
@@ -1058,7 +1078,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1058 struct net_device *dev = NULL; 1078 struct net_device *dev = NULL;
1059 struct lbs_private *priv = NULL; 1079 struct lbs_private *priv = NULL;
1060 1080
1061 lbs_deb_enter(LBS_DEB_NET); 1081 lbs_deb_enter(LBS_DEB_MAIN);
1062 1082
1063 /* Allocate an Ethernet device and register it */ 1083 /* Allocate an Ethernet device and register it */
1064 dev = alloc_etherdev(sizeof(struct lbs_private)); 1084 dev = alloc_etherdev(sizeof(struct lbs_private));
@@ -1124,7 +1144,7 @@ err_init_adapter:
1124 priv = NULL; 1144 priv = NULL;
1125 1145
1126done: 1146done:
1127 lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); 1147 lbs_deb_leave_args(LBS_DEB_MAIN, "priv %p", priv);
1128 return priv; 1148 return priv;
1129} 1149}
1130EXPORT_SYMBOL_GPL(lbs_add_card); 1150EXPORT_SYMBOL_GPL(lbs_add_card);
@@ -1338,26 +1358,19 @@ static void lbs_remove_mesh(struct lbs_private *priv)
1338{ 1358{
1339 struct net_device *mesh_dev; 1359 struct net_device *mesh_dev;
1340 1360
1341 lbs_deb_enter(LBS_DEB_MAIN);
1342
1343 if (!priv)
1344 goto out;
1345 1361
1346 mesh_dev = priv->mesh_dev; 1362 mesh_dev = priv->mesh_dev;
1347 if (!mesh_dev) 1363 if (!mesh_dev)
1348 goto out; 1364 return;
1349 1365
1366 lbs_deb_enter(LBS_DEB_MESH);
1350 netif_stop_queue(mesh_dev); 1367 netif_stop_queue(mesh_dev);
1351 netif_carrier_off(priv->mesh_dev); 1368 netif_carrier_off(priv->mesh_dev);
1352
1353 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); 1369 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1354 unregister_netdev(mesh_dev); 1370 unregister_netdev(mesh_dev);
1355
1356 priv->mesh_dev = NULL; 1371 priv->mesh_dev = NULL;
1357 free_netdev(mesh_dev); 1372 free_netdev(mesh_dev);
1358 1373 lbs_deb_leave(LBS_DEB_MESH);
1359out:
1360 lbs_deb_leave(LBS_DEB_MAIN);
1361} 1374}
1362EXPORT_SYMBOL_GPL(lbs_remove_mesh); 1375EXPORT_SYMBOL_GPL(lbs_remove_mesh);
1363 1376
@@ -1404,22 +1417,20 @@ int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
1404 1417
1405 memset(priv->region_channel, 0, sizeof(priv->region_channel)); 1418 memset(priv->region_channel, 0, sizeof(priv->region_channel));
1406 1419
1407 { 1420 cfp = lbs_get_region_cfp_table(region, band, &cfp_no);
1408 cfp = lbs_get_region_cfp_table(region, band, &cfp_no); 1421 if (cfp != NULL) {
1409 if (cfp != NULL) { 1422 priv->region_channel[i].nrcfp = cfp_no;
1410 priv->region_channel[i].nrcfp = cfp_no; 1423 priv->region_channel[i].CFP = cfp;
1411 priv->region_channel[i].CFP = cfp; 1424 } else {
1412 } else { 1425 lbs_deb_main("wrong region code %#x in band B/G\n",
1413 lbs_deb_main("wrong region code %#x in band B/G\n", 1426 region);
1414 region); 1427 ret = -1;
1415 ret = -1; 1428 goto out;
1416 goto out;
1417 }
1418 priv->region_channel[i].valid = 1;
1419 priv->region_channel[i].region = region;
1420 priv->region_channel[i].band = band;
1421 i++;
1422 } 1429 }
1430 priv->region_channel[i].valid = 1;
1431 priv->region_channel[i].region = region;
1432 priv->region_channel[i].band = band;
1433 i++;
1423out: 1434out:
1424 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); 1435 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1425 return ret; 1436 return ret;
@@ -1438,12 +1449,9 @@ void lbs_interrupt(struct lbs_private *priv)
1438 lbs_deb_enter(LBS_DEB_THREAD); 1449 lbs_deb_enter(LBS_DEB_THREAD);
1439 1450
1440 lbs_deb_thread("lbs_interrupt: intcounter=%d\n", priv->intcounter); 1451 lbs_deb_thread("lbs_interrupt: intcounter=%d\n", priv->intcounter);
1441
1442 priv->intcounter++; 1452 priv->intcounter++;
1443
1444 if (priv->psstate == PS_STATE_SLEEP) 1453 if (priv->psstate == PS_STATE_SLEEP)
1445 priv->psstate = PS_STATE_AWAKE; 1454 priv->psstate = PS_STATE_AWAKE;
1446
1447 wake_up_interruptible(&priv->waitq); 1455 wake_up_interruptible(&priv->waitq);
1448 1456
1449 lbs_deb_leave(LBS_DEB_THREAD); 1457 lbs_deb_leave(LBS_DEB_THREAD);
@@ -1475,9 +1483,7 @@ static int __init lbs_init_module(void)
1475static void __exit lbs_exit_module(void) 1483static void __exit lbs_exit_module(void)
1476{ 1484{
1477 lbs_deb_enter(LBS_DEB_MAIN); 1485 lbs_deb_enter(LBS_DEB_MAIN);
1478
1479 lbs_debugfs_remove(); 1486 lbs_debugfs_remove();
1480
1481 lbs_deb_leave(LBS_DEB_MAIN); 1487 lbs_deb_leave(LBS_DEB_MAIN);
1482} 1488}
1483 1489
@@ -1488,49 +1494,61 @@ static void __exit lbs_exit_module(void)
1488static int lbs_rtap_open(struct net_device *dev) 1494static int lbs_rtap_open(struct net_device *dev)
1489{ 1495{
1490 /* Yes, _stop_ the queue. Because we don't support injection */ 1496 /* Yes, _stop_ the queue. Because we don't support injection */
1491 netif_carrier_off(dev); 1497 lbs_deb_enter(LBS_DEB_MAIN);
1492 netif_stop_queue(dev); 1498 netif_carrier_off(dev);
1493 return 0; 1499 netif_stop_queue(dev);
1500 lbs_deb_leave(LBS_DEB_LEAVE);
1501 return 0;
1494} 1502}
1495 1503
1496static int lbs_rtap_stop(struct net_device *dev) 1504static int lbs_rtap_stop(struct net_device *dev)
1497{ 1505{
1498 return 0; 1506 lbs_deb_enter(LBS_DEB_MAIN);
1507 lbs_deb_leave(LBS_DEB_MAIN);
1508 return 0;
1499} 1509}
1500 1510
1501static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 1511static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1502{ 1512{
1503 netif_stop_queue(dev); 1513 netif_stop_queue(dev);
1504 return NETDEV_TX_BUSY; 1514 return NETDEV_TX_BUSY;
1505} 1515}
1506 1516
1507static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev) 1517static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev)
1508{ 1518{
1509 struct lbs_private *priv = dev->priv; 1519 struct lbs_private *priv = dev->priv;
1520 lbs_deb_enter(LBS_DEB_NET);
1510 return &priv->stats; 1521 return &priv->stats;
1511} 1522}
1512 1523
1513 1524
1514static void lbs_remove_rtap(struct lbs_private *priv) 1525static void lbs_remove_rtap(struct lbs_private *priv)
1515{ 1526{
1527 lbs_deb_enter(LBS_DEB_MAIN);
1516 if (priv->rtap_net_dev == NULL) 1528 if (priv->rtap_net_dev == NULL)
1517 return; 1529 return;
1518 unregister_netdev(priv->rtap_net_dev); 1530 unregister_netdev(priv->rtap_net_dev);
1519 free_netdev(priv->rtap_net_dev); 1531 free_netdev(priv->rtap_net_dev);
1520 priv->rtap_net_dev = NULL; 1532 priv->rtap_net_dev = NULL;
1533 lbs_deb_leave(LBS_DEB_MAIN);
1521} 1534}
1522 1535
1523static int lbs_add_rtap(struct lbs_private *priv) 1536static int lbs_add_rtap(struct lbs_private *priv)
1524{ 1537{
1525 int rc = 0; 1538 int ret = 0;
1526 struct net_device *rtap_dev; 1539 struct net_device *rtap_dev;
1527 1540
1528 if (priv->rtap_net_dev) 1541 lbs_deb_enter(LBS_DEB_MAIN);
1529 return -EPERM; 1542 if (priv->rtap_net_dev) {
1543 ret = -EPERM;
1544 goto out;
1545 }
1530 1546
1531 rtap_dev = alloc_netdev(0, "rtap%d", ether_setup); 1547 rtap_dev = alloc_netdev(0, "rtap%d", ether_setup);
1532 if (rtap_dev == NULL) 1548 if (rtap_dev == NULL) {
1533 return -ENOMEM; 1549 ret = -ENOMEM;
1550 goto out;
1551 }
1534 1552
1535 memcpy(rtap_dev->dev_addr, priv->current_addr, ETH_ALEN); 1553 memcpy(rtap_dev->dev_addr, priv->current_addr, ETH_ALEN);
1536 rtap_dev->type = ARPHRD_IEEE80211_RADIOTAP; 1554 rtap_dev->type = ARPHRD_IEEE80211_RADIOTAP;
@@ -1541,14 +1559,16 @@ static int lbs_add_rtap(struct lbs_private *priv)
1541 rtap_dev->set_multicast_list = lbs_set_multicast_list; 1559 rtap_dev->set_multicast_list = lbs_set_multicast_list;
1542 rtap_dev->priv = priv; 1560 rtap_dev->priv = priv;
1543 1561
1544 rc = register_netdev(rtap_dev); 1562 ret = register_netdev(rtap_dev);
1545 if (rc) { 1563 if (ret) {
1546 free_netdev(rtap_dev); 1564 free_netdev(rtap_dev);
1547 return rc; 1565 goto out;
1548 } 1566 }
1549 priv->rtap_net_dev = rtap_dev; 1567 priv->rtap_net_dev = rtap_dev;
1550 1568
1551 return 0; 1569out:
1570 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1571 return ret;
1552} 1572}
1553 1573
1554 1574