ath10k: add WMI support for WOW
Add WMI support for WOW like enable, wakeup events and host wakeup indication. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:
parent
b3e71d7a51
commit
f5431e87ae
@ -47,6 +47,8 @@ struct wmi_ops {
|
||||
struct ath10k_fw_stats *stats);
|
||||
int (*pull_roam_ev)(struct ath10k *ar, struct sk_buff *skb,
|
||||
struct wmi_roam_ev_arg *arg);
|
||||
int (*pull_wow_event)(struct ath10k *ar, struct sk_buff *skb,
|
||||
struct wmi_wow_ev_arg *arg);
|
||||
|
||||
struct sk_buff *(*gen_pdev_suspend)(struct ath10k *ar, u32 suspend_opt);
|
||||
struct sk_buff *(*gen_pdev_resume)(struct ath10k *ar);
|
||||
@ -150,6 +152,11 @@ struct wmi_ops {
|
||||
u32 num_ac);
|
||||
struct sk_buff *(*gen_sta_keepalive)(struct ath10k *ar,
|
||||
const struct wmi_sta_keepalive_arg *arg);
|
||||
struct sk_buff *(*gen_wow_enable)(struct ath10k *ar);
|
||||
struct sk_buff *(*gen_wow_add_wakeup_event)(struct ath10k *ar, u32 vdev_id,
|
||||
enum wmi_wow_wakeup_event event,
|
||||
u32 enable);
|
||||
struct sk_buff *(*gen_wow_host_wakeup_ind)(struct ath10k *ar);
|
||||
};
|
||||
|
||||
int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
|
||||
@ -285,6 +292,16 @@ ath10k_wmi_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
|
||||
return ar->wmi.ops->pull_roam_ev(ar, skb, arg);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ath10k_wmi_pull_wow_event(struct ath10k *ar, struct sk_buff *skb,
|
||||
struct wmi_wow_ev_arg *arg)
|
||||
{
|
||||
if (!ar->wmi.ops->pull_wow_event)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return ar->wmi.ops->pull_wow_event(ar, skb, arg);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
|
||||
{
|
||||
@ -1072,4 +1089,57 @@ ath10k_wmi_sta_keepalive(struct ath10k *ar,
|
||||
return ath10k_wmi_cmd_send(ar, skb, cmd_id);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ath10k_wmi_wow_enable(struct ath10k *ar)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
u32 cmd_id;
|
||||
|
||||
if (!ar->wmi.ops->gen_wow_enable)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
skb = ar->wmi.ops->gen_wow_enable(ar);
|
||||
if (IS_ERR(skb))
|
||||
return PTR_ERR(skb);
|
||||
|
||||
cmd_id = ar->wmi.cmd->wow_enable_cmdid;
|
||||
return ath10k_wmi_cmd_send(ar, skb, cmd_id);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ath10k_wmi_wow_add_wakeup_event(struct ath10k *ar, u32 vdev_id,
|
||||
enum wmi_wow_wakeup_event event,
|
||||
u32 enable)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
u32 cmd_id;
|
||||
|
||||
if (!ar->wmi.ops->gen_wow_add_wakeup_event)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
skb = ar->wmi.ops->gen_wow_add_wakeup_event(ar, vdev_id, event, enable);
|
||||
if (IS_ERR(skb))
|
||||
return PTR_ERR(skb);
|
||||
|
||||
cmd_id = ar->wmi.cmd->wow_enable_disable_wake_event_cmdid;
|
||||
return ath10k_wmi_cmd_send(ar, skb, cmd_id);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ath10k_wmi_wow_host_wakeup_ind(struct ath10k *ar)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
u32 cmd_id;
|
||||
|
||||
if (!ar->wmi.ops->gen_wow_host_wakeup_ind)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
skb = ar->wmi.ops->gen_wow_host_wakeup_ind(ar);
|
||||
if (IS_ERR(skb))
|
||||
return PTR_ERR(skb);
|
||||
|
||||
cmd_id = ar->wmi.cmd->wow_hostwakeup_from_sleep_cmdid;
|
||||
return ath10k_wmi_cmd_send(ar, skb, cmd_id);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -33,9 +33,9 @@ struct wmi_tlv_policy {
|
||||
|
||||
static const struct wmi_tlv_policy wmi_tlv_policies[] = {
|
||||
[WMI_TLV_TAG_ARRAY_BYTE]
|
||||
= { .min_len = sizeof(u8) },
|
||||
= { .min_len = 0 },
|
||||
[WMI_TLV_TAG_ARRAY_UINT32]
|
||||
= { .min_len = sizeof(u32) },
|
||||
= { .min_len = 0 },
|
||||
[WMI_TLV_TAG_STRUCT_SCAN_EVENT]
|
||||
= { .min_len = sizeof(struct wmi_scan_event) },
|
||||
[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
|
||||
@ -68,6 +68,8 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = {
|
||||
= { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
|
||||
[WMI_TLV_TAG_STRUCT_ROAM_EVENT]
|
||||
= { .min_len = sizeof(struct wmi_tlv_roam_ev) },
|
||||
[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]
|
||||
= { .min_len = sizeof(struct wmi_tlv_wow_event_info) },
|
||||
};
|
||||
|
||||
static int
|
||||
@ -1090,6 +1092,36 @@ static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb,
|
||||
struct wmi_wow_ev_arg *arg)
|
||||
{
|
||||
const void **tb;
|
||||
const struct wmi_tlv_wow_event_info *ev;
|
||||
int ret;
|
||||
|
||||
tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
|
||||
if (IS_ERR(tb)) {
|
||||
ret = PTR_ERR(tb);
|
||||
ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO];
|
||||
if (!ev) {
|
||||
kfree(tb);
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
arg->vdev_id = __le32_to_cpu(ev->vdev_id);
|
||||
arg->flag = __le32_to_cpu(ev->flag);
|
||||
arg->wake_reason = __le32_to_cpu(ev->wake_reason);
|
||||
arg->data_len = __le32_to_cpu(ev->data_len);
|
||||
|
||||
kfree(tb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct sk_buff *
|
||||
ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
|
||||
{
|
||||
@ -2563,6 +2595,82 @@ ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
|
||||
return skb;
|
||||
}
|
||||
|
||||
static struct sk_buff *
|
||||
ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar)
|
||||
{
|
||||
struct wmi_tlv_wow_enable_cmd *cmd;
|
||||
struct wmi_tlv *tlv;
|
||||
struct sk_buff *skb;
|
||||
size_t len;
|
||||
|
||||
len = sizeof(*tlv) + sizeof(*cmd);
|
||||
skb = ath10k_wmi_alloc_skb(ar, len);
|
||||
if (!skb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
tlv = (struct wmi_tlv *)skb->data;
|
||||
tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD);
|
||||
tlv->len = __cpu_to_le16(sizeof(*cmd));
|
||||
cmd = (void *)tlv->value;
|
||||
|
||||
cmd->enable = __cpu_to_le32(1);
|
||||
|
||||
ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n");
|
||||
return skb;
|
||||
}
|
||||
|
||||
static struct sk_buff *
|
||||
ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,
|
||||
u32 vdev_id,
|
||||
enum wmi_wow_wakeup_event event,
|
||||
u32 enable)
|
||||
{
|
||||
struct wmi_tlv_wow_add_del_event_cmd *cmd;
|
||||
struct wmi_tlv *tlv;
|
||||
struct sk_buff *skb;
|
||||
size_t len;
|
||||
|
||||
len = sizeof(*tlv) + sizeof(*cmd);
|
||||
skb = ath10k_wmi_alloc_skb(ar, len);
|
||||
if (!skb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
tlv = (struct wmi_tlv *)skb->data;
|
||||
tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD);
|
||||
tlv->len = __cpu_to_le16(sizeof(*cmd));
|
||||
cmd = (void *)tlv->value;
|
||||
|
||||
cmd->vdev_id = __cpu_to_le32(vdev_id);
|
||||
cmd->is_add = __cpu_to_le32(enable);
|
||||
cmd->event_bitmap = __cpu_to_le32(1 << event);
|
||||
|
||||
ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
|
||||
wow_wakeup_event(event), enable, vdev_id);
|
||||
return skb;
|
||||
}
|
||||
|
||||
static struct sk_buff *
|
||||
ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar)
|
||||
{
|
||||
struct wmi_tlv_wow_host_wakeup_ind *cmd;
|
||||
struct wmi_tlv *tlv;
|
||||
struct sk_buff *skb;
|
||||
size_t len;
|
||||
|
||||
len = sizeof(*tlv) + sizeof(*cmd);
|
||||
skb = ath10k_wmi_alloc_skb(ar, len);
|
||||
if (!skb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
tlv = (struct wmi_tlv *)skb->data;
|
||||
tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
|
||||
tlv->len = __cpu_to_le16(sizeof(*cmd));
|
||||
cmd = (void *)tlv->value;
|
||||
|
||||
ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
|
||||
return skb;
|
||||
}
|
||||
|
||||
/****************/
|
||||
/* TLV mappings */
|
||||
/****************/
|
||||
@ -2815,6 +2923,7 @@ static const struct wmi_ops wmi_tlv_ops = {
|
||||
.pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
|
||||
.pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
|
||||
.pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev,
|
||||
.pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev,
|
||||
|
||||
.gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
|
||||
.gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
|
||||
@ -2860,6 +2969,9 @@ static const struct wmi_ops wmi_tlv_ops = {
|
||||
.gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
|
||||
.gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
|
||||
.gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
|
||||
.gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable,
|
||||
.gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event,
|
||||
.gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
|
||||
};
|
||||
|
||||
/************/
|
||||
|
@ -1464,6 +1464,27 @@ struct wmi_tlv_roam_ev {
|
||||
__le32 rssi;
|
||||
} __packed;
|
||||
|
||||
struct wmi_tlv_wow_add_del_event_cmd {
|
||||
__le32 vdev_id;
|
||||
__le32 is_add;
|
||||
__le32 event_bitmap;
|
||||
} __packed;
|
||||
|
||||
struct wmi_tlv_wow_enable_cmd {
|
||||
__le32 enable;
|
||||
} __packed;
|
||||
|
||||
struct wmi_tlv_wow_host_wakeup_ind {
|
||||
__le32 reserved;
|
||||
} __packed;
|
||||
|
||||
struct wmi_tlv_wow_event_info {
|
||||
__le32 vdev_id;
|
||||
__le32 flag;
|
||||
__le32 wake_reason;
|
||||
__le32 data_len;
|
||||
} __packed;
|
||||
|
||||
void ath10k_wmi_tlv_attach(struct ath10k *ar);
|
||||
|
||||
#endif
|
||||
|
@ -4884,6 +4884,150 @@ struct wmi_pdev_temperature_event {
|
||||
__le32 temperature;
|
||||
} __packed;
|
||||
|
||||
/* WOW structures */
|
||||
enum wmi_wow_wakeup_event {
|
||||
WOW_BMISS_EVENT = 0,
|
||||
WOW_BETTER_AP_EVENT,
|
||||
WOW_DEAUTH_RECVD_EVENT,
|
||||
WOW_MAGIC_PKT_RECVD_EVENT,
|
||||
WOW_GTK_ERR_EVENT,
|
||||
WOW_FOURWAY_HSHAKE_EVENT,
|
||||
WOW_EAPOL_RECVD_EVENT,
|
||||
WOW_NLO_DETECTED_EVENT,
|
||||
WOW_DISASSOC_RECVD_EVENT,
|
||||
WOW_PATTERN_MATCH_EVENT,
|
||||
WOW_CSA_IE_EVENT,
|
||||
WOW_PROBE_REQ_WPS_IE_EVENT,
|
||||
WOW_AUTH_REQ_EVENT,
|
||||
WOW_ASSOC_REQ_EVENT,
|
||||
WOW_HTT_EVENT,
|
||||
WOW_RA_MATCH_EVENT,
|
||||
WOW_HOST_AUTO_SHUTDOWN_EVENT,
|
||||
WOW_IOAC_MAGIC_EVENT,
|
||||
WOW_IOAC_SHORT_EVENT,
|
||||
WOW_IOAC_EXTEND_EVENT,
|
||||
WOW_IOAC_TIMER_EVENT,
|
||||
WOW_DFS_PHYERR_RADAR_EVENT,
|
||||
WOW_BEACON_EVENT,
|
||||
WOW_CLIENT_KICKOUT_EVENT,
|
||||
WOW_EVENT_MAX,
|
||||
};
|
||||
|
||||
#define C2S(x) case x: return #x
|
||||
|
||||
static inline const char *wow_wakeup_event(enum wmi_wow_wakeup_event ev)
|
||||
{
|
||||
switch (ev) {
|
||||
C2S(WOW_BMISS_EVENT);
|
||||
C2S(WOW_BETTER_AP_EVENT);
|
||||
C2S(WOW_DEAUTH_RECVD_EVENT);
|
||||
C2S(WOW_MAGIC_PKT_RECVD_EVENT);
|
||||
C2S(WOW_GTK_ERR_EVENT);
|
||||
C2S(WOW_FOURWAY_HSHAKE_EVENT);
|
||||
C2S(WOW_EAPOL_RECVD_EVENT);
|
||||
C2S(WOW_NLO_DETECTED_EVENT);
|
||||
C2S(WOW_DISASSOC_RECVD_EVENT);
|
||||
C2S(WOW_PATTERN_MATCH_EVENT);
|
||||
C2S(WOW_CSA_IE_EVENT);
|
||||
C2S(WOW_PROBE_REQ_WPS_IE_EVENT);
|
||||
C2S(WOW_AUTH_REQ_EVENT);
|
||||
C2S(WOW_ASSOC_REQ_EVENT);
|
||||
C2S(WOW_HTT_EVENT);
|
||||
C2S(WOW_RA_MATCH_EVENT);
|
||||
C2S(WOW_HOST_AUTO_SHUTDOWN_EVENT);
|
||||
C2S(WOW_IOAC_MAGIC_EVENT);
|
||||
C2S(WOW_IOAC_SHORT_EVENT);
|
||||
C2S(WOW_IOAC_EXTEND_EVENT);
|
||||
C2S(WOW_IOAC_TIMER_EVENT);
|
||||
C2S(WOW_DFS_PHYERR_RADAR_EVENT);
|
||||
C2S(WOW_BEACON_EVENT);
|
||||
C2S(WOW_CLIENT_KICKOUT_EVENT);
|
||||
C2S(WOW_EVENT_MAX);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
enum wmi_wow_wake_reason {
|
||||
WOW_REASON_UNSPECIFIED = -1,
|
||||
WOW_REASON_NLOD = 0,
|
||||
WOW_REASON_AP_ASSOC_LOST,
|
||||
WOW_REASON_LOW_RSSI,
|
||||
WOW_REASON_DEAUTH_RECVD,
|
||||
WOW_REASON_DISASSOC_RECVD,
|
||||
WOW_REASON_GTK_HS_ERR,
|
||||
WOW_REASON_EAP_REQ,
|
||||
WOW_REASON_FOURWAY_HS_RECV,
|
||||
WOW_REASON_TIMER_INTR_RECV,
|
||||
WOW_REASON_PATTERN_MATCH_FOUND,
|
||||
WOW_REASON_RECV_MAGIC_PATTERN,
|
||||
WOW_REASON_P2P_DISC,
|
||||
WOW_REASON_WLAN_HB,
|
||||
WOW_REASON_CSA_EVENT,
|
||||
WOW_REASON_PROBE_REQ_WPS_IE_RECV,
|
||||
WOW_REASON_AUTH_REQ_RECV,
|
||||
WOW_REASON_ASSOC_REQ_RECV,
|
||||
WOW_REASON_HTT_EVENT,
|
||||
WOW_REASON_RA_MATCH,
|
||||
WOW_REASON_HOST_AUTO_SHUTDOWN,
|
||||
WOW_REASON_IOAC_MAGIC_EVENT,
|
||||
WOW_REASON_IOAC_SHORT_EVENT,
|
||||
WOW_REASON_IOAC_EXTEND_EVENT,
|
||||
WOW_REASON_IOAC_TIMER_EVENT,
|
||||
WOW_REASON_ROAM_HO,
|
||||
WOW_REASON_DFS_PHYERR_RADADR_EVENT,
|
||||
WOW_REASON_BEACON_RECV,
|
||||
WOW_REASON_CLIENT_KICKOUT_EVENT,
|
||||
WOW_REASON_DEBUG_TEST = 0xFF,
|
||||
};
|
||||
|
||||
static inline const char *wow_reason(enum wmi_wow_wake_reason reason)
|
||||
{
|
||||
switch (reason) {
|
||||
C2S(WOW_REASON_UNSPECIFIED);
|
||||
C2S(WOW_REASON_NLOD);
|
||||
C2S(WOW_REASON_AP_ASSOC_LOST);
|
||||
C2S(WOW_REASON_LOW_RSSI);
|
||||
C2S(WOW_REASON_DEAUTH_RECVD);
|
||||
C2S(WOW_REASON_DISASSOC_RECVD);
|
||||
C2S(WOW_REASON_GTK_HS_ERR);
|
||||
C2S(WOW_REASON_EAP_REQ);
|
||||
C2S(WOW_REASON_FOURWAY_HS_RECV);
|
||||
C2S(WOW_REASON_TIMER_INTR_RECV);
|
||||
C2S(WOW_REASON_PATTERN_MATCH_FOUND);
|
||||
C2S(WOW_REASON_RECV_MAGIC_PATTERN);
|
||||
C2S(WOW_REASON_P2P_DISC);
|
||||
C2S(WOW_REASON_WLAN_HB);
|
||||
C2S(WOW_REASON_CSA_EVENT);
|
||||
C2S(WOW_REASON_PROBE_REQ_WPS_IE_RECV);
|
||||
C2S(WOW_REASON_AUTH_REQ_RECV);
|
||||
C2S(WOW_REASON_ASSOC_REQ_RECV);
|
||||
C2S(WOW_REASON_HTT_EVENT);
|
||||
C2S(WOW_REASON_RA_MATCH);
|
||||
C2S(WOW_REASON_HOST_AUTO_SHUTDOWN);
|
||||
C2S(WOW_REASON_IOAC_MAGIC_EVENT);
|
||||
C2S(WOW_REASON_IOAC_SHORT_EVENT);
|
||||
C2S(WOW_REASON_IOAC_EXTEND_EVENT);
|
||||
C2S(WOW_REASON_IOAC_TIMER_EVENT);
|
||||
C2S(WOW_REASON_ROAM_HO);
|
||||
C2S(WOW_REASON_DFS_PHYERR_RADADR_EVENT);
|
||||
C2S(WOW_REASON_BEACON_RECV);
|
||||
C2S(WOW_REASON_CLIENT_KICKOUT_EVENT);
|
||||
C2S(WOW_REASON_DEBUG_TEST);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#undef C2S
|
||||
|
||||
struct wmi_wow_ev_arg {
|
||||
u32 vdev_id;
|
||||
u32 flag;
|
||||
enum wmi_wow_wake_reason wake_reason;
|
||||
u32 data_len;
|
||||
};
|
||||
|
||||
struct ath10k;
|
||||
struct ath10k_vif;
|
||||
struct ath10k_fw_stats_pdev;
|
||||
|
Loading…
Reference in New Issue
Block a user