From be9a952aa2538a37adc3eaf6b62b03f1f6977728 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Mon, 25 Feb 2019 11:25:44 -0800 Subject: [PATCH] qcacmn: Refine the STA keepalive interface The unified WMI struct used to support the STA keepalive feature has a few flaws: - It is poorly named. Struct sta_params is a very generic name for a struct that has a very specific purpose. - It is poorly designed. It utilizes pointers to the IPv4 and MAC addresses rather than support having those addresses within the struct itself. This prevents the struct from completely representing the payload, which is required if we want to utilize this struct in the converged UMAC. To resolve these issues rename and redesign the struct. This is co-dependent with I20cf9f54a7ec920a90575ffd73c51708414d46a0 ("qcacld-3.0: Use the redesigned STA keepalive interface"). Change-Id: I2a401fa6934f05555cb3c30088af62cfbc9a3c59 CRs-Fixed: 2404895 --- wmi/inc/wmi_unified_priv.h | 2 +- wmi/inc/wmi_unified_sta_api.h | 7 ++++--- wmi/inc/wmi_unified_sta_param.h | 10 +++++----- wmi/src/wmi_unified_sta_api.c | 7 +++---- wmi/src/wmi_unified_sta_tlv.c | 26 +++++++++----------------- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 9ddd6ff850..ed15e74362 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -887,7 +887,7 @@ QDF_STATUS (*send_vdev_set_gtx_cfg_cmd)(wmi_unified_t wmi_handle, struct wmi_gtx_config *gtx_info); QDF_STATUS (*send_set_sta_keep_alive_cmd)(wmi_unified_t wmi_handle, - struct sta_params *params); + struct sta_keep_alive_params *params); QDF_STATUS (*send_set_sta_sa_query_param_cmd)(wmi_unified_t wmi_handle, uint8_t vdev_id, uint32_t max_retries, diff --git a/wmi/inc/wmi_unified_sta_api.h b/wmi/inc/wmi_unified_sta_api.h index c1a6a4346f..f40db701bd 100644 --- a/wmi/inc/wmi_unified_sta_api.h +++ b/wmi/inc/wmi_unified_sta_api.h @@ -47,15 +47,16 @@ QDF_STATUS wmi_unified_set_sta_sa_query_param_cmd(void *wmi_hdl, /** * wmi_unified_set_sta_keep_alive_cmd() - set sta keep alive parameters - * @wmi_hdl: wmi handle + * @wmi_handle: wmi handle * @params: sta keep alive parameter * * This function sets keep alive related parameters in fw. * * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure */ -QDF_STATUS wmi_unified_set_sta_keep_alive_cmd(void *wmi_hdl, - struct sta_params *params); +QDF_STATUS +wmi_unified_set_sta_keep_alive_cmd(wmi_unified_t wmi_handle, + struct sta_keep_alive_params *params); /** * wmi_unified_vdev_set_gtx_cfg_cmd() - set GTX params diff --git a/wmi/inc/wmi_unified_sta_param.h b/wmi/inc/wmi_unified_sta_param.h index e63734e999..4276217b24 100644 --- a/wmi/inc/wmi_unified_sta_param.h +++ b/wmi/inc/wmi_unified_sta_param.h @@ -24,7 +24,7 @@ #define _WMI_UNIFIED_STA_PARAM_H_ /** - * struct sta_params - sta keep alive parameters + * struct sta_keep_alive_params - sta keep alive parameters * @vdev_id: vdev id * @method: keep alive method * @timeperiod: time to keep alive @@ -32,13 +32,13 @@ * @destv4addr: destination ipv4 address * @destmac: destination mac address */ -struct sta_params { +struct sta_keep_alive_params { uint8_t vdev_id; uint32_t method; uint32_t timeperiod; - uint8_t *hostv4addr; - uint8_t *destv4addr; - uint8_t *destmac; + uint8_t hostv4addr[QDF_IPV4_ADDR_SIZE]; + uint8_t destv4addr[QDF_IPV4_ADDR_SIZE]; + uint8_t destmac[QDF_MAC_ADDR_SIZE]; }; /** diff --git a/wmi/src/wmi_unified_sta_api.c b/wmi/src/wmi_unified_sta_api.c index a1db228866..98a998509c 100644 --- a/wmi/src/wmi_unified_sta_api.c +++ b/wmi/src/wmi_unified_sta_api.c @@ -37,11 +37,10 @@ QDF_STATUS wmi_unified_set_sta_sa_query_param_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } -QDF_STATUS wmi_unified_set_sta_keep_alive_cmd(void *wmi_hdl, - struct sta_params *params) +QDF_STATUS +wmi_unified_set_sta_keep_alive_cmd(wmi_unified_t wmi_handle, + struct sta_keep_alive_params *params) { - wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; - if (wmi_handle->ops->send_set_sta_keep_alive_cmd) return wmi_handle->ops->send_set_sta_keep_alive_cmd(wmi_handle, params); diff --git a/wmi/src/wmi_unified_sta_tlv.c b/wmi/src/wmi_unified_sta_tlv.c index 9511e33227..6c69af44d4 100644 --- a/wmi/src/wmi_unified_sta_tlv.c +++ b/wmi/src/wmi_unified_sta_tlv.c @@ -85,8 +85,9 @@ static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle, * * Return: CDF status */ -static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle, - struct sta_params *params) +static QDF_STATUS +send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle, + struct sta_keep_alive_params *params) { wmi_buf_t buf; WMI_STA_KEEPALIVE_CMD_fixed_param *cmd; @@ -112,8 +113,8 @@ static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle, cmd->interval = params->timeperiod; cmd->enable = (params->timeperiod) ? 1 : 0; cmd->vdev_id = params->vdev_id; - WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id, - params->timeperiod, params->method); + WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", + params->vdev_id, params->timeperiod, params->method); arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd)); WMITLV_SET_HDR(&arp_rsp->tlv_header, WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE, @@ -122,22 +123,13 @@ static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle, if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) || (params->method == WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) { - if ((NULL == params->hostv4addr) || - (NULL == params->destv4addr) || - (NULL == params->destmac)) { - WMI_LOGE("%s: received null pointer, hostv4addr:%pK " - "destv4addr:%pK destmac:%pK ", __func__, - params->hostv4addr, params->destv4addr, - params->destmac); - wmi_buf_free(buf); - return QDF_STATUS_E_FAILURE; - } cmd->method = params->method; qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr, - WMI_IPV4_ADDR_LEN); + QDF_IPV4_ADDR_SIZE); qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr, - WMI_IPV4_ADDR_LEN); - WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr); + QDF_IPV4_ADDR_SIZE); + WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, + &arp_rsp->dest_mac_addr); } else { cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME; }