qcacmn: Add tlv formation of key installation commands in common wmi layer

Move tlv formation of wmi setup key installation commands from umac to
common wmi layer.

Change-Id: I51250a9b1b6bb5aed06657b9f88f4659430f4c74
CRs-Fixed: 987362
This commit is contained in:
Himanshu Agarwal
2016-03-09 18:49:18 +05:30
committed by Gerrit - the friendly Code Review server
parent 7e30287bde
commit a41da1d50f
6 changed files with 163 additions and 0 deletions

View File

@@ -429,6 +429,9 @@ QDF_STATUS wmi_unified_probe_rsp_tmpl_send_cmd(void *wmi_hdl,
struct wmi_probe_resp_params *probe_rsp_info,
uint8_t *frm);
QDF_STATUS wmi_unified_setup_install_key_cmd(void *wmi_hdl,
struct set_key_params *key_params);
QDF_STATUS wmi_unified_p2p_go_set_beacon_ie_cmd(void *wmi_hdl,
A_UINT32 vdev_id, uint8_t *p2p_ie);

View File

@@ -61,6 +61,7 @@
#define WMI_IPV4_ADDR_LEN 4
#define WMI_KEEP_ALIVE_NULL_PKT 1
#define WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP 2
#define WMI_MAC_MAX_KEY_LENGTH 32
#define WMI_KRK_KEY_LEN 16
#ifdef WLAN_FEATURE_ROAM_OFFLOAD
#define WMI_BTK_KEY_LEN 32
@@ -856,6 +857,36 @@ struct wmi_probe_resp_params {
uint32_t ucProxyProbeReqValidIEBmap[8];
};
/* struct set_key_params: structure containing
* installation key parameters
* @vdev_id: vdev id
* @key_len: key length
* @key_idx: key index
* @peer_mac: peer mac address
* @key_flags: key flags, 0:pairwise key, 1:group key, 2:static key
* @key_cipher: key cipher based on security mode
* @key_txmic_len: tx mic length
* @key_rxmic_len: rx mic length
* @rx_iv: receive IV, applicable only in case of WAPI
* @tx_iv: transmit IV, applicable only in case of WAPI
* @key_data: key data
*/
struct set_key_params {
uint8_t vdev_id;
uint16_t key_len;
uint32_t key_idx;
uint8_t peer_mac[IEEE80211_ADDR_LEN];
uint32_t key_flags;
uint32_t key_cipher;
uint32_t key_txmic_len;
uint32_t key_rxmic_len;
#ifdef FEATURE_WLAN_WAPI
uint8_t rx_iv[16];
uint8_t tx_iv[16];
#endif
uint8_t key_data[WMI_MAC_MAX_KEY_LENGTH];
};
/**
* struct sta_params - sta keep alive parameters
* @vdev_id: vdev id

View File

@@ -248,6 +248,9 @@ QDF_STATUS (*send_probe_rsp_tmpl_send_cmd)(wmi_unified_t wmi_handle,
struct wmi_probe_resp_params *probe_rsp_info,
uint8_t *frm);
QDF_STATUS (*send_setup_install_key_cmd)(wmi_unified_t wmi_handle,
struct set_key_params *key_params);
QDF_STATUS (*send_process_update_edca_param_cmd)(wmi_unified_t wmi_handle,
uint8_t vdev_id,
wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC]);

View File

@@ -210,6 +210,9 @@ QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
struct wmi_probe_resp_params *probe_rsp_info,
uint8_t *frm);
QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
struct set_key_params *key_params);
QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
uint8_t vdev_id,
wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC]);

View File

@@ -1209,6 +1209,25 @@ QDF_STATUS wmi_unified_probe_rsp_tmpl_send_cmd(void *wmi_hdl,
return QDF_STATUS_E_FAILURE;
}
/**
* wmi_unified_setup_install_key_cmd - send key to install to fw
* @wmi_hdl: wmi handle
* @key_params: key parameters
*
* Return: 0 for success or error code
*/
QDF_STATUS wmi_unified_setup_install_key_cmd(void *wmi_hdl,
struct set_key_params *key_params)
{
wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl;
if (wmi_handle->ops->send_setup_install_key_cmd)
return wmi_handle->ops->send_setup_install_key_cmd(wmi_handle,
key_params);
return QDF_STATUS_E_FAILURE;
}
/**
* wmi_unified_p2p_go_set_beacon_ie_cmd() - set beacon IE for p2p go
* @wma_handle: wma handle

View File

@@ -3377,6 +3377,108 @@ QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
return ret;
}
#ifdef FEATURE_WLAN_WAPI
#define WPI_IV_LEN 16
/**
* wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
*
* @dest_tx: destination address of tsc key counter
* @src_tx: source address of tsc key counter
* @dest_rx: destination address of rsc key counter
* @src_rx: source address of rsc key counter
*
* This function copies WAPI tsc and rsc key counters in the wmi buffer.
*
* Return: None
*
*/
static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
uint8_t *dest_rx, uint8_t *src_rx)
{
qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
}
#else
static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
uint8_t *dest_rx, uint8_t *src_rx)
{
return;
}
#endif
/**
* send_setup_install_key_cmd_tlv() - set key parameters
* @wmi_handle: wmi handle
* @key_params: key parameters
*
* This function fills structure from information
* passed in key_params.
*
* Return: QDF_STATUS_SUCCESS - success
* QDF_STATUS_E_FAILURE - failure
* QDF_STATUS_E_NOMEM - not able to allocate buffer
*/
QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
struct set_key_params *key_params)
{
wmi_vdev_install_key_cmd_fixed_param *cmd;
wmi_buf_t buf;
uint8_t *buf_ptr;
uint32_t len;
uint8_t *key_data;
uint8_t status;
len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
WMI_TLV_HDR_SIZE;
buf = wmi_buf_alloc(wmi_handle, len);
if (!buf) {
WMA_LOGE("Failed to allocate buffer to send set key cmd");
return QDF_STATUS_E_NOMEM;
}
buf_ptr = (uint8_t *) wmi_buf_data(buf);
cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
WMITLV_SET_HDR(&cmd->tlv_header,
WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
WMITLV_GET_STRUCT_TLVLEN
(wmi_vdev_install_key_cmd_fixed_param));
cmd->vdev_id = key_params->vdev_id;
cmd->key_ix = key_params->key_idx;
WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
cmd->key_flags |= key_params->key_flags;
cmd->key_cipher = key_params->key_cipher;
if ((key_params->key_txmic_len) &&
(key_params->key_rxmic_len)) {
cmd->key_txmic_len = key_params->key_txmic_len;
cmd->key_rxmic_len = key_params->key_rxmic_len;
}
wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
key_params->tx_iv,
cmd->wpi_key_rsc_counter,
key_params->rx_iv);
buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
roundup(key_params->key_len, sizeof(uint32_t)));
key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
qdf_mem_copy((void *)key_data,
(const void *)key_params->key_data, key_params->key_len);
cmd->key_len = key_params->key_len;
status = wmi_unified_cmd_send(wmi_handle, buf, len,
WMI_VDEV_INSTALL_KEY_CMDID);
if (status) {
qdf_nbuf_free(buf);
return QDF_STATUS_E_FAILURE;
}
return QDF_STATUS_SUCCESS;
}
/**
* send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
* @wmi_handle: wmi handle
@@ -10258,6 +10360,8 @@ struct wmi_ops tlv_ops = {
send_probe_rsp_tmpl_send_cmd_tlv,
.send_p2p_go_set_beacon_ie_cmd =
send_p2p_go_set_beacon_ie_cmd_tlv,
.send_setup_install_key_cmd =
send_setup_install_key_cmd_tlv,
.send_set_gateway_params_cmd =
send_set_gateway_params_cmd_tlv,
.send_set_rssi_monitoring_cmd =