qtnfmac: pass complete channel info in regulatory notifier
authorIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Wed, 20 Mar 2019 10:03:53 +0000 (10:03 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 4 Apr 2019 09:57:26 +0000 (12:57 +0300)
Currently only a portion of per-channel information is passed to
firmware. Extend logic to pass all useful per-channel data.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h

index b1b622019f123cdbe0340329575c46ba646b109c..e61bec7c5d8a57d5fd5416285277a140568da5cd 100644 (file)
@@ -1709,21 +1709,7 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
        struct qlink_resp_band_info_get *resp;
        size_t info_len = 0;
        int ret = 0;
-       u8 qband;
-
-       switch (band->band) {
-       case NL80211_BAND_2GHZ:
-               qband = QLINK_BAND_2GHZ;
-               break;
-       case NL80211_BAND_5GHZ:
-               qband = QLINK_BAND_5GHZ;
-               break;
-       case NL80211_BAND_60GHZ:
-               qband = QLINK_BAND_60GHZ;
-               break;
-       default:
-               return -EINVAL;
-       }
+       u8 qband = qlink_utils_band_cfg2q(band->band);
 
        cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
                                            QLINK_CMD_BAND_INFO_GET,
@@ -2107,22 +2093,23 @@ out:
 static void qtnf_cmd_channel_tlv_add(struct sk_buff *cmd_skb,
                                     const struct ieee80211_channel *sc)
 {
-       struct qlink_tlv_channel *qchan;
-       u32 flags = 0;
-
-       qchan = skb_put_zero(cmd_skb, sizeof(*qchan));
-       qchan->hdr.type = cpu_to_le16(QTN_TLV_ID_CHANNEL);
-       qchan->hdr.len = cpu_to_le16(sizeof(*qchan) - sizeof(qchan->hdr));
-       qchan->chan.center_freq = cpu_to_le16(sc->center_freq);
-       qchan->chan.hw_value = cpu_to_le16(sc->hw_value);
-
-       if (sc->flags & IEEE80211_CHAN_NO_IR)
-               flags |= QLINK_CHAN_NO_IR;
-
-       if (sc->flags & IEEE80211_CHAN_RADAR)
-               flags |= QLINK_CHAN_RADAR;
-
-       qchan->chan.flags = cpu_to_le32(flags);
+       struct qlink_tlv_channel *tlv;
+       struct qlink_channel *qch;
+
+       tlv = skb_put_zero(cmd_skb, sizeof(*tlv));
+       qch = &tlv->chan;
+       tlv->hdr.type = cpu_to_le16(QTN_TLV_ID_CHANNEL);
+       tlv->hdr.len = cpu_to_le16(sizeof(*qch));
+
+       qch->center_freq = cpu_to_le16(sc->center_freq);
+       qch->hw_value = cpu_to_le16(sc->hw_value);
+       qch->band = qlink_utils_band_cfg2q(sc->band);
+       qch->max_power = sc->max_power;
+       qch->max_reg_power = sc->max_reg_power;
+       qch->max_antenna_gain = sc->max_antenna_gain;
+       qch->beacon_found = sc->beacon_found;
+       qch->dfs_state = qlink_utils_dfs_state_cfg2q(sc->dfs_state);
+       qch->flags = cpu_to_le32(qlink_utils_chflags_cfg2q(sc->flags));
 }
 
 static void qtnf_cmd_randmac_tlv_add(struct sk_buff *cmd_skb,
index 72bfd17cb687cfead142a814b78b8027d5839fca..8cae9d8d1ab6fd7eb6bdd9642c699844d847d95d 100644 (file)
@@ -182,3 +182,58 @@ void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
        memcpy(qacl->mac_addrs, acl->mac_addrs,
               acl->n_acl_entries * sizeof(*qacl->mac_addrs));
 }
+
+enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band)
+{
+       switch (band) {
+       case NL80211_BAND_2GHZ:
+               return QLINK_BAND_2GHZ;
+       case NL80211_BAND_5GHZ:
+               return QLINK_BAND_5GHZ;
+       case NL80211_BAND_60GHZ:
+               return QLINK_BAND_60GHZ;
+       default:
+               return -EINVAL;
+       }
+}
+
+enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state)
+{
+       switch (state) {
+       case NL80211_DFS_USABLE:
+               return QLINK_DFS_USABLE;
+       case NL80211_DFS_AVAILABLE:
+               return QLINK_DFS_AVAILABLE;
+       case NL80211_DFS_UNAVAILABLE:
+       default:
+               return QLINK_DFS_UNAVAILABLE;
+       }
+}
+
+u32 qlink_utils_chflags_cfg2q(u32 cfgflags)
+{
+       u32 flags = 0;
+
+       if (cfgflags & IEEE80211_CHAN_DISABLED)
+               flags |= QLINK_CHAN_DISABLED;
+
+       if (cfgflags & IEEE80211_CHAN_NO_IR)
+               flags |= QLINK_CHAN_NO_IR;
+
+       if (cfgflags & IEEE80211_CHAN_RADAR)
+               flags |= QLINK_CHAN_RADAR;
+
+       if (cfgflags & IEEE80211_CHAN_NO_HT40PLUS)
+               flags |= QLINK_CHAN_NO_HT40PLUS;
+
+       if (cfgflags & IEEE80211_CHAN_NO_HT40MINUS)
+               flags |= QLINK_CHAN_NO_HT40MINUS;
+
+       if (cfgflags & IEEE80211_CHAN_NO_80MHZ)
+               flags |= QLINK_CHAN_NO_80MHZ;
+
+       if (cfgflags & IEEE80211_CHAN_NO_160MHZ)
+               flags |= QLINK_CHAN_NO_160MHZ;
+
+       return flags;
+}
index 781ea7fe79f211d4beb224021f38612be7ced232..9d10a2098ca74f7b6ccf435827ab18790d26ec6f 100644 (file)
@@ -79,5 +79,8 @@ bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit,
                           unsigned int arr_max_len);
 void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
                          struct qlink_acl_data *qacl);
+enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band);
+enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state);
+u32 qlink_utils_chflags_cfg2q(u32 cfgflags);
 
 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */