Skip to contentSkip to conversation

UAPSD support for STA/AP mode

PATCH Superseded Janusz Dziedzic 3 participants 13 messages May 8, 2013 – May 9, 2013 Qualcomm Atheros ATH10K wireless driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover UAPSD support for STA/AP mode

First two paches add PS/UAPSD support for AP/P2P_GO mode. Last one enable UAPSD for STA mode.

In case of FW issues we can easy disable this features by cleaning:
IEEE80211_HW_SUPPORTS_UAPSD/WIPHY_FLAG_AP_UAPSD still have code included.

Janusz Dziedzic (3):
ath10k: WMI add AP PS
ath10k: add AP UAPSD support
ath10k: enable STA UAPSD support

 drivers/net/wireless/ath/ath10k/core.h |    1 +
 drivers/net/wireless/ath/ath10k/mac.c  |  165 +++++++++++++++++++++++++++++---
 drivers/net/wireless/ath/ath10k/wmi.c  |   26 +++++
 drivers/net/wireless/ath/ath10k/wmi.h  |   68 +++++++++++++
 4 files changed, 249 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 ath10k: WMI add AP PS

Add AP power save (UAPSD) structures, enums.

---
 drivers/net/wireless/ath/ath10k/wmi.c |   26 +++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h |   68 +++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +26 -0
index 15e8123..c5f6fda 100644
@@ -1896,6 +1896,32 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
 	return ath10k_wmi_cmd_send(ar, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
 }
 
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+			       enum wmi_ap_ps_peer_param param_id, u32 value)
+{
+	struct wmi_ap_ps_peer_cmd *cmd;
+	struct sk_buff *skb;
+
+	if (!mac)
+		return -EINVAL;
+
+	skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+	if (!skb)
+		return -ENOMEM;
+
+	cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
+	cmd->vdev_id     = __cpu_to_le32(vdev_id);
+	cmd->param_id    = __cpu_to_le32(param_id);
+	cmd->param_value = __cpu_to_le32(value);
+	memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
+
+	ath10k_dbg(ATH10K_DBG_WMI,
+		   "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
+		   vdev_id, param_id, value, mac);
+
+	return ath10k_wmi_cmd_send(ar, skb, WMI_AP_PS_PEER_PARAM_CMDID);
+}
+
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
 			      const struct wmi_scan_chan_list_arg *arg)
 {
drivers/net/wireless/ath/ath10k/wmi.h +68 -0

80 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/3 ath10k: WMI add AP PS

Quoted 3 lines · Janusz Dziedzic

Add AP power save (UAPSD) structures, enums.

[...]

drivers/net/wireless/ath/ath10k/wmi.c int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, · line 1915

Quoted 3 lines
drivers/net/wireless/ath/ath10k/wmi.c +3 -0
+	cmd->vdev_id     = __cpu_to_le32(vdev_id);
+	cmd->param_id    = __cpu_to_le32(param_id);
+	cmd->param_value = __cpu_to_le32(value);

Remove the extra whitespace before '='.

Signature · 1 line
Kalle Valo
#3 lore raw

PATCH 1/3 ath10k: WMI add AP PS

Quoted 13 lines

-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 9 maja 2013 09:10
To: Dziedzic Janusz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH 1/3] ath10k: WMI add AP PS

Quoted 3 lines · Janusz Dziedzic

Add AP power save (UAPSD) structures, enums.

Quoted 8 lines

[...]

drivers/net/wireless/ath/ath10k/wmi.c int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, · line 1915

Quoted 3 lines
drivers/net/wireless/ath/ath10k/wmi.c +3 -0
+	cmd->vdev_id     = __cpu_to_le32(vdev_id);
+	cmd->param_id    = __cpu_to_le32(param_id);
+	cmd->param_value = __cpu_to_le32(value);

Remove the extra whitespace before '='.

I did same style we have in wmi.c In other functions, Eg. (ath10k_wmi_set_psmode)

        cmd->vdev_id     = __cpu_to_le32(vdev_id);
        cmd->sta_ps_mode = __cpu_to_le32(psmode);

So, should I change this?

BR
Janusz

#4 lore raw

PATCH 1/3 ath10k: WMI add AP PS

Quoted 15 lines · <[email protected]> writes:
Quoted 15 lines

-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 9 maja 2013 09:10
To: Dziedzic Janusz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH 1/3] ath10k: WMI add AP PS

Quoted 3 lines · Janusz Dziedzic

Add AP power save (UAPSD) structures, enums.

[...]

Quoted 8 lines
Quoted 6 lines

drivers/net/wireless/ath/ath10k/wmi.c int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, · line 1915

Quoted 3 lines
drivers/net/wireless/ath/ath10k/wmi.c +3 -0
+	cmd->vdev_id     = __cpu_to_le32(vdev_id);
+	cmd->param_id    = __cpu_to_le32(param_id);
+	cmd->param_value = __cpu_to_le32(value);

Remove the extra whitespace before '='.

I did same style we have in wmi.c In other functions,

Yeah, I know. But I would prefer not to use that style in ath10k. I have been trying to remove that style from ath10k, but I haven't converted all cases yet.

Quoted 5 lines

Eg. (ath10k_wmi_set_psmode)

        cmd->vdev_id     = __cpu_to_le32(vdev_id);
        cmd->sta_ps_mode = __cpu_to_le32(psmode);

So, should I change this?

I'm happy to take patches :)

Signature · 1 line
Kalle Valo
#5 lore raw

PATCH 2/3 ath10k: add AP UAPSD support

In reply to Janusz Dziedzic

Add support for AP (P2P_GO) UAPSD.

---
 drivers/net/wireless/ath/ath10k/mac.c |   85 ++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +78 -7
index 930a092..91de248 100644
@@ -886,21 +886,91 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
 		   arg->peer_num_spatial_streams);
 }
 
+static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
+				       struct ath10k_vif *arvif,
+				       struct ieee80211_sta *sta,
+				       struct ieee80211_bss_conf *bss_conf,
+				       struct wmi_peer_assoc_complete_arg *arg)
+{
+	u32 uapsd = 0;
+	u32 max_sp = 0;
+
+	if (sta->wme)
+		arg->peer_flags |= WMI_PEER_QOS;
+
+	if (sta->wme && sta->uapsd_queues) {
+		ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, max_sp: %d\n",
+			   sta->uapsd_queues, sta->max_sp);
+
+		arg->peer_flags |= WMI_PEER_APSD;
+		arg->peer_flags |= WMI_RC_UAPSD_FLAG;
+
+		if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+			uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
+				 WMI_AP_PS_UAPSD_AC3_TRIGGER_EN;
+		if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
+			uapsd |= WMI_AP_PS_UAPSD_AC2_DELIVERY_EN |
+				 WMI_AP_PS_UAPSD_AC2_TRIGGER_EN;
+		if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
+			uapsd |= WMI_AP_PS_UAPSD_AC1_DELIVERY_EN |
+				 WMI_AP_PS_UAPSD_AC1_TRIGGER_EN;
+		if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+			uapsd |= WMI_AP_PS_UAPSD_AC0_DELIVERY_EN |
+				 WMI_AP_PS_UAPSD_AC0_TRIGGER_EN;
+
+
+		if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP)
+			max_sp = sta->max_sp;
+
+		ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+					   sta->addr,
+					   WMI_AP_PS_PEER_PARAM_UAPSD,
+					   uapsd);
+
+		ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+					   sta->addr,
+					   WMI_AP_PS_PEER_PARAM_MAX_SP,
+					   max_sp);
+
+		/* TODO setup this based on STA listen interval and
+		   beacon interval. Currently we don't know
+		   sta->listen_interval - mac80211 patch required.
+		   Currently use 10 seconds */
+		ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+					   sta->addr,
+					   WMI_AP_PS_PEER_PARAM_AGEOUT_TIME,
+					   10);
+	}
+}
+
 /*
- * FIXME: Handle UAPSD later.
+ * FIXME: Handle STA UAPSD later.
  */
+static void ath10k_peer_assoc_h_qos_sta(struct ath10k *ar,
+					struct ath10k_vif *arvif,
+					struct ieee80211_sta *sta,
+					struct ieee80211_bss_conf *bss_conf,
+					struct wmi_peer_assoc_complete_arg *arg)
+{
+	if (bss_conf->qos)
+		arg->peer_flags |= WMI_PEER_QOS;
+}
+
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
 				    struct ath10k_vif *arvif,
 				    struct ieee80211_sta *sta,
 				    struct ieee80211_bss_conf *bss_conf,
 				    struct wmi_peer_assoc_complete_arg *arg)
 {
-	if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
-		if (sta->wme)
-			arg->peer_flags |= WMI_PEER_QOS;
-	} else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
-		if (bss_conf->qos)
-			arg->peer_flags |= WMI_PEER_QOS;
+	switch (arvif->vdev_type) {
+	case WMI_VDEV_TYPE_AP:
+		ath10k_peer_assoc_h_qos_ap(ar, arvif, sta, bss_conf, arg);
+		break;
+	case WMI_VDEV_TYPE_STA:
+		ath10k_peer_assoc_h_qos_sta(ar, arvif, sta, bss_conf, arg);
+		break;
+	default:
+		break;
 	}
 }
 
@@ -2798,6 +2868,7 @@ int ath10k_mac_register(struct ath10k *ar)
 	ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
 	ar->hw->wiphy->max_remain_on_channel_duration = 5000;
 
+	ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
 	/*
 	 * on LL hardware queues are managed entirely by the FW
 	 * so we only advertise to mac we can do the queues thing
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 2/3 ath10k: add AP UAPSD support

Quoted 3 lines · Janusz Dziedzic

Add support for AP (P2P_GO) UAPSD.

You should briefly mention in the commit log how you have tested this.

Signature · 1 line
Kalle Valo
#7 lore raw

PATCH 3/3 ath10k: enable STA UAPSD support

In reply to Janusz Dziedzic

Enable UAPSD support for STA mode.

---
 drivers/net/wireless/ath/ath10k/core.h |    1 +
 drivers/net/wireless/ath/ath10k/mac.c  |   80 ++++++++++++++++++++++++++++++--
 2 files changed, 77 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +1 -0
index 6c681cf..bef85fb 100644
@@ -217,6 +217,7 @@ struct ath10k_vif {
 	union {
 		struct {
 			u8 bssid[ETH_ALEN];
+			u32 uapsd;
 		} sta;
 		struct {
 			/* 127 stations; wmi limit */
drivers/net/wireless/ath/ath10k/mac.c +76 -4

109 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 3/3 ath10k: enable STA UAPSD support

Quoted 3 lines · Janusz Dziedzic

Enable UAPSD support for STA mode.

Same here, please explain briefly what you have tested.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw *hw, · line 2304

Quoted 12 lines
drivers/net/wireless/ath/ath10k/mac.c +6 -0
@@ -2296,6 +2296,68 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
 	return ret;
 }
 
+#define SET_UAPSD(enable, out, flags) do {	\
+	if ((enable))				\
+		(out) |= (flags);		\
+	else					\
+		(out) &= ~(flags);		\
+} while (0)

Why the macro? To workaround a long line warning from checkpatch?

If that's a problem we could increate line length limit, for example to 85 or 90. In some cases the 80 char limit is a bit too excessive. Would that help?

[...]

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw *hw, · line 2343

Quoted 2 lines
drivers/net/wireless/ath/ath10k/mac.c +2 -0
+	if (ret) {
+		ath10k_warn("could not set uapsd params (%d)\n", ret);

"could not set uapsd params: %d\n"

Quoted 6 lines
drivers/net/wireless/ath/ath10k/mac.c +6 -0
+		goto exit;
+	}
+
+	if (arvif->u.sta.uapsd)
+		value = WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD;
+	else

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw *hw, · line 2359

Quoted 10 lines
drivers/net/wireless/ath/ath10k/mac.c +10 -0
+		value = WMI_STA_PS_RX_WAKE_POLICY_WAKE;
+
+	ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
+					  WMI_STA_PS_PARAM_RX_WAKE_POLICY,
+					  value);
+	if (ret)
+		ath10k_warn("could not set rx wake param (%d)\n", ret);
+exit:
+	return ret;
+}

Empty line before the exit label.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_conf_tx(struct ieee80211_hw *hw, · line 2402

Quoted 6 lines
drivers/net/wireless/ath/ath10k/mac.c +1 -1
@@ -2335,13 +2399,20 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
 	 */
 	p->txop = params->txop * 32;
 
-	/* FIXME: can we pass the params->uapsd to the FW? */
+

This now has two empty lines, one is enough.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_conf_tx(struct ieee80211_hw *hw, · line 2409

Quoted 5 lines
drivers/net/wireless/ath/ath10k/mac.c +3 -1
-	if (ret)
+	if (ret) {
 		ath10k_warn("could not set wmm params (%d)\n", ret);
+		goto exit;
+	}

The same comment as with the other warning message above.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_conf_tx(struct ieee80211_hw *hw, · line 2413

Quoted 3 lines
drivers/net/wireless/ath/ath10k/mac.c +3 -0
+	ret = ath10k_conf_tx_uapsd(ar, vif, ac, params->uapsd);
+	if (ret)
+		ath10k_warn("could not set sta uapsd (%d)\n", ret);

Ditto.

Signature · 1 line
Kalle Valo
#9 lore raw

PATCH 3/3 ath10k: enable STA UAPSD support

Quoted 31 lines

-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 9 maja 2013 09:17
To: Dziedzic Janusz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH 3/3] ath10k: enable STA UAPSD support

Quoted 3 lines · Janusz Dziedzic

Enable UAPSD support for STA mode.

Same here, please explain briefly what you have tested.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw

Quoted 3 lines
drivers/net/wireless/ath/ath10k/mac.c +0 -0
@@ -2296,6 +2296,68 @@ static int ath10k_sta_state(struct ieee80211_hw

*hw,

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw *hw, · line 2304

Quoted 9 lines
drivers/net/wireless/ath/ath10k/mac.c +6 -0
 	return ret;
 }
 
+#define SET_UAPSD(enable, out, flags) do {	\
+	if ((enable))				\
+		(out) |= (flags);		\
+	else					\
+		(out) &= ~(flags);		\
+} while (0)

Why the macro? To workaround a long line warning from checkpatch?

Quoted 3 lines

If that's a problem we could increate line length limit, for example to 85 or 90. In some cases the 80 char limit is a bit too excessive. Would that help?

Not really. This is because we have to set/clean this flags for every ACs. So, this is just to prevent code duplication.

        case IEEE80211_AC_VO:
               if (enable)
                        ...
               else
                      ....
               break;
       case IEEE80211_AC_VI:
               if (enable)
                      ....
                else
                     ....
               break;
        .....

I can remove this macro and create inline function instead.

BR
Janusz

#10 lore raw

PATCH 3/3 ath10k: enable STA UAPSD support

Quoted 52 lines · Janusz.Dziedzic at tieto.com
Quoted 31 lines

-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 9 maja 2013 09:17
To: Dziedzic Janusz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH 3/3] ath10k: enable STA UAPSD support

Quoted 3 lines · Janusz Dziedzic

Enable UAPSD support for STA mode.

Same here, please explain briefly what you have tested.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw

Quoted 3 lines
drivers/net/wireless/ath/ath10k/mac.c +0 -0
@@ -2296,6 +2296,68 @@ static int ath10k_sta_state(struct ieee80211_hw

*hw,

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_sta_state(struct ieee80211_hw *hw, · line 2304

Quoted 9 lines
drivers/net/wireless/ath/ath10k/mac.c +6 -0
  	return ret;
  }
 
+#define SET_UAPSD(enable, out, flags) do {	\
+	if ((enable))				\
+		(out) |= (flags);		\
+	else					\
+		(out) &= ~(flags);		\
+} while (0)

Why the macro? To workaround a long line warning from checkpatch?

Quoted 3 lines

If that's a problem we could increate line length limit, for example to 85 or 90. In some cases the 80 char limit is a bit too excessive. Would that help?

Not really. This is because we have to set/clean this flags for every ACs. So, this is just to prevent code duplication.

         case IEEE80211_AC_VO:
                if (enable)
                         ...
                else
                       ....
                break;
        case IEEE80211_AC_VI:
                if (enable)
                       ....
                 else
                      ....
                break;
         .....
Quoted 1 line

I can remove this macro and create inline function instead.

Hmm, but since this is per-ac can't we do the following?

switch (ac) {
case IEEE80211_AC_VO:

	val = WMI_STA_PS_UAPSD_AC3_DELIVERY_EN |
               WMI_STA_PS_UAPSD_AC3_TRIGGER_EN;
	break;

// ..
}

if (enable)

	arvif->u.sta.uapsd |= val;
else
	arvif->u.sta.uapsd &= ~val;

No macros and no code duplication.

-- Pozdrawiam / Best regards, Michal Kazior.

#11 lore raw

PATCH 3/3 ath10k: enable STA UAPSD support

Quoted 29 lines · Michal Kazior
Quoted 17 lines

Not really. This is because we have to set/clean this flags for every ACs. So, this is just to prevent code duplication.

         case IEEE80211_AC_VO:
                if (enable)
                         ...
                else
                       ....
                break;
        case IEEE80211_AC_VI:
                if (enable)
                       ....
                 else
                      ....
                break;
         .....
Quoted 1 line

I can remove this macro and create inline function instead.

Hmm, but since this is per-ac can't we do the following?

switch (ac) {
case IEEE80211_AC_VO:

	val = WMI_STA_PS_UAPSD_AC3_DELIVERY_EN |
              WMI_STA_PS_UAPSD_AC3_TRIGGER_EN;
	break;

// ..
}

Quoted 7 lines

if (enable)

	arvif->u.sta.uapsd |= val;
else
	arvif->u.sta.uapsd &= ~val;

No macros and no code duplication.

Yes, much better. I hate macros :)

Signature · 1 line
Kalle Valo
#12 lore raw

cover UAPSD support for STA/AP mode

In reply to Janusz Dziedzic
Quoted 20 lines

-----Original Message-----
From: Dziedzic Janusz
Sent: 8 maja 2013 09:49
To: ath9k-devel at lists.ath9k.org
Cc: Dziedzic Janusz
Subject: [PATCH 0/3] UAPSD support for STA/AP mode

First two paches add PS/UAPSD support for AP/P2P_GO mode. Last one enable UAPSD for STA mode.

In case of FW issues we can easy disable this features by cleaning:
IEEE80211_HW_SUPPORTS_UAPSD/WIPHY_FLAG_AP_UAPSD still have code included.

Janusz Dziedzic (3):
ath10k: WMI add AP PS
ath10k: add AP UAPSD support
ath10k: enable STA UAPSD support

Quoted 7 lines

drivers/net/wireless/ath/ath10k/core.h | 1 +
drivers/net/wireless/ath/ath10k/mac.c | 165
+++++++++++++++++++++++++++++---

drivers/net/wireless/ath/ath10k/wmi.c  |   26 +++++
drivers/net/wireless/ath/ath10k/wmi.h  |   68 +++++++++++++
4 files changed, 249 insertions(+), 11 deletions(-)

Send V2.

BR
Janusz