diff --git a/iot_sim/core/iot_sim_cmn_api_i.h b/iot_sim/core/iot_sim_cmn_api_i.h index 7431c812137b..a8cd37b61e97 100644 --- a/iot_sim/core/iot_sim_cmn_api_i.h +++ b/iot_sim/core/iot_sim_cmn_api_i.h @@ -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, diff --git a/iot_sim/core/iot_sim_common.c b/iot_sim/core/iot_sim_common.c index ebc1333b5bad..debc8fd9473f 100644 --- a/iot_sim/core/iot_sim_common.c +++ b/iot_sim/core/iot_sim_common.c @@ -22,6 +22,27 @@ #include #include +/* + * iot_sim_oper_to_str - function to return iot sim operation string + * @oper: iot sim operation + * + * Return: string pointer + */ +uint8_t * +iot_sim_oper_to_str(enum iot_sim_operations oper) +{ + switch (oper) { + case CONTENT_CHANGE: + return "content change"; + case DELAY: + return "delay"; + case DROP: + return "drop"; + default: + return "invalid"; + } +} + /* * iot_sim_convert_offset_to_hex_str - function to convert offset into binary * @offset: user provided offset value while action frame rule deletion @@ -47,6 +68,73 @@ iot_sim_convert_offset_to_hex_str(uint16_t offset, uint8_t *hex, int8_t count) return QDF_STATUS_SUCCESS; } +/* + * iot_sim_parse_action_frame - function to parse action frame to decode + * category and action code + * + * @length: length for content provided by user + * @offset: offset provided by user + * @content: user provided content + * @category: buffer to store iot specific category code + * @action: buffer to store iot specific action code + * + * Return: QDF_STATUS_SUCCESS on success otherwise failure + */ +QDF_STATUS +iot_sim_parse_action_frame(uint16_t length, uint16_t offset, uint8_t *content, + uint8_t *category, uint8_t *action) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + uint8_t hex[2], *ptr = NULL; + + if (!length) { + status = iot_sim_convert_offset_to_hex_str(offset, hex, + sizeof(hex)); + if (QDF_IS_STATUS_ERROR(status)) + return status; + + /* Offset represet category type and action type */ + status = iot_sim_get_index_for_action_frm(hex, category, + action); + if (status == QDF_STATUS_E_FAULT) { + iot_sim_err("Get indices for action failed"); + return status; + } + } else if (length && content) { + /* if offset is zero, move ptr post header */ + if (offset == 0) { + ptr = content + sizeof(struct ieee80211_frame); + } else if (offset == sizeof(struct ieee80211_frame)) { + ptr = content; + } else { + iot_sim_err("wrong offset for action frame content"); + return QDF_STATUS_E_FAILURE; + } + status = iot_sim_get_index_for_action_frm(ptr, category, + action); + } + return status; +} + +/* + * iot_sim_find_peer_from_mac - function to find the iot sim peer data + * based on the mac address provided + * + * @isc: iot_sim pdev private object + * @mac: mac address of the peer + * + * Return: iot_sim_rule_per_peer reference if exists else NULL + */ +struct iot_sim_rule_per_peer * +iot_sim_find_peer_from_mac(struct iot_sim_context *isc, + struct qdf_mac_addr *mac) +{ + if (qdf_is_macaddr_zero(mac) || qdf_is_macaddr_broadcast(mac)) + return &isc->bcast_peer; + else + return NULL; +} + /* * iot_sim_validate_content - function to validate frame content. User provided * content must be either full frame or full frame @@ -127,18 +215,18 @@ iot_sim_handle_frame_content(struct iot_sim_context *isc, if (ret == -1) { iot_sim_err("iot_sim:hex2bin conversion failed"); status = QDF_STATUS_E_FAULT; - goto error2; + goto error; } status = iot_sim_validate_content(*storage, len, offset); if (QDF_IS_STATUS_ERROR(status)) { iot_sim_err("iot_sim:User Content Invalid"); - goto error2; + goto error; } return QDF_STATUS_SUCCESS; -error2: +error: qdf_mem_free(*storage); *storage = NULL; return status; @@ -260,8 +348,11 @@ iot_sim_parse_user_input_content_change(struct iot_sim_context *isc, /* * If argv[5] is valid, this must be mac address */ - if (argv[5]) + if (argv[5]) { status = qdf_mac_parse(argv[5], addr); + if (QDF_IS_STATUS_ERROR(status)) + qdf_mem_free(content); + } return status; err: @@ -270,8 +361,8 @@ err: } QDF_STATUS -iot_sim_get_index_for_action_frm(uint8_t *frm, uint8_t *cat, - uint8_t *act) +iot_sim_get_index_for_action_frm(uint8_t *frm, uint8_t *cat_type, + uint8_t *act_type) { uint8_t category, action; @@ -284,10 +375,13 @@ iot_sim_get_index_for_action_frm(uint8_t *frm, uint8_t *cat, case IEEE80211_ACTION_CAT_BA: switch (action) { case IEEE80211_ACTION_BA_ADDBA_REQUEST: + *cat_type = category; + *act_type = action; + break; case IEEE80211_ACTION_BA_ADDBA_RESPONSE: case IEEE80211_ACTION_BA_DELBA: - *cat = CAT_BA; - *act = action; + *cat_type = CAT_BA; + *act_type = action; break; default: return QDF_STATUS_E_FAULT; @@ -297,8 +391,8 @@ iot_sim_get_index_for_action_frm(uint8_t *frm, uint8_t *cat, switch (action) { case IEEE80211_ACTION_SA_QUERY_REQUEST: case IEEE80211_ACTION_SA_QUERY_RESPONSE: - *cat = CAT_SA_QUERY; - *act = action; + *cat_type = CAT_SA_QUERY; + *act_type = action; break; default: return QDF_STATUS_E_FAULT; @@ -311,106 +405,6 @@ iot_sim_get_index_for_action_frm(uint8_t *frm, uint8_t *cat, return QDF_STATUS_SUCCESS; } -QDF_STATUS -iot_sim_del_cnt_cng_rule_peer_action(struct iot_sim_rule_per_peer *peer, - uint16_t seq, enum iot_sim_operations oper, - uint8_t cat, uint8_t act) -{ - /* seq entries and frame entries */ - struct iot_sim_rule_per_seq *s_e; - struct iot_sim_rule *f_e; - uint8_t bm; - - qdf_spin_lock(&peer->iot_sim_lock); - s_e = peer->rule_per_seq[seq]; - if (!s_e) { - qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_err("s_e is null"); - return QDF_STATUS_SUCCESS; - } - - f_e = s_e->rule_per_action_frm[cat][act]; - if (f_e && f_e->frm_content) { - qdf_mem_free(f_e->frm_content); - f_e->frm_content = NULL; - bm = f_e->rule_bitmap; - s_e->use_count--; - if (IOT_SIM_CLEAR_OP_BIT(bm, oper)) { - qdf_mem_free(f_e); - s_e->rule_per_action_frm[cat][act] = NULL; - } - } - if (s_e->use_count == 0) { - qdf_mem_free(s_e); - peer->rule_per_seq[seq] = NULL; - } - qdf_spin_unlock(&peer->iot_sim_lock); - - return QDF_STATUS_SUCCESS; -} - -/* - * iot_sim_del_cnt_cng_rule_peer - function to delete content change rule - * @peer: iot sim peer - * @type: 802.11 frame type - * @subtype: 802.11 frame subtype - * @seq: authentication sequence number, mostly 0 for non-authentication frame - * @oper: iot sim operation - * @cat: action category code - * @act: action code - * @action: boolean to indicate action frame - * - * Return: QDF_STATUS_SUCCESS - */ -QDF_STATUS -iot_sim_del_cnt_cng_rule_peer(struct iot_sim_rule_per_peer *peer, - uint8_t type, uint8_t subtype, - uint16_t seq, enum iot_sim_operations oper, - uint8_t cat, uint8_t act, bool action) -{ - /* seq entries and frame entries */ - struct iot_sim_rule_per_seq *s_e; - struct iot_sim_rule *f_e; - uint8_t bm; - QDF_STATUS status = QDF_STATUS_SUCCESS; - - if (action) { - status = iot_sim_del_cnt_cng_rule_peer_action(peer, seq, oper, - cat, act); - if (QDF_IS_STATUS_ERROR(status)) - iot_sim_err("Rule deletion for action frame failed"); - - return status; - } - - qdf_spin_lock(&peer->iot_sim_lock); - s_e = peer->rule_per_seq[seq]; - if (!s_e) { - qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_info("s_e is null"); - return QDF_STATUS_SUCCESS; - } - - f_e = s_e->rule_per_type[type][subtype]; - if (f_e && f_e->frm_content) { - qdf_mem_free(f_e->frm_content); - f_e->frm_content = NULL; - bm = f_e->rule_bitmap; - s_e->use_count--; - if (IOT_SIM_CLEAR_OP_BIT(bm, oper)) { - qdf_mem_free(f_e); - s_e->rule_per_type[type][subtype] = NULL; - } - if (s_e->use_count == 0) { - qdf_mem_free(s_e); - peer->rule_per_seq[seq] = NULL; - } - } - qdf_spin_unlock(&peer->iot_sim_lock); - - return QDF_STATUS_SUCCESS; -} - /* * iot_sim_frame_supported_by_fw - function to find if frame is supported by fw * @type: 802.11 frame type @@ -451,213 +445,41 @@ iot_sim_frame_supported_by_fw(uint8_t type, uint8_t subtype) } /* - * iot_sim_delete_rule_for_mac - function to delete content change rule - * for given peer mac + * iot_sim_send_rule_to_fw - function to send iot_sim rule to fw + * * @isc: iot sim context * @oper: iot sim operation - * @seq: authentication sequence number, mostly 0 for non-authentication frame + * @mac: peer mac address * @type: 802.11 frame type * @subtype: 802.11 frame subtype - * @mac: peer mac address - * @cat: action category code - * @act: action code - * @action: boolean to indicate action frame + * @seq: authentication sequence number, mostly 0 for non-authentication frame + * @offset: user provided offset + * @frm: user provided frame content + * @length: length of frm + * @clear: flag to indicate set rule or clear * - * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE otherwise + * Return: QDF_STATUS_SUCCESS */ QDF_STATUS -iot_sim_delete_rule_for_mac(struct iot_sim_context *isc, - enum iot_sim_operations oper, - uint16_t seq, uint8_t type, - uint8_t subtype, struct qdf_mac_addr *mac, - uint8_t cat, uint8_t act, bool action) +iot_sim_send_rule_to_fw(struct iot_sim_context *isc, + enum iot_sim_operations oper, + struct qdf_mac_addr *mac, + uint8_t type, uint8_t subtype, + uint16_t seq, uint16_t offset, + uint8_t *frm, uint16_t len, bool clear) { - QDF_STATUS ret = QDF_STATUS_SUCCESS; struct simulation_test_params param; - if (qdf_is_macaddr_zero(mac)) - iot_sim_info("Rule deletion for all peers"); - else - iot_sim_info("Rule deletion for " QDF_MAC_ADDR_STR, - QDF_MAC_ADDR_ARRAY(mac->bytes)); - if (action) - iot_sim_info("oper:%u cat type:%hu act type:%hu seq:%hu", - oper, cat, act, seq); - else - iot_sim_info("oper:%u type:%hu subtype:%hu seq:%hu", oper, type, - subtype, seq); - - if (!isc) { - iot_sim_err("iot_sim: isc is null"); - return QDF_STATUS_E_FAILURE; - } - - if (oper == CONTENT_CHANGE) { - if (qdf_is_macaddr_broadcast(mac)) { - /* - * Clear rules for bcast peer - */ - ret = iot_sim_del_cnt_cng_rule_peer(&isc->bcast_peer, - type, subtype, - seq, oper, cat, act, - action); - } else if (qdf_is_macaddr_zero(mac)) { - /* - * Zero mac address, rules will be deleted - * for all peer and including for bcast peer - */ - - /* - * Clear rules for bcast peer - */ - ret = iot_sim_del_cnt_cng_rule_peer(&isc->bcast_peer, - type, subtype, - seq, oper, cat, act, - action); - /* Clear rules for individual peer - * TBD - */ - } else { - /* TBD: clear the rules for peer with address 'mac'*/ - } - } else if (oper == DROP) { - /* TBD */ - } else if (oper == DELAY) { - /* TBD */ - } - if (iot_sim_frame_supported_by_fw(type, subtype)) { qdf_mem_zero(¶m, sizeof(struct simulation_test_params)); param.pdev_id = wlan_objmgr_pdev_get_pdev_id(isc->pdev_obj); qdf_mem_copy(param.peer_mac, mac, QDF_MAC_ADDR_SIZE); param.test_cmd_type = oper; /* subtype_cmd: Rule:- set:0 clear:1 */ - param.test_subcmd_type = 1; + param.test_subcmd_type = clear; param.frame_type = type; param.frame_subtype = subtype; - param.seq = seq; - param.bufp = NULL; - if (QDF_IS_STATUS_ERROR(tgt_send_simulation_cmd(isc->pdev_obj, - ¶m))) - iot_sim_info("Sending del rule to fw failed!"); - } - return ret; -} - -/* - * iot_sim_add_cnt_cng_rule_peer_action - function to add content change rule - * for action frame - * @isc: iot sim context - * @peer: iot sim peer - * @seq: authentication sequence number, mostly 0 for non-authentication frame - * @frm: frame content to store - * @offset: offset value - * @len: length of frame content - * @oper: iot sim operation - * @cat: iot sim category code for action frame - * @act: iot sim action code for action frame - * - * Return: QDF_STATUS_SUCCESS on success, failure otherwise - */ -QDF_STATUS -iot_sim_add_cnt_cng_rule_peer_action(struct iot_sim_context *isc, - struct iot_sim_rule_per_peer *peer, - uint16_t seq, uint8_t *frm, - uint16_t offset, uint16_t len, - enum iot_sim_operations oper, - uint8_t cat, uint8_t act) -{ - struct iot_sim_rule_per_seq *s_e = NULL; - struct iot_sim_rule *f_e = NULL; - - qdf_spin_lock(&peer->iot_sim_lock); - s_e = peer->rule_per_seq[seq]; - if (s_e) { - f_e = s_e->rule_per_action_frm[cat][act]; - if (!f_e) { - f_e = qdf_mem_malloc(sizeof(struct iot_sim_rule)); - if (!f_e) { - iot_sim_err("can't allocate f_e for action frm"); - qdf_spin_unlock(&peer->iot_sim_lock); - return QDF_STATUS_E_NOMEM; - } - s_e->rule_per_action_frm[cat][act] = f_e; - } - } else { - s_e = qdf_mem_malloc(sizeof(struct iot_sim_rule_per_seq)); - if (!s_e) { - qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_err("can't allocate s_e for action"); - return QDF_STATUS_E_NOMEM; - } - - f_e = qdf_mem_malloc(sizeof(struct iot_sim_rule)); - if (!f_e) { - qdf_mem_free(s_e); - peer->rule_per_seq[seq] = NULL; - qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_err("iot_sim: f_e is null"); - return QDF_STATUS_E_NOMEM; - } - s_e->rule_per_action_frm[cat][act] = f_e; - peer->rule_per_seq[seq] = s_e; - } - - s_e->use_count++; - f_e->frm_content = qdf_mem_malloc(len); - qdf_mem_copy(f_e->frm_content, frm, len); - f_e->len = len; - f_e->offset = offset; - IOT_SIM_SET_OP_BIT(f_e->rule_bitmap, oper); - qdf_spin_unlock(&peer->iot_sim_lock); - - iot_sim_info("iot_sim: Rule added for oper:%u", oper); - iot_sim_info("cat:%x act:%x sq:%hu off:%hu len:%hu", - cat, act, seq, offset, len); - - return QDF_STATUS_SUCCESS; -} - -/* - * iot_sim_add_cnt_cng_rule_peer - function to add content change rule on peer - * @peer: iot sim peer - * @type: 802.11 frame type - * @subtype: 802.11 frame subtype - * @seq: authentication sequence number, mostly 0 for non-authentication frame - * @frm: frame content to store - * @offset: offset value - * @len: length of frame content - * @oper: iot sim operation - * @cat: action category code - * @act: action code - * @action: boolean to indicate action frame - * - * Return: QDF_STATUS_SUCCESS on success, failure otherwise - */ -QDF_STATUS -iot_sim_add_cnt_cng_rule_peer(struct iot_sim_context *isc, - struct iot_sim_rule_per_peer *peer, - uint8_t type, uint8_t subtype, - uint16_t seq, uint8_t *frm, - uint16_t offset, uint16_t len, - enum iot_sim_operations oper, - uint8_t cat, uint8_t act, bool is_action) -{ - struct iot_sim_rule_per_seq *s_e = NULL; - struct iot_sim_rule *f_e = NULL; - struct simulation_test_params param; - QDF_STATUS status = QDF_STATUS_SUCCESS; - - if (iot_sim_frame_supported_by_fw(type, subtype)) { - qdf_mem_zero(¶m, sizeof(struct simulation_test_params)); - param.pdev_id = wlan_objmgr_pdev_get_pdev_id(isc->pdev_obj); - qdf_mem_copy(param.peer_mac, &peer->addr, QDF_MAC_ADDR_SIZE); - param.test_cmd_type = oper; - /* subtype_cmd: Rule:- set:0 clear:1 */ - param.test_subcmd_type = 0; - param.frame_type = type; - param.frame_subtype = subtype; param.seq = seq; param.offset = offset; param.frame_length = len; @@ -665,69 +487,158 @@ iot_sim_add_cnt_cng_rule_peer(struct iot_sim_context *isc, param.bufp = frm; if (QDF_IS_STATUS_ERROR(tgt_send_simulation_cmd(isc->pdev_obj, ¶m))) - iot_sim_info("Sending del rule to fw failed!"); + iot_sim_err("Sending del rule to fw failed!"); if (!FRAME_TYPE_IS_BEACON(type, subtype)) - return status; + return QDF_STATUS_SUCCESS; } - if (is_action) { - status = iot_sim_add_cnt_cng_rule_peer_action(isc, peer, - seq, frm, - offset, len, - oper, cat, act); - if (QDF_IS_STATUS_ERROR(status)) - iot_sim_err("Add action rule failed!"); + return QDF_STATUS_E_NOSUPPORT; +} - return status; +/* + * iot_sim_del_rule - function to delete iot_sim rule + * + * @s_e: address of seq for which rule to be removed + * @f_e: address of the rule present in s_e to be removed + * @oper: iot sim operation + * + * Return: QDF_STATUS_SUCCESS + */ +QDF_STATUS +iot_sim_del_rule(struct iot_sim_rule_per_seq **s_e, + struct iot_sim_rule **f_e, + enum iot_sim_operations oper) +{ + if (oper == CONTENT_CHANGE) { + qdf_mem_free((*f_e)->frm_content); + (*f_e)->frm_content = NULL; + } else if (oper == DROP) { + /* TBD */ + } else if (oper == DELAY) { + /* TBD */ } - qdf_spin_lock(&peer->iot_sim_lock); - s_e = peer->rule_per_seq[seq]; - if (s_e) { - f_e = s_e->rule_per_type[type][subtype]; - if (!f_e) { - f_e = qdf_mem_malloc(sizeof(struct iot_sim_rule)); - if (!f_e) { - iot_sim_err("can't allocate f_e"); - qdf_spin_unlock(&peer->iot_sim_lock); - return QDF_STATUS_E_NOMEM; - } - s_e->rule_per_type[type][subtype] = f_e; - } - } else { - s_e = qdf_mem_malloc(sizeof(struct iot_sim_rule_per_seq)); - if (!s_e) { + (*s_e)->use_count--; + qdf_clear_bit(oper, (unsigned long *) + &(*f_e)->rule_bitmap); + if (!(*f_e)->rule_bitmap) { + qdf_mem_free(*f_e); + *f_e = NULL; + } + if ((*s_e)->use_count == 0) { + qdf_mem_free(*s_e); + *s_e = NULL; + } + return QDF_STATUS_SUCCESS; +} + +/* + * 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, + uint16_t seq, uint8_t type, + uint8_t subtype, + struct qdf_mac_addr *mac, + bool action) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct iot_sim_rule_per_seq **s_e; + struct iot_sim_rule **f_e; + struct iot_sim_rule_per_peer *peer; + + if (qdf_is_macaddr_zero(mac)) + iot_sim_info("Rule deletion for all peers"); + else + iot_sim_info("Rule deletion for " QDF_MAC_ADDR_STR, + QDF_MAC_ADDR_ARRAY(mac->bytes)); + + iot_sim_debug("oper:%s seq: %hu %s:%hu/%hu", + iot_sim_oper_to_str(oper), seq, + action ? "category/action code" : "type/subtype", + type, subtype); + + if (!isc) { + iot_sim_err("iot_sim: isc is null"); + return QDF_STATUS_E_FAILURE; + } + + peer = iot_sim_find_peer_from_mac(isc, mac); + if (peer) { + qdf_spin_lock(&peer->iot_sim_lock); + s_e = &peer->rule_per_seq[seq]; + if (!*s_e) { qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_err("iot_sim: s_e is null"); + return QDF_STATUS_SUCCESS; + } + + if (action) + f_e = &((*s_e)->rule_per_action_frm[type][subtype]); + else + f_e = &((*s_e)->rule_per_type[type][subtype]); + + if (*f_e) + status = iot_sim_del_rule(s_e, f_e, oper); + qdf_spin_unlock(&peer->iot_sim_lock); + } + + return status; +} + +/* + * iot_sim_add_rule - function to add iot_sim rule + * + * @s_e: address of seq for which rule to be added + * @f_e: address of the rule present in s_e to be added + * @oper: iot sim operation + * @frm: user provided frame content + * @offset: user provided offset + * @len: length of the user provided frame content + * + * Return: QDF_STATUS_SUCCESS + */ +QDF_STATUS +iot_sim_add_rule(struct iot_sim_rule_per_seq **s_e, + struct iot_sim_rule **f_e, + enum iot_sim_operations oper, + uint8_t *frm, uint16_t offset, uint16_t len) +{ + if (!*f_e) { + *f_e = qdf_mem_malloc(sizeof(struct iot_sim_rule)); + if (!*f_e) { + iot_sim_err("can't allocate f_e"); return QDF_STATUS_E_NOMEM; } - - f_e = qdf_mem_malloc(sizeof(struct iot_sim_rule)); - if (!f_e) { - qdf_mem_free(s_e); - peer->rule_per_seq[seq] = NULL; - qdf_spin_unlock(&peer->iot_sim_lock); - iot_sim_err("iot_sim: f_e is null"); - return QDF_STATUS_E_NOMEM; - } - - s_e->rule_per_type[type][subtype] = f_e; - peer->rule_per_seq[seq] = s_e; } - f_e->frm_content = qdf_mem_malloc(len); - qdf_mem_copy(f_e->frm_content, frm, len); - f_e->len = len; - f_e->offset = offset; - s_e->use_count++; - IOT_SIM_SET_OP_BIT(f_e->rule_bitmap, oper); - qdf_spin_unlock(&peer->iot_sim_lock); + if (oper == CONTENT_CHANGE) { + (*f_e)->frm_content = qdf_mem_malloc(len); + if (!((*f_e)->frm_content)) + return QDF_STATUS_E_NOMEM; + qdf_mem_copy((*f_e)->frm_content, frm, len); + (*f_e)->len = len; + (*f_e)->offset = offset; + } else if (oper == DROP) { + /* TBD */ + } else if (oper == DELAY) { + /* TBD */ + } - iot_sim_info("iot_sim:Rule added for mac: " QDF_MAC_ADDR_STR " oper:%u", - QDF_MAC_ADDR_ARRAY(peer->addr.bytes), oper); - iot_sim_info("type:%x stype:%x sq:%hu off:%hu len:%hu", - type, subtype, seq, offset, len); + (*s_e)->use_count++; + qdf_set_bit(oper, (unsigned long *) + &(*f_e)->rule_bitmap); return QDF_STATUS_SUCCESS; } @@ -743,9 +654,7 @@ iot_sim_add_cnt_cng_rule_peer(struct iot_sim_context *isc, * @seq: authentication sequence number, mostly 0 for non-authentication frame * @offset: user provided offset * @frm: user provided frame content - * @length: length of frm - * @cat: action category code - * @act: action code + * @len: length of frm * @action: boolean to indicate action frame * * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE otherwise @@ -757,45 +666,63 @@ iot_sim_add_rule_for_mac(struct iot_sim_context *isc, uint8_t type, uint8_t subtype, uint16_t seq, uint16_t offset, uint8_t *frm, uint16_t len, - uint8_t cat, uint8_t act, bool is_action) + bool action) { QDF_STATUS status = QDF_STATUS_E_FAILURE; + struct iot_sim_rule_per_peer *peer; + struct iot_sim_rule_per_seq **s_e = NULL; + struct iot_sim_rule **f_e = NULL; if (!isc) { iot_sim_err("iot_sim: isc is null"); return status; } - if (oper == CONTENT_CHANGE) { - if (!frm) - return status; - - status = iot_sim_delete_rule_for_mac(isc, oper, seq, - type, subtype, mac, - cat, act, is_action); - if (status == QDF_STATUS_E_FAILURE) { - iot_sim_err("iot_sim: Rule removed - Fail"); - return status; - } - - if (qdf_is_macaddr_broadcast(mac)) { - iot_sim_add_cnt_cng_rule_peer(isc, &isc->bcast_peer, - type, subtype, seq, frm, - offset, len, oper, - cat, act, is_action); - } else { - /* - * Add entry to peer with MAC 'mac' - */ - /* TBD */ - } - } else if (oper == DROP) { - /* TBD */ - } else if (oper == DELAY) { - /* TBD */ + status = iot_sim_delete_rule_for_mac(isc, oper, seq, + type, subtype, mac, + action); + if (status == QDF_STATUS_E_FAILURE) { + iot_sim_err("iot_sim: Rule removed - Fail"); + return status; } - return QDF_STATUS_SUCCESS; + peer = iot_sim_find_peer_from_mac(isc, mac); + if (peer) { + qdf_spin_lock(&peer->iot_sim_lock); + s_e = &peer->rule_per_seq[seq]; + if (!*s_e) { + *s_e = qdf_mem_malloc(sizeof(struct + iot_sim_rule_per_seq)); + if (!*s_e) { + iot_sim_err("can't allocate s_e"); + qdf_spin_unlock(&peer->iot_sim_lock); + return QDF_STATUS_E_NOMEM; + } + } + + if (action) + f_e = &((*s_e)->rule_per_action_frm[type][subtype]); + else + f_e = &((*s_e)->rule_per_type[type][subtype]); + + if (qdf_is_macaddr_zero(mac)) + iot_sim_info("Rule addition for all peers"); + else + iot_sim_info("Rule addition for " QDF_MAC_ADDR_STR, + QDF_MAC_ADDR_ARRAY(mac->bytes)); + + iot_sim_info("oper:%s seq: %hu %s:%hu/%hu", + iot_sim_oper_to_str(oper), seq, + action ? "category/action code" : "type/subtype", + type, subtype); + + status = iot_sim_add_rule(s_e, f_e, oper, frm, offset, len); + qdf_spin_unlock(&peer->iot_sim_lock); + } else { + /* TBD: clear the rules for peer with address 'mac'*/ + } + + return status; } /* @@ -826,13 +753,13 @@ iot_sim_debug_content_change_write(struct file *file, QDF_STATUS status = QDF_STATUS_SUCCESS; unsigned char t_st, type, subtype, *content = NULL; uint16_t offset = 0, length = 0, seq = 0; - char *locbuf, *ptr, hex[2]; + char *locbuf = NULL; enum iot_sim_operations oper = CONTENT_CHANGE; struct qdf_mac_addr mac_addr = QDF_MAC_ADDR_BCAST_INIT; struct iot_sim_context *isc = ((struct seq_file *)file->private_data)->private; - uint8_t act_t = 0, cat_t = 0; - bool is_action_frm = 0; + uint8_t action = 0, category = 0; + bool is_action = 0, clear = false; if ((!buf) || (count > USER_BUF_LEN) || (count < 7)) return -EFAULT; @@ -850,77 +777,50 @@ iot_sim_debug_content_change_write(struct file *file, &t_st, &seq, &offset, &length, &content, &mac_addr); - if (QDF_IS_STATUS_ERROR(status)) { - qdf_mem_free(locbuf); - return count; - } + if (QDF_IS_STATUS_ERROR(status)) + goto free; type = (t_st & IEEE80211_FC0_TYPE_MASK) >> IEEE80211_FC0_TYPE_SHIFT; subtype = (t_st & IEEE80211_FC0_SUBTYPE_MASK); subtype >>= IEEE80211_FC0_SUBTYPE_SHIFT; - if (type > N_FRAME_TYPE || subtype > N_FRAME_SUBTYPE || seq > MAX_SEQ) { - qdf_mem_free(locbuf); - return -EFAULT; - } + if (type > N_FRAME_TYPE || subtype > N_FRAME_SUBTYPE || seq > MAX_SEQ) + goto free; if (FRAME_TYPE_IS_ACTION(type, subtype)) { - if (!length) { - status = iot_sim_convert_offset_to_hex_str(offset, - hex, - sizeof(hex)); - if (QDF_IS_STATUS_ERROR(status)) { - qdf_mem_free(locbuf); - return count; - } + status = iot_sim_parse_action_frame(length, offset, content, + &category, &action); + if (QDF_IS_STATUS_ERROR(status)) + goto free; - /* Offset represet category type and action type */ - status = iot_sim_get_index_for_action_frm(hex, - &cat_t, - &act_t); - if (status == QDF_STATUS_E_FAULT) { - iot_sim_err("Get indices for action failed"); - goto free; - } - } else if (length && content) { - /* if offset is zero, move ptr post header */ - if (offset == 0) { - ptr = content + sizeof(struct ieee80211_frame); - } else if (offset == sizeof(struct ieee80211_frame)) { - ptr = content; - } else { - iot_sim_err("wrong offset for action frm cnt"); - goto free; - } - status = iot_sim_get_index_for_action_frm(ptr, - &cat_t, - &act_t); - } - is_action_frm = 1; + is_action = 1; + type = category; + subtype = action; } + clear = length ? false : true; + status = iot_sim_send_rule_to_fw(isc, oper, &mac_addr, type, subtype, + seq, offset, content, length, clear); + if (QDF_IS_STATUS_SUCCESS(status)) + goto free; + /* check for rule removal */ if (!length || !content) { status = iot_sim_delete_rule_for_mac(isc, oper, seq, type, subtype, &mac_addr, - cat_t, act_t, - is_action_frm); - if (QDF_IS_STATUS_ERROR(status)) - iot_sim_err("iot_sim: Rule removed - Fail"); - else - iot_sim_err("iot_sim: Rule removed - success"); + is_action); - qdf_mem_free(locbuf); - return count; + } else { + status = iot_sim_add_rule_for_mac(isc, oper, &mac_addr, + type, subtype, seq, offset, + content, length, is_action); } + if (QDF_IS_STATUS_SUCCESS(status)) + iot_sim_err("iot_sim: Content Change Operation - success"); + else + iot_sim_err("iot_sim: Content Change Operation - Fail"); - status = iot_sim_add_rule_for_mac(isc, oper, &mac_addr, type, subtype, - seq, offset, content, length, - cat_t, act_t, is_action_frm); - - if (QDF_IS_STATUS_ERROR(status)) - iot_sim_err("iot_sim: Rule Add - Fail"); free: qdf_mem_free(content); qdf_mem_free(locbuf); @@ -1024,41 +924,6 @@ struct iot_sim_dbgfs_file iot_sim_dbgfs_files[IOT_SIM_DEBUGFS_FILE_NUM] = { DEBUG_IOT_SIM(delay), }; -QDF_STATUS -iot_sim_control_cmn(struct wlan_objmgr_pdev *pdev, wbuf_t wbuf) -{ - QDF_STATUS status = QDF_STATUS_E_FAILURE; - struct iot_sim_context *isc; - - if (!pdev) { - iot_sim_err("PDEV is NULL!"); - goto bad; - } - - isc = iot_sim_get_ctx_from_pdev(pdev); - if (!isc) { - iot_sim_err("iot_sim context is NULL!"); - goto bad; - } - - status = QDF_STATUS_SUCCESS; -bad: - return status; -} - -/** - * iot_sim_ctx_deinit() - De-initialize function pointers from iot_sim context - * @sc - Reference to iot_sim_context object - * - * Return: None - */ -static void -iot_sim_ctx_deinit(struct iot_sim_context *isc) -{ - if (isc) - isc->iot_sim_operation_handler = NULL; -} - /** * iot_sim_debugfs_deinit() - Deinit functions to remove debugfs directory and * it's file enteries. @@ -1088,25 +953,23 @@ iot_sim_remove_all_oper_rules(struct iot_sim_context *isc, enum iot_sim_operations oper) { uint16_t seq; - uint8_t type, subtype, cat = 0, act = 0; + uint8_t type, subtype, category = 0, action = 0; struct qdf_mac_addr zero_mac_addr = QDF_MAC_ADDR_ZERO_INIT; - /* Remove rules for non-action type frames */ - for (seq = 0; seq < MAX_SEQ; seq++) + for (seq = 0; seq < MAX_SEQ; seq++) { + /* Remove rules for non-action type frames */ for (type = 0; type < N_FRAME_TYPE; type++) for (subtype = 0; subtype < N_FRAME_SUBTYPE; subtype++) iot_sim_delete_rule_for_mac(isc, oper, seq, type, subtype, - &zero_mac_addr, - cat, act, 0); - /* Remove rules for action frames */ - for (seq = 0; seq < MAX_SEQ; seq++) - for (cat = 0; cat < IOT_SIM_MAX_CAT; cat++) - for (act = 0; act < MAX_ACTION; act++) + &zero_mac_addr, 0); + /* Remove rules for action frames */ + for (category = 0; category < IOT_SIM_MAX_CAT; category++) + for (action = 0; action < MAX_ACTION; action++) iot_sim_delete_rule_for_mac(isc, oper, seq, - type, subtype, - &zero_mac_addr, - cat, act, 1); + category, action, + &zero_mac_addr, 1); + } } /* @@ -1187,7 +1050,6 @@ QDF_STATUS wlan_iot_sim_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg) { struct iot_sim_context *isc = NULL; - QDF_STATUS status = QDF_STATUS_SUCCESS; if (!pdev) { iot_sim_err("pdev is NULL"); @@ -1208,14 +1070,15 @@ wlan_iot_sim_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg) qdf_set_macaddr_broadcast(&isc->bcast_peer.addr); qdf_spinlock_create(&isc->bcast_peer.iot_sim_lock); - qdf_list_create(&isc->bcast_peer.p_list, 0); + qdf_list_create(&isc->bcast_peer.list, 0); wlan_objmgr_pdev_component_obj_attach(pdev, WLAN_IOT_SIM_COMP, (void *)isc, QDF_STATUS_SUCCESS); - iot_sim_err("iot_sim component pdev object created"); + iot_sim_debug("iot_sim component pdev%u object created", + wlan_objmgr_pdev_get_pdev_id(isc->pdev_obj)); - return status; + return QDF_STATUS_SUCCESS; } QDF_STATUS @@ -1236,13 +1099,13 @@ wlan_iot_sim_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, WLAN_IOT_SIM_COMP, (void *)isc); /* Deinitilise function pointers from iot_sim context */ - iot_sim_ctx_deinit(isc); iot_sim_debugfs_deinit(isc); iot_sim_remove_all_rules(isc); qdf_spinlock_destroy(&isc->bcast_peer.iot_sim_lock); qdf_mem_free(isc); } - iot_sim_err("iot_sim component pdev object destroyed"); + iot_sim_debug("iot_sim component pdev%u object created", + wlan_objmgr_pdev_get_pdev_id(isc->pdev_obj)); return QDF_STATUS_SUCCESS; } diff --git a/iot_sim/core/iot_sim_defs_i.h b/iot_sim/core/iot_sim_defs_i.h index 28873edc2678..291880acc039 100644 --- a/iot_sim/core/iot_sim_defs_i.h +++ b/iot_sim/core/iot_sim_defs_i.h @@ -26,6 +26,7 @@ #include #include #include +#include #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 diff --git a/iot_sim/core/iot_sim_utils.c b/iot_sim/core/iot_sim_utils.c index 50f651281e98..ac1e62477c79 100644 --- a/iot_sim/core/iot_sim_utils.c +++ b/iot_sim/core/iot_sim_utils.c @@ -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; } diff --git a/iot_sim/dispatcher/inc/wlan_iot_sim_public_structs.h b/iot_sim/dispatcher/inc/wlan_iot_sim_public_structs.h new file mode 100644 index 000000000000..858f10c08a06 --- /dev/null +++ b/iot_sim/dispatcher/inc/wlan_iot_sim_public_structs.h @@ -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 + +#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_ */ diff --git a/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c b/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c index bcc686345783..a16fc0b296e0 100644 --- a/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c +++ b/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c @@ -17,24 +17,6 @@ #include #include -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) { diff --git a/target_if/iot_sim/target_if_iot_sim.h b/target_if/iot_sim/target_if_iot_sim.h index 4b8311b7603c..d44e100ab742 100644 --- a/target_if/iot_sim/target_if_iot_sim.h +++ b/target_if/iot_sim/target_if_iot_sim.h @@ -22,6 +22,7 @@ #ifdef WLAN_IOT_SIM_SUPPORT #include +#include /** * target_if_iot_sim_register_tx_ops() - Register IOT Sim target_if Tx Ops