qcacmn: Fix compilation issue with crypto set key

Fix compilation issue with crypto set key feature.

Change-Id: I82d8220a9fea1f9e48338baa74307c124c98e784
CRs-Fixed: 2381329
This commit is contained in:
Kiran Kumar Lokere 2019-01-11 18:32:32 -08:00 • committed by nshrivas
commit b4d634fbf2
7 changed files with 68 additions and 41 deletions

View file

@ -23,7 +23,7 @@
#ifndef _WLAN_CFG80211_CRYPTO_H_
#define _WLAN_CFG80211_CRYPTO_H_
#include <net/cfg80211.h>
#include "wlan_crypto_global_def.h"
#ifdef CONFIG_CRYPTO_COMPONENT
/**
* wlan_cfg80211_set_default_key() - to set the default key to be used
@ -49,24 +49,26 @@ static inline int wlan_cfg80211_set_default_key(struct wlan_objmgr_vdev *vdev,
* wlan_cfg80211_store_key() - Store the key
* @vdev: VDEV Object pointer
* @key_index: Index to be set as the default
* @pairwise: denotes if the key is pairwise or group key
* @key_type: denotes if the key is pairwise or group key
* @mac_addr: BSSID for which the key is to be set
* @key_params: Params received from the kernel
*
* Return: Zero for success and negative for failure.
*/
int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
uint8_t key_index, bool pairwise,
uint8_t key_index,
enum wlan_crypto_key_type key_type,
const u8 *mac_addr, struct key_params *params);
/**
* wlan_cfg80211_crypto_add_key() - Add key for the specified vdev
* @vdev: vdev object
* @pairwise: denotes if the add key request is for pairwise or group key
* @key_type: denotes if the add key request is for pairwise or group key
* @key_index: Index of the key that needs to be added
*
* Return: Zero on Success, negative value on failure
*/
int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev, bool pairwise,
int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev,
enum wlan_crypto_key_type key_type,
uint8_t key_index);
#endif

View file

@ -28,13 +28,13 @@
#include "wlan_cfg80211_crypto.h"
#include <wlan_cfg80211.h>
static void wlan_cfg80211_translate_key(uint8_t key_index, bool pairwise,
static void wlan_cfg80211_translate_key(struct wlan_objmgr_vdev *vdev,
uint8_t key_index,
enum wlan_crypto_key_type key_type,
const u8 *mac_addr,
struct key_params *params,
struct wlan_crypto_key *crypto_key)
{
static const struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT;
qdf_mem_zero(crypto_key, sizeof(*crypto_key));
crypto_key->keylen = params->key_len;
crypto_key->keyix = key_index;
@ -42,19 +42,25 @@ static void wlan_cfg80211_translate_key(uint8_t key_index, bool pairwise,
qdf_mem_copy(&crypto_key->keyrsc[0], params->seq, params->seq_len);
crypto_key->cipher_type = osif_nl_to_crypto_cipher_type(params->cipher);
if (pairwise) {
crypto_key->flags |= PAIRWISE_USAGE;
qdf_mem_copy(&crypto_key->macaddr, mac_addr,
QDF_MAC_ADDR_SIZE);
if (key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) {
qdf_mem_copy(&crypto_key->macaddr, mac_addr, QDF_MAC_ADDR_SIZE);
} else {
crypto_key->flags |= GROUP_USAGE;
qdf_mem_copy(&crypto_key->macaddr, &bcast_mac,
QDF_MAC_ADDR_SIZE);
if ((vdev->vdev_mlme.vdev_opmode == QDF_STA_MODE) ||
(vdev->vdev_mlme.vdev_opmode == QDF_P2P_CLIENT_MODE))
qdf_mem_copy(&crypto_key->macaddr, mac_addr,
QDF_MAC_ADDR_SIZE);
else
qdf_mem_copy(&crypto_key->macaddr,
vdev->vdev_mlme.macaddr,
QDF_MAC_ADDR_SIZE);
}
cfg80211_debug("key_type %d, opmode %d, mac %pM", key_type,
vdev->vdev_mlme.vdev_opmode, crypto_key->macaddr);
}
int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
uint8_t key_index, bool pairwise,
uint8_t key_index,
enum wlan_crypto_key_type key_type,
const u8 *mac_addr, struct key_params *params)
{
struct wlan_crypto_key *crypto_key = NULL;
@ -70,7 +76,7 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
cfg80211_err("Key params is NULL");
return -EINVAL;
}
if (pairwise && !mac_addr) {
if ((key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) && !mac_addr) {
cfg80211_err("mac_addr is NULL for pairwise Key");
return -EINVAL;
}
@ -106,13 +112,14 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
}
}
wlan_cfg80211_translate_key(key_index, pairwise, mac_addr,
wlan_cfg80211_translate_key(vdev, key_index, key_type, mac_addr,
params, crypto_key);
return 0;
}
int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev, bool pairwise,
int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev,
enum wlan_crypto_key_type key_type,
uint8_t key_index)
{
struct wlan_crypto_key *crypto_key;
@ -123,7 +130,7 @@ int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev, bool pairwise,
cfg80211_err("Crypto KEY is NULL");
return -EINVAL;
}
status = ucfg_crypto_set_key_req(vdev, crypto_key, pairwise);
status = ucfg_crypto_set_key_req(vdev, crypto_key, key_type);
return qdf_status_to_os_return(status);
}

View file

@ -119,7 +119,7 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
uint8_t peer_id;
uint8_t def_tx_idx;
void *pdev_wmi_handle;
bool pairwise = false;
bool pairwise;
QDF_STATUS status;
pdev = wlan_vdev_get_pdev(vdev);
@ -146,11 +146,17 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
return QDF_STATUS_E_FAILURE;
}
if (key_type != WLAN_CRYPTO_KEY_TYPE_UNICAST)
params.key_flags = req->flags;
if (key_type != WLAN_CRYPTO_KEY_TYPE_UNICAST) {
pairwise = false;
params.key_flags |= GROUP_USAGE;
} else {
pairwise = true;
params.key_flags |= PAIRWISE_USAGE;
}
qdf_mem_copy(&params.key_rsc_ctr,
&req->keyrsc[0], sizeof(uint64_t));
params.key_flags = req->flags;
txrx_vdev = (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
(struct cdp_pdev *)txrx_pdev, params.vdev_id);
peer = cdp_peer_find_by_addr(soc, txrx_pdev, req->macaddr, &peer_id);
@ -160,7 +166,12 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
return QDF_STATUS_E_FAILURE;
}
if (!peer) {
target_if_debug("key_type %d, mac: %02x:%02x:%02x:%02x:%02x:%02x",
key_type, req->macaddr[0], req->macaddr[1],
req->macaddr[2], req->macaddr[3], req->macaddr[4],
req->macaddr[5]);
if ((key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) && !peer) {
target_if_err("Invalid peer");
return QDF_STATUS_E_FAILURE;
}
@ -190,12 +201,14 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
&req->keyval[0],
req->keylen);
params.key_len = req->keylen;
/* Set PN check & security type in data path */
cdp_set_pn_check(soc, txrx_vdev, peer, sec_type, pn);
cdp_set_key(soc, peer, pairwise,
(uint32_t *)(req->keyval +
WLAN_CRYPTO_IV_SIZE +
WLAN_CRYPTO_MIC_LEN));
if (peer) {
/* Set PN check & security type in data path */
cdp_set_pn_check(soc, txrx_vdev, peer, sec_type, pn);
cdp_set_key(soc, peer, pairwise, (uint32_t *)(req->keyval +
WLAN_CRYPTO_IV_SIZE + WLAN_CRYPTO_MIC_LEN));
} else {
target_if_info("peer not found");
}
target_if_debug("vdev_id:%d, key: idx:%d,len:%d", params.vdev_id,
params.key_idx, params.key_len);

View file

@ -684,12 +684,13 @@ static inline int omac1_aes_256(const uint8_t *key, const uint8_t *data,
* ucfg_crypto_set_key_req() - Set key request to UCFG
* @vdev: vdev object
* @req: key request information
* @pairwise: indicates the type of key to be set, unicast or group key
* @key_type: indicates the type of key to be set, unicast or group key
*
* Return: None
*/
QDF_STATUS ucfg_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req, bool pairwise);
struct wlan_crypto_key *req,
enum wlan_crypto_key_type key_type);
/**
* wlan_crypto_get_default_key_idx() - Get the default key index
@ -766,12 +767,13 @@ struct wlan_crypto_key *wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev,
* wlan_crypto_set_key_req() - Set key request
* @vdev: vdev object
* @req: key request information
* @pairwise: indicates the type of key to be set, unicast or group key
* @key_type: indicates the type of key to be set, unicast or group key
*
* Return: QDF status
*/
QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req, bool pairwise);
struct wlan_crypto_key *req,
enum wlan_crypto_key_type key_type);
#else
static inline void wlan_crypto_update_set_key_peer(
struct wlan_objmgr_vdev *vdev,
@ -794,9 +796,10 @@ wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev, uint8_t key_index)
return NULL;
}
static inline QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req,
bool pairwise)
static inline
QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req,
enum wlan_crypto_key_type key_type)
{
return QDF_STATUS_SUCCESS;
}

View file

@ -28,6 +28,7 @@
#include "wlan_crypto_fils_def.h"
#endif
#include <wlan_objmgr_cmn.h>
#include <wlan_cmn_ieee80211.h>
#define WLAN_CRYPTO_TID_SIZE (17)
#define WLAN_CRYPTO_RSC_SIZE (16)

View file

@ -4004,13 +4004,13 @@ struct wlan_crypto_key *wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev,
QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req,
bool pairwise)
enum wlan_crypto_key_type key_type)
{
struct wlan_objmgr_psoc *psoc;
psoc = wlan_vdev_get_psoc(vdev);
if (psoc && WLAN_CRYPTO_TX_OPS_SET_KEY(psoc))
WLAN_CRYPTO_TX_OPS_SET_KEY(psoc)(vdev, req, pairwise);
WLAN_CRYPTO_TX_OPS_SET_KEY(psoc)(vdev, req, key_type);
else
return QDF_STATUS_E_FAILURE;

View file

@ -25,7 +25,8 @@
#include <wlan_objmgr_vdev_obj.h>
#include <wlan_crypto_global_api.h>
QDF_STATUS ucfg_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
struct wlan_crypto_key *req, bool pairwise)
struct wlan_crypto_key *req,
enum wlan_crypto_key_type key_type)
{
/*
* It is the job of dispatcher to decide whether the
@ -37,6 +38,6 @@ QDF_STATUS ucfg_crypto_set_key_req(struct wlan_objmgr_vdev *vdev,
* Hence the request handler is directly called from
* here.
*/
return wlan_crypto_set_key_req(vdev, req, pairwise);
return wlan_crypto_set_key_req(vdev, req, key_type);
}