1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906 |
- /*
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
- *
- * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
- *
- *
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- /*
- * This file was originally distributed by Qualcomm Atheros, Inc.
- * under proprietary terms before Copyright ownership was assigned
- * to the Linux Foundation.
- */
- #include "wmi_unified_tlv.h"
- #include "wmi_unified_api.h"
- #include "wmi.h"
- #include "wmi_unified_priv.h"
- #include "wma_api.h"
- #include "wma.h"
- /**
- * send_vdev_create_cmd_tlv() - send VDEV create command to fw
- * @wmi_handle: wmi handle
- * @param: pointer to hold vdev create parameter
- * @macaddr: vdev mac address
- *
- * Return: 0 for success or error code
- */
- int32_t send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t macaddr[IEEE80211_ADDR_LEN],
- struct vdev_create_params *param)
- {
- wmi_vdev_create_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- int32_t ret;
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGP("%s:wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_vdev_create_cmd_fixed_param));
- cmd->vdev_id = param->if_id;
- cmd->vdev_type = param->type;
- cmd->vdev_subtype = param->subtype;
- WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
- WMA_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
- __func__, param->if_id,
- macaddr[0], macaddr[1], macaddr[2],
- macaddr[3], macaddr[4], macaddr[5]);
- ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
- if (ret != EOK) {
- WMA_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
- wmi_buf_free(buf);
- }
- return ret;
- }
- /**
- * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
- * @wmi_handle: wmi handle
- * @if_id: vdev id
- *
- * Return: 0 for success or error code
- */
- int32_t send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t if_id)
- {
- wmi_vdev_delete_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t ret;
- buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
- if (!buf) {
- WMA_LOGP("%s:wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_vdev_delete_cmd_fixed_param));
- cmd->vdev_id = if_id;
- ret = wmi_unified_cmd_send(wmi_handle, buf,
- sizeof(wmi_vdev_delete_cmd_fixed_param),
- WMI_VDEV_DELETE_CMDID);
- if (ret != EOK) {
- WMA_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
- wmi_buf_free(buf);
- }
- WMA_LOGD("%s:vdev id = %d", __func__, if_id);
- return ret;
- }
- /**
- * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
- * @wmi: wmi handle
- * @vdev_id: vdev id
- *
- * Return: 0 for success or erro code
- */
- int32_t send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
- uint8_t vdev_id)
- {
- wmi_vdev_stop_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s : wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
- cmd->vdev_id = vdev_id;
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
- WMA_LOGP("%s: Failed to send vdev stop command", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_vdev_down_cmd_tlv() - send vdev down command to fw
- * @wmi: wmi handle
- * @vdev_id: vdev id
- *
- * Return: 0 for success or error code
- */
- int32_t send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
- {
- wmi_vdev_down_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s : wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
- cmd->vdev_id = vdev_id;
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
- WMA_LOGP("%s: Failed to send vdev down", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- WMA_LOGD("%s: vdev_id %d", __func__, vdev_id);
- return 0;
- }
- /**
- * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
- * @wmi: wmi handle
- * @peer_addr: peer mac address
- * @param: pointer to hold peer flush tid parameter
- *
- * Return: 0 for sucess or error code
- */
- int32_t send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
- uint8_t peer_addr[IEEE80211_ADDR_LEN],
- struct peer_flush_params *param)
- {
- wmi_peer_flush_tids_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s: wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_peer_flush_tids_cmd_fixed_param));
- WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
- cmd->peer_tid_bitmap = param->peer_tid_bitmap;
- cmd->vdev_id = param->vdev_id;
- WMA_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
- peer_addr, param->vdev_id,
- param->peer_tid_bitmap);
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
- WMA_LOGP("%s: Failed to send flush tid command", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_peer_delete_cmd_tlv() - send PEER delete command to fw
- * @wmi: wmi handle
- * @peer_addr: peer mac addr
- * @vdev_id: vdev id
- *
- * Return: 0 for success or error code
- */
- int32_t send_peer_delete_cmd_tlv(wmi_unified_t wmi,
- uint8_t peer_addr[IEEE80211_ADDR_LEN],
- uint8_t vdev_id)
- {
- wmi_peer_delete_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s: wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_peer_delete_cmd_fixed_param));
- WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
- cmd->vdev_id = vdev_id;
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
- WMA_LOGP("%s: Failed to send peer delete command", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- WMA_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
- return 0;
- }
- /**
- * send_peer_param_cmd_tlv() - set peer parameter in fw
- * @wma_ctx: wmi handle
- * @peer_addr: peer mac address
- * @param : pointer to hold peer set parameter
- *
- * Return: 0 for success or error code
- */
- int32_t send_peer_param_cmd_tlv(wmi_unified_t wmi,
- uint8_t peer_addr[IEEE80211_ADDR_LEN],
- struct peer_set_params *param)
- {
- wmi_peer_set_param_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t err;
- buf = wmi_buf_alloc(wmi, sizeof(*cmd));
- if (!buf) {
- WMA_LOGE("Failed to allocate buffer to send set_param cmd");
- return -ENOMEM;
- }
- cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_peer_set_param_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
- cmd->param_id = param->param_id;
- cmd->param_value = param->param_value;
- err = wmi_unified_cmd_send(wmi, buf,
- sizeof(wmi_peer_set_param_cmd_fixed_param),
- WMI_PEER_SET_PARAM_CMDID);
- if (err) {
- WMA_LOGE("Failed to send set_param cmd");
- cdf_mem_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_vdev_up_cmd_tlv() - send vdev up command in fw
- * @wmi: wmi handle
- * @bssid: bssid
- * @vdev_up_params: pointer to hold vdev up parameter
- *
- * Return: 0 for success or error code
- */
- int32_t send_vdev_up_cmd_tlv(wmi_unified_t wmi,
- uint8_t bssid[IEEE80211_ADDR_LEN],
- struct vdev_up_params *params)
- {
- wmi_vdev_up_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- WMA_LOGD("%s: VDEV_UP", __func__);
- WMA_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
- params->vdev_id, params->assoc_id, bssid);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s: wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
- cmd->vdev_id = params->vdev_id;
- cmd->vdev_assoc_id = params->assoc_id;
- WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
- WMA_LOGP("%s: Failed to send vdev up command", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_peer_create_cmd_tlv() - send peer create command to fw
- * @wmi: wmi handle
- * @peer_addr: peer mac address
- * @peer_type: peer type
- * @vdev_id: vdev id
- *
- * Return: 0 for success or error code
- */
- int32_t send_peer_create_cmd_tlv(wmi_unified_t wmi,
- struct peer_create_params *param)
- {
- wmi_peer_create_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi, len);
- if (!buf) {
- WMA_LOGP("%s: wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_peer_create_cmd_fixed_param));
- WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
- cmd->peer_type = param->peer_type;
- cmd->vdev_id = param->vdev_id;
- if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
- WMA_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- WMA_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
- param->vdev_id);
- return 0;
- }
- /**
- * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
- * @wmi_handle: wmi handle
- * @value: value
- * @mac_id: mac id to have radio context
- *
- * Return: 0 for success or error code
- */
- int32_t send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
- uint32_t value, uint8_t mac_id)
- {
- wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- WMA_LOGD("Set Green AP PS val %d", value);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
- cmd->reserved0 = 0;
- cmd->enable = value;
- if (wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
- WMA_LOGE("Set Green AP PS param Failed val %d", value);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_pdev_utf_cmd_tlv() - send utf command to fw
- * @wmi_handle: wmi handle
- * @param: pointer to pdev_utf_params
- * @mac_id: mac id to have radio context
- *
- * Return: 0 for success or error code
- */
- int32_t
- send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
- struct pdev_utf_params *param,
- uint8_t mac_id)
- {
- wmi_buf_t buf;
- uint8_t *cmd;
- int32_t ret = 0;
- static uint8_t msgref = 1;
- uint8_t segNumber = 0, segInfo, numSegments;
- uint16_t chunk_len, total_bytes;
- uint8_t *bufpos;
- struct seg_hdr_info segHdrInfo;
- bufpos = param->utf_payload;
- total_bytes = param->len;
- ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
- (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
- numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
- if (param->len - (numSegments * MAX_WMI_UTF_LEN))
- numSegments++;
- while (param->len) {
- if (param->len > MAX_WMI_UTF_LEN)
- chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
- else
- chunk_len = param->len;
- buf = wmi_buf_alloc(wmi_handle,
- (chunk_len + sizeof(segHdrInfo) +
- WMI_TLV_HDR_SIZE));
- if (!buf) {
- WMA_LOGE("%s:wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- cmd = (uint8_t *) wmi_buf_data(buf);
- segHdrInfo.len = total_bytes;
- segHdrInfo.msgref = msgref;
- segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
- segHdrInfo.segmentInfo = segInfo;
- segHdrInfo.pad = 0;
- WMA_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
- " segHdrInfo.segmentInfo = %d",
- __func__, segHdrInfo.len, segHdrInfo.msgref,
- segHdrInfo.segmentInfo);
- WMA_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
- "chunk len %d", __func__, total_bytes, segNumber,
- numSegments, chunk_len);
- segNumber++;
- WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
- (chunk_len + sizeof(segHdrInfo)));
- cmd += WMI_TLV_HDR_SIZE;
- memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
- memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
- ret = wmi_unified_cmd_send(wmi_handle, buf,
- (chunk_len + sizeof(segHdrInfo) +
- WMI_TLV_HDR_SIZE),
- WMI_PDEV_UTF_CMDID);
- if (ret != EOK) {
- WMA_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
- wmi_buf_free(buf);
- break;
- }
- param->len -= chunk_len;
- bufpos += chunk_len;
- }
- msgref++;
- return ret;
- }
- /**
- * send_pdev_param_cmd_tlv() - set pdev parameters
- * @wmi_handle: wmi handle
- * @param: pointer to pdev parameter
- * @mac_id: radio context
- *
- * Return: 0 on success, errno on failure
- */
- int32_t
- send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
- struct pdev_params *param,
- uint8_t mac_id)
- {
- int32_t ret;
- wmi_pdev_set_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_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_pdev_set_param_cmd_fixed_param));
- cmd->reserved0 = 0;
- cmd->param_id = param->param_id;
- cmd->param_value = param->param_value;
- WMA_LOGD("Setting pdev param = %x, value = %u", param->param_id,
- param->param_value);
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_PDEV_SET_PARAM_CMDID);
- if (ret != EOK) {
- WMA_LOGE("Failed to send set param command ret = %d", ret);
- wmi_buf_free(buf);
- }
- return ret;
- }
- /**
- * send_suspend_cmd_tlv() - WMI suspend function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold suspend parameter
- * @mac_id: radio context
- *
- * Return 0 on success and -ve on failure.
- */
- int32_t send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
- struct suspend_params *param,
- uint8_t mac_id)
- {
- wmi_pdev_suspend_cmd_fixed_param *cmd;
- wmi_buf_t wmibuf;
- uint32_t len = sizeof(*cmd);
- int32_t ret;
- /*
- * send the comand to Target to ignore the
- * PCIE reset so as to ensure that Host and target
- * states are in sync
- */
- wmibuf = wmi_buf_alloc(wmi_handle, len);
- if (wmibuf == NULL)
- return -ENOMEM;
- cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_pdev_suspend_cmd_fixed_param));
- if (param->disable_target_intr)
- cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
- else
- cmd->suspend_opt = WMI_PDEV_SUSPEND;
- ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
- WMI_PDEV_SUSPEND_CMDID);
- if (ret) {
- cdf_nbuf_free(wmibuf);
- WMA_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
- }
- return ret;
- }
- /**
- * send_resume_cmd_tlv() - WMI resume function
- * @param wmi_handle : handle to WMI.
- * @mac_id: radio context
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_resume_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t mac_id)
- {
- wmi_buf_t wmibuf;
- wmi_pdev_resume_cmd_fixed_param *cmd;
- int32_t ret;
- wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
- if (wmibuf == NULL)
- return -ENOMEM;
- cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_pdev_resume_cmd_fixed_param));
- cmd->reserved0 = 0;
- ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
- WMI_PDEV_RESUME_CMDID);
- if (ret != EOK) {
- WMA_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
- wmi_buf_free(wmibuf);
- }
- return ret;
- }
- /**
- * send_wow_enable_cmd_tlv() - WMI wow enable function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold wow enable parameter
- * @mac_id: radio context
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
- struct wow_cmd_params *param,
- uint8_t mac_id)
- {
- wmi_wow_enable_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len;
- int32_t ret;
- len = sizeof(wmi_wow_enable_cmd_fixed_param);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
- return CDF_STATUS_E_NOMEM;
- }
- cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_wow_enable_cmd_fixed_param));
- cmd->enable = param->enable;
- if (param->can_suspend_link)
- cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
- else
- cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
- WMA_LOGI("suspend type: %s",
- cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
- "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_WOW_ENABLE_CMDID);
- if (ret)
- wmi_buf_free(buf);
- return ret;
- }
- /**
- * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
- * @wma_ctx: wma context
- * @peer_addr: peer mac address
- * @param: pointer to ap_ps parameter structure
- *
- * Return: 0 for success or error code
- */
- int32_t send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t *peer_addr,
- struct ap_ps_params *param)
- {
- wmi_ap_ps_peer_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t err;
- buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
- if (!buf) {
- WMA_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
- return -ENOMEM;
- }
- cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_ap_ps_peer_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
- cmd->param = param->param;
- cmd->value = param->value;
- err = wmi_unified_cmd_send(wmi_handle, buf,
- sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
- if (err) {
- WMA_LOGE("Failed to send set_ap_ps_param cmd");
- cdf_mem_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
- * @wma_ctx: wma context
- * @peer_addr: peer mac address
- * @param: pointer to sta_ps parameter structure
- *
- * Return: 0 for success or error code
- */
- int32_t send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
- struct sta_ps_params *param)
- {
- wmi_sta_powersave_param_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- int32_t len = sizeof(*cmd);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
- return -ENOMEM;
- }
- cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_sta_powersave_param_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- cmd->param = param->param;
- cmd->value = param->value;
- if (wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_STA_POWERSAVE_PARAM_CMDID)) {
- WMA_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
- param->vdev_id, param->param, param->value);
- cdf_nbuf_free(buf);
- return -EIO;
- }
- return 0;
- }
- /**
- * send_crash_inject_cmd_tlv() - inject fw crash
- * @wma_handle: wma handle
- * @param: ponirt to crash inject paramter structure
- *
- * Return: 0 for success or return error
- */
- int32_t send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
- struct crash_inject *param)
- {
- int32_t ret = 0;
- WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
- uint16_t len = sizeof(*cmd);
- wmi_buf_t buf;
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGE("%s: wmi_buf_alloc failed!", __func__);
- return -ENOMEM;
- }
- cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (WMI_FORCE_FW_HANG_CMD_fixed_param));
- cmd->type = param->type;
- cmd->delay_time_ms = param->delay_time_ms;
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_FORCE_FW_HANG_CMDID);
- if (ret) {
- WMA_LOGE("%s: Failed to send set param command, ret = %d",
- __func__, ret);
- wmi_buf_free(buf);
- }
- return ret;
- }
- /**
- * send_dbglog_cmd_tlv() - set debug log level
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold dbglog level parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t
- send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
- struct dbglog_params *dbglog_param)
- {
- wmi_buf_t buf;
- wmi_debug_log_config_cmd_fixed_param *configmsg;
- A_STATUS status = A_OK;
- int32_t i;
- int32_t len;
- int8_t *buf_ptr;
- int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
- ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
- /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
- len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
- (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (buf == NULL)
- return A_NO_MEMORY;
- configmsg =
- (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
- buf_ptr = (int8_t *) configmsg;
- WMITLV_SET_HDR(&configmsg->tlv_header,
- WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_debug_log_config_cmd_fixed_param));
- configmsg->dbg_log_param = dbglog_param->param;
- configmsg->value = dbglog_param->val;
- /* Filling in the data part of second tlv -- should
- * follow first tlv _ WMI_TLV_HDR_SIZE */
- module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
- sizeof
- (wmi_debug_log_config_cmd_fixed_param)
- + WMI_TLV_HDR_SIZE);
- WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
- WMITLV_TAG_ARRAY_UINT32,
- sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
- if (dbglog_param->module_id_bitmap) {
- for (i = 0; i < dbglog_param->bitmap_len; ++i) {
- module_id_bitmap_array[i] =
- dbglog_param->module_id_bitmap[i];
- }
- }
- status = wmi_unified_cmd_send(wmi_handle, buf,
- len, WMI_DBGLOG_CFG_CMDID);
- if (status != A_OK)
- cdf_nbuf_free(buf);
- return status;
- }
- /**
- * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
- * @param wmi_handle : handle to WMI.
- * @param macaddr : MAC address
- * @param param : pointer to hold vdev set parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
- struct vdev_set_params *param)
- {
- int32_t ret;
- wmi_vdev_set_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_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_vdev_set_param_cmd_fixed_param));
- cmd->vdev_id = param->if_id;
- cmd->param_id = param->param_id;
- cmd->param_value = param->param_value;
- WMA_LOGD("Setting vdev %d param = %x, value = %u",
- param->if_id, param->param_id, param->param_value);
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_VDEV_SET_PARAM_CMDID);
- if (ret < 0) {
- WMA_LOGE("Failed to send set param command ret = %d", ret);
- wmi_buf_free(buf);
- }
- return ret;
- }
- /**
- * send_stats_request_cmd_tlv() - WMI request stats function
- * @param wmi_handle : handle to WMI.
- * @param macaddr : MAC address
- * @param param : pointer to hold stats request parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t macaddr[IEEE80211_ADDR_LEN],
- struct stats_request_params *param)
- {
- int32_t ret;
- wmi_request_stats_cmd_fixed_param *cmd;
- wmi_buf_t buf;
- uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
- return -CDF_STATUS_E_NOMEM;
- }
- cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_request_stats_cmd_fixed_param));
- cmd->stats_id = param->stats_id;
- cmd->vdev_id = param->vdev_id;
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_REQUEST_STATS_CMDID);
- if (ret) {
- WMA_LOGE("Failed to send status request to fw =%d", ret);
- wmi_buf_free(buf);
- }
- return ret;
- }
- /**
- * send_packet_log_enable_cmd_tlv() - WMI request stats function
- * @param wmi_handle : handle to WMI.
- * @param macaddr : MAC address
- * @param param : pointer to hold stats request parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
- uint8_t macaddr[IEEE80211_ADDR_LEN],
- struct packet_enable_params *param)
- {
- return 0;
- }
- /**
- * send_beacon_send_cmd_tlv() - WMI beacon send function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold beacon send cmd parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
- struct beacon_params *param)
- {
- int32_t ret;
- wmi_bcn_tmpl_cmd_fixed_param *cmd;
- wmi_bcn_prb_info *bcn_prb_info;
- wmi_buf_t wmi_buf;
- uint8_t *buf_ptr;
- uint32_t wmi_buf_len;
- wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
- sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
- param->tmpl_len_aligned;
- wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
- if (!wmi_buf) {
- WMA_LOGE("%s : wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
- cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- cmd->tim_ie_offset = param->tim_ie_offset;
- cmd->buf_len = param->tmpl_len;
- buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
- bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
- WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
- WMITLV_TAG_STRUC_wmi_bcn_prb_info,
- WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
- bcn_prb_info->caps = 0;
- bcn_prb_info->erp = 0;
- buf_ptr += sizeof(wmi_bcn_prb_info);
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
- buf_ptr += WMI_TLV_HDR_SIZE;
- cdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
- ret = wmi_unified_cmd_send(wmi_handle,
- wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
- if (ret) {
- WMA_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
- wmi_buf_free(wmi_buf);
- }
- return 0;
- }
- /**
- * send_peer_assoc_cmd_tlv() - WMI peer assoc function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to peer assoc parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
- struct peer_assoc_params *param)
- {
- wmi_peer_assoc_complete_cmd_fixed_param *cmd;
- wmi_vht_rate_set *mcs;
- wmi_buf_t buf;
- int32_t len;
- uint8_t *buf_ptr;
- int ret;
- len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
- (param->num_peer_legacy_rates * sizeof(uint8_t)) +
- WMI_TLV_HDR_SIZE +
- (param->num_peer_ht_rates * sizeof(uint8_t)) +
- sizeof(wmi_vht_rate_set);
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
- return -ENOMEM;
- }
- buf_ptr = (uint8_t *) wmi_buf_data(buf);
- cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_peer_assoc_complete_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- cmd->peer_new_assoc = param->peer_new_assoc;
- cmd->peer_associd = param->peer_associd;
- cmd->peer_flags = param->peer_flags;
- cmd->peer_rate_caps = param->peer_rate_caps;
- cmd->peer_caps = param->peer_caps;
- cmd->peer_listen_intval = param->peer_listen_intval;
- cmd->peer_ht_caps = param->peer_ht_caps;
- cmd->peer_max_mpdu = param->peer_max_mpdu;
- cmd->peer_mpdu_density = param->peer_mpdu_density;
- cmd->num_peer_legacy_rates = param->num_peer_legacy_rates;
- cmd->num_peer_ht_rates = param->num_peer_ht_rates;
- cmd->peer_vht_caps = param->peer_vht_caps;
- cmd->peer_phymode = param->peer_phymode;
- /* Update peer legacy rate information */
- buf_ptr += sizeof(*cmd);
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
- param->num_peer_legacy_rates);
- buf_ptr += WMI_TLV_HDR_SIZE;
- cmd->num_peer_legacy_rates = param->num_peer_legacy_rates;
- cdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
- param->peer_legacy_rates.num_rates);
- /* Update peer HT rate information */
- buf_ptr += param->num_peer_legacy_rates;
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
- param->num_peer_ht_rates);
- buf_ptr += WMI_TLV_HDR_SIZE;
- cmd->num_peer_ht_rates = param->num_peer_ht_rates;
- cdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
- param->peer_ht_rates.num_rates);
- /* VHT Rates */
- buf_ptr += param->num_peer_ht_rates;
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
- WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
- cmd->peer_nss = param->peer_nss;
- mcs = (wmi_vht_rate_set *) buf_ptr;
- if (param->vht_capable) {
- mcs->rx_max_rate = param->rx_max_rate;
- mcs->rx_mcs_set = param->rx_mcs_set;
- mcs->tx_max_rate = param->tx_max_rate;
- mcs->tx_mcs_set = param->tx_mcs_set;
- }
- WMA_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
- "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
- "nss %d phymode %d peer_mpdu_density %d "
- "cmd->peer_vht_caps %x", __func__,
- cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
- cmd->peer_rate_caps, cmd->peer_caps,
- cmd->peer_listen_intval, cmd->peer_ht_caps,
- cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
- cmd->peer_mpdu_density,
- cmd->peer_vht_caps);
- ret = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_PEER_ASSOC_CMDID);
- if (ret != EOK) {
- WMA_LOGP("%s: Failed to send peer assoc command ret = %d",
- __func__, ret);
- cdf_nbuf_free(buf);
- }
- return ret;
- }
- /**
- * send_scan_start_cmd_tlv() - WMI scan start function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold scan start cmd parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
- struct scan_start_params *params)
- {
- int32_t ret = 0;
- int32_t i;
- wmi_buf_t wmi_buf;
- wmi_start_scan_cmd_fixed_param *cmd;
- uint8_t *buf_ptr;
- uint32_t *tmp_ptr;
- wmi_ssid *ssid = NULL;
- wmi_mac_addr *bssid;
- int len = sizeof(*cmd);
- /* Length TLV placeholder for array of uint32_t */
- len += WMI_TLV_HDR_SIZE;
- /* calculate the length of buffer required */
- if (params->num_chan)
- len += params->num_chan * sizeof(uint32_t);
- /* Length TLV placeholder for array of wmi_ssid structures */
- len += WMI_TLV_HDR_SIZE;
- if (params->num_ssids)
- len += params->num_ssids * sizeof(wmi_ssid);
- /* Length TLV placeholder for array of wmi_mac_addr structures */
- len += WMI_TLV_HDR_SIZE;
- len += sizeof(wmi_mac_addr);
- /* Length TLV placeholder for array of bytes */
- len += WMI_TLV_HDR_SIZE;
- if (params->ie_len)
- len += roundup(params->ie_len, sizeof(uint32_t));
- /* Allocate the memory */
- wmi_buf = wmi_buf_alloc(wmi_handle, len);
- if (!wmi_buf) {
- WMA_LOGP("%s: failed to allocate memory for start scan cmd",
- __func__);
- return CDF_STATUS_E_FAILURE;
- }
- buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
- cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_start_scan_cmd_fixed_param));
- cmd->scan_id = params->scan_id;
- cmd->scan_req_id = params->scan_req_id;
- cmd->vdev_id = params->vdev_id;
- cmd->scan_priority = params->scan_priority;
- cmd->notify_scan_events = params->notify_scan_events;
- cmd->dwell_time_active = params->dwell_time_active;
- cmd->dwell_time_passive = params->dwell_time_passive;
- cmd->min_rest_time = params->min_rest_time;
- cmd->max_rest_time = params->max_rest_time;
- cmd->repeat_probe_time = params->repeat_probe_time;
- cmd->probe_spacing_time = params->probe_spacing_time;
- cmd->idle_time = params->idle_time;
- cmd->max_scan_time = params->max_scan_time;
- cmd->probe_delay = params->probe_delay;
- cmd->scan_ctrl_flags = params->scan_ctrl_flags;
- cmd->burst_duration = params->burst_duration;
- cmd->num_chan = params->num_chan;
- cmd->num_bssid = params->num_bssid;
- cmd->num_ssids = params->num_ssids;
- cmd->ie_len = params->ie_len;
- cmd->n_probes = params->n_probes;
- buf_ptr += sizeof(*cmd);
- tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
- for (i = 0; i < params->num_chan; ++i)
- tmp_ptr[i] = params->chan_list[i];
- WMITLV_SET_HDR(buf_ptr,
- WMITLV_TAG_ARRAY_UINT32,
- (params->num_chan * sizeof(uint32_t)));
- buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
- if (params->num_ssids > SIR_SCAN_MAX_NUM_SSID) {
- WMA_LOGE("Invalid value for numSsid");
- goto error;
- }
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
- (params->num_ssids * sizeof(wmi_ssid)));
- if (params->num_ssids) {
- ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
- for (i = 0; i < params->num_ssids; ++i) {
- ssid->ssid_len = params->ssid[i].length;
- cdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
- params->ssid[i].length);
- ssid++;
- }
- }
- buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
- (params->num_bssid * sizeof(wmi_mac_addr)));
- bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
- WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
- buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
- WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
- if (params->ie_len) {
- cdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
- (uint8_t *) params->ie_base +
- (params->uie_fieldOffset), params->ie_len);
- }
- buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
- ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
- len, WMI_START_SCAN_CMDID);
- if (ret) {
- WMA_LOGE("%s: Failed to start scan: %d", __func__, ret);
- wmi_buf_free(wmi_buf);
- }
- return ret;
- error:
- cdf_nbuf_free(wmi_buf);
- return CDF_STATUS_E_FAILURE;
- }
- /**
- * send_scan_stop_cmd_tlv() - WMI scan start function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold scan start cmd parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
- struct scan_stop_params *param)
- {
- wmi_stop_scan_cmd_fixed_param *cmd;
- int ret;
- int len = sizeof(*cmd);
- wmi_buf_t wmi_buf;
- /* Allocate the memory */
- wmi_buf = wmi_buf_alloc(wmi_handle, len);
- if (!wmi_buf) {
- WMA_LOGP("%s: failed to allocate memory for stop scan cmd",
- __func__);
- ret = -ENOMEM;
- goto error;
- }
- cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
- cmd->vdev_id = param->vdev_id;
- cmd->requestor = param->requestor;
- cmd->scan_id = param->scan_id;
- /* stop the scan with the corresponding scan_id */
- cmd->req_type = param->req_type;
- ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
- len, WMI_STOP_SCAN_CMDID);
- if (ret) {
- WMA_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
- wmi_buf_free(wmi_buf);
- }
- error:
- return ret;
- }
- /**
- * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
- * @param wmi_handle : handle to WMI.
- * @param param : pointer to hold scan channel list parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- int32_t send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
- struct scan_chan_list_params *chan_list)
- {
- wmi_buf_t buf;
- CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
- wmi_scan_chan_list_cmd_fixed_param *cmd;
- int status, i;
- uint8_t *buf_ptr;
- wmi_channel *chan_info, *tchan_info;
- uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
- len += sizeof(wmi_channel) * chan_list->num_scan_chans;
- buf = wmi_buf_alloc(wmi_handle, len);
- if (!buf) {
- WMA_LOGE("Failed to allocate memory");
- cdf_status = CDF_STATUS_E_NOMEM;
- goto end;
- }
- buf_ptr = (uint8_t *) wmi_buf_data(buf);
- cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
- WMITLV_SET_HDR(&cmd->tlv_header,
- WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
- WMITLV_GET_STRUCT_TLVLEN
- (wmi_scan_chan_list_cmd_fixed_param));
- WMA_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
- cmd->num_scan_chans = chan_list->num_scan_chans;
- WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
- WMITLV_TAG_ARRAY_STRUC,
- sizeof(wmi_channel) * chan_list->num_scan_chans);
- chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
- tchan_info = chan_list->chan_info;
- for (i = 0; i < chan_list->num_scan_chans; ++i) {
- WMITLV_SET_HDR(&chan_info->tlv_header,
- WMITLV_TAG_STRUC_wmi_channel,
- WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
- chan_info->mhz = tchan_info->mhz;
- chan_info->band_center_freq1 =
- tchan_info->band_center_freq1;
- chan_info->band_center_freq2 =
- tchan_info->band_center_freq2;
- chan_info->info = tchan_info->info;
- chan_info->reg_info_1 = tchan_info->reg_info_1;
- chan_info->reg_info_2 = tchan_info->reg_info_2;
- WMA_LOGD("chan[%d] = %u", i, chan_info->mhz);
- /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
- /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
- /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
- tchan_info++;
- chan_info++;
- }
- status = wmi_unified_cmd_send(wmi_handle, buf, len,
- WMI_SCAN_CHAN_LIST_CMDID);
- if (status != EOK) {
- cdf_status = CDF_STATUS_E_FAILURE;
- WMA_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
- wmi_buf_free(buf);
- }
- end:
- return cdf_status;
- }
- /**
- * send_mgmt_cmd_tlv() - WMI scan start function
- * @wmi_handle : handle to WMI.
- * @param : pointer to hold mgmt cmd parameter
- *
- * Return: 0 on success and -ve on failure.
- */
- 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,
- .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
- .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,
- .send_suspend_cmd = send_suspend_cmd_tlv,
- .send_resume_cmd = send_resume_cmd_tlv,
- .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
- .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
- .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
- .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
- .send_dbglog_cmd = send_dbglog_cmd_tlv,
- .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
- .send_stats_request_cmd = send_stats_request_cmd_tlv,
- .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
- .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
- .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
- .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 */
- };
- /**
- * wmi_get_tlv_ops() - gives pointer to wmi tlv ops
- *
- * Return: pointer to wmi tlv ops
- */
- struct wmi_ops *wmi_get_tlv_ops(void)
- {
- return &tlv_ops;
- }
|