From 294f63373db71aa3a7b777c82c238929b18b6de3 Mon Sep 17 00:00:00 2001 From: Christopher Chopp Date: Thu, 21 Nov 2019 16:23:21 -0800 Subject: [PATCH] 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 --- wmi/inc/wmi_unified_priv.h | 19 +++ wmi/inc/wmi_unified_twt_api.h | 57 +++++++- wmi/inc/wmi_unified_twt_param.h | 121 ++++++++++++++++- wmi/src/wmi_unified_twt_api.c | 52 ++++++- wmi/src/wmi_unified_twt_tlv.c | 233 +++++++++++++++++++++++++++++--- 5 files changed, 459 insertions(+), 23 deletions(-) diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 8cd7b2f3aa..1d7ca98206 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1996,6 +1996,14 @@ QDF_STATUS (*send_twt_pause_dialog_cmd)(wmi_unified_t wmi_handle, QDF_STATUS (*send_twt_resume_dialog_cmd)(wmi_unified_t wmi_handle, struct wmi_twt_resume_dialog_cmd_param *params); +#ifdef WLAN_SUPPORT_BCAST_TWT +QDF_STATUS (*send_twt_btwt_invite_sta_cmd)(wmi_unified_t wmi_handle, + struct wmi_twt_btwt_invite_sta_cmd_param *params); + +QDF_STATUS (*send_twt_btwt_remove_sta_cmd)(wmi_unified_t wmi_handle, + struct wmi_twt_btwt_remove_sta_cmd_param *params); +#endif + QDF_STATUS (*extract_twt_enable_comp_event)(wmi_unified_t wmi_handle, uint8_t *evt_buf, struct wmi_twt_enable_complete_event_param *params); @@ -2019,6 +2027,17 @@ QDF_STATUS (*extract_twt_pause_dialog_comp_event)(wmi_unified_t wmi_handle, QDF_STATUS (*extract_twt_resume_dialog_comp_event)(wmi_unified_t wmi_handle, uint8_t *evt_buf, struct wmi_twt_resume_dialog_complete_event_param *params); + +#ifdef WLAN_SUPPORT_BCAST_TWT +QDF_STATUS (*extract_twt_btwt_invite_sta_comp_event)(wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_invite_sta_complete_event_param *params); + +QDF_STATUS (*extract_twt_btwt_remove_sta_comp_event)(wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_remove_sta_complete_event_param *params); +#endif + #endif #ifdef QCA_SUPPORT_CP_STATS diff --git a/wmi/inc/wmi_unified_twt_api.h b/wmi/inc/wmi_unified_twt_api.h index de3a0b3e88..00bcc26397 100644 --- a/wmi/inc/wmi_unified_twt_api.h +++ b/wmi/inc/wmi_unified_twt_api.h @@ -1,6 +1,6 @@ /* - * 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 @@ -92,6 +92,31 @@ QDF_STATUS wmi_unified_twt_resume_dialog_cmd( wmi_unified_t wmi_handle, struct wmi_twt_resume_dialog_cmd_param *params); +#ifdef WLAN_SUPPORT_BCAST_TWT +/** + * wmi_unified_twt_btwt_invite_sta_cmd() - Send WMI command for bTWT sta + * invitation + * @wmi_handle: wmi handle + * @params: Parameters to be configured + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_twt_btwt_invite_sta_cmd( + wmi_unified_t wmi_handle, + struct wmi_twt_btwt_invite_sta_cmd_param *params); + +/** + * wmi_unified_twt_btwt_remove_sta_cmd() - Send WMI command for bTWT sta kickoff + * @wmi_handle: wmi handle + * @params: Parameters to be configured + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_twt_btwt_remove_sta_cmd( + wmi_unified_t wmi_handle, + struct wmi_twt_btwt_remove_sta_cmd_param *params); +#endif + /** * wmi_extract_twt_enable_comp_event() - Extract WMI event params for TWT enable * completion event @@ -176,6 +201,36 @@ QDF_STATUS wmi_extract_twt_resume_dialog_comp_event( uint8_t *evt_buf, struct wmi_twt_resume_dialog_complete_event_param *params); +#ifdef WLAN_SUPPORT_BCAST_TWT +/** + * wmi_extract_twt_btwt_invite_sta_comp_event() - Extract WMI event params for + * BTWT sta invitation completion event + * @wmi_handle: wmi handle + * @evt_buf: Pointer event buffer + * @params: Parameters to extract + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_extract_twt_btwt_invite_sta_comp_event( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_invite_sta_complete_event_param *params); + +/** + * wmi_extract_twt_btwt_remove_sta_comp_event() - Extract WMI event params for + * BTWT sta kickoff completion event + * @wmi_handle: wmi handle + * @evt_buf: Pointer event buffer + * @params: Parameters to extract + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_extract_twt_btwt_remove_sta_comp_event( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_remove_sta_complete_event_param *params); +#endif + #ifdef WLAN_SUPPORT_TWT void wmi_twt_attach_tlv(struct wmi_unified *wmi_handle); #else diff --git a/wmi/inc/wmi_unified_twt_param.h b/wmi/inc/wmi_unified_twt_param.h index aa736258b0..151f61f5e4 100644 --- a/wmi/inc/wmi_unified_twt_param.h +++ b/wmi/inc/wmi_unified_twt_param.h @@ -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 @@ -162,6 +162,11 @@ enum WMI_HOST_TWT_COMMAND { * 1 means un-announced TWT * @flag_protection: 0 means TWT protection is required, * 1 means TWT protection is not required + * @b_twt_id0: 0 means BTWT recommendation will not be used + * 1 means BTWT recommendation will be used + * @flag_reserved: unused bits + * @b_twt_recommendation: defines types of frames tx during bTWT SP + * @b_twt_persistence: Countdown VAL frames to param update/teardown */ struct wmi_twt_add_dialog_param { uint32_t vdev_id; @@ -176,7 +181,11 @@ struct wmi_twt_add_dialog_param { flag_bcast:1, flag_trigger:1, flag_flow_type:1, - flag_protection:1; + flag_protection:1, + flag_b_twt_id0:1, + flag_reserved:11, + b_twt_persistence:8, + b_twt_recommendation:3; }; /* enum - status code of adding TWT dialog @@ -223,11 +232,15 @@ struct wmi_twt_add_dialog_complete_event_param { * @vdev_id: VDEV identifier * @peer_macaddr: Peer mac address * @dialog_id: TWT dialog ID + * @b_twt_persistence: persistence val for b-twt */ struct wmi_twt_del_dialog_param { uint32_t vdev_id; uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; uint32_t dialog_id; +#ifdef WLAN_SUPPORT_BCAST_TWT + uint32_t b_twt_persistence; +#endif }; /* status code of deleting TWT dialog @@ -256,12 +269,16 @@ enum WMI_HOST_DEL_TWT_STATUS { * @vdev_id: VDEV identifier * @peer_macaddr: Peer mac address * @dialog_id: TWT dialog ID + * @b_twt_persistence: persistence val for b-twt * @status: refer to WMI_HOST_DEL_TWT_STATUS enum */ struct wmi_twt_del_dialog_complete_event_param { uint32_t vdev_id; uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; uint32_t dialog_id; +#ifdef WLAN_SUPPORT_BCAST_TWT + uint32_t b_twt_persistence; +#endif uint32_t status; }; @@ -364,4 +381,104 @@ struct wmi_twt_resume_dialog_complete_event_param { uint32_t status; }; +#ifdef WLAN_SUPPORT_BCAST_TWT +/** struct wmi_twt_btwt_invite_sta_cmd_param - + * @vdev_id: VDEV identifier + * @peer_macaddr: Peer mac address + * @dialog_id: TWT dialog ID + */ +struct wmi_twt_btwt_invite_sta_cmd_param { + uint32_t vdev_id; + uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; + uint32_t dialog_id; +}; + +/* enum WMI_HOST_INVITATION_TWT_BTWT_STATUS - status code of TWT Invitation + * dialog + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_OK: BTWT invitation successfully + * completed + * WMI_HOST_INVITATION_TWT_TWT_STATUS_DIALOG_ID_NOT_EXIST: BTWT dialog ID not + * exists + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_INVALID_PARAM: invalid parameters + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_DIALOG_ID_BUSY: FW is in the process of + * handling this dialog + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_NO_RESOURCE: FW resource exhausted + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_NO_ACK: peer AP/STA did not ACK the + * request/response frame + * WMI_HOST_INVITATION_TWT_BTWT_STATUS_UNKNOWN_ERROR: BTWT invitation failed + * with an unknown reason + */ +enum WMI_HOST_INVITATION_TWT_BTWT_STATUS { + WMI_HOST_INVITATION_TWT_BTWT_STATUS_OK, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_DIALOG_ID_NOT_EXIST, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_INVALID_PARAM, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_DIALOG_ID_BUSY, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_NO_RESOURCE, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_NO_ACK, + WMI_HOST_INVITATION_TWT_BTWT_STATUS_UNKNOWN_ERROR, +}; + +/** struct wmi_twt_btwt_invite_sta_complete_event_param - + * @vdev_id: VDEV identifier + * @peer_macaddr: Peer mac address + * @dialog_id: BTWT dialog ID + * @status: refer to WMI_HOST_INVITATION_TWT_BTWT_STATUS + */ +struct wmi_twt_btwt_invite_sta_complete_event_param { + uint32_t vdev_id; + uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; + uint32_t dialog_id; + uint32_t status; +}; + +/** struct wmi_twt_btwt_remove_sta_cmd_param - + * @vdev_id: VDEV identifier + * @peer_macaddr: Peer mac address + * @dialog_id: BTWT dialog ID + */ +struct wmi_twt_btwt_remove_sta_cmd_param { + uint32_t vdev_id; + uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; + uint32_t dialog_id; +}; + +/* enum WMI_HOST_KICKOFF_TWT_BTWT_STATUS - status code of resuming TWT dialog + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_OK: TWT kickoff successfully completed + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_DIALOG_ID_NOT_EXIST: BTWT dialog ID not + * exists + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_INVALID_PARAM: invalid parameters + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_DIALOG_ID_BUSY: FW is in the process of + * handling this dialog + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NOT_PAUSED: Dialog not currently paused + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NO_RESOURCE: FW resource exhausted + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NO_ACK: peer AP/STA did not ACK the + * request/response frame + * WMI_HOST_KICKOFF_TWT_BTWT_STATUS_UNKNOWN_ERROR: BTWT kickoff failed with an + * unknown reason + */ +enum WMI_HOST_KICKOFF_TWT_BTWT_STATUS { + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_OK, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_DIALOG_ID_NOT_EXIST, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_INVALID_PARAM, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_DIALOG_ID_BUSY, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NOT_PAUSED, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NO_RESOURCE, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_NO_ACK, + WMI_HOST_KICKOFF_TWT_BTWT_STATUS_UNKNOWN_ERROR, +}; + +/** struct wmi_twt_btwt_remove_sta_complete_event_param - + * @vdev_id: VDEV identifier + * @peer_macaddr: Peer mac address + * @dialog_id: BTWT dialog ID + * @status: refer to WMI_HOST_KICKOFF_TWT_BTWT_STATUS + */ +struct wmi_twt_btwt_remove_sta_complete_event_param { + uint32_t vdev_id; + uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE]; + uint32_t dialog_id; + uint32_t status; +}; +#endif + #endif /* _WMI_UNIFIED_TWT_PARAM_H_ */ diff --git a/wmi/src/wmi_unified_twt_api.c b/wmi/src/wmi_unified_twt_api.c index 0c7778e552..bae359f540 100644 --- a/wmi/src/wmi_unified_twt_api.c +++ b/wmi/src/wmi_unified_twt_api.c @@ -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 @@ -89,6 +89,30 @@ QDF_STATUS wmi_unified_twt_resume_dialog_cmd( return QDF_STATUS_E_FAILURE; } +#ifdef WLAN_SUPPORT_BCAST_TWT +QDF_STATUS wmi_unified_twt_btwt_invite_sta_cmd( + wmi_unified_t wmi_handle, + struct wmi_twt_btwt_invite_sta_cmd_param *params) +{ + if (wmi_handle->ops->send_twt_btwt_invite_sta_cmd) + return wmi_handle->ops->send_twt_btwt_invite_sta_cmd( + wmi_handle, params); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_unified_twt_btwt_remove_sta_cmd( + wmi_unified_t wmi_handle, + struct wmi_twt_btwt_remove_sta_cmd_param *params) +{ + if (wmi_handle->ops->send_twt_btwt_remove_sta_cmd) + return wmi_handle->ops->send_twt_btwt_remove_sta_cmd( + wmi_handle, params); + + return QDF_STATUS_E_FAILURE; +} +#endif + QDF_STATUS wmi_extract_twt_enable_comp_event( wmi_unified_t wmi_handle, uint8_t *evt_buf, @@ -160,3 +184,29 @@ QDF_STATUS wmi_extract_twt_resume_dialog_comp_event( return QDF_STATUS_E_FAILURE; } + +#ifdef WLAN_SUPPORT_BCAST_TWT +QDF_STATUS wmi_extract_twt_btwt_invite_sta_comp_event( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_invite_sta_complete_event_param *params) +{ + if (wmi_handle->ops->extract_twt_btwt_invite_sta_comp_event) + return wmi_handle->ops->extract_twt_btwt_invite_sta_comp_event( + wmi_handle, evt_buf, params); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_extract_twt_btwt_remove_sta_comp_event( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wmi_twt_btwt_remove_sta_complete_event_param *params) +{ + if (wmi_handle->ops->extract_twt_btwt_remove_sta_comp_event) + return wmi_handle->ops->extract_twt_btwt_remove_sta_comp_event( + wmi_handle, evt_buf, params); + + return QDF_STATUS_E_FAILURE; +} +#endif diff --git a/wmi/src/wmi_unified_twt_tlv.c b/wmi/src/wmi_unified_twt_tlv.c index 38f3c3cbbd..03d7c2580d 100644 --- a/wmi/src/wmi_unified_twt_tlv.c +++ b/wmi/src/wmi_unified_twt_tlv.c @@ -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); }