diff options
author | Holger Schurig <hs4233@mail.mn-solutions.de> | 2007-05-25 11:49:19 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2007-06-11 14:28:37 -0400 |
commit | 78523daa86cf0b02c4d2f73b962c04ad565e9140 (patch) | |
tree | 2be493edecfc3f225979ba33edaddf36a1f6bccb /drivers/net/wireless/libertas/main.c | |
parent | a46c64108b06ec68337e62e7c2d4b3e8aed74b82 (diff) |
[PATCH] libertas: single out mesh code
This patches adds the two functions wlan_add_mesh() and wlan_remove_mesh(),
which are responsible for the mshX interface. In a CF driver with a non-
mesh-aware firmware you can omit the calls to this functions.
Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/main.c')
-rw-r--r-- | drivers/net/wireless/libertas/main.c | 136 |
1 files changed, 93 insertions, 43 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 6fcb2bdfbed1..abba7ec499b2 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -208,7 +208,6 @@ static ssize_t libertas_mpp_set(struct device * dev, | |||
208 | struct device_attribute *attr, const char * buf, size_t count) { | 208 | struct device_attribute *attr, const char * buf, size_t count) { |
209 | struct cmd_ds_mesh_access mesh_access; | 209 | struct cmd_ds_mesh_access mesh_access; |
210 | 210 | ||
211 | |||
212 | memset(&mesh_access, 0, sizeof(mesh_access)); | 211 | memset(&mesh_access, 0, sizeof(mesh_access)); |
213 | sscanf(buf, "%d", &(mesh_access.data[0])); | 212 | sscanf(buf, "%d", &(mesh_access.data[0])); |
214 | libertas_prepare_and_send_command((to_net_dev(dev))->priv, | 213 | libertas_prepare_and_send_command((to_net_dev(dev))->priv, |
@@ -287,7 +286,7 @@ static int mesh_open(struct net_device *dev) | |||
287 | { | 286 | { |
288 | wlan_private *priv = (wlan_private *) dev->priv ; | 287 | wlan_private *priv = (wlan_private *) dev->priv ; |
289 | 288 | ||
290 | if(pre_open_check(dev) == -1) | 289 | if (pre_open_check(dev) == -1) |
291 | return -1; | 290 | return -1; |
292 | priv->mesh_open = 1 ; | 291 | priv->mesh_open = 1 ; |
293 | netif_start_queue(priv->mesh_dev); | 292 | netif_start_queue(priv->mesh_dev); |
@@ -352,7 +351,8 @@ static int mesh_close(struct net_device *dev) | |||
352 | * @param dev A pointer to net_device structure | 351 | * @param dev A pointer to net_device structure |
353 | * @return 0 | 352 | * @return 0 |
354 | */ | 353 | */ |
355 | static int wlan_close(struct net_device *dev) { | 354 | static int wlan_close(struct net_device *dev) |
355 | { | ||
356 | wlan_private *priv = (wlan_private *) dev->priv; | 356 | wlan_private *priv = (wlan_private *) dev->priv; |
357 | 357 | ||
358 | netif_stop_queue(priv->wlan_dev.netdev); | 358 | netif_stop_queue(priv->wlan_dev.netdev); |
@@ -487,7 +487,8 @@ static int wlan_set_mac_address(struct net_device *dev, void *addr) | |||
487 | 487 | ||
488 | lbs_dbg_hex("adapter->macaddr:", adapter->current_addr, ETH_ALEN); | 488 | lbs_dbg_hex("adapter->macaddr:", adapter->current_addr, ETH_ALEN); |
489 | memcpy(dev->dev_addr, adapter->current_addr, ETH_ALEN); | 489 | memcpy(dev->dev_addr, adapter->current_addr, ETH_ALEN); |
490 | memcpy(((wlan_private *) dev->priv)->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); | 490 | if (priv->mesh_dev) |
491 | memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); | ||
491 | 492 | ||
492 | done: | 493 | done: |
493 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); | 494 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
@@ -767,7 +768,6 @@ static int wlan_service_main_thread(void *data) | |||
767 | wlan_private *wlan_add_card(void *card) | 768 | wlan_private *wlan_add_card(void *card) |
768 | { | 769 | { |
769 | struct net_device *dev = NULL; | 770 | struct net_device *dev = NULL; |
770 | struct net_device *mesh_dev = NULL; | ||
771 | wlan_private *priv = NULL; | 771 | wlan_private *priv = NULL; |
772 | 772 | ||
773 | lbs_deb_enter(LBS_DEB_NET); | 773 | lbs_deb_enter(LBS_DEB_NET); |
@@ -786,15 +786,6 @@ wlan_private *wlan_add_card(void *card) | |||
786 | goto err_kmalloc; | 786 | goto err_kmalloc; |
787 | } | 787 | } |
788 | 788 | ||
789 | /* Allocate a virtual mesh device */ | ||
790 | if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { | ||
791 | lbs_deb_mesh("init mshX device failed\n"); | ||
792 | return NULL; | ||
793 | } | ||
794 | |||
795 | /* Both intervaces share the priv structure */ | ||
796 | mesh_dev->priv = priv; | ||
797 | |||
798 | /* init wlan_adapter */ | 789 | /* init wlan_adapter */ |
799 | memset(priv->adapter, 0, sizeof(wlan_adapter)); | 790 | memset(priv->adapter, 0, sizeof(wlan_adapter)); |
800 | 791 | ||
@@ -802,10 +793,8 @@ wlan_private *wlan_add_card(void *card) | |||
802 | priv->wlan_dev.card = card; | 793 | priv->wlan_dev.card = card; |
803 | priv->mesh_open = 0; | 794 | priv->mesh_open = 0; |
804 | priv->infra_open = 0; | 795 | priv->infra_open = 0; |
805 | priv->mesh_dev = mesh_dev; | ||
806 | 796 | ||
807 | SET_MODULE_OWNER(dev); | 797 | SET_MODULE_OWNER(dev); |
808 | SET_MODULE_OWNER(mesh_dev); | ||
809 | 798 | ||
810 | /* Setup the OS Interface to our functions */ | 799 | /* Setup the OS Interface to our functions */ |
811 | dev->open = wlan_open; | 800 | dev->open = wlan_open; |
@@ -813,12 +802,6 @@ wlan_private *wlan_add_card(void *card) | |||
813 | dev->stop = wlan_close; | 802 | dev->stop = wlan_close; |
814 | dev->do_ioctl = libertas_do_ioctl; | 803 | dev->do_ioctl = libertas_do_ioctl; |
815 | dev->set_mac_address = wlan_set_mac_address; | 804 | dev->set_mac_address = wlan_set_mac_address; |
816 | mesh_dev->open = mesh_open; | ||
817 | mesh_dev->hard_start_xmit = mesh_pre_start_xmit; | ||
818 | mesh_dev->stop = mesh_close; | ||
819 | mesh_dev->do_ioctl = libertas_do_ioctl; | ||
820 | memcpy(mesh_dev->dev_addr, priv->wlan_dev.netdev->dev_addr, | ||
821 | sizeof(priv->wlan_dev.netdev->dev_addr)); | ||
822 | 805 | ||
823 | #define WLAN_WATCHDOG_TIMEOUT (5 * HZ) | 806 | #define WLAN_WATCHDOG_TIMEOUT (5 * HZ) |
824 | 807 | ||
@@ -826,12 +809,9 @@ wlan_private *wlan_add_card(void *card) | |||
826 | dev->get_stats = wlan_get_stats; | 809 | dev->get_stats = wlan_get_stats; |
827 | dev->watchdog_timeo = WLAN_WATCHDOG_TIMEOUT; | 810 | dev->watchdog_timeo = WLAN_WATCHDOG_TIMEOUT; |
828 | dev->ethtool_ops = &libertas_ethtool_ops; | 811 | dev->ethtool_ops = &libertas_ethtool_ops; |
829 | mesh_dev->get_stats = wlan_get_stats; | ||
830 | mesh_dev->ethtool_ops = &libertas_ethtool_ops; | ||
831 | 812 | ||
832 | #ifdef WIRELESS_EXT | 813 | #ifdef WIRELESS_EXT |
833 | dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; | 814 | dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; |
834 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; | ||
835 | #endif | 815 | #endif |
836 | #define NETIF_F_DYNALLOC 16 | 816 | #define NETIF_F_DYNALLOC 16 |
837 | dev->features |= NETIF_F_DYNALLOC; | 817 | dev->features |= NETIF_F_DYNALLOC; |
@@ -875,12 +855,6 @@ wlan_private *wlan_add_card(void *card) | |||
875 | goto err_init_fw; | 855 | goto err_init_fw; |
876 | } | 856 | } |
877 | 857 | ||
878 | /* Register virtual mesh interface */ | ||
879 | if (register_netdev(mesh_dev)) { | ||
880 | lbs_pr_err("cannot register mshX virtual interface\n"); | ||
881 | goto err_init_fw; | ||
882 | } | ||
883 | |||
884 | lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name); | 858 | lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name); |
885 | 859 | ||
886 | libertas_debugfs_init_one(priv, dev); | 860 | libertas_debugfs_init_one(priv, dev); |
@@ -889,14 +863,10 @@ wlan_private *wlan_add_card(void *card) | |||
889 | goto err_init_fw; | 863 | goto err_init_fw; |
890 | libertas_devs[libertas_found] = dev; | 864 | libertas_devs[libertas_found] = dev; |
891 | libertas_found++; | 865 | libertas_found++; |
892 | if (device_create_file(&(mesh_dev->dev), &dev_attr_libertas_mpp)) | ||
893 | goto err_create_file; | ||
894 | 866 | ||
895 | lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); | 867 | lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); |
896 | return priv; | 868 | return priv; |
897 | 869 | ||
898 | err_create_file: | ||
899 | device_remove_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); | ||
900 | err_init_fw: | 870 | err_init_fw: |
901 | libertas_sbi_unregister_dev(priv); | 871 | libertas_sbi_unregister_dev(priv); |
902 | err_registerdev: | 872 | err_registerdev: |
@@ -907,12 +877,76 @@ err_registerdev: | |||
907 | kfree(priv->adapter); | 877 | kfree(priv->adapter); |
908 | err_kmalloc: | 878 | err_kmalloc: |
909 | free_netdev(dev); | 879 | free_netdev(dev); |
910 | free_netdev(mesh_dev); | ||
911 | 880 | ||
912 | lbs_deb_leave_args(LBS_DEB_NET, "priv NULL"); | 881 | lbs_deb_leave_args(LBS_DEB_NET, "priv NULL"); |
913 | return NULL; | 882 | return NULL; |
914 | } | 883 | } |
915 | 884 | ||
885 | /** | ||
886 | * @brief This function adds mshX interface | ||
887 | * | ||
888 | * @param priv A pointer to the wlan_private structure | ||
889 | * @return 0 if successful, -X otherwise | ||
890 | */ | ||
891 | int wlan_add_mesh(wlan_private *priv) | ||
892 | { | ||
893 | struct net_device *mesh_dev = NULL; | ||
894 | int ret = 0; | ||
895 | |||
896 | lbs_deb_enter(LBS_DEB_MESH); | ||
897 | |||
898 | /* Allocate a virtual mesh device */ | ||
899 | if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { | ||
900 | lbs_deb_mesh("init mshX device failed\n"); | ||
901 | ret = -ENOMEM; | ||
902 | goto done; | ||
903 | } | ||
904 | mesh_dev->priv = priv; | ||
905 | priv->mesh_dev = mesh_dev; | ||
906 | |||
907 | SET_MODULE_OWNER(mesh_dev); | ||
908 | |||
909 | mesh_dev->open = mesh_open; | ||
910 | mesh_dev->hard_start_xmit = mesh_pre_start_xmit; | ||
911 | mesh_dev->stop = mesh_close; | ||
912 | mesh_dev->do_ioctl = libertas_do_ioctl; | ||
913 | mesh_dev->get_stats = wlan_get_stats; | ||
914 | mesh_dev->ethtool_ops = &libertas_ethtool_ops; | ||
915 | memcpy(mesh_dev->dev_addr, priv->wlan_dev.netdev->dev_addr, | ||
916 | sizeof(priv->wlan_dev.netdev->dev_addr)); | ||
917 | |||
918 | #ifdef WIRELESS_EXT | ||
919 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; | ||
920 | #endif | ||
921 | #define NETIF_F_DYNALLOC 16 | ||
922 | |||
923 | /* Register virtual mesh interface */ | ||
924 | ret = register_netdev(mesh_dev); | ||
925 | if (ret) { | ||
926 | lbs_pr_err("cannot register mshX virtual interface\n"); | ||
927 | goto err_free; | ||
928 | } | ||
929 | |||
930 | ret = device_create_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); | ||
931 | if (ret) | ||
932 | goto err_unregister; | ||
933 | |||
934 | /* Everything successful */ | ||
935 | ret = 0; | ||
936 | goto done; | ||
937 | |||
938 | |||
939 | err_unregister: | ||
940 | unregister_netdev(mesh_dev); | ||
941 | |||
942 | err_free: | ||
943 | free_netdev(mesh_dev); | ||
944 | |||
945 | done: | ||
946 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); | ||
947 | return ret; | ||
948 | } | ||
949 | |||
916 | static void wake_pending_cmdnodes(wlan_private *priv) | 950 | static void wake_pending_cmdnodes(wlan_private *priv) |
917 | { | 951 | { |
918 | struct cmd_ctrl_node *cmdnode; | 952 | struct cmd_ctrl_node *cmdnode; |
@@ -934,7 +968,6 @@ int wlan_remove_card(void *card) | |||
934 | wlan_private *priv = libertas_sbi_get_priv(card); | 968 | wlan_private *priv = libertas_sbi_get_priv(card); |
935 | wlan_adapter *adapter; | 969 | wlan_adapter *adapter; |
936 | struct net_device *dev; | 970 | struct net_device *dev; |
937 | struct net_device *mesh_dev; | ||
938 | union iwreq_data wrqu; | 971 | union iwreq_data wrqu; |
939 | int i; | 972 | int i; |
940 | 973 | ||
@@ -949,16 +982,12 @@ int wlan_remove_card(void *card) | |||
949 | goto out; | 982 | goto out; |
950 | 983 | ||
951 | dev = priv->wlan_dev.netdev; | 984 | dev = priv->wlan_dev.netdev; |
952 | mesh_dev = priv->mesh_dev; | ||
953 | 985 | ||
954 | netif_stop_queue(mesh_dev); | ||
955 | netif_stop_queue(priv->wlan_dev.netdev); | 986 | netif_stop_queue(priv->wlan_dev.netdev); |
956 | netif_carrier_off(priv->wlan_dev.netdev); | 987 | netif_carrier_off(priv->wlan_dev.netdev); |
957 | 988 | ||
958 | wake_pending_cmdnodes(priv); | 989 | wake_pending_cmdnodes(priv); |
959 | 990 | ||
960 | device_remove_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); | ||
961 | unregister_netdev(mesh_dev); | ||
962 | unregister_netdev(dev); | 991 | unregister_netdev(dev); |
963 | 992 | ||
964 | cancel_delayed_work(&priv->assoc_work); | 993 | cancel_delayed_work(&priv->assoc_work); |
@@ -994,8 +1023,6 @@ int wlan_remove_card(void *card) | |||
994 | lbs_deb_net("unregister finish\n"); | 1023 | lbs_deb_net("unregister finish\n"); |
995 | 1024 | ||
996 | priv->wlan_dev.netdev = NULL; | 1025 | priv->wlan_dev.netdev = NULL; |
997 | priv->mesh_dev = NULL ; | ||
998 | free_netdev(mesh_dev); | ||
999 | free_netdev(dev); | 1026 | free_netdev(dev); |
1000 | 1027 | ||
1001 | out: | 1028 | out: |
@@ -1003,6 +1030,29 @@ out: | |||
1003 | return 0; | 1030 | return 0; |
1004 | } | 1031 | } |
1005 | 1032 | ||
1033 | void wlan_remove_mesh(wlan_private *priv) | ||
1034 | { | ||
1035 | struct net_device *mesh_dev; | ||
1036 | |||
1037 | lbs_deb_enter(LBS_DEB_NET); | ||
1038 | |||
1039 | if (!priv) | ||
1040 | goto out; | ||
1041 | |||
1042 | mesh_dev = priv->mesh_dev; | ||
1043 | |||
1044 | netif_stop_queue(mesh_dev); | ||
1045 | |||
1046 | device_remove_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); | ||
1047 | unregister_netdev(mesh_dev); | ||
1048 | |||
1049 | priv->mesh_dev = NULL ; | ||
1050 | free_netdev(mesh_dev); | ||
1051 | |||
1052 | out: | ||
1053 | lbs_deb_leave(LBS_DEB_NET); | ||
1054 | } | ||
1055 | |||
1006 | /** | 1056 | /** |
1007 | * @brief This function finds the CFP in | 1057 | * @brief This function finds the CFP in |
1008 | * region_cfp_table based on region and band parameter. | 1058 | * region_cfp_table based on region and band parameter. |