diff options
Diffstat (limited to 'drivers/staging/wilc1000/linux_mon.c')
-rw-r--r-- | drivers/staging/wilc1000/linux_mon.c | 218 |
1 files changed, 12 insertions, 206 deletions
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index b8d7d048439b..450af1b77f99 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -11,15 +11,10 @@ #include "wilc_wlan_if.h" #include "wilc_wlan.h" -#ifdef WILC_FULLY_HOSTING_AP -#include "wilc_host_ap.h" -#endif -#ifdef WILC_AP_EXTERNAL_MLME struct wilc_wfi_radiotap_hdr { struct ieee80211_radiotap_header hdr; u8 rate; - /* u32 channel; */ } __attribute__((packed)); struct wilc_wfi_radiotap_cb_hdr { @@ -27,16 +22,11 @@ struct wilc_wfi_radiotap_cb_hdr { u8 rate; u8 dump; u16 tx_flags; - /* u32 channel; */ } __attribute__((packed)); -extern linux_wlan_t *g_linux_wlan; - static struct net_device *wilc_wfi_mon; /* global monitor netdev */ -#if USE_WIRELESS extern int mac_xmit(struct sk_buff *skb, struct net_device *dev); -#endif u8 srcAdd[6]; @@ -59,20 +49,15 @@ u8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; #define IS_MGMT_STATUS_SUCCES 0x040 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) -void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size) +void WILC_WFI_monitor_rx(u8 *buff, u32 size) { - uint32_t header, pkt_offset; + u32 header, pkt_offset; struct sk_buff *skb = NULL; struct wilc_wfi_radiotap_hdr *hdr; struct wilc_wfi_radiotap_cb_hdr *cb_hdr; PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n"); - /* struct WILC_WFI_priv *priv = netdev_priv(dev); */ - - /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ - - /* Bug 4601 */ if (wilc_wfi_mon == NULL) return; @@ -129,30 +114,19 @@ void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size) return; } - /* skb = skb_copy_expand(tx_skb, sizeof(*hdr), 0, GFP_ATOMIC); */ - /* if (skb == NULL) */ - /* return; */ - memcpy(skb_put(skb, size), buff, size); hdr = (struct wilc_wfi_radiotap_hdr *) skb_push(skb, sizeof(*hdr)); memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ - /* hdr->hdr.it_pad = 0; */ hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr)); PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len); hdr->hdr.it_present = cpu_to_le32 (1 << IEEE80211_RADIOTAP_RATE); /* | */ - /* (1 << IEEE80211_RADIOTAP_CHANNEL)); */ PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present); hdr->rate = 5; /* txrate->bitrate / 5; */ } -/* if(INFO || if(skb->data[9] == 0x00 || skb->data[9] == 0xb0)) - * { - * for(i=0;i<skb->len;i++) - * PRINT_INFO(HOSTAPD_DBG,"Mon RxData[%d] = %02x\n",i,skb->data[i]); - * }*/ skb->dev = wilc_wfi_mon; @@ -175,9 +149,6 @@ struct tx_complete_mon_data { static void mgmt_tx_complete(void *priv, int status) { - /* struct sk_buff *skb2; */ - /* struct wilc_wfi_radiotap_cb_hdr *cb_hdr; */ - struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; u8 *buf = pv_data->buff; @@ -191,42 +162,11 @@ static void mgmt_tx_complete(void *priv, int status) } -/* //(skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) - * { - * skb2 = dev_alloc_skb(pv_data->size+sizeof(struct wilc_wfi_radiotap_cb_hdr)); - * - * memcpy(skb_put(skb2,pv_data->size),pv_data->buff, pv_data->size); - * - * cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr)); - * memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); - * - * cb_hdr->hdr.it_version = 0;//PKTHDR_RADIOTAP_VERSION; - * - * cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); - * - * cb_hdr->hdr.it_present = cpu_to_le32( - * (1 << IEEE80211_RADIOTAP_RATE) | - * (1 << IEEE80211_RADIOTAP_TX_FLAGS)); - * - * cb_hdr->rate = 5;//txrate->bitrate / 5; - * cb_hdr->tx_flags = 0x0004; - * - * skb2->dev = wilc_wfi_mon; - * skb_set_mac_header(skb2, 0); - * skb2->ip_summed = CHECKSUM_UNNECESSARY; - * skb2->pkt_type = PACKET_OTHERHOST; - * skb2->protocol = htons(ETH_P_802_2); - * memset(skb2->cb, 0, sizeof(skb2->cb)); - * - * netif_rx(skb2); - * }*/ /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ - #ifndef WILC_FULLY_HOSTING_AP kfree(pv_data->buff); kfree(pv_data); - #endif } static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) { @@ -234,44 +174,29 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) if (dev == NULL) { PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n"); - return WILC_FAIL; + return -EFAULT; } netif_stop_queue(dev); mgmt_tx = kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); if (mgmt_tx == NULL) { PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); - return WILC_FAIL; + return -EFAULT; } - #ifdef WILC_FULLY_HOSTING_AP - /* add space for the pointer to tx_complete_mon_data */ - len += sizeof(struct tx_complete_mon_data *); - #endif - mgmt_tx->buff = kmalloc(len, GFP_ATOMIC); if (mgmt_tx->buff == NULL) { PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); - return WILC_FAIL; + kfree(mgmt_tx); + return -EFAULT; } mgmt_tx->size = len; - #ifndef WILC_FULLY_HOSTING_AP memcpy(mgmt_tx->buff, buf, len); - #else - memcpy(mgmt_tx->buff, buf, len - sizeof(struct tx_complete_mon_data *)); - memcpy((mgmt_tx->buff) + (len - sizeof(struct tx_complete_mon_data *)), &mgmt_tx, sizeof(struct tx_complete_mon_data *)); - - /* filter data frames to handle it's PS */ - if (filter_monitor_data_frames((mgmt_tx->buff), len) == true) { - return; - } - - #endif /* WILC_FULLY_HOSTING_AP */ - - g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, mgmt_tx_complete); + wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, + mgmt_tx_complete); netif_wake_queue(dev); return 0; @@ -295,17 +220,14 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, struct sk_buff *skb2; struct wilc_wfi_radiotap_cb_hdr *cb_hdr; - /* Bug 4601 */ if (wilc_wfi_mon == NULL) - return WILC_FAIL; - - /* if(skb->data[3] == 0x10 || skb->data[3] == 0xb0) */ + return -EFAULT; mon_priv = netdev_priv(wilc_wfi_mon); if (mon_priv == NULL) { PRINT_ER("Monitor interface private structure is NULL\n"); - return WILC_FAIL; + return -EFAULT; } @@ -367,7 +289,6 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name); PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name); - #if USE_WIRELESS /* Identify if Ethernet or MAC header (data or mgmt) */ memcpy(srcAdd, &skb->data[10], 6); memcpy(bssid, &skb->data[16], 6); @@ -378,9 +299,7 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, dev_kfree_skb(skb); } else ret = mac_xmit(skb, mon_priv->real_ndev); - #endif - /* return NETDEV_TX_OK; */ return ret; } @@ -389,117 +308,6 @@ static const struct net_device_ops wilc_wfi_netdev_ops = { }; -#ifdef WILC_FULLY_HOSTING_AP -/* - * @brief WILC_mgm_HOSTAPD_ACK - * @details report the status of transmitted mgmt frames to HOSTAPD - * @param[in] priv : pointer to tx_complete_mon_data struct - * bStatus : status of transmission - * @author Abd Al-Rahman Diab - * @date 9 May 2013 - * @version 1.0 - */ -void WILC_mgm_HOSTAPD_ACK(void *priv, bool bStatus) -{ - struct sk_buff *skb; - struct wilc_wfi_radiotap_cb_hdr *cb_hdr; - - struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; - u8 *buf = pv_data->buff; - - /* len of the original frame without the added pointer at the tail */ - u16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *); - - - /*if(bStatus == 1){ - * if(INFO || buf[0] == 0x10 || buf[0] == 0xb0) - * PRINT_D(HOSTAPD_DBG,"Packet sent successfully - Size = %d - Address = %p.\n",u16len,pv_data->buff); - * }else{ - * PRINT_D(HOSTAPD_DBG,"Couldn't send packet - Size = %d - Address = %p.\n",u16len,pv_data->buff); - * } - */ - - /* (skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) */ - { - skb = dev_alloc_skb(u16len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); - - memcpy(skb_put(skb, u16len), pv_data->buff, u16len); - - cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr)); - memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); - - cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ - - cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); - - cb_hdr->hdr.it_present = cpu_to_le32( - (1 << IEEE80211_RADIOTAP_RATE) | - (1 << IEEE80211_RADIOTAP_TX_FLAGS)); - - cb_hdr->rate = 5; /* txrate->bitrate / 5; */ - - - if (bStatus) { - /* success */ - cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; - } else { - cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; - } - - skb->dev = wilc_wfi_mon; - skb_set_mac_header(skb, 0); - skb->ip_summed = CHECKSUM_UNNECESSARY; - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - - netif_rx(skb); - } - - /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ - kfree(pv_data->buff); - - kfree(pv_data); - -} -#endif /* WILC_FULLY_HOSTING_AP */ - -/** - * @brief WILC_WFI_mon_setup - * @details - * @param[in] - * @return int : Return 0 on Success - * @author mdaftedar - * @date 12 JUL 2012 - * @version 1.0 - */ -static void WILC_WFI_mon_setup(struct net_device *dev) -{ - - dev->netdev_ops = &wilc_wfi_netdev_ops; - /* dev->destructor = free_netdev; */ - PRINT_INFO(CORECONFIG_DBG, "In Ethernet setup function\n"); - ether_setup(dev); - dev->priv_flags |= IFF_NO_QUEUE; - dev->type = ARPHRD_IEEE80211_RADIOTAP; - eth_zero_addr(dev->dev_addr); - - #ifdef USE_WIRELESS - { - /* u8 * mac_add; */ - unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x8f}; - /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ - /* mac_add = (u8*)WILC_MALLOC(ETH_ALEN); */ - /* status = host_int_get_MacAddress(priv->hWILCWFIDrv,mac_add); */ - /* mac_add[ETH_ALEN-1]+=1; */ - memcpy(dev->dev_addr, mac_add, ETH_ALEN); - } - #else - dev->dev_addr[0] = 0x12; - #endif - -} - /** * @brief WILC_WFI_init_mon_interface * @details @@ -513,7 +321,7 @@ struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_devi { - u32 ret = WILC_SUCCESS; + u32 ret = 0; struct WILC_WFI_mon_priv *priv; /*If monitor interface is already initialized, return it*/ @@ -571,7 +379,6 @@ int WILC_WFI_deinit_mon_interface(void) } PRINT_D(HOSTAPD_DBG, "Unregister netdev\n"); unregister_netdev(wilc_wfi_mon); - /* free_netdev(wilc_wfi_mon); */ if (rollback_lock) { rtnl_lock(); @@ -579,7 +386,6 @@ int WILC_WFI_deinit_mon_interface(void) } wilc_wfi_mon = NULL; } - return WILC_SUCCESS; + return 0; } -#endif /* WILC_AP_EXTERNAL_MLME */ |