diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 61f5722ad7..d806e23637 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -324,4 +324,28 @@ int32_t wmi_unified_pdev_utf_cmd_send(void *wmi_hdl, int32_t wmi_unified_dbglog_cmd_send(void *wmi_hdl, struct dbglog_params *param); +int32_t wmi_mgmt_unified_cmd_send(void *wmi_hdl, + struct wmi_mgmt_params *param); + +int32_t wmi_unified_modem_power_state(void *wmi_hdl, + uint32_t param_value); + +int32_t wmi_unified_set_sta_ps_mode(void *wmi_hdl, + uint32_t vdev_id, uint8_t val); +int32_t +wmi_unified_set_sta_uapsd_auto_trig_cmd(void *wmi_hdl, + struct sta_uapsd_trig_params *param); + +int32_t wmi_unified_get_temperature(void *wmi_hdl); + +int32_t wmi_unified_set_p2pgo_oppps_req(void *wmi_hdl, + struct p2p_ps_params *oppps); + +int32_t wmi_unified_set_p2pgo_noa_req_cmd(void *wmi_hdl, + struct p2p_ps_params *noa); + +int32_t wmi_unified_set_smps_params(void *wmi_hdl, uint8_t vdev_id, + int value); + +int32_t wmi_unified_set_mimops(void *wmi_hdl, uint8_t vdev_id, int value); #endif /* _WMI_UNIFIED_API_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index b350b9b056..a88322a963 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -164,6 +164,32 @@ int32_t (*send_scan_stop_cmd)(wmi_unified_t wmi_handle, int32_t (*send_scan_chan_list_cmd)(wmi_unified_t wmi_handle, struct scan_chan_list_params *param); + +int32_t (*send_mgmt_cmd)(wmi_unified_t wmi_handle, + struct wmi_mgmt_params *param); + +int32_t (*send_modem_power_state_cmd)(wmi_unified_t wmi_handle, + uint32_t param_value); + +int32_t (*send_set_sta_ps_mode_cmd)(wmi_unified_t wmi_handle, + uint32_t vdev_id, uint8_t val); + +int32_t (*send_get_temperature_cmd)(wmi_unified_t wmi_handle); + +int32_t (*send_set_p2pgo_oppps_req_cmd)(wmi_unified_t wmi_handle, + struct p2p_ps_params *oppps); + +int32_t (*send_set_p2pgo_noa_req_cmd)(wmi_unified_t wmi_handle, + struct p2p_ps_params *noa); + +int32_t (*send_set_smps_params_cmd)(wmi_unified_t wmi_handle, uint8_t vdev_id, + int value); + +int32_t (*send_set_mimops_cmd)(wmi_unified_t wmi_handle, + uint8_t vdev_id, int value); + +int32_t (*send_set_sta_uapsd_auto_trig_cmd)(wmi_unified_t wmi_handle, + struct sta_uapsd_trig_params *param); }; struct wmi_unified { diff --git a/wmi/inc/wmi_unified_tlv.h b/wmi/inc/wmi_unified_tlv.h index 0cb1abc2a7..b3ced03db1 100644 --- a/wmi/inc/wmi_unified_tlv.h +++ b/wmi/inc/wmi_unified_tlv.h @@ -127,3 +127,29 @@ int32_t send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle, int32_t send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle, struct scan_chan_list_params *param); +int32_t send_mgmt_cmd_tlv(wmi_unified_t wmi_handle, + struct wmi_mgmt_params *param); + +int32_t send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t param_value); + +int32_t send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t vdev_id, uint8_t val); + +int32_t send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle, + struct sta_uapsd_trig_params *param); + +int32_t send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle); + +int32_t send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle, + struct p2p_ps_params *oppps); + +int32_t send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle, + struct p2p_ps_params *noa); + +int32_t send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id, + int value); + +int32_t send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t vdev_id, int value); + diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index c737cc1dbc..cce2184eb6 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -591,3 +591,181 @@ int32_t wmi_unified_scan_chan_list_cmd_send(void *wmi_hdl, return CDF_STATUS_E_FAILURE; } + +/** + * wmi_mgmt_unified_cmd_send() - management cmd over wmi layer + * @wmi_hdl : handle to WMI. + * @param : pointer to hold mgmt cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_mgmt_unified_cmd_send(void *wmi_hdl, + struct wmi_mgmt_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_mgmt_cmd) + return wmi_handle->ops->send_mgmt_cmd(wmi_handle, + param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_modem_power_state() - set modem power state to fw + * @wmi_hdl: wmi handle + * @param_value: parameter value + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_modem_power_state(void *wmi_hdl, + uint32_t param_value) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_modem_power_state_cmd) + return wmi_handle->ops->send_modem_power_state_cmd(wmi_handle, + param_value); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_set_sta_ps_mode() - set sta powersave params in fw + * @wmi_hdl: wmi handle + * @vdev_id: vdev id + * @val: value + * + * Return: 0 for success or error code. + */ +int32_t wmi_unified_set_sta_ps_mode(void *wmi_hdl, + uint32_t vdev_id, uint8_t val) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_sta_ps_mode_cmd) + return wmi_handle->ops->send_set_sta_ps_mode_cmd(wmi_handle, + vdev_id, val); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_set_mimops() - set MIMO powersave + * @wmi_hdl: wmi handle + * @vdev_id: vdev id + * @value: value + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t wmi_unified_set_mimops(void *wmi_hdl, uint8_t vdev_id, int value) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_mimops_cmd) + return wmi_handle->ops->send_set_mimops_cmd(wmi_handle, + vdev_id, value); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_set_smps_params() - set smps params + * @wmi_hdl: wmi handle + * @vdev_id: vdev id + * @value: value + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t wmi_unified_set_smps_params(void *wmi_hdl, uint8_t vdev_id, + int value) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_smps_params_cmd) + return wmi_handle->ops->send_set_smps_params_cmd(wmi_handle, + vdev_id, value); + + return CDF_STATUS_E_FAILURE; +} + + +/** + * wmi_set_p2pgo_oppps_req() - send p2p go opp power save request to fw + * @wmi_hdl: wmi handle + * @opps: p2p opp power save parameters + * + * Return: none + */ +int32_t wmi_unified_set_p2pgo_oppps_req(void *wmi_hdl, + struct p2p_ps_params *oppps) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_p2pgo_oppps_req_cmd) + return wmi_handle->ops->send_set_p2pgo_oppps_req_cmd(wmi_handle, + oppps); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_set_p2pgo_noa_req_cmd() - send p2p go noa request to fw + * @wmi_hdl: wmi handle + * @noa: p2p power save parameters + * + * Return: none + */ +int32_t wmi_unified_set_p2pgo_noa_req_cmd(void *wmi_hdl, + struct p2p_ps_params *noa) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_p2pgo_noa_req_cmd) + return wmi_handle->ops->send_set_p2pgo_noa_req_cmd(wmi_handle, + noa); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_get_temperature() - get pdev temperature req + * @wmi_hdl: wmi handle + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t wmi_unified_get_temperature(void *wmi_hdl) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_get_temperature_cmd) + return wmi_handle->ops->send_get_temperature_cmd(wmi_handle); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_set_sta_uapsd_auto_trig_cmd() - set uapsd auto trigger command + * @wmi_hdl: wmi handle + * @end_set_sta_ps_mode_cmd: cmd paramter strcture + * + * This function sets the trigger + * uapsd params such as service interval, delay interval + * and suspend interval which will be used by the firmware + * to send trigger frames periodically when there is no + * traffic on the transmit side. + * + * Return: 0 for success or error code. + */ +int32_t +wmi_unified_set_sta_uapsd_auto_trig_cmd(void *wmi_hdl, + struct sta_uapsd_trig_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_sta_uapsd_auto_trig_cmd) + return wmi_handle->ops->send_set_sta_uapsd_auto_trig_cmd(wmi_handle, + param); + + return CDF_STATUS_E_FAILURE; +} diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 679229ed6e..d9f23813c6 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -1378,9 +1378,481 @@ end: int32_t send_mgmt_cmd_tlv(wmi_unified_t wmi_handle, struct wmi_mgmt_params *param) { + wmi_buf_t buf; + wmi_mgmt_tx_send_cmd_fixed_param *cmd; + int32_t cmd_len; + uint64_t dma_addr; + struct wmi_desc_t *wmi_desc = NULL; + void *cdf_ctx = param->cdf_ctx; + uint8_t *bufp; + int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len : + mgmt_tx_dl_frm_len; + + cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) + + WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t)); + + buf = wmi_buf_alloc(wmi_handle, cmd_len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return CDF_STATUS_E_NOMEM; + } + + cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf); + bufp = (uint8_t *) cmd; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_mgmt_tx_send_cmd_fixed_param)); + + cmd->vdev_id = param->vdev_id; + + wmi_desc = param->wmi_desc; + if (!wmi_desc) { + WMA_LOGE("%s: Failed to get wmi_desc", __func__); + goto err1; + } + wmi_desc->nbuf = param->tx_frame; + wmi_desc->tx_cmpl_cb = param->tx_complete_cb; + wmi_desc->ota_post_proc_cb = param->tx_ota_post_proc_cb; + + cmd->desc_id = wmi_desc->desc_id; + cmd->chanfreq = param->chanfreq; + bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param); + WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len, + sizeof(uint32_t))); + bufp += WMI_TLV_HDR_SIZE; + cdf_mem_copy(bufp, param->pdata, bufp_len); + cdf_nbuf_map_single(cdf_ctx, param->tx_frame, CDF_DMA_TO_DEVICE); + dma_addr = cdf_nbuf_get_frag_paddr_lo(param->tx_frame, 0); + cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff); +#if defined(HELIUMPLUS_PADDR64) + cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F); +#endif + cmd->frame_len = param->frm_len; + cmd->buf_len = bufp_len; + + if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len, + WMI_MGMT_TX_SEND_CMDID)) { + WMA_LOGE("%s: Failed to send mgmt Tx", __func__); + goto err1; + } + return CDF_STATUS_SUCCESS; + +err1: + wmi_buf_free(buf); + return CDF_STATUS_E_FAILURE; +} + +/** + * send_modem_power_state_cmd_tlv() - set modem power state to fw + * @wmi_handle: wmi handle + * @param_value: parameter value + * + * Return: 0 for success or error code + */ +int32_t send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t param_value) +{ + int ret; + wmi_modem_power_state_cmd_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_modem_power_state_cmd_param)); + cmd->modem_power_state = param_value; + WMA_LOGD("%s: Setting cmd->modem_power_state = %u", __func__, + param_value); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_MODEM_POWER_STATE_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send notify cmd ret = %d", ret); + wmi_buf_free(buf); + } + return ret; +} + +/** + * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * @val: value + * + * Return: 0 for success or error code. + */ +int32_t send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t vdev_id, uint8_t val) +{ + wmi_sta_powersave_mode_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + WMA_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__); + return -ENOMEM; + } + cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_powersave_mode_cmd_fixed_param)); + cmd->vdev_id = vdev_id; + if (val) + cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED; + else + cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED; + + if (wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_STA_POWERSAVE_MODE_CMDID)) { + WMA_LOGE("Set Sta Mode Ps Failed vdevId %d val %d", + vdev_id, val); + cdf_nbuf_free(buf); + return -EIO; + } return 0; } +/** + * send_set_mimops_cmd_tlv() - set MIMO powersave + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * @value: value + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t vdev_id, int value) +{ + int ret = CDF_STATUS_SUCCESS; + wmi_sta_smps_force_mode_cmd_fixed_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_smps_force_mode_cmd_fixed_param)); + + cmd->vdev_id = vdev_id; + + switch (value) { + case 0: + cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE; + break; + case 1: + cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED; + break; + case 2: + cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC; + break; + case 3: + cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC; + break; + default: + WMA_LOGE("%s:INVALID Mimo PS CONFIG", __func__); + return CDF_STATUS_E_FAILURE; + } + + WMA_LOGD("Setting vdev %d value = %u", vdev_id, value); + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_STA_SMPS_FORCE_MODE_CMDID); + if (ret < 0) { + WMA_LOGE("Failed to send set Mimo PS ret = %d", ret); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_set_smps_params_cmd_tlv() - set smps params + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * @value: value + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id, + int value) +{ + int ret = CDF_STATUS_SUCCESS; + wmi_sta_smps_param_cmd_fixed_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_smps_param_cmd_fixed_param)); + + cmd->vdev_id = vdev_id; + cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS; + cmd->param = + (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS; + + WMA_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value, + cmd->param); + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_STA_SMPS_PARAM_CMDID); + if (ret < 0) { + WMA_LOGE("Failed to send set Mimo PS ret = %d", ret); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw + * @wmi_handle: wmi handle + * @noa: p2p power save parameters + * + * Return: none + */ +int32_t send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle, + struct p2p_ps_params *noa) +{ + wmi_p2p_set_noa_cmd_fixed_param *cmd; + wmi_p2p_noa_descriptor *noa_discriptor; + wmi_buf_t buf; + uint8_t *buf_ptr; + uint16_t len; + int32_t status; + uint32_t duration; + + WMA_LOGD("%s: Enter", __func__); + len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor); + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("Failed to allocate memory"); + status = CDF_STATUS_E_FAILURE; + goto end; + } + + buf_ptr = (uint8_t *) wmi_buf_data(buf); + cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_p2p_set_noa_cmd_fixed_param)); + duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration; + cmd->vdev_id = noa->session_id; + cmd->enable = (duration) ? true : false; + cmd->num_noa = 1; + + WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)), + WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor)); + noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr + + sizeof + (wmi_p2p_set_noa_cmd_fixed_param) + + WMI_TLV_HDR_SIZE); + WMITLV_SET_HDR(&noa_discriptor->tlv_header, + WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor, + WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor)); + noa_discriptor->type_count = noa->count; + noa_discriptor->duration = duration; + noa_discriptor->interval = noa->interval; + noa_discriptor->start_time = 0; + + WMA_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d", + cmd->vdev_id, noa->count, noa_discriptor->duration, + noa->interval); + status = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID); + if (status != EOK) { + WMA_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID"); + wmi_buf_free(buf); + } + +end: + WMA_LOGD("%s: Exit", __func__); + return status; +} + + +/** + * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw + * @wmi_handle: wmi handle + * @noa: p2p opp power save parameters + * + * Return: none + */ +int32_t send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle, + struct p2p_ps_params *oppps) +{ + wmi_p2p_set_oppps_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t status; + + WMA_LOGD("%s: Enter", __func__); + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMA_LOGE("Failed to allocate memory"); + status = CDF_STATUS_E_FAILURE; + goto end; + } + + cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_p2p_set_oppps_cmd_fixed_param)); + cmd->vdev_id = oppps->session_id; + if (oppps->ctwindow) + WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd); + + WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow); + WMA_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d", + cmd->vdev_id, oppps->ctwindow); + status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd), + WMI_P2P_SET_OPPPS_PARAM_CMDID); + if (status != EOK) { + WMA_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID"); + wmi_buf_free(buf); + } + +end: + WMA_LOGD("%s: Exit", __func__); + return status; +} + +/** + * send_get_temperature_cmd_tlv() - get pdev temperature req + * @wmi_handle: wmi handle + * + * Return: CDF_STATUS_SUCCESS for success or error code. + */ +int32_t send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle) +{ + wmi_pdev_get_temperature_cmd_fixed_param *cmd; + wmi_buf_t wmi_buf; + uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param); + uint8_t *buf_ptr; + + if (!wmi_handle) { + WMA_LOGE(FL("WMA is closed, can not issue cmd")); + return CDF_STATUS_E_INVAL; + } + + wmi_buf = wmi_buf_alloc(wmi_handle, len); + if (!wmi_buf) { + WMA_LOGE(FL("wmi_buf_alloc failed")); + return CDF_STATUS_E_NOMEM; + } + + buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf); + + cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_pdev_get_temperature_cmd_fixed_param)); + + if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len, + WMI_PDEV_GET_TEMPERATURE_CMDID)) { + WMA_LOGE(FL("failed to send get temperature command")); + wmi_buf_free(wmi_buf); + return CDF_STATUS_E_FAILURE; + } + return CDF_STATUS_SUCCESS; +} + +/** + * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command + * @wmi_handle: wmi handle + * @vdevid: vdev id + * @peer_addr: peer mac address + * @auto_triggerparam: auto trigger parameters + * @num_ac: number of access category + * + * This function sets the trigger + * uapsd params such as service interval, delay interval + * and suspend interval which will be used by the firmware + * to send trigger frames periodically when there is no + * traffic on the transmit side. + * + * Return: 0 for success or error code. + */ +int32_t send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle, + struct sta_uapsd_trig_params *param) +{ + wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd; + int32_t ret; + uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param); + uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE; + uint32_t i; + wmi_buf_t buf; + uint8_t *buf_ptr; + + buf = wmi_buf_alloc(wmi_handle, cmd_len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + + buf_ptr = (uint8_t *) wmi_buf_data(buf); + cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_uapsd_auto_trig_cmd_fixed_param)); + cmd->vdev_id = param->vdevid; + cmd->num_ac = param->num_ac; + WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr); + + /* TLV indicating array of structures to follow */ + buf_ptr += sizeof(*cmd); + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len); + + buf_ptr += WMI_TLV_HDR_SIZE; + cdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len); + + /* + * Update tag and length for uapsd auto trigger params (this will take + * care of updating tag and length if it is not pre-filled by caller). + */ + for (i = 0; i < param->num_ac; i++) { + WMITLV_SET_HDR((buf_ptr + + (i * sizeof(wmi_sta_uapsd_auto_trig_param))), + WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_uapsd_auto_trig_param)); + } + + ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len, + WMI_STA_UAPSD_AUTO_TRIG_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send set uapsd param ret = %d", ret); + wmi_buf_free(buf); + } + return ret; +} + struct wmi_ops tlv_ops = { .send_vdev_create_cmd = send_vdev_create_cmd_tlv, .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv, @@ -1388,7 +1860,9 @@ struct wmi_ops tlv_ops = { .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv, .send_peer_param_cmd = send_peer_param_cmd_tlv, .send_vdev_up_cmd = send_vdev_up_cmd_tlv, + .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv, .send_peer_create_cmd = send_peer_create_cmd_tlv, + .send_peer_delete_cmd = send_peer_delete_cmd_tlv, .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv, .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv, .send_pdev_param_cmd = send_pdev_param_cmd_tlv, @@ -1407,6 +1881,15 @@ struct wmi_ops tlv_ops = { .send_scan_start_cmd = send_scan_start_cmd_tlv, .send_scan_stop_cmd = send_scan_stop_cmd_tlv, .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv, + .send_mgmt_cmd = send_mgmt_cmd_tlv, + .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv, + .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv, + .send_set_sta_uapsd_auto_trig_cmd = send_set_sta_uapsd_auto_trig_cmd_tlv, + .send_get_temperature_cmd = send_get_temperature_cmd_tlv, + .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv, + .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv, + .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv, + .send_set_mimops_cmd = send_set_mimops_cmd_tlv, /* TODO - Add other tlv apis here */ };