소스 검색

qcacmn: Add APIs to query min and max chanwidth supported by channel

1. Add reg_get_min_chwidth to return the max chanwidth supported by
regulatory given the primary frequency and the pdev.

2. Add reg_get_max_chwidth to return the max chanwidth supported by
regulatory given the primary frequency and the pdev.

3. Add dispatcher functions for both

Change-Id: Ia21198fe778d32b1673e5dd30c8cd621cded2c45
CRs-Fixed: 3098311
Ananya Barat 3 년 전
부모
커밋
6ee7701aab

+ 51 - 6
umac/regulatory/core/src/reg_services_common.c

@@ -2246,32 +2246,77 @@ bool reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq)
 				     FIVE_GIG_ENDING_EDGE_FREQ);
 }
 
-bool reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
+static struct regulatory_channel *
+reg_get_reg_chan(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
 {
 	struct regulatory_channel *cur_chan_list;
 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
 	enum channel_enum chan_enum;
 
 	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;
+		return NULL;
 	}
 
 	chan_enum = reg_get_chan_enum_for_freq(freq);
-
 	if (chan_enum == INVALID_CHANNEL) {
 		reg_err_rl("Invalid chan enum %d", chan_enum);
-		return false;
+		return NULL;
 	}
 
 	cur_chan_list = pdev_priv_obj->cur_chan_list;
+	if (cur_chan_list[chan_enum].state == CHANNEL_STATE_DISABLE) {
+		reg_err("Channel %u is not enabled for this pdev", freq);
+		return NULL;
+	}
+
+	return &cur_chan_list[chan_enum];
+}
+
+bool reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
+{
+	struct regulatory_channel *reg_chan;
+
+	reg_chan = reg_get_reg_chan(pdev, freq);
+
+	if (!reg_chan) {
+		reg_err("reg channel is NULL");
+		return false;
+	}
 
-	return (cur_chan_list[chan_enum].chan_flags &
+	return (reg_chan->chan_flags &
 		REGULATORY_CHAN_INDOOR_ONLY);
 }
 
+uint16_t reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
+{
+	struct regulatory_channel *reg_chan;
+
+	reg_chan = reg_get_reg_chan(pdev, freq);
+
+	if (!reg_chan) {
+		reg_err("reg channel is NULL");
+		return 0;
+	}
+
+	return reg_chan->min_bw;
+}
+
+uint16_t reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
+{
+	struct regulatory_channel *reg_chan;
+
+	reg_chan = reg_get_reg_chan(pdev, freq);
+
+	if (!reg_chan) {
+		reg_err("reg channel is NULL");
+		return 0;
+	}
+
+	return reg_chan->max_bw;
+}
+
 #ifdef CONFIG_REG_CLIENT
 bool reg_is_freq_indoor_in_secondary_list(struct wlan_objmgr_pdev *pdev,
 					  qdf_freq_t freq)

+ 18 - 0
umac/regulatory/core/src/reg_services_common.h

@@ -456,6 +456,24 @@ bool reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq);
  */
 bool reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
 
+/**
+ * reg_get_min_chwidth() - Return min chanwidth supported by freq.
+ * @pdev: Pointer to pdev.
+ * @freq: Channel frequency.
+ *
+ * Return: Min chwidth supported by freq as per regulatory DB.
+ */
+uint16_t reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
+
+/**
+ * reg_get_max_chwidth() - Return max chanwidth supported by freq.
+ * @pdev: Pointer to pdev.
+ * @freq: Channel frequency.
+ *
+ * Return: Max chwidth supported by freq as per regulatory DB.
+ */
+uint16_t reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
+
 #ifdef CONFIG_REG_CLIENT
 /**
  * reg_is_freq_indoor_in_secondary_list() - Check if the input frequency is

+ 20 - 0
umac/regulatory/dispatcher/inc/wlan_reg_services_api.h

@@ -122,6 +122,26 @@ bool wlan_reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq);
  */
 bool wlan_reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
 
+/**
+ * wlan_reg_get_min_chwidth() - Return min chanwidth supported by freq.
+ * @pdev: Pointer to pdev.
+ * @freq: Channel frequency.
+ *
+ * Return: Min chwidth supported by freq as per regulatory DB.
+ */
+uint16_t wlan_reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev,
+				  qdf_freq_t freq);
+
+/**
+ * wlan_reg_get_max_chwidth() - Return max chanwidth supported by freq.
+ * @pdev: Pointer to pdev.
+ * @freq: Channel frequency.
+ *
+ * Return: Max chwidth supported by freq as per regulatory DB.
+ */
+uint16_t wlan_reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev,
+				  qdf_freq_t freq);
+
 /**
  * wlan_reg_get_next_lower_bandwidth() - Get next lower bandwdith
  * @ch_width: channel bandwdith

+ 12 - 0
umac/regulatory/dispatcher/src/wlan_reg_services_api.c

@@ -832,6 +832,18 @@ bool wlan_reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
 	return reg_is_freq_indoor(pdev, freq);
 }
 
+uint16_t wlan_reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev,
+				  qdf_freq_t freq)
+{
+	return reg_get_min_chwidth(pdev, freq);
+}
+
+uint16_t wlan_reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev,
+				  qdf_freq_t freq)
+{
+	return reg_get_max_chwidth(pdev, freq);
+}
+
 enum phy_ch_width
 wlan_reg_get_next_lower_bandwidth(enum phy_ch_width ch_width)
 {