ath6kl: Remove unnecessary bssinfo event header conversion
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 19 Sep 2011 16:15:05 +0000 (19:15 +0300)
committerKalle Valo <kvalo@qca.qualcomm.com>
Thu, 22 Sep 2011 07:07:59 +0000 (10:07 +0300)
There is no point in unconditionally converting the bssinfo header
to the old version since only the new header is being used and the
driver can as well read the values from it when needed. Leaving out
the conversion saves some extra memory copying.

In addition, use the calculated "rssi" value snr - 95 dBm to get the
proper value in cfg80211 BSS table (i.e., something that more or less
matches with the value used in STA info).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/wmi.c
drivers/net/wireless/ath/ath6kl/wmi.h

index 3ade9a1..72cf78c 100644 (file)
@@ -381,25 +381,6 @@ int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
        return 0;
 }
 
-static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb,
-                                                  u8 *datap)
-{
-       struct wmi_bss_info_hdr2 bih2;
-       struct wmi_bss_info_hdr *bih;
-
-       memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2));
-
-       skb_push(skb, 4);
-       bih = (struct wmi_bss_info_hdr *) skb->data;
-
-       bih->ch = bih2.ch;
-       bih->frame_type = bih2.frame_type;
-       bih->snr = bih2.snr;
-       bih->rssi = a_cpu_to_sle16(bih2.snr - 95);
-       bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask));
-       memcpy(bih->bssid, bih2.bssid, ETH_ALEN);
-}
-
 static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
 {
        struct tx_complete_msg_v1 *msg_v1;
@@ -912,24 +893,24 @@ static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len)
 
 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len)
 {
-       struct wmi_bss_info_hdr *bih;
+       struct wmi_bss_info_hdr2 *bih;
        u8 *buf;
        struct ieee80211_channel *channel;
        struct ath6kl *ar = wmi->parent_dev;
        struct ieee80211_mgmt *mgmt;
        struct cfg80211_bss *bss;
 
-       if (len <= sizeof(struct wmi_bss_info_hdr))
+       if (len <= sizeof(struct wmi_bss_info_hdr2))
                return -EINVAL;
 
-       bih = (struct wmi_bss_info_hdr *) datap;
-       buf = datap + sizeof(struct wmi_bss_info_hdr);
-       len -= sizeof(struct wmi_bss_info_hdr);
+       bih = (struct wmi_bss_info_hdr2 *) datap;
+       buf = datap + sizeof(struct wmi_bss_info_hdr2);
+       len -= sizeof(struct wmi_bss_info_hdr2);
 
        ath6kl_dbg(ATH6KL_DBG_WMI,
                   "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
                   "frame_type=%d\n",
-                  bih->ch, bih->snr, a_sle16_to_cpu(bih->rssi), bih->bssid,
+                  bih->ch, bih->snr, bih->snr - 95, bih->bssid,
                   bih->frame_type);
 
        if (bih->frame_type != BEACON_FTYPE &&
@@ -973,7 +954,8 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len)
        memcpy(&mgmt->u.beacon, buf, len);
 
        bss = cfg80211_inform_bss_frame(ar->wdev->wiphy, channel, mgmt,
-                                       24 + len, bih->snr * 100, GFP_ATOMIC);
+                                       24 + len, (bih->snr - 95) * 100,
+                                       GFP_ATOMIC);
        kfree(mgmt);
        if (bss == NULL)
                return -ENOMEM;
@@ -2859,8 +2841,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
                break;
        case WMI_BSSINFO_EVENTID:
                ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
-               ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap);
-               ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len);
+               ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len);
                break;
        case WMI_REGDOMAIN_EVENTID:
                ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
index f65bc0d..d458d6d 100644 (file)
@@ -1393,33 +1393,14 @@ struct roam_ctrl_cmd {
        u8 roam_ctrl;
 } __packed;
 
-struct wmi_bss_info_hdr {
-       __le16 ch;
-
-       /* see, enum wmi_bi_ftype */
-       u8 frame_type;
-
-       u8 snr;
-       a_sle16 rssi;
-       u8 bssid[ETH_ALEN];
-       __le32 ie_mask;
-} __packed;
-
-/*
- * BSS INFO HDR version 2.0
- * With 6 bytes HTC header and 6 bytes of WMI header
- * WMI_BSS_INFO_HDR cannot be accommodated in the removed 802.11 management
- * header space.
- * - Reduce the ie_mask to 2 bytes as only two bit flags are used
- * - Remove rssi and compute it on the host. rssi = snr - 95
- */
+/* BSS INFO HDR version 2.0 */
 struct wmi_bss_info_hdr2 {
-       __le16 ch;
+       __le16 ch; /* frequency in MHz */
 
        /* see, enum wmi_bi_ftype */
        u8 frame_type;
 
-       u8 snr;
+       u8 snr; /* note: rssi = snr - 95 dBm */
        u8 bssid[ETH_ALEN];
        __le16 ie_mask;
 } __packed;