wlan: Update driver for Linux kernel 3.6 and 3.7 changes

Linux kernel versions 3.6 and 3.7 have modified some of the cfg80211
APIs used by the driver.  Update our implementation to support the
revised APIs.

CRs-Fixed: 443387
Change-Id: Id65f6b438c02d9b051ce0174f60ab360453db6b7
(cherry picked from commit 661ec495b3c9f305237bcfd3598e2d34c4aa03be)
diff --git a/CORE/HDD/inc/wlan_hdd_p2p.h b/CORE/HDD/inc/wlan_hdd_p2p.h
index 0469785..8145de4 100644
--- a/CORE/HDD/inc/wlan_hdd_p2p.h
+++ b/CORE/HDD/inc/wlan_hdd_p2p.h
@@ -103,18 +103,30 @@
 }p2p_app_setP2pPs_t;
 
 int wlan_hdd_cfg80211_remain_on_channel( struct wiphy *wiphy,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                                struct wireless_dev *wdev,
+#else
                                 struct net_device *dev,
+#endif
                                 struct ieee80211_channel *chan,
                                 enum nl80211_channel_type channel_type,
                                 unsigned int duration, u64 *cookie );
 
 int wlan_hdd_cfg80211_cancel_remain_on_channel( struct wiphy *wiphy,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                                       struct wireless_dev *wdev,
+#else
                                        struct net_device *dev,
+#endif
                                        u64 cookie );
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
 int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                                          struct wireless_dev *wdev,
+#else
                                           struct net_device *dev,
+#endif
                                           u64 cookie);
 #endif
 
@@ -132,7 +144,14 @@
 int wlan_hdd_check_remain_on_channel(hdd_adapter_t *pAdapter);
 void wlan_hdd_cancel_existing_remain_on_channel(hdd_adapter_t *pAdapter);
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+int wlan_hdd_action( struct wiphy *wiphy, struct wireless_dev *wdev,
+                     struct ieee80211_channel *chan, bool offchan,
+                     enum nl80211_channel_type channel_type,
+                     bool channel_type_valid, unsigned int wait,
+                     const u8 *buf, size_t len,  bool no_cck,
+                     bool dont_wait_for_ack, u64 *cookie );
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
 int wlan_hdd_action( struct wiphy *wiphy, struct net_device *dev,
                      struct ieee80211_channel *chan, bool offchan,
                      enum nl80211_channel_type channel_type,
@@ -155,11 +174,30 @@
 
 #endif // WLAN_FEATURE_P2P
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+struct wireless_dev* wlan_hdd_add_virtual_intf(
+                  struct wiphy *wiphy, const char *name,
+                  enum nl80211_iftype type,
+                  u32 *flags, struct vif_params *params );
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+struct wireless_dev* wlan_hdd_add_virtual_intf(
+                  struct wiphy *wiphy, char *name, enum nl80211_iftype type,
+                  u32 *flags, struct vif_params *params );
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
 struct net_device* wlan_hdd_add_virtual_intf(
                   struct wiphy *wiphy, char *name, enum nl80211_iftype type,
                   u32 *flags, struct vif_params *params );
+#else
+int wlan_hdd_add_virtual_intf( struct wiphy *wiphy, char *name,
+                               enum nl80211_iftype type,
+                               u32 *flags, struct vif_params *params );
+#endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct wireless_dev *wdev );
+#else
 int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct net_device *dev );
+#endif
 
 #endif // CONFIG_CFG80211
 
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 28b9b17..e8b1efa 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -348,7 +348,7 @@
             BIT(SIR_MAC_MGMT_DEAUTH) |
             BIT(SIR_MAC_MGMT_ACTION),
     },
-#endif    
+#endif
 };
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
@@ -545,7 +545,7 @@
 #ifdef WLAN_FEATURE_P2P
                              | BIT(NL80211_IFTYPE_P2P_CLIENT)
                              | BIT(NL80211_IFTYPE_P2P_GO)
-#endif                       
+#endif
                              | BIT(NL80211_IFTYPE_AP);
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
@@ -3322,6 +3322,7 @@
     return status;
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
 /**
  * FUNCTION: wlan_hdd_cfg80211_set_channel
  * This function is used to set the channel number 
@@ -3448,6 +3449,7 @@
     EXIT();
     return 0;
 }
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) */
 
 
 
@@ -4026,9 +4028,15 @@
  * this scan respond to scan trigger and update cfg80211 scan database
  * later, scan dump command can be used to recieve scan results
  */
-int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, struct net_device *dev,
-        struct cfg80211_scan_request *request)
-{  
+int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
+                            struct net_device *dev,
+#endif
+                            struct cfg80211_scan_request *request)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+   struct net_device *dev = request->wdev->netdev;
+#endif
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); 
     hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
     hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
@@ -6616,7 +6624,9 @@
     .get_key = wlan_hdd_cfg80211_get_key,
     .del_key = wlan_hdd_cfg80211_del_key,
     .set_default_key = wlan_hdd_cfg80211_set_default_key,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
     .set_channel = wlan_hdd_cfg80211_set_channel,
+#endif
     .scan = wlan_hdd_cfg80211_scan,
     .connect = wlan_hdd_cfg80211_connect,
     .disconnect = wlan_hdd_cfg80211_disconnect,
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index 04a1881..c9d6746 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -146,7 +146,12 @@
                    "%s: We need to receive yet an ack from one of tx packet",
                    __func__);
         }
-        cfg80211_remain_on_channel_expired( pRemainChanCtx->dev,
+        cfg80211_remain_on_channel_expired(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                              pRemainChanCtx->dev->ieee80211_ptr,
+#else
+                              pRemainChanCtx->dev,
+#endif
                               pRemainChanCtx->cookie,
                               &pRemainChanCtx->chan,
                               pRemainChanCtx->chan_type, GFP_KERNEL );
@@ -383,11 +388,18 @@
 }
 
 int wlan_hdd_cfg80211_remain_on_channel( struct wiphy *wiphy,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                                struct wireless_dev *wdev,
+#else
                                 struct net_device *dev,
+#endif
                                 struct ieee80211_channel *chan,
                                 enum nl80211_channel_type channel_type,
                                 unsigned int duration, u64 *cookie )
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    struct net_device *dev = wdev->netdev;
+#endif
     return wlan_hdd_request_remain_on_channel(wiphy, dev,
                                         chan, channel_type, duration, cookie,
                                         REMAIN_ON_CHANNEL_REQUEST);
@@ -404,7 +416,13 @@
     {
         if( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request )
         {
-            cfg80211_ready_on_channel( pAdapter->dev, (tANI_U32)pRemainChanCtx,
+            cfg80211_ready_on_channel(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                               pAdapter->dev->ieee80211_ptr,
+#else
+                               pAdapter->dev,
+#endif
+                               (tANI_U32)pRemainChanCtx,
                                &pRemainChanCtx->chan, pRemainChanCtx->chan_type,
                                pRemainChanCtx->duration, GFP_KERNEL );
         }
@@ -424,8 +442,16 @@
 }
 
 int wlan_hdd_cfg80211_cancel_remain_on_channel( struct wiphy *wiphy,
-                                      struct net_device *dev, u64 cookie )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                                                struct wireless_dev *wdev,
+#else
+                                                struct net_device *dev,
+#endif
+                                                u64 cookie )
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    struct net_device *dev = wdev->netdev;
+#endif
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
     hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
     int status = 0;
@@ -492,7 +518,14 @@
     return 0;
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+int wlan_hdd_action( struct wiphy *wiphy, struct wireless_dev *wdev,
+                     struct ieee80211_channel *chan, bool offchan,
+                     enum nl80211_channel_type channel_type,
+                     bool channel_type_valid, unsigned int wait,
+                     const u8 *buf, size_t len,  bool no_cck,
+                     bool dont_wait_for_ack, u64 *cookie )
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
 int wlan_hdd_action( struct wiphy *wiphy, struct net_device *dev,
                      struct ieee80211_channel *chan, bool offchan,
                      enum nl80211_channel_type channel_type,
@@ -513,6 +546,9 @@
                      const u8 *buf, size_t len, u64 *cookie )
 #endif //LINUX_VERSION_CODE
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    struct net_device *dev = wdev->netdev;
+#endif
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
     hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
     tANI_U16 extendedWait = 0;
@@ -765,18 +801,33 @@
     return 0;
 err_rem_channel:
     *cookie = (tANI_U32)cfgState;
-    cfg80211_mgmt_tx_status( pAdapter->dev, *cookie, buf, len, FALSE, GFP_KERNEL );
+    cfg80211_mgmt_tx_status(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                            pAdapter->dev->ieee80211_ptr,
+#else
+                            pAdapter->dev,
+#endif
+                            *cookie, buf, len, FALSE, GFP_KERNEL );
     return 0;
 }
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
-int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
+                                          struct wireless_dev *wdev,
+                                          u64 cookie)
+{
+    return wlan_hdd_cfg80211_cancel_remain_on_channel( wiphy, wdev, cookie );
+}
+#else
+int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
                                           struct net_device *dev,
                                           u64 cookie)
 {
     return wlan_hdd_cfg80211_cancel_remain_on_channel( wiphy, dev, cookie );
 }
 #endif
+#endif
 
 void hdd_sendActionCnf( hdd_adapter_t *pAdapter, tANI_BOOLEAN actionSendSuccess )
 {
@@ -800,7 +851,13 @@
          * In case of mac80211, they just push it to the skb and pass the same
          * data while sending tx ack status.
          * */
-         cfg80211_mgmt_tx_status( pAdapter->dev, cfgState->action_cookie,
+         cfg80211_mgmt_tx_status(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+                pAdapter->dev->ieee80211_ptr,
+#else
+                pAdapter->dev,
+#endif
+                cfgState->action_cookie,
                 cfgState->buf, cfgState->len, actionSendSuccess, GFP_KERNEL );
          vos_mem_free( cfgState->buf );
          cfgState->buf = NULL;
@@ -1069,7 +1126,16 @@
     return sessionType;
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+struct wireless_dev* wlan_hdd_add_virtual_intf(
+                  struct wiphy *wiphy, const char *name,
+                  enum nl80211_iftype type,
+                  u32 *flags, struct vif_params *params )
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+struct wireless_dev* wlan_hdd_add_virtual_intf(
+                  struct wiphy *wiphy, char *name, enum nl80211_iftype type,
+                  u32 *flags, struct vif_params *params )
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
 struct net_device* wlan_hdd_add_virtual_intf(
                   struct wiphy *wiphy, char *name, enum nl80211_iftype type,
                   u32 *flags, struct vif_params *params )
@@ -1133,15 +1199,24 @@
 #endif
     }
     EXIT();
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    return pAdapter->dev->ieee80211_ptr;
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
     return pAdapter->dev;
 #else
     return 0;
 #endif
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct wireless_dev *wdev )
+#else
 int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct net_device *dev )
+#endif
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    struct net_device *dev = wdev->netdev;
+#endif
      hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
      hdd_adapter_t *pVirtAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
      ENTER();
@@ -1416,7 +1491,11 @@
     //Indicate Frame Over Normal Interface
     hddLog( LOG1, FL("Indicate Frame over NL80211 Interface"));
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+    cfg80211_rx_mgmt( pAdapter->dev->ieee80211_ptr, freq, 0,
+                      pbFrames, nFrameLength,
+                      GFP_ATOMIC );
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
     cfg80211_rx_mgmt( pAdapter->dev, freq, 0,
                       pbFrames, nFrameLength,
                       GFP_ATOMIC );