All of lore.kernel.org
 help / color / mirror / Atom feed
From: <rmani@qca.qualcomm.com>
To: <kvalo@qca.qualcomm.com>
Cc: <linux-wireless@vger.kernel.org>, <ath6kl-devel@qualcomm.com>,
	Raja Mani <rmani@qca.qualcomm.com>
Subject: [PATCH] ath6kl: Check wow state before sending control and data pkt
Date: Mon, 6 Feb 2012 19:26:53 +0530	[thread overview]
Message-ID: <1328536613-17521-1-git-send-email-rmani@qca.qualcomm.com> (raw)

From: Raja Mani <rmani@qca.qualcomm.com>

* TX operation (ctrl tx and data tx) has to be controlled based on
  WOW suspend state. i.e, control packets are allowed to send from
  the host until the suspend state goes ATH6KL_STATE_WOW and
  the data packets are allowed until WOW suspend operation starts.

* Similary, wow resume is NOT allowed if WOW suspend is in progress.

Both of the above scenarios are taken care in this patch.

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c |   14 ++++++++++++++
 drivers/net/wireless/ath/ath6kl/core.c     |    2 ++
 drivers/net/wireless/ath/ath6kl/core.h     |    7 +++++++
 drivers/net/wireless/ath/ath6kl/txrx.c     |   11 ++++++++++-
 4 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index d1922d8..11d9670 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -1941,6 +1941,8 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
 	if (ret)
 		return ret;
 
+	ar->wow_state = ATH6KL_WOW_STATE_SUSPENDING;
+
 	/* Setup own IP addr for ARP agent. */
 	in_dev = __in_dev_get_rtnl(vif->ndev);
 	if (!in_dev)
@@ -2015,10 +2017,15 @@ static int ath6kl_wow_resume(struct ath6kl *ar)
 	struct ath6kl_vif *vif;
 	int ret;
 
+	if (ar->wow_state == ATH6KL_WOW_STATE_NONE)
+		return 0;
+
 	vif = ath6kl_vif_first(ar);
 	if (!vif)
 		return -EIO;
 
+	ar->wow_state = ATH6KL_WOW_STATE_NONE;
+
 	ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx,
 						 ATH6KL_HOST_MODE_AWAKE);
 	return ret;
@@ -2041,9 +2048,13 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar,
 		ret = ath6kl_wow_suspend(ar, wow);
 		if (ret) {
 			ath6kl_err("wow suspend failed: %d\n", ret);
+			ar->wow_state = ATH6KL_WOW_STATE_NONE;
 			return ret;
 		}
+
+		ar->wow_state = ATH6KL_WOW_STATE_SUSPENDED;
 		ar->state = ATH6KL_STATE_WOW;
+
 		break;
 
 	case ATH6KL_CFG_SUSPEND_DEEPSLEEP:
@@ -2188,6 +2199,9 @@ static int __ath6kl_cfg80211_resume(struct wiphy *wiphy)
  */
 void ath6kl_check_wow_status(struct ath6kl *ar)
 {
+	if (ar->wow_state == ATH6KL_WOW_STATE_SUSPENDING)
+		return;
+
 	if (ar->state == ATH6KL_STATE_WOW)
 		ath6kl_cfg80211_resume(ar);
 }
diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 722ca59..b522135 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -154,6 +154,8 @@ int ath6kl_core_init(struct ath6kl *ar)
 	else
 		ar->suspend_mode = 0;
 
+	ar->wow_state = ATH6KL_WOW_STATE_NONE;
+
 	if (uart_debug)
 		ar->conf_flags |= ATH6KL_CONF_UART_DEBUG;
 
diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index c4d66e0..182ff01 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -527,11 +527,18 @@ enum ath6kl_state {
 	ATH6KL_STATE_SCHED_SCAN,
 };
 
+enum ath6kl_wow_state {
+	ATH6KL_WOW_STATE_NONE,
+	ATH6KL_WOW_STATE_SUSPENDING,
+	ATH6KL_WOW_STATE_SUSPENDED,
+};
+
 struct ath6kl {
 	struct device *dev;
 	struct wiphy *wiphy;
 
 	enum ath6kl_state state;
+	enum ath6kl_wow_state wow_state;
 	unsigned int testmode;
 
 	struct ath6kl_bmi bmi;
diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c
index a3dc694..53a2894 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -284,6 +284,10 @@ int ath6kl_control_tx(void *devt, struct sk_buff *skb,
 	int status = 0;
 	struct ath6kl_cookie *cookie = NULL;
 
+#ifdef CONFIG_PM
+	if (ar->wow_state == ATH6KL_WOW_STATE_SUSPENDED)
+		return -EACCES;
+#endif
 	spin_lock_bh(&ar->lock);
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
@@ -352,7 +356,12 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
 	ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
 		   "%s: skb=0x%p, data=0x%p, len=0x%x\n", __func__,
 		   skb, skb->data, skb->len);
-
+#ifdef CONFIG_PM
+	if (ar->wow_state != ATH6KL_WOW_STATE_NONE) {
+		dev_kfree_skb(skb);
+		return 0;
+	}
+#endif
 	/* If target is not associated */
 	if (!test_bit(CONNECTED, &vif->flags)) {
 		dev_kfree_skb(skb);
-- 
1.7.1


             reply	other threads:[~2012-02-06 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 13:56 rmani [this message]
2012-02-06 14:14 ` [PATCH] ath6kl: Check wow state before sending control and data pkt Kalle Valo
2012-02-07 10:14   ` Raja Mani
2012-02-07 13:33     ` Kalle Valo
2012-02-08  9:40       ` Raja Mani
2012-02-06 14:30 ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328536613-17521-1-git-send-email-rmani@qca.qualcomm.com \
    --to=rmani@qca.qualcomm.com \
    --cc=ath6kl-devel@qualcomm.com \
    --cc=kvalo@qca.qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.