Skip to contentSkip to conversation

qtnfmac: implement basic WoWLAN support

PATCH In review Sergey Matyukevich 2 participants 2 messages Aug 2, 2018 Quantenna qtnfmac wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qtnfmac: implement basic WoWLAN support

This patch implements basic WoWLAN support in qtnfmac driver, including processing of WoWLAN features reported by firmware and implementation of cfg80211 suspend/resume/wakeup callbacks. Currently the following WoWLAN triggers are supported: disconnect, magic packet, custom pattern packet.

---

Hello Kalle and all,

The first four patches from the original patch set has been accepted. So the changes for v2 are as follows:
- drop patch with vendor speicific commands for PTA
-- to be clarified and resend separately
- rebase WoWLAN patch on top of wireless-drivers-next

Regards,
Sergey

 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c |  76 +++++++++++++++
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 112 ++++++++++++++++++++++
 drivers/net/wireless/quantenna/qtnfmac/commands.h |   2 +
 drivers/net/wireless/quantenna/qtnfmac/core.c     |   1 +
 drivers/net/wireless/quantenna/qtnfmac/core.h     |   1 +
 drivers/net/wireless/quantenna/qtnfmac/qlink.h    |  56 +++++++++++
 6 files changed, 248 insertions(+)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +76 -0
index 0032fa9fdddd..4aa332f4646b 100644
@@ -859,6 +859,72 @@ static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
 	return ret;
 }
 
+#ifdef CONFIG_PM
+static int qtnf_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wowlan)
+{
+	struct qtnf_wmac *mac = wiphy_priv(wiphy);
+	struct qtnf_vif *vif;
+	int ret = 0;
+
+	vif = qtnf_mac_get_base_vif(mac);
+	if (!vif) {
+		pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
+		ret = -EFAULT;
+		goto exit;
+	}
+
+	if (!wowlan) {
+		pr_debug("WoWLAN triggers are not enabled\n");
+		qtnf_virtual_intf_cleanup(vif->netdev);
+		goto exit;
+	}
+
+	qtnf_scan_done(vif->mac, true);
+
+	ret = qtnf_cmd_send_wowlan_set(vif, wowlan);
+	if (ret) {
+		pr_err("MAC%u: failed to set WoWLAN triggers\n",
+		       mac->macid);
+		goto exit;
+	}
+
+exit:
+	return ret;
+}
+
+static int qtnf_resume(struct wiphy *wiphy)
+{
+	struct qtnf_wmac *mac = wiphy_priv(wiphy);
+	struct qtnf_vif *vif;
+	int ret = 0;
+
+	vif = qtnf_mac_get_base_vif(mac);
+	if (!vif) {
+		pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
+		ret = -EFAULT;
+		goto exit;
+	}
+
+	ret = qtnf_cmd_send_wowlan_set(vif, NULL);
+	if (ret) {
+		pr_err("MAC%u: failed to reset WoWLAN triggers\n",
+		       mac->macid);
+		goto exit;
+	}
+
+exit:
+	return ret;
+}
+
+static void qtnf_set_wakeup(struct wiphy *wiphy, bool enabled)
+{
+	struct qtnf_wmac *mac = wiphy_priv(wiphy);
+	struct qtnf_bus *bus = mac->bus;
+
+	device_set_wakeup_enable(bus->dev, enabled);
+}
+#endif
+
 static struct cfg80211_ops qtn_cfg80211_ops = {
 	.add_virtual_intf	= qtnf_add_virtual_intf,
 	.change_virtual_intf	= qtnf_change_virtual_intf,
@@ -886,6 +952,11 @@ static struct cfg80211_ops qtn_cfg80211_ops = {
 	.start_radar_detection	= qtnf_start_radar_detection,
 	.set_mac_acl		= qtnf_set_mac_acl,
 	.set_power_mgmt		= qtnf_set_power_mgmt,
+#ifdef CONFIG_PM
+	.suspend		= qtnf_suspend,
+	.resume			= qtnf_resume,
+	.set_wakeup		= qtnf_set_wakeup,
+#endif
 };
 
 static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
@@ -1038,6 +1109,11 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
 	if (hw_info->hw_capab & QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR)
 		wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
 
+#ifdef CONFIG_PM
+	if (macinfo->wowlan)
+		wiphy->wowlan = macinfo->wowlan;
+#endif
+
 	if (hw_info->hw_capab & QLINK_HW_CAPAB_REG_UPDATE) {
 		wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
 			REGULATORY_CUSTOM_REG;
drivers/net/wireless/quantenna/qtnfmac/commands.c +112 -0

134 lines not on this page · raw message

drivers/net/wireless/quantenna/qtnfmac/commands.h +2 -0
index 03a57e37a665..1ac41156c192 100644
@@ -77,5 +77,7 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif,
 int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,
 			 const struct cfg80211_acl_data *params);
 int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout);
+int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif,
+			     const struct cfg80211_wowlan *wowl);
 
 #endif /* QLINK_COMMANDS_H_ */
drivers/net/wireless/quantenna/qtnfmac/core.c +1 -0
index c318340e1bd5..19abbc4e23e0 100644
@@ -495,6 +495,7 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid)
 	qtnf_mac_iface_comb_free(mac);
 	kfree(mac->macinfo.extended_capabilities);
 	kfree(mac->macinfo.extended_capabilities_mask);
+	kfree(mac->macinfo.wowlan);
 	wiphy_free(wiphy);
 	bus->mac[macid] = NULL;
 }
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -0
index c4808f1ba8b0..a1e338a1f055 100644
@@ -110,6 +110,7 @@ struct qtnf_mac_info {
 	u8 *extended_capabilities;
 	u8 *extended_capabilities_mask;
 	u8 extended_capabilities_len;
+	struct wiphy_wowlan_support *wowlan;
 };
 
 struct qtnf_chan_stats {
drivers/net/wireless/quantenna/qtnfmac/qlink.h +56 -0

78 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · Sergey Matyukevich

This patch implements basic WoWLAN support in qtnfmac driver, including processing of WoWLAN features reported by firmware and implementation of cfg80211 suspend/resume/wakeup callbacks. Currently the following WoWLAN triggers are supported: disconnect, magic packet, custom pattern packet.

Patch applied to wireless-drivers-next.git, thanks.

28b918848390 qtnfmac: implement basic WoWLAN support

Signature · 3 lines
https://patchwork.kernel.org/patch/10553471/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches