瀏覽代碼

qca-wifi: Add a new API to check band capability

Add a new API wlan_reg_is_band_present to check band capability
by taking band as input and return true if a band channel is found, else
return false.

Change-Id: I4fb3b79d8327307ac15b8a656689c0186fdf063b
CRs-Fixed: 2828765
Hariharan Basuthkar 4 年之前
父節點
當前提交
5bf6fe272f

+ 59 - 0
umac/regulatory/core/reg_channel.c

@@ -27,6 +27,7 @@
 #include <reg_priv_objs.h>
 #include <reg_priv_objs.h>
 #include <reg_services_common.h>
 #include <reg_services_common.h>
 #include "reg_channel.h"
 #include "reg_channel.h"
+#include <wlan_reg_channel_api.h>
 
 
 #ifdef CONFIG_HOST_FIND_CHAN
 #ifdef CONFIG_HOST_FIND_CHAN
 
 
@@ -277,4 +278,62 @@ void reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev)
 	for (i = 0; i < NUM_CHANNELS; i++)
 	for (i = 0; i < NUM_CHANNELS; i++)
 		cur_chan_list[i].is_chan_hop_blocked = false;
 		cur_chan_list[i].is_chan_hop_blocked = false;
 }
 }
+
+/*
+ * reg_is_band_found_internal - Check if a band channel is found in the
+ * current channel list.
+ *
+ * @start_idx - Start index.
+ * @end_idx - End index.
+ * @cur_chan_list - Pointer to cur_chan_list.
+ */
+static bool reg_is_band_found_internal(enum channel_enum start_idx,
+				       enum channel_enum end_idx,
+				       struct regulatory_channel *cur_chan_list)
+{
+	uint8_t i;
+
+	for (i = start_idx; i <= end_idx; i++)
+		if (!(reg_is_chan_disabled(cur_chan_list[i])))
+			return true;
+
+	return false;
+}
+
+bool reg_is_band_present(struct wlan_objmgr_pdev *pdev,
+			 enum reg_wifi_band reg_band)
+{
+	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
+	struct regulatory_channel *cur_chan_list;
+	enum channel_enum min_chan_idx, max_chan_idx;
+
+	switch (reg_band) {
+	case REG_BAND_2G:
+		min_chan_idx = MIN_24GHZ_CHANNEL;
+		max_chan_idx = MAX_24GHZ_CHANNEL;
+		break;
+	case REG_BAND_5G:
+		min_chan_idx = MIN_49GHZ_CHANNEL;
+		max_chan_idx = MAX_5GHZ_CHANNEL;
+		break;
+	case REG_BAND_6G:
+		min_chan_idx = MIN_6GHZ_CHANNEL;
+		max_chan_idx = MAX_6GHZ_CHANNEL;
+		break;
+	default:
+		return false;
+	}
+
+	pdev_priv_obj = reg_get_pdev_obj(pdev);
+
+	if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
+		reg_err("reg pdev priv obj is NULL");
+		return false;
+	}
+
+	cur_chan_list = pdev_priv_obj->cur_chan_list;
+
+	return reg_is_band_found_internal(min_chan_idx, max_chan_idx,
+					  cur_chan_list);
+}
 #endif
 #endif

+ 31 - 0
umac/regulatory/core/reg_channel.h

@@ -150,6 +150,22 @@ enum {
 #define WIRELESS_160_MODES   (HOST_REGDMN_MODE_11AC_VHT160 \
 #define WIRELESS_160_MODES   (HOST_REGDMN_MODE_11AC_VHT160 \
 			      | HOST_REGDMN_MODE_11AXA_HE160)
 			      | HOST_REGDMN_MODE_11AXA_HE160)
 
 
+/**
+ * REG_IS_CHAN_DISABLED() - In the regulatory channel list, a channel
+ * may be disabled by the regulatory/device or by radar. Radar is temporary
+ * and a radar disabled channel does not mean that the channel is permanently
+ * disabled. The API checks if the channel is disabled, but not due to radar.
+ * @chan - Regulatory channel object
+ *
+ * Return - True,  the channel is disabled, but not due to radar, else false.
+ */
+static bool reg_is_chan_disabled(struct regulatory_channel chan)
+{
+	return (((chan).chan_flags & REGULATORY_CHAN_DISABLED) &&
+		((chan).state == CHANNEL_STATE_DISABLE) &&
+		(!((chan).nol_chan)) && (!((chan).nol_history)));
+}
+
 /**
 /**
  * reg_is_phymode_chwidth_allowed() - Check if requested phymode is allowed
  * reg_is_phymode_chwidth_allowed() - Check if requested phymode is allowed
  * @pdev_priv_obj: Pointer to regulatory pdev private object.
  * @pdev_priv_obj: Pointer to regulatory pdev private object.
@@ -195,6 +211,15 @@ bool reg_is_chan_blocked(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
  */
  */
 void reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev);
 void reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev);
 
 
+/*
+ * reg_is_band_present() - Check if input band channels are present
+ * in the regulatory current channel list.
+ * @pdev: pdev pointer.
+ * @reg_band: regulatory band.
+ *
+ */
+bool reg_is_band_present(struct wlan_objmgr_pdev *pdev,
+			 enum reg_wifi_band reg_band);
 #else
 #else
 static inline bool reg_is_phymode_chwidth_allowed(
 static inline bool reg_is_phymode_chwidth_allowed(
 		struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj,
 		struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj,
@@ -219,6 +244,12 @@ bool reg_is_chan_blocked(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
 static inline void reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev)
 static inline void reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev)
 {
 {
 }
 }
+
+static inline bool
+reg_is_band_present(struct wlan_objmgr_pdev *pdev, enum reg_wifi_band reg_band)
+{
+	return false;
+}
 #endif /* CONFIG_HOST_FIND_CHAN */
 #endif /* CONFIG_HOST_FIND_CHAN */
 
 
 #endif /* __REG_CHANNEL_H_ */
 #endif /* __REG_CHANNEL_H_ */

+ 17 - 0
umac/regulatory/dispatcher/inc/wlan_reg_channel_api.h

@@ -122,6 +122,16 @@ void wlan_reg_get_chan_flags(struct wlan_objmgr_pdev *pdev,
 			     qdf_freq_t freq2,
 			     qdf_freq_t freq2,
 			     uint16_t *sec_flags,
 			     uint16_t *sec_flags,
 			     uint64_t *pri_flags);
 			     uint64_t *pri_flags);
+
+/**
+ * wlan_reg_is_band_present() - Check if input band channels are present
+ * in the regulatory current channel list.
+ * @pdev: pdev pointer.
+ * @reg_band: regulatory band.
+ *
+ */
+bool wlan_reg_is_band_present(struct wlan_objmgr_pdev *pdev,
+			      enum reg_wifi_band reg_band);
 #else
 #else
 static inline
 static inline
 void wlan_reg_set_chan_blocked(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
 void wlan_reg_set_chan_blocked(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
@@ -171,6 +181,13 @@ wlan_reg_get_chan_flags(struct wlan_objmgr_pdev *pdev,
 			uint64_t *pri_flags)
 			uint64_t *pri_flags)
 {
 {
 }
 }
+
+static inline
+bool wlan_reg_is_band_present(struct wlan_objmgr_pdev *pdev,
+			      enum reg_wifi_band reg_band)
+{
+	return false;
+}
 #endif /* CONFIG_HOST_FIND_CHAN */
 #endif /* CONFIG_HOST_FIND_CHAN */
 
 
 #endif /* __WLAN_REG_CHANNEL_API_H */
 #endif /* __WLAN_REG_CHANNEL_API_H */

+ 8 - 0
umac/regulatory/dispatcher/src/wlan_reg_channel_api.c

@@ -156,4 +156,12 @@ void wlan_reg_clear_allchan_blocked(struct wlan_objmgr_pdev *pdev)
 {
 {
 	 reg_clear_allchan_blocked(pdev);
 	 reg_clear_allchan_blocked(pdev);
 }
 }
+
+bool wlan_reg_is_band_present(struct wlan_objmgr_pdev *pdev,
+			      enum reg_wifi_band reg_band)
+{
+	return reg_is_band_present(pdev, reg_band);
+}
+
+qdf_export_symbol(wlan_reg_is_band_present);
 #endif /* CONFIG_HOST_FIND_CHAN */
 #endif /* CONFIG_HOST_FIND_CHAN */