diff mbox

ath10k: set MAC timestamp in management Rx frame

Message ID 1456251439-14720-1-git-send-email-poh@qca.qualcomm.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show

Commit Message

Peter Oh Feb. 23, 2016, 6:17 p.m. UTC
From: poh <poh@qca.qualcomm.com>

Check and set Rx MAC timestamp when firmware indicates it.
Firmware adds it in Rx beacon frame only at this moment.
Driver and mac80211 may utilize it to detect such clockdrift
or beacon collision and use the result for beacon collision
avoidance.

Signed-off-by: poh <poh@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/wmi.c | 13 +++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h |  8 ++++++++
 2 files changed, 21 insertions(+)

Comments

kernel test robot Feb. 23, 2016, 6:43 p.m. UTC | #1
Hi poh,

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.5-rc5 next-20160223]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Oh/ath10k-set-MAC-timestamp-in-management-Rx-frame/20160224-022132
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: xtensa-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/ath10k/wmi.c: In function 'ath10k_wmi_event_mgmt_rx':
>> drivers/net/wireless/ath/ath10k/wmi.c:2293:4: warning: left shift count >= width of type
       __le32_to_cpu(arg.ext_info.rx_mac_timestamp_u32) << 32 |
       ^

vim +2293 drivers/net/wireless/ath/ath10k/wmi.c

  2277	
  2278		ath10k_dbg(ar, ATH10K_DBG_MGMT,
  2279			   "event mgmt rx status %08x\n", rx_status);
  2280	
  2281		if ((test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) ||
  2282		    (rx_status & (WMI_RX_STATUS_ERR_DECRYPT |
  2283		    WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) {
  2284			dev_kfree_skb(skb);
  2285			return 0;
  2286		}
  2287	
  2288		if (rx_status & WMI_RX_STATUS_ERR_MIC)
  2289			status->flag |= RX_FLAG_MMIC_ERROR;
  2290	
  2291		if (rx_status & WMI_RX_STATUS_EXT_INFO) {
  2292			status->mactime =
> 2293				__le32_to_cpu(arg.ext_info.rx_mac_timestamp_u32) << 32 |
  2294				__le32_to_cpu(arg.ext_info.rx_mac_timestamp_l32);
  2295			status->flag |= RX_FLAG_MACTIME_END;
  2296		}
  2297		/* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
  2298		 * MODE_11B. This means phy_mode is not a reliable source for the band
  2299		 * of mgmt rx.
  2300		 */
  2301		if (channel >= 1 && channel <= 14) {

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 0f01a8d..fc7b468 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -2167,6 +2167,7 @@  static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
 	struct wmi_mgmt_rx_event_v1 *ev_v1;
 	struct wmi_mgmt_rx_event_v2 *ev_v2;
 	struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
+	struct wmi_mgmt_rx_ext_info *ext_info;
 	size_t pull_len;
 	u32 msdu_len;
 
@@ -2195,6 +2196,12 @@  static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
 	if (skb->len < msdu_len)
 		return -EPROTO;
 
+	if (arg->status & WMI_RX_STATUS_EXT_INFO) {
+		ext_info = (struct wmi_mgmt_rx_ext_info *)
+			   (skb->data + arg->buf_len);
+		memcpy(&arg->ext_info, ext_info,
+		       sizeof(struct wmi_mgmt_rx_ext_info));
+	}
 	/* the WMI buffer might've ended up being padded to 4 bytes due to HTC
 	 * trailer with credit update. Trim the excess garbage.
 	 */
@@ -2281,6 +2288,12 @@  int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 	if (rx_status & WMI_RX_STATUS_ERR_MIC)
 		status->flag |= RX_FLAG_MMIC_ERROR;
 
+	if (rx_status & WMI_RX_STATUS_EXT_INFO) {
+		status->mactime =
+			__le32_to_cpu(arg.ext_info.rx_mac_timestamp_u32) << 32 |
+			__le32_to_cpu(arg.ext_info.rx_mac_timestamp_l32);
+		status->flag |= RX_FLAG_MACTIME_END;
+	}
 	/* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
 	 * MODE_11B. This means phy_mode is not a reliable source for the band
 	 * of mgmt rx.
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 806d4bb..8667a6b 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -3025,11 +3025,18 @@  struct wmi_10_4_mgmt_rx_event {
 	u8 buf[0];
 } __packed;
 
+struct wmi_mgmt_rx_ext_info {
+	__le32 rx_mac_timestamp_l32;
+	__le32 rx_mac_timestamp_u32;
+} __packed;
+
 #define WMI_RX_STATUS_OK			0x00
 #define WMI_RX_STATUS_ERR_CRC			0x01
 #define WMI_RX_STATUS_ERR_DECRYPT		0x08
 #define WMI_RX_STATUS_ERR_MIC			0x10
 #define WMI_RX_STATUS_ERR_KEY_CACHE_MISS	0x20
+/* Extension data at the end of mgmt frame */
+#define WMI_RX_STATUS_EXT_INFO		0x40
 
 #define PHY_ERROR_GEN_SPECTRAL_SCAN		0x26
 #define PHY_ERROR_GEN_FALSE_RADAR_EXT		0x24
@@ -6076,6 +6083,7 @@  struct wmi_mgmt_rx_ev_arg {
 	__le32 phy_mode;
 	__le32 buf_len;
 	__le32 status; /* %WMI_RX_STATUS_ */
+	struct wmi_mgmt_rx_ext_info ext_info;
 };
 
 struct wmi_ch_info_ev_arg {