Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | /*! |
| 2 | * @file linux_mon.c |
| 3 | * @brief File Operations OS wrapper functionality |
| 4 | * @author mdaftedar |
| 5 | * @sa wilc_wfi_netdevice.h |
| 6 | * @date 01 MAR 2012 |
| 7 | * @version 1.0 |
| 8 | */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 9 | #include "wilc_wfi_cfgoperations.h" |
| 10 | #include "linux_wlan_common.h" |
| 11 | #include "wilc_wlan_if.h" |
| 12 | #include "wilc_wlan.h" |
Tony Cho | 9690df3 | 2015-07-28 17:47:22 +0900 | [diff] [blame] | 13 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 14 | |
| 15 | struct wilc_wfi_radiotap_hdr { |
| 16 | struct ieee80211_radiotap_header hdr; |
| 17 | u8 rate; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 18 | } __attribute__((packed)); |
| 19 | |
| 20 | struct wilc_wfi_radiotap_cb_hdr { |
| 21 | struct ieee80211_radiotap_header hdr; |
| 22 | u8 rate; |
| 23 | u8 dump; |
| 24 | u16 tx_flags; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 25 | } __attribute__((packed)); |
| 26 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 27 | static struct net_device *wilc_wfi_mon; /* global monitor netdev */ |
| 28 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 29 | static u8 srcAdd[6]; |
| 30 | static u8 bssid[6]; |
| 31 | static u8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 32 | /** |
| 33 | * @brief WILC_WFI_monitor_rx |
| 34 | * @details |
| 35 | * @param[in] |
| 36 | * @return int : Return 0 on Success |
| 37 | * @author mdaftedar |
| 38 | * @date 12 JUL 2012 |
| 39 | * @version 1.0 |
| 40 | */ |
| 41 | |
| 42 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ |
| 43 | #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive*/ |
| 44 | #define IS_MANAGMEMENT 0x100 |
| 45 | #define IS_MANAGMEMENT_CALLBACK 0x080 |
| 46 | #define IS_MGMT_STATUS_SUCCES 0x040 |
| 47 | #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) |
| 48 | |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 49 | void WILC_WFI_monitor_rx(u8 *buff, u32 size) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 50 | { |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 51 | u32 header, pkt_offset; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 52 | struct sk_buff *skb = NULL; |
| 53 | struct wilc_wfi_radiotap_hdr *hdr; |
| 54 | struct wilc_wfi_radiotap_cb_hdr *cb_hdr; |
| 55 | |
| 56 | PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n"); |
| 57 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 58 | if (wilc_wfi_mon == NULL) |
| 59 | return; |
| 60 | |
| 61 | if (!netif_running(wilc_wfi_mon)) { |
| 62 | PRINT_INFO(HOSTAPD_DBG, "Monitor interface already RUNNING\n"); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | /* Get WILC header */ |
| 67 | memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); |
| 68 | |
| 69 | /* The packet offset field conain info about what type of managment frame */ |
| 70 | /* we are dealing with and ack status */ |
| 71 | pkt_offset = GET_PKT_OFFSET(header); |
| 72 | |
| 73 | if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { |
| 74 | |
| 75 | /* hostapd callback mgmt frame */ |
| 76 | |
| 77 | skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 78 | if (skb == NULL) { |
| 79 | PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | memcpy(skb_put(skb, size), buff, size); |
| 84 | |
| 85 | cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr)); |
| 86 | memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 87 | |
| 88 | cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ |
| 89 | |
| 90 | cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 91 | |
| 92 | cb_hdr->hdr.it_present = cpu_to_le32( |
| 93 | (1 << IEEE80211_RADIOTAP_RATE) | |
| 94 | (1 << IEEE80211_RADIOTAP_TX_FLAGS)); |
| 95 | |
| 96 | cb_hdr->rate = 5; /* txrate->bitrate / 5; */ |
| 97 | |
| 98 | if (pkt_offset & IS_MGMT_STATUS_SUCCES) { |
| 99 | /* success */ |
| 100 | cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; |
| 101 | } else { |
| 102 | cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; |
| 103 | } |
| 104 | |
| 105 | } else { |
| 106 | |
| 107 | skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr)); |
| 108 | |
| 109 | if (skb == NULL) { |
| 110 | PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); |
| 111 | return; |
| 112 | } |
| 113 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 114 | memcpy(skb_put(skb, size), buff, size); |
| 115 | hdr = (struct wilc_wfi_radiotap_hdr *) skb_push(skb, sizeof(*hdr)); |
| 116 | memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); |
| 117 | hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 118 | hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr)); |
| 119 | PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len); |
| 120 | hdr->hdr.it_present = cpu_to_le32 |
| 121 | (1 << IEEE80211_RADIOTAP_RATE); /* | */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 122 | PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present); |
| 123 | hdr->rate = 5; /* txrate->bitrate / 5; */ |
| 124 | |
| 125 | } |
| 126 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 127 | |
| 128 | |
| 129 | skb->dev = wilc_wfi_mon; |
| 130 | skb_set_mac_header(skb, 0); |
| 131 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 132 | skb->pkt_type = PACKET_OTHERHOST; |
| 133 | skb->protocol = htons(ETH_P_802_2); |
| 134 | memset(skb->cb, 0, sizeof(skb->cb)); |
| 135 | |
| 136 | netif_rx(skb); |
| 137 | |
| 138 | |
| 139 | } |
| 140 | |
| 141 | struct tx_complete_mon_data { |
| 142 | int size; |
| 143 | void *buff; |
| 144 | }; |
| 145 | |
| 146 | static void mgmt_tx_complete(void *priv, int status) |
| 147 | { |
| 148 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 149 | struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 150 | u8 *buf = pv_data->buff; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 151 | |
| 152 | |
| 153 | |
| 154 | if (status == 1) { |
| 155 | if (INFO || buf[0] == 0x10 || buf[0] == 0xb0) |
| 156 | PRINT_INFO(HOSTAPD_DBG, "Packet sent successfully - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); |
| 157 | } else { |
| 158 | PRINT_INFO(HOSTAPD_DBG, "Couldn't send packet - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); |
| 159 | } |
| 160 | |
| 161 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 162 | |
| 163 | /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 164 | kfree(pv_data->buff); |
| 165 | |
| 166 | kfree(pv_data); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 167 | } |
| 168 | static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) |
| 169 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 170 | struct tx_complete_mon_data *mgmt_tx = NULL; |
| 171 | |
| 172 | if (dev == NULL) { |
| 173 | PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 174 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 175 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 176 | |
| 177 | netif_stop_queue(dev); |
Abdul Hussain | 25fe227 | 2015-06-17 04:48:23 +0000 | [diff] [blame] | 178 | mgmt_tx = kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 179 | if (mgmt_tx == NULL) { |
| 180 | PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 181 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 182 | } |
| 183 | |
ChengYi He | 30ef5c8 | 2015-06-16 03:04:59 +0800 | [diff] [blame] | 184 | mgmt_tx->buff = kmalloc(len, GFP_ATOMIC); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 185 | if (mgmt_tx->buff == NULL) { |
| 186 | PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); |
Tony Cho | f638dd3 | 2015-09-07 19:09:31 +0900 | [diff] [blame] | 187 | kfree(mgmt_tx); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 188 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 189 | |
| 190 | } |
| 191 | |
| 192 | mgmt_tx->size = len; |
| 193 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 194 | memcpy(mgmt_tx->buff, buf, len); |
Glen Lee | 829c477 | 2015-10-29 12:18:44 +0900 | [diff] [blame] | 195 | wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size, |
Glen Lee | c9d4834 | 2015-10-01 16:03:43 +0900 | [diff] [blame] | 196 | mgmt_tx_complete); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 197 | |
| 198 | netif_wake_queue(dev); |
| 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * @brief WILC_WFI_mon_xmit |
| 204 | * @details |
| 205 | * @param[in] |
| 206 | * @return int : Return 0 on Success |
| 207 | * @author mdaftedar |
| 208 | * @date 12 JUL 2012 |
| 209 | * @version 1.0 |
| 210 | */ |
| 211 | static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, |
| 212 | struct net_device *dev) |
| 213 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 214 | u32 rtap_len, i, ret = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 215 | struct WILC_WFI_mon_priv *mon_priv; |
| 216 | |
| 217 | struct sk_buff *skb2; |
| 218 | struct wilc_wfi_radiotap_cb_hdr *cb_hdr; |
| 219 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 220 | if (wilc_wfi_mon == NULL) |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 221 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 222 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 223 | mon_priv = netdev_priv(wilc_wfi_mon); |
| 224 | |
| 225 | if (mon_priv == NULL) { |
| 226 | PRINT_ER("Monitor interface private structure is NULL\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 227 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 228 | } |
| 229 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 230 | |
| 231 | rtap_len = ieee80211_get_radiotap_len(skb->data); |
| 232 | if (skb->len < rtap_len) { |
| 233 | PRINT_ER("Error in radiotap header\n"); |
| 234 | return -1; |
| 235 | } |
| 236 | /* skip the radiotap header */ |
| 237 | PRINT_INFO(HOSTAPD_DBG, "Radiotap len: %d\n", rtap_len); |
| 238 | |
| 239 | if (INFO) { |
| 240 | for (i = 0; i < rtap_len; i++) |
| 241 | PRINT_INFO(HOSTAPD_DBG, "Radiotap_hdr[%d] %02x\n", i, skb->data[i]); |
| 242 | } |
| 243 | /* Skip the ratio tap header */ |
| 244 | skb_pull(skb, rtap_len); |
| 245 | |
| 246 | if (skb->data[0] == 0xc0) |
| 247 | PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n", skb->data[4], skb->data[5], skb->data[6], skb->data[7], skb->data[8], skb->data[9]); |
| 248 | |
| 249 | if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) { |
| 250 | skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 251 | |
| 252 | memcpy(skb_put(skb2, skb->len), skb->data, skb->len); |
| 253 | |
| 254 | cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr)); |
| 255 | memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 256 | |
| 257 | cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ |
| 258 | |
| 259 | cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); |
| 260 | |
| 261 | cb_hdr->hdr.it_present = cpu_to_le32( |
| 262 | (1 << IEEE80211_RADIOTAP_RATE) | |
| 263 | (1 << IEEE80211_RADIOTAP_TX_FLAGS)); |
| 264 | |
| 265 | cb_hdr->rate = 5; /* txrate->bitrate / 5; */ |
| 266 | cb_hdr->tx_flags = 0x0004; |
| 267 | |
| 268 | skb2->dev = wilc_wfi_mon; |
| 269 | skb_set_mac_header(skb2, 0); |
| 270 | skb2->ip_summed = CHECKSUM_UNNECESSARY; |
| 271 | skb2->pkt_type = PACKET_OTHERHOST; |
| 272 | skb2->protocol = htons(ETH_P_802_2); |
| 273 | memset(skb2->cb, 0, sizeof(skb2->cb)); |
| 274 | |
| 275 | netif_rx(skb2); |
| 276 | |
| 277 | return 0; |
| 278 | } |
| 279 | skb->dev = mon_priv->real_ndev; |
| 280 | |
| 281 | PRINT_INFO(HOSTAPD_DBG, "Skipping the radiotap header\n"); |
| 282 | |
| 283 | |
| 284 | |
| 285 | /* actual deliver of data is device-specific, and not shown here */ |
| 286 | PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name); |
| 287 | PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name); |
| 288 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 289 | /* Identify if Ethernet or MAC header (data or mgmt) */ |
| 290 | memcpy(srcAdd, &skb->data[10], 6); |
| 291 | memcpy(bssid, &skb->data[16], 6); |
| 292 | /* if source address and bssid fields are equal>>Mac header */ |
| 293 | /*send it to mgmt frames handler */ |
| 294 | if (!(memcmp(srcAdd, bssid, 6))) { |
| 295 | mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); |
| 296 | dev_kfree_skb(skb); |
| 297 | } else |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 298 | ret = wilc_mac_xmit(skb, mon_priv->real_ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 299 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 300 | return ret; |
| 301 | } |
| 302 | |
| 303 | static const struct net_device_ops wilc_wfi_netdev_ops = { |
| 304 | .ndo_start_xmit = WILC_WFI_mon_xmit, |
| 305 | |
| 306 | }; |
| 307 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 308 | /** |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 309 | * @brief WILC_WFI_init_mon_interface |
| 310 | * @details |
| 311 | * @param[in] |
| 312 | * @return int : Return 0 on Success |
| 313 | * @author mdaftedar |
| 314 | * @date 12 JUL 2012 |
| 315 | * @version 1.0 |
| 316 | */ |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 317 | struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 318 | { |
| 319 | |
| 320 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 321 | u32 ret = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 322 | struct WILC_WFI_mon_priv *priv; |
| 323 | |
| 324 | /*If monitor interface is already initialized, return it*/ |
| 325 | if (wilc_wfi_mon) { |
| 326 | return wilc_wfi_mon; |
| 327 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 328 | |
| 329 | wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv)); |
| 330 | if (!wilc_wfi_mon) { |
| 331 | PRINT_ER("failed to allocate memory\n"); |
| 332 | return NULL; |
| 333 | |
| 334 | } |
| 335 | |
| 336 | wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP; |
| 337 | strncpy(wilc_wfi_mon->name, name, IFNAMSIZ); |
| 338 | wilc_wfi_mon->name[IFNAMSIZ - 1] = 0; |
| 339 | wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops; |
| 340 | |
| 341 | ret = register_netdevice(wilc_wfi_mon); |
| 342 | if (ret) { |
| 343 | PRINT_ER(" register_netdevice failed (%d)\n", ret); |
| 344 | return NULL; |
| 345 | } |
| 346 | priv = netdev_priv(wilc_wfi_mon); |
| 347 | if (priv == NULL) { |
| 348 | PRINT_ER("private structure is NULL\n"); |
| 349 | return NULL; |
| 350 | } |
| 351 | |
| 352 | priv->real_ndev = real_dev; |
| 353 | |
| 354 | return wilc_wfi_mon; |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * @brief WILC_WFI_deinit_mon_interface |
| 359 | * @details |
| 360 | * @param[in] |
| 361 | * @return int : Return 0 on Success |
| 362 | * @author mdaftedar |
| 363 | * @date 12 JUL 2012 |
| 364 | * @version 1.0 |
| 365 | */ |
Chandra S Gorentla | a96c47e | 2015-08-05 22:11:55 +0530 | [diff] [blame] | 366 | int WILC_WFI_deinit_mon_interface(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 367 | { |
| 368 | bool rollback_lock = false; |
| 369 | |
| 370 | if (wilc_wfi_mon != NULL) { |
| 371 | PRINT_D(HOSTAPD_DBG, "In Deinit monitor interface\n"); |
| 372 | PRINT_D(HOSTAPD_DBG, "RTNL is being locked\n"); |
| 373 | if (rtnl_is_locked()) { |
| 374 | rtnl_unlock(); |
| 375 | rollback_lock = true; |
| 376 | } |
| 377 | PRINT_D(HOSTAPD_DBG, "Unregister netdev\n"); |
| 378 | unregister_netdev(wilc_wfi_mon); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 379 | |
| 380 | if (rollback_lock) { |
| 381 | rtnl_lock(); |
| 382 | rollback_lock = false; |
| 383 | } |
| 384 | wilc_wfi_mon = NULL; |
| 385 | } |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 386 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 387 | |
| 388 | } |