diff options
author | Franky Lin <frankyl@broadcom.com> | 2011-10-21 10:16:32 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-08 15:54:24 -0500 |
commit | 15d45b6fbd01ecebc5a77b1e06ae7ebffad8018a (patch) | |
tree | f85fa9db486dc3c87887701ddd73edcd4ac2ee5d | |
parent | 3fd172d30b59d9b73cb35ab263a1f0173dae974c (diff) |
brcm80211: fmac: use brcmf_add_if for all net devices
Use brcmf_add_if for primary and virtual net device interfaces. This
is part of the net device interface clean up for fullmac.
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4 files changed, 54 insertions, 86 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 54b055b6d5a2..2cf22e0ad061 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h | |||
@@ -729,8 +729,7 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, | |||
729 | extern void brcmf_c_init(void); | 729 | extern void brcmf_c_init(void); |
730 | 730 | ||
731 | extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, | 731 | extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, |
732 | struct net_device *ndev, char *name, u8 *mac_addr, | 732 | char *name, u8 *mac_addr); |
733 | u32 flags, u8 bssidx); | ||
734 | extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); | 733 | extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); |
735 | 734 | ||
736 | /* Send packet to dongle via data channel */ | 735 | /* Send packet to dongle via data channel */ |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 891826197f96..40928e58b6a6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c | |||
@@ -488,10 +488,9 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, | |||
488 | 488 | ||
489 | if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { | 489 | if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { |
490 | if (ifevent->action == BRCMF_E_IF_ADD) | 490 | if (ifevent->action == BRCMF_E_IF_ADD) |
491 | brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, | 491 | brcmf_add_if(drvr_priv, ifevent->ifidx, |
492 | event->ifname, | 492 | event->ifname, |
493 | pvt_data->eth.h_dest, | 493 | pvt_data->eth.h_dest); |
494 | ifevent->flags, ifevent->bssidx); | ||
495 | else | 494 | else |
496 | brcmf_del_if(drvr_priv, ifevent->ifidx); | 495 | brcmf_del_if(drvr_priv, ifevent->ifidx); |
497 | } else { | 496 | } else { |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 6739ece56587..14ac2102ad5b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | |||
@@ -904,30 +904,21 @@ static const struct net_device_ops brcmf_netdev_ops_pri = { | |||
904 | }; | 904 | }; |
905 | 905 | ||
906 | int | 906 | int |
907 | brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, | 907 | brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) |
908 | char *name, u8 *mac_addr, u32 flags, u8 bssidx) | ||
909 | { | 908 | { |
910 | struct brcmf_if *ifp; | 909 | struct brcmf_if *ifp; |
911 | int ret = 0, err = 0; | 910 | int err = 0; |
912 | 911 | ||
913 | brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); | 912 | brcmf_dbg(TRACE, "idx %d\n", ifidx); |
914 | 913 | ||
915 | ifp = drvr_priv->iflist[ifidx]; | 914 | ifp = drvr_priv->iflist[ifidx]; |
916 | if (!ifp) { | 915 | if (!ifp) { |
917 | ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); | 916 | ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); |
918 | if (!ifp) | 917 | if (!ifp) |
919 | return -ENOMEM; | 918 | return -ENOMEM; |
920 | } | ||
921 | 919 | ||
922 | memset(ifp, 0, sizeof(struct brcmf_if)); | 920 | drvr_priv->iflist[ifidx] = ifp; |
923 | ifp->info = drvr_priv; | 921 | } else { |
924 | drvr_priv->iflist[ifidx] = ifp; | ||
925 | if (mac_addr != NULL) | ||
926 | memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); | ||
927 | |||
928 | if (ndev == NULL) { | ||
929 | ifp->state = BRCMF_E_IF_ADD; | ||
930 | ifp->idx = ifidx; | ||
931 | /* | 922 | /* |
932 | * Delete the existing interface before overwriting it | 923 | * Delete the existing interface before overwriting it |
933 | * in case we missed the BRCMF_E_IF_DEL event. | 924 | * in case we missed the BRCMF_E_IF_DEL event. |
@@ -939,41 +930,42 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, | |||
939 | unregister_netdev(ifp->ndev); | 930 | unregister_netdev(ifp->ndev); |
940 | free_netdev(ifp->ndev); | 931 | free_netdev(ifp->ndev); |
941 | } | 932 | } |
933 | } | ||
934 | memset(ifp, 0, sizeof(struct brcmf_if)); | ||
935 | ifp->info = drvr_priv; | ||
936 | drvr_priv->iflist[ifidx] = ifp; | ||
937 | ifp->state = BRCMF_E_IF_ADD; | ||
938 | ifp->idx = ifidx; | ||
942 | 939 | ||
943 | /* Allocate netdev, including space for private structure */ | 940 | /* Allocate netdev, including space for private structure */ |
944 | ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", | 941 | ifp->ndev = alloc_netdev(sizeof(drvr_priv), name, ether_setup); |
945 | ether_setup); | 942 | if (!ifp->ndev) { |
946 | if (!ifp->ndev) { | 943 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); |
947 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); | 944 | err = -ENOMEM; |
948 | ret = -ENOMEM; | 945 | goto errout; |
949 | } | 946 | } |
950 | 947 | ||
951 | if (ret == 0) { | 948 | if (mac_addr != NULL) |
952 | memcpy(netdev_priv(ifp->ndev), &drvr_priv, | 949 | memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); |
953 | sizeof(drvr_priv)); | ||
954 | err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); | ||
955 | if (err != 0) { | ||
956 | brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", | ||
957 | err); | ||
958 | ret = -EOPNOTSUPP; | ||
959 | } else { | ||
960 | brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", | ||
961 | current->pid, ifp->ndev->name); | ||
962 | ifp->state = 0; | ||
963 | } | ||
964 | } | ||
965 | 950 | ||
966 | if (ret < 0) { | 951 | memcpy(netdev_priv(ifp->ndev), &drvr_priv, sizeof(drvr_priv)); |
967 | if (ifp->ndev) | 952 | if (brcmf_net_attach(&drvr_priv->pub, ifp->idx)) { |
968 | free_netdev(ifp->ndev); | 953 | brcmf_dbg(ERROR, "brcmf_net_attach failed"); |
954 | free_netdev(ifp->ndev); | ||
955 | err = -EOPNOTSUPP; | ||
956 | goto errout; | ||
957 | } | ||
969 | 958 | ||
970 | drvr_priv->iflist[ifp->idx] = NULL; | 959 | brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", |
971 | kfree(ifp); | 960 | current->pid, ifp->ndev->name); |
972 | } | 961 | ifp->state = 0; |
973 | } else | ||
974 | ifp->ndev = ndev; | ||
975 | 962 | ||
976 | return 0; | 963 | return 0; |
964 | |||
965 | errout: | ||
966 | kfree(ifp); | ||
967 | drvr_priv->iflist[ifidx] = NULL; | ||
968 | return err; | ||
977 | } | 969 | } |
978 | 970 | ||
979 | void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) | 971 | void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) |
@@ -1011,32 +1003,14 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) | |||
1011 | struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) | 1003 | struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) |
1012 | { | 1004 | { |
1013 | struct brcmf_info *drvr_priv = NULL; | 1005 | struct brcmf_info *drvr_priv = NULL; |
1014 | struct net_device *ndev; | ||
1015 | 1006 | ||
1016 | brcmf_dbg(TRACE, "Enter\n"); | 1007 | brcmf_dbg(TRACE, "Enter\n"); |
1017 | 1008 | ||
1018 | /* Allocate netdev, including space for private structure */ | ||
1019 | ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); | ||
1020 | if (!ndev) { | ||
1021 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); | ||
1022 | goto fail; | ||
1023 | } | ||
1024 | |||
1025 | /* Allocate primary brcmf_info */ | 1009 | /* Allocate primary brcmf_info */ |
1026 | drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); | 1010 | drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); |
1027 | if (!drvr_priv) | 1011 | if (!drvr_priv) |
1028 | goto fail; | 1012 | goto fail; |
1029 | 1013 | ||
1030 | /* | ||
1031 | * Save the brcmf_info into the priv | ||
1032 | */ | ||
1033 | memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); | ||
1034 | |||
1035 | if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == | ||
1036 | BRCMF_BAD_IF) | ||
1037 | goto fail; | ||
1038 | |||
1039 | ndev->netdev_ops = NULL; | ||
1040 | mutex_init(&drvr_priv->proto_block); | 1014 | mutex_init(&drvr_priv->proto_block); |
1041 | 1015 | ||
1042 | /* Link to info module */ | 1016 | /* Link to info module */ |
@@ -1052,29 +1026,12 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) | |||
1052 | goto fail; | 1026 | goto fail; |
1053 | } | 1027 | } |
1054 | 1028 | ||
1055 | /* Attach and link in the cfg80211 */ | ||
1056 | drvr_priv->pub.config = | ||
1057 | brcmf_cfg80211_attach(ndev, | ||
1058 | brcmf_bus_get_device(bus), | ||
1059 | &drvr_priv->pub); | ||
1060 | if (drvr_priv->pub.config == NULL) { | ||
1061 | brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); | ||
1062 | goto fail; | ||
1063 | } | ||
1064 | |||
1065 | INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); | 1029 | INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); |
1066 | INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); | 1030 | INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); |
1067 | 1031 | ||
1068 | /* | ||
1069 | * Save the brcmf_info into the priv | ||
1070 | */ | ||
1071 | memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); | ||
1072 | |||
1073 | return &drvr_priv->pub; | 1032 | return &drvr_priv->pub; |
1074 | 1033 | ||
1075 | fail: | 1034 | fail: |
1076 | if (ndev) | ||
1077 | free_netdev(ndev); | ||
1078 | if (drvr_priv) | 1035 | if (drvr_priv) |
1079 | brcmf_detach(&drvr_priv->pub); | 1036 | brcmf_detach(&drvr_priv->pub); |
1080 | 1037 | ||
@@ -1178,6 +1135,18 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) | |||
1178 | 1135 | ||
1179 | memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); | 1136 | memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); |
1180 | 1137 | ||
1138 | /* attach to cfg80211 for primary interface */ | ||
1139 | if (!ifidx) { | ||
1140 | drvr->config = | ||
1141 | brcmf_cfg80211_attach(ndev, | ||
1142 | brcmf_bus_get_device(drvr->bus), | ||
1143 | drvr); | ||
1144 | if (drvr->config == NULL) { | ||
1145 | brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); | ||
1146 | goto fail; | ||
1147 | } | ||
1148 | } | ||
1149 | |||
1181 | if (register_netdev(ndev) != 0) { | 1150 | if (register_netdev(ndev) != 0) { |
1182 | brcmf_dbg(ERROR, "couldn't register the net device\n"); | 1151 | brcmf_dbg(ERROR, "couldn't register the net device\n"); |
1183 | goto fail; | 1152 | goto fail; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 785ab089f26e..6de489b1a162 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |||
@@ -4546,9 +4546,10 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, | |||
4546 | goto fail; | 4546 | goto fail; |
4547 | } | 4547 | } |
4548 | } | 4548 | } |
4549 | /* Ok, have the per-port tell the stack we're open for business */ | 4549 | |
4550 | if (brcmf_net_attach(bus->drvr, 0) != 0) { | 4550 | /* add interface and open for business */ |
4551 | brcmf_dbg(ERROR, "Net attach failed!!\n"); | 4551 | if (brcmf_add_if((struct brcmf_info *)bus->drvr, 0, "wlan%d", NULL)) { |
4552 | brcmf_dbg(ERROR, "Add primary net device interface failed!!\n"); | ||
4552 | goto fail; | 4553 | goto fail; |
4553 | } | 4554 | } |
4554 | 4555 | ||