qcacmn: iot_sim code cleanup

Optimize the content change operation
code for action and non-action type frames.

Change-Id: Ie3719715eebbe465851f4b84ffb6deefbab81844
CRs-Fixed: 2684013
Šī revīzija ir iekļauta:
Jayachandran Sreekumaran
2020-06-10 16:31:11 +05:30
revīziju iesūtīja nshrivas
vecāks f6f4cfc6f2
revīzija f71f32ada9
7 mainīti faili ar 511 papildinājumiem un 594 dzēšanām

Parādīt failu

@@ -31,8 +31,6 @@
*
*/
#define USER_BUF_LEN (1 + 2 + 2 + 2 + MAX_BUFFER_SIZE + 6)
#define IOT_SIM_SET_OP_BIT(bitmap, oper) ((bitmap) |= 1 << (oper))
#define IOT_SIM_CLEAR_OP_BIT(bitmap, oper) (((bitmap) &= ~(1 << (oper))) == 0)
/**
* wlan_iot_sim_pdev_obj_create_handler() - handler for pdev object create
@@ -115,15 +113,44 @@ iot_sim_get_ctx_from_pdev(struct wlan_objmgr_pdev *pdev)
return isc;
}
/*
* iot_sim_delete_rule_for_mac - function to delete content change rule
* for given peer mac
* @isc: iot sim context
* @oper: iot sim operation
* @seq: authentication sequence number, mostly 0 for non-authentication frame
* @type: 802.11 frame type
* @subtype: 802.11 frame subtype
* @mac: peer mac address
* @action: action frame or not
*
* Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE otherwise
*/
QDF_STATUS
iot_sim_delete_rule_for_mac(struct iot_sim_context *isc,
enum iot_sim_operations oper,
unsigned short seq,
unsigned char type,
unsigned char subtype,
uint16_t seq, uint8_t type,
uint8_t subtype,
struct qdf_mac_addr *mac,
uint8_t cat, uint8_t act, bool action);
bool action);
/*
* iot_sim_parse_user_input_content_change - function to parse user input into
* predefined format for content
* change operation. All arguments
* passed will be filled upon success
* @isc: iot sim context
* @userbuf: local copy of user input
* @count: length of userbuf
* @t_st: address of type variable
* @seq: address of seq variable
* @offset: address of offset variable
* @length: address of length variable
* @content: double pointer to storage to store frame content after processing
* @mac: pointer to mac address
*
* Return: QDF_STATUS_SUCCESS on success
* QDF_STATUS_E_FAILURE otherwise
*/
QDF_STATUS
iot_sim_parse_user_input_content_change(struct iot_sim_context *isc,
char *userbuf, ssize_t count,

Failā izmaiņas netiks attēlotas, jo tās ir par lielu Ielādēt izmaiņas

Parādīt failu

@@ -26,6 +26,7 @@
#include <qdf_timer.h>
#include <wbuf.h>
#include <wlan_iot_sim_utils_api.h>
#include <wlan_iot_sim_public_structs.h>
#define iot_sim_fatal(format, args...) \
QDF_TRACE_FATAL(QDF_MODULE_ID_IOT_SIM, format, ## args)
@@ -132,13 +133,13 @@ struct iot_sim_rule_per_seq {
* @addr - address of peer
* @iot_sim_lock - spinlock
* @rule_per_seq - array of iot_sim_rule_per_seq
* @p_list - list variable
* @list - list variable
*/
struct iot_sim_rule_per_peer {
struct qdf_mac_addr addr;
qdf_spinlock_t iot_sim_lock;
struct iot_sim_rule_per_seq *rule_per_seq[MAX_SEQ];
qdf_list_t p_list;
qdf_list_t list;
};
/**
@@ -146,17 +147,12 @@ struct iot_sim_rule_per_peer {
* @pdev_obj:Reference to pdev global object
* @iot_sim_peer_list: peer list for peer specific rules
* @bcast_peer: broadcast peer entry for storing rules for all peers
* @p_iot_sim_target_handle: handle to iot_sim target_if
* @iot_sim_operation_handler: callback for iot sim operation handler
*/
struct iot_sim_context {
struct wlan_objmgr_pdev *pdev_obj;
/* IOT_SIM Peer list & Bcast Peer */
struct iot_sim_rule_per_peer *iot_sim_peer_list, bcast_peer;
void *p_iot_sim_target_handle;
struct iot_sim_debugfs iot_sim_dbgfs_ctx;
QDF_STATUS (*iot_sim_operation_handler)(struct wlan_objmgr_pdev *pdev,
wbuf_t wbuf);
};
/* enum iot_sim_operations - iot sim operations

Parādīt failu

@@ -24,36 +24,42 @@
QDF_STATUS iot_sim_frame_update(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t nbuf)
{
u8 type, subtype, seq = 0;
uint8_t type, subtype, seq = 0;
struct iot_sim_context *isc;
u8 *buf = qdf_nbuf_data(nbuf);
uint8_t *buf = qdf_nbuf_data(nbuf), *frm = NULL;
int fixed_param_length = 0;
bool is_action_frm = false;
u8 cat, cat_index;
uint8_t cat, cat_index;
int auth_seq_index = 0, offset = 0;
struct iot_sim_rule *piot_sim_rule = NULL;
qdf_size_t buf_len = 0;
type = (buf[0] & IEEE80211_FC0_TYPE_MASK) >> IEEE80211_FC0_TYPE_SHIFT;
subtype = (buf[0] & IEEE80211_FC0_SUBTYPE_MASK);
subtype >>= IEEE80211_FC0_SUBTYPE_SHIFT;
isc = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_IOT_SIM_COMP);
if (!isc) {
iot_sim_err("pdev IOT_SIM object is NULL!");
return QDF_STATUS_SUCCESS;
}
if (type == 0x00 && subtype == 0x0b) {
if (type == IEEE80211_FC0_TYPE_MGT &&
subtype == IEEE80211_FC0_SUBTYPE_AUTH) {
/* Authentication frame */
int auth_seq_index = IEEE80211_FRAME_BODY_OFFSET + 2;
auth_seq_index = IEEE80211_FRAME_BODY_OFFSET + 2;
seq = le16toh(*(u_int16_t *)(buf + auth_seq_index));
} else if (type == 0x00 && subtype == 0x05)
} else if (type == IEEE80211_FC0_TYPE_MGT &&
subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)
/* Probe response frame */
fixed_param_length = 12;
else if (type == 0x00 && (subtype == 0x01 || subtype == 0x03))
else if (type == IEEE80211_FC0_TYPE_MGT &&
(subtype == IEEE80211_FC0_SUBTYPE_ASSOC_RESP ||
subtype == IEEE80211_FC0_SUBTYPE_REASSOC_RESP))
/* Assoc/Reassoc response frame */
fixed_param_length = 6;
else if (type == 0x00 && subtype == 0x0d) {
else if (type == IEEE80211_FC0_TYPE_MGT &&
subtype == IEEE80211_FC0_SUBTYPE_ACTION) {
/* Action frame */
u8 *frm = buf + IEEE80211_FRAME_BODY_OFFSET;
frm = buf + IEEE80211_FRAME_BODY_OFFSET;
is_action_frm = true;
if (iot_sim_get_index_for_action_frm(frm, &cat, &cat_index)) {
@@ -62,76 +68,65 @@ QDF_STATUS iot_sim_frame_update(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t nbuf)
}
}
subtype >>= IEEE80211_FC0_SUBTYPE_SHIFT;
iot_sim_debug("iot_sim: Change content operation for frame");
iot_sim_debug("type:%d subtype:%d seq:%d, is_action_frm: %u",
type, subtype, seq, is_action_frm);
/* Only broadcast peer is getting handled right now.
* Need to add support for peer based content modification
*/
qdf_spin_lock(&isc->bcast_peer.iot_sim_lock);
if (isc->bcast_peer.rule_per_seq[seq]) {
struct iot_sim_rule *piot_sim_rule;
qdf_size_t buf_len = qdf_nbuf_len(nbuf);
if (!isc->bcast_peer.rule_per_seq[seq])
goto norule;
if (is_action_frm)
piot_sim_rule = isc->bcast_peer.rule_per_seq[seq]->
rule_per_action_frm[cat][cat_index];
else
piot_sim_rule = isc->bcast_peer.rule_per_seq[seq]->
rule_per_type[type][subtype];
if (!piot_sim_rule) {
iot_sim_info("iot sim rule not set");
iot_sim_info("frame type:%d, subtype:%d, seq:%d",
type, subtype, seq);
qdf_spin_unlock(&isc->bcast_peer.iot_sim_lock);
return QDF_STATUS_SUCCESS;
buf_len = qdf_nbuf_len(nbuf);
if (is_action_frm)
piot_sim_rule = isc->bcast_peer.rule_per_seq[seq]->
rule_per_action_frm[cat][cat_index];
else
piot_sim_rule = isc->bcast_peer.rule_per_seq[seq]->
rule_per_type[type][subtype];
if (!piot_sim_rule)
goto norule;
if (!piot_sim_rule->frm_content || !piot_sim_rule->len)
goto norule;
if (piot_sim_rule->offset ==
IEEE80211_FRAME_BODY_OFFSET) {
offset = IEEE80211_FRAME_BODY_OFFSET;
} else if (piot_sim_rule->offset == 0) {
offset = 0;
} else if (buf[piot_sim_rule->offset] ==
piot_sim_rule->frm_content[0]) {
offset = piot_sim_rule->offset;
} else {
offset = IEEE80211_FRAME_BODY_OFFSET +
fixed_param_length;
while (((offset + 1) < buf_len) &&
(buf[offset] < piot_sim_rule->frm_content[0])) {
offset += buf[offset + 1] + 2;
}
if (piot_sim_rule->frm_content && piot_sim_rule->len) {
int offset;
if (piot_sim_rule->offset ==
IEEE80211_FRAME_BODY_OFFSET) {
offset = IEEE80211_FRAME_BODY_OFFSET;
} else if (piot_sim_rule->offset == 0) {
offset = 0;
} else if (buf[piot_sim_rule->offset] ==
piot_sim_rule->frm_content[0]) {
offset = piot_sim_rule->offset;
} else {
offset = IEEE80211_FRAME_BODY_OFFSET +
fixed_param_length;
while (((offset + 1) < buf_len) &&
(buf[offset] < piot_sim_rule->
frm_content[0])) {
offset += buf[offset + 1] + 2;
}
}
if (offset <= buf_len) {
buf += offset;
qdf_mem_copy(buf, piot_sim_rule->frm_content,
piot_sim_rule->len);
qdf_nbuf_set_pktlen(nbuf, offset +
piot_sim_rule->len);
iot_sim_info("Content updated for peer");
iot_sim_info("frame type:%d, subtype:%d",
type, subtype);
iot_sim_info("seq:%d", seq);
} else {
iot_sim_err("Failed to modify content");
iot_sim_err("type:%d, subtype:%d",
type, subtype);
iot_sim_err("seq:%d", seq);
}
} else {
iot_sim_info("Content update rule not set");
iot_sim_info("frame type:%d, subtype:%d, seq:%d",
type, subtype, seq);
}
} else {
iot_sim_info("IOT simulation rule not set");
iot_sim_info("frame type:%d, subtype:%d, seq:%d",
type, subtype, seq);
}
if (offset <= buf_len) {
buf += offset;
qdf_mem_copy(buf, piot_sim_rule->frm_content,
piot_sim_rule->len);
qdf_nbuf_set_pktlen(nbuf, offset +
piot_sim_rule->len);
iot_sim_debug("iot_sim: Content updated");
} else {
iot_sim_err("Failed to modify content");
}
qdf_spin_unlock(&isc->bcast_peer.iot_sim_lock);
return QDF_STATUS_SUCCESS;
norule:
iot_sim_debug("Rule not set for this frame");
qdf_spin_unlock(&isc->bcast_peer.iot_sim_lock);
return QDF_STATUS_SUCCESS;
}

Parādīt failu

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
*
* 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.
*/
#include <qdf_types.h>
#ifndef _WLAN_IOT_SIM__PUBLIC_STRUCTS_H_
#define _WLAN_IOT_SIM__PUBLIC_STRUCTS_H_
/**
* struct simulation_test_params
* pdev_id: pdev id
* vdev_id: vdev id
* peer_macaddr: peer MAC address
* test_cmd_type: test command type
* test_subcmd_type: test command sub type
* frame_type: frame type
* frame_subtype: frame subtype
* seq: sequence number
* offset: Frame content offset
* frame_length: Frame content length
* buf_len: Buffer length
* bufp: buffer
*/
struct simulation_test_params {
u32 pdev_id;
u32 vdev_id;
u8 peer_mac[QDF_MAC_ADDR_SIZE];
u32 test_cmd_type;
u32 test_subcmd_type;
u8 frame_type;
u8 frame_subtype;
u8 seq;
u8 reserved;
u16 offset;
u16 frame_length;
u32 buf_len;
u8 *bufp;
};
#endif /* _WLAN_IOT_SIM__PUBLIC_STRUCTS_H_ */

Parādīt failu

@@ -17,24 +17,6 @@
#include <wlan_iot_sim_tgt_api.h>
#include <wlan_iot_sim_utils_api.h>
void *
tgt_get_target_handle(struct wlan_objmgr_pdev *pdev)
{
struct iot_sim_context *isc;
if (!pdev) {
iot_sim_err("pdev is NULL!");
return NULL;
}
isc = wlan_objmgr_pdev_get_comp_private_obj(pdev,
WLAN_IOT_SIM_COMP);
if (!isc) {
iot_sim_err("pdev IOT_SIM object is NULL!");
return NULL;
}
return isc->p_iot_sim_target_handle;
}
QDF_STATUS tgt_send_simulation_cmd(struct wlan_objmgr_pdev *pdev,
struct simulation_test_params *param)
{

Parādīt failu

@@ -22,6 +22,7 @@
#ifdef WLAN_IOT_SIM_SUPPORT
#include <wlan_iot_sim_utils_api.h>
#include <wlan_iot_sim_public_structs.h>
/**
* target_if_iot_sim_register_tx_ops() - Register IOT Sim target_if Tx Ops