qcacmn: Add wmi support for btwt wifitool commands

Add WMI support for broadcast twt sta invitation and
sta kickoff. Additionally, update the current WMI twt
fields to include btwt recommendation and btwt persistence.

Change-Id: I88dee854557bbb8c3263f42041e0b90a07cdd27e
This commit is contained in:
Christopher Chopp
2019-11-21 16:23:21 -08:00
committed by nshrivas
parent df2c759d94
commit 294f63373d
5 changed files with 459 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -109,8 +109,29 @@ static QDF_STATUS send_twt_disable_cmd_tlv(wmi_unified_t wmi_handle,
return status;
}
static QDF_STATUS send_twt_add_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_add_dialog_param *params)
#ifdef WLAN_SUPPORT_BCAST_TWT
static void
twt_add_dialog_set_bcast_twt_params(struct wmi_twt_add_dialog_param *params,
wmi_twt_add_dialog_cmd_fixed_param *cmd)
{
TWT_FLAGS_SET_BTWT_ID0(cmd->flags, params->flag_b_twt_id0);
cmd->b_twt_persistence = params->b_twt_persistence;
cmd->b_twt_recommendation = params->b_twt_recommendation;
return;
}
#else
static void
twt_add_dialog_set_bcast_twt_params(struct wmi_twt_add_dialog_param *params,
wmi_twt_add_dialog_cmd_fixed_param *cmd)
{
return;
}
#endif
static QDF_STATUS
send_twt_add_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_add_dialog_param *params)
{
wmi_twt_add_dialog_cmd_fixed_param *cmd;
wmi_buf_t buf;
@@ -124,9 +145,9 @@ static QDF_STATUS send_twt_add_dialog_cmd_tlv(wmi_unified_t wmi_handle,
cmd = (wmi_twt_add_dialog_cmd_fixed_param *) wmi_buf_data(buf);
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_twt_add_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_add_dialog_cmd_fixed_param));
WMITLV_TAG_STRUC_wmi_twt_add_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_add_dialog_cmd_fixed_param));
cmd->vdev_id = params->vdev_id;
WMI_CHAR_ARRAY_TO_MAC_ADDR(params->peer_macaddr, &cmd->peer_macaddr);
@@ -141,8 +162,10 @@ static QDF_STATUS send_twt_add_dialog_cmd_tlv(wmi_unified_t wmi_handle,
TWT_FLAGS_SET_FLOW_TYPE(cmd->flags, params->flag_flow_type);
TWT_FLAGS_SET_PROTECTION(cmd->flags, params->flag_protection);
twt_add_dialog_set_bcast_twt_params(params, cmd);
status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
WMI_TWT_ADD_DIALOG_CMDID);
WMI_TWT_ADD_DIALOG_CMDID);
if (QDF_IS_STATUS_ERROR(status)) {
WMI_LOGE("Failed to send WMI_TWT_ADD_DIALOG_CMDID");
wmi_buf_free(buf);
@@ -151,8 +174,26 @@ static QDF_STATUS send_twt_add_dialog_cmd_tlv(wmi_unified_t wmi_handle,
return status;
}
static QDF_STATUS send_twt_del_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_del_dialog_param *params)
#ifdef WLAN_SUPPORT_BCAST_TWT
static void
twt_del_dialog_set_bcast_twt_params(struct wmi_twt_del_dialog_param *params,
wmi_twt_del_dialog_cmd_fixed_param *cmd)
{
cmd->b_twt_persistence = params->b_twt_persistence;
return;
}
#else
static void
twt_del_dialog_set_bcast_twt_params(struct wmi_twt_del_dialog_param *params,
wmi_twt_del_dialog_cmd_fixed_param *cmd)
{
return;
}
#endif
static QDF_STATUS
send_twt_del_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_del_dialog_param *params)
{
wmi_twt_del_dialog_cmd_fixed_param *cmd;
wmi_buf_t buf;
@@ -166,16 +207,18 @@ static QDF_STATUS send_twt_del_dialog_cmd_tlv(wmi_unified_t wmi_handle,
cmd = (wmi_twt_del_dialog_cmd_fixed_param *) wmi_buf_data(buf);
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_twt_del_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_del_dialog_cmd_fixed_param));
WMITLV_TAG_STRUC_wmi_twt_del_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_del_dialog_cmd_fixed_param));
cmd->vdev_id = params->vdev_id;
WMI_CHAR_ARRAY_TO_MAC_ADDR(params->peer_macaddr, &cmd->peer_macaddr);
cmd->dialog_id = params->dialog_id;
twt_del_dialog_set_bcast_twt_params(params, cmd);
status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
WMI_TWT_DEL_DIALOG_CMDID);
WMI_TWT_DEL_DIALOG_CMDID);
if (QDF_IS_STATUS_ERROR(status)) {
WMI_LOGE("Failed to send WMI_TWT_DEL_DIALOG_CMDID");
wmi_buf_free(buf);
@@ -184,8 +227,9 @@ static QDF_STATUS send_twt_del_dialog_cmd_tlv(wmi_unified_t wmi_handle,
return status;
}
static QDF_STATUS send_twt_pause_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_pause_dialog_cmd_param *params)
static QDF_STATUS
send_twt_pause_dialog_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_pause_dialog_cmd_param *params)
{
wmi_twt_pause_dialog_cmd_fixed_param *cmd;
wmi_buf_t buf;
@@ -199,16 +243,16 @@ static QDF_STATUS send_twt_pause_dialog_cmd_tlv(wmi_unified_t wmi_handle,
cmd = (wmi_twt_pause_dialog_cmd_fixed_param *) wmi_buf_data(buf);
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_twt_pause_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_pause_dialog_cmd_fixed_param));
WMITLV_TAG_STRUC_wmi_twt_pause_dialog_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_pause_dialog_cmd_fixed_param));
cmd->vdev_id = params->vdev_id;
WMI_CHAR_ARRAY_TO_MAC_ADDR(params->peer_macaddr, &cmd->peer_macaddr);
cmd->dialog_id = params->dialog_id;
status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
WMI_TWT_PAUSE_DIALOG_CMDID);
WMI_TWT_PAUSE_DIALOG_CMDID);
if (QDF_IS_STATUS_ERROR(status)) {
WMI_LOGE("Failed to send WMI_TWT_PAUSE_DIALOG_CMDID");
wmi_buf_free(buf);
@@ -252,6 +296,76 @@ static QDF_STATUS send_twt_resume_dialog_cmd_tlv(wmi_unified_t wmi_handle,
return status;
}
#ifdef WLAN_SUPPORT_BCAST_TWT
static QDF_STATUS
send_twt_btwt_invite_sta_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_btwt_invite_sta_cmd_param
*params)
{
wmi_twt_btwt_invite_sta_cmd_fixed_param *cmd;
wmi_buf_t buf;
QDF_STATUS status;
buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
if (!buf) {
WMI_LOGE("Failed to allocate memory");
return QDF_STATUS_E_FAILURE;
}
cmd = (wmi_twt_btwt_invite_sta_cmd_fixed_param *)wmi_buf_data(buf);
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_twt_btwt_invite_sta_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_btwt_invite_sta_cmd_fixed_param));
cmd->vdev_id = params->vdev_id;
WMI_CHAR_ARRAY_TO_MAC_ADDR(params->peer_macaddr, &cmd->peer_macaddr);
cmd->dialog_id = params->dialog_id;
status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
WMI_TWT_BTWT_INVITE_STA_CMDID);
if (QDF_IS_STATUS_ERROR(status)) {
wmi_buf_free(buf);
}
return status;
}
static QDF_STATUS
send_twt_btwt_remove_sta_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_twt_btwt_remove_sta_cmd_param
*params)
{
wmi_twt_btwt_remove_sta_cmd_fixed_param *cmd;
wmi_buf_t buf;
QDF_STATUS status;
buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
if (!buf) {
WMI_LOGE("Failed to allocate memory");
return QDF_STATUS_E_FAILURE;
}
cmd = (wmi_twt_btwt_remove_sta_cmd_fixed_param *)wmi_buf_data(buf);
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_twt_btwt_remove_sta_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_twt_btwt_remove_sta_cmd_fixed_param));
cmd->vdev_id = params->vdev_id;
WMI_CHAR_ARRAY_TO_MAC_ADDR(params->peer_macaddr, &cmd->peer_macaddr);
cmd->dialog_id = params->dialog_id;
status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
WMI_TWT_BTWT_REMOVE_STA_CMDID);
if (QDF_IS_STATUS_ERROR(status)) {
wmi_buf_free(buf);
}
return status;
}
#endif
static QDF_STATUS extract_twt_enable_comp_event_tlv(wmi_unified_t wmi_handle,
uint8_t *evt_buf,
struct wmi_twt_enable_complete_event_param *params)
@@ -395,6 +509,85 @@ static QDF_STATUS extract_twt_resume_dialog_comp_event_tlv(
return QDF_STATUS_SUCCESS;
}
#ifdef WLAN_SUPPORT_BCAST_TWT
static QDF_STATUS
extract_twt_btwt_invite_sta_comp_event_tlv(
wmi_unified_t wmi_handle,
uint8_t *evt_buf,
struct
wmi_twt_btwt_invite_sta_complete_event_param
*params)
{
WMI_TWT_BTWT_INVITE_STA_COMPLETE_EVENTID_param_tlvs *param_buf;
wmi_twt_btwt_invite_sta_complete_event_fixed_param *ev;
param_buf =
(WMI_TWT_BTWT_INVITE_STA_COMPLETE_EVENTID_param_tlvs *)evt_buf;
if (!param_buf) {
WMI_LOGE("evt_buf is NULL");
return QDF_STATUS_E_INVAL;
}
ev = param_buf->fixed_param;
params->vdev_id = ev->vdev_id;
WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr, params->peer_macaddr);
params->status = ev->status;
params->dialog_id = ev->dialog_id;
return QDF_STATUS_SUCCESS;
}
static QDF_STATUS
extract_twt_btwt_remove_sta_comp_event_tlv(
wmi_unified_t wmi_handle,
uint8_t *evt_buf,
struct
wmi_twt_btwt_remove_sta_complete_event_param
*params)
{
WMI_TWT_BTWT_REMOVE_STA_COMPLETE_EVENTID_param_tlvs *param_buf;
wmi_twt_btwt_remove_sta_complete_event_fixed_param *ev;
param_buf =
(WMI_TWT_BTWT_REMOVE_STA_COMPLETE_EVENTID_param_tlvs *)evt_buf;
if (!param_buf) {
WMI_LOGE("evt_buf is NULL");
return QDF_STATUS_E_INVAL;
}
ev = param_buf->fixed_param;
params->vdev_id = ev->vdev_id;
WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr, params->peer_macaddr);
params->status = ev->status;
params->dialog_id = ev->dialog_id;
return QDF_STATUS_SUCCESS;
}
#endif
#ifdef WLAN_SUPPORT_BCAST_TWT
static void
wmi_twt_attach_bcast_twt_tlv(struct wmi_ops *ops)
{
ops->send_twt_btwt_invite_sta_cmd = send_twt_btwt_invite_sta_cmd_tlv;
ops->send_twt_btwt_remove_sta_cmd = send_twt_btwt_remove_sta_cmd_tlv;
ops->extract_twt_btwt_invite_sta_comp_event =
extract_twt_btwt_invite_sta_comp_event_tlv;
ops->extract_twt_btwt_remove_sta_comp_event =
extract_twt_btwt_remove_sta_comp_event_tlv;
return;
}
#else
static void
wmi_twt_attach_bcast_twt_tlv(struct wmi_ops *ops)
{
return;
}
#endif
void wmi_twt_attach_tlv(wmi_unified_t wmi_handle)
{
struct wmi_ops *ops = wmi_handle->ops;
@@ -416,4 +609,6 @@ void wmi_twt_attach_tlv(wmi_unified_t wmi_handle)
extract_twt_pause_dialog_comp_event_tlv;
ops->extract_twt_resume_dialog_comp_event =
extract_twt_resume_dialog_comp_event_tlv;
wmi_twt_attach_bcast_twt_tlv(ops);
}