@@ -18,7 +18,8 @@ wfx-y := \
key.o \
main.o \
sta.o \
- debug.o
+ debug.o \
+ nl80211_vendor.o
wfx-$(CONFIG_SPI) += bus_spi.o
wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o
@@ -34,6 +34,7 @@
#include "secure_link.h"
#include "hif_tx_mib.h"
#include "hif_api_cmd.h"
+#include "nl80211_vendor.h"
#define WFX_PDS_MAX_SIZE 1500
@@ -312,6 +313,9 @@ struct wfx_dev *wfx_init_common(struct device *dev,
sizeof(struct hif_msg)
+ sizeof(struct hif_req_tx)
+ 4 /* alignment */ + 8 /* TKIP IV */;
+
+ hw->wiphy->n_vendor_commands = ARRAY_SIZE(wfx_nl80211_vendor_commands);
+ hw->wiphy->vendor_commands = wfx_nl80211_vendor_commands;
hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_AP);
new file mode 100644
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Extra commands for nl80211 interface.
+ *
+ * Copyright (c) 2020, Silicon Laboratories, Inc.
+ */
+#include "nl80211_vendor.h"
+#include "wfx.h"
+#include "sta.h"
+
+int wfx_nl_ps_timeout(struct wiphy *wiphy, struct wireless_dev *widev,
+ const void *data, int data_len)
+{
+ int reply_size = nla_total_size(sizeof(u32));
+ struct nlattr *tb[WFX_NL80211_ATTR_MAX];
+ struct ieee80211_vif *vif;
+ struct wfx_vif *wvif;
+ struct sk_buff *msg;
+ int rc, ps_timeout;
+
+ rc = nla_parse(tb, WFX_NL80211_ATTR_MAX - 1, data, data_len,
+ wfx_nl_policy, NULL);
+ if (rc)
+ return rc;
+ vif = wdev_to_ieee80211_vif(widev);
+ if (!vif)
+ return -ENODEV;
+ wvif = (struct wfx_vif *)vif->drv_priv;
+
+ if (tb[WFX_NL80211_ATTR_PS_TIMEOUT]) {
+ wvif->force_ps_timeout =
+ nla_get_s32(tb[WFX_NL80211_ATTR_PS_TIMEOUT]);
+ wfx_update_pm(wvif);
+ }
+
+ msg = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, reply_size);
+ if (!msg)
+ return -ENOMEM;
+ ps_timeout = wfx_get_ps_timeout(wvif, NULL);
+ rc = nla_put_s32(msg, WFX_NL80211_ATTR_PS_TIMEOUT, ps_timeout);
+ if (rc)
+ goto error;
+ return cfg80211_vendor_cmd_reply(msg);
+
+error:
+ kfree_skb(msg);
+ return rc;
+}
+
new file mode 100644
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Extra commands for nl80211 interface.
+ *
+ * Copyright (c) 2020, Silicon Laboratories, Inc.
+ */
+#ifndef WFX_NL80211_VENDOR_H
+#define WFX_NL80211_VENDOR_H
+
+#include <net/netlink.h>
+#include <net/cfg80211.h>
+
+#include "hif_api_general.h"
+
+#define WFX_NL80211_ID 0x90fd9f
+
+int wfx_nl_ps_timeout(struct wiphy *wiphy, struct wireless_dev *widev,
+ const void *data, int data_len);
+
+enum {
+ WFX_NL80211_SUBCMD_PS_TIMEOUT = 0x10,
+};
+
+enum {
+ WFX_NL80211_ATTR_PS_TIMEOUT = 1,
+ WFX_NL80211_ATTR_MAX
+};
+
+static const struct nla_policy wfx_nl_policy[WFX_NL80211_ATTR_MAX] = {
+ [WFX_NL80211_ATTR_PS_TIMEOUT] = NLA_POLICY_RANGE(NLA_S32, -1, 127),
+};
+
+static const struct wiphy_vendor_command wfx_nl80211_vendor_commands[] = {
+ {
+ .info.vendor_id = WFX_NL80211_ID,
+ .info.subcmd = WFX_NL80211_SUBCMD_PS_TIMEOUT,
+ .flags = WIPHY_VENDOR_CMD_NEED_WDEV,
+ .policy = wfx_nl_policy,
+ .doit = wfx_nl_ps_timeout,
+ .maxattr = WFX_NL80211_ATTR_MAX - 1,
+ },
+};
+
+#endif /* WFX_NL80211_VENDOR_H */
@@ -217,14 +217,18 @@ int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)
// are differents.
if (enable_ps)
*enable_ps = true;
- if (wvif->bss_not_support_ps_poll)
+ if (wvif->force_ps_timeout > -1)
+ return wvif->force_ps_timeout;
+ else if (wvif->bss_not_support_ps_poll)
return 30;
else
return 0;
}
if (enable_ps)
*enable_ps = wvif->vif->bss_conf.ps;
- if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)
+ if (wvif->force_ps_timeout > -1)
+ return wvif->force_ps_timeout;
+ else if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)
return conf->dynamic_ps_timeout;
else
return -1;
@@ -788,6 +792,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
wvif->vif = vif;
wvif->wdev = wdev;
+ wvif->force_ps_timeout = -1;
wvif->link_id_map = 1; // link-id 0 is reserved for multicast
INIT_WORK(&wvif->update_tim_work, wfx_update_tim_work);
INIT_DELAYED_WORK(&wvif->beacon_loss_work, wfx_beacon_loss_work);
@@ -69,9 +69,11 @@ void wfx_cooling_timeout_work(struct work_struct *work);
void wfx_suspend_hot_dev(struct wfx_dev *wdev, enum sta_notify_cmd cmd);
void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd);
void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi);
+int wfx_update_pm(struct wfx_vif *wvif);
// Other Helpers
void wfx_reset(struct wfx_vif *wvif);
+int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *force_ps);
u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates);
#endif /* WFX_STA_H */
@@ -92,6 +92,7 @@ struct wfx_vif {
bool scan_abort;
struct ieee80211_scan_request *scan_req;
+ int force_ps_timeout;
bool bss_not_support_ps_poll;
struct work_struct update_pm_work;
struct completion set_pm_mode_complete;