[WCNCR00147618] misc: Fix build errors on linux-3.13.y

[Description]
Fix build errors on linux-3.13.y:
gen4m/os/linux/include/gl_os.h:908:22: error: unknown type name
'select_queue_fallback_t'
    void *accel_priv, select_queue_fallback_t fallback);
                      ^

Move duplicate lines from wlanSelectQueue() to a new inline function
mtk_wlan_ndev_select_queue() in gl_os.h. Also change return type of
wlanSelectQueue() to u16 to align definitions in struct net_device_ops.

Tested ok by
1. build 12 variants ok:
    make -f Makefile.x86 \
       LINUX_SRC={3.10.23/arm, 3.18.42/i386, 4.4.23/amd64, 3.13.11/amd64} \
       hif={sdio, pcie, usb}
2. insmod ok on 4.4.39/amd64

Change-Id: I46a9808bd07c40536720644f630e2cff07db3e9b
Feature: misc
CR-Id: WCNCR00147618
Signed-off-by: George Kuo <george.kuo@mediatek.com>
diff --git a/os/linux/gl_init.c b/os/linux/gl_init.c
index c98c177..71d7c81 100644
--- a/os/linux/gl_init.c
+++ b/os/linux/gl_init.c
@@ -508,36 +508,25 @@
 }
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
-UINT_16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
-			void *accel_priv, select_queue_fallback_t fallback)
+#if KERNEL_VERSION(3, 14, 0) <= LINUX_VERSION_CODE
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
+		    void *accel_priv, select_queue_fallback_t fallback)
 {
-	UINT_16 au16Wlan1dToQueueIdx[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
-
-	/* Use Linux wireless utility function */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
-	skb->priority = cfg80211_classify8021d(skb);
-#else
-	skb->priority = cfg80211_classify8021d(skb, NULL);
-#endif
-
-	return au16Wlan1dToQueueIdx[skb->priority];
+	return mtk_wlan_ndev_select_queue(skb);
+}
+#elif KERNEL_VERSION(3, 13, 0) <= LINUX_VERSION_CODE
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
+		    void *accel_priv)
+{
+	return mtk_wlan_ndev_select_queue(skb);
 }
 #else
-UINT_16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb)
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb)
 {
-	UINT_16 au16Wlan1dToQueueIdx[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
-
-	/* Use Linux wireless utility function */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
-	skb->priority = cfg80211_classify8021d(skb);
-#else
-	skb->priority = cfg80211_classify8021d(skb, NULL);
-#endif
-
-	return au16Wlan1dToQueueIdx[skb->priority];
+	return mtk_wlan_ndev_select_queue(skb);
 }
 #endif
+
 /*----------------------------------------------------------------------------*/
 /*!
 * \brief Load NVRAM data and translate it into REG_INFO_T
diff --git a/os/linux/include/gl_os.h b/os/linux/include/gl_os.h
index 1cd81d9..f91e630 100644
--- a/os/linux/include/gl_os.h
+++ b/os/linux/include/gl_os.h
@@ -874,6 +874,19 @@
 	DATA_STRUCT_INSPECTING_ASSERT(sizeof(PACKET_PRIVATE_DATA) <= sizeof(((struct sk_buff *) 0)->cb));
 }
 
+static inline u16 mtk_wlan_ndev_select_queue(struct sk_buff *skb)
+{
+	static u16 ieee8021d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
+
+	/* cfg80211_classify8021d returns 0~7 */
+#if KERNEL_VERSION(3, 14, 0) > LINUX_VERSION_CODE
+	skb->priority = cfg80211_classify8021d(skb);
+#else
+	skb->priority = cfg80211_classify8021d(skb, NULL);
+#endif
+	return ieee8021d_to_queue[skb->priority];
+}
+
 /*******************************************************************************
 *                  F U N C T I O N   D E C L A R A T I O N S
 ********************************************************************************
@@ -903,11 +916,14 @@
 
 P_GLUE_INFO_T wlanGetGlueInfo(VOID);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
-UINT_16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
-			void *accel_priv, select_queue_fallback_t fallback);
+#if KERNEL_VERSION(3, 14, 0) <= LINUX_VERSION_CODE
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
+		    void *accel_priv, select_queue_fallback_t fallback);
+#elif KERNEL_VERSION(3, 13, 0) <= LINUX_VERSION_CODE
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb,
+		    void *accel_priv);
 #else
-UINT_16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb);
+u16 wlanSelectQueue(struct net_device *dev, struct sk_buff *skb);
 #endif
 
 VOID wlanDebugInit(VOID);