1 /*
2 * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 /*
20 * DOC: csr_cmd_process.c
21 *
22 * Implementation for processing various commands.
23 */
24 #include "ani_global.h"
25 #include "csr_inside_api.h"
26 #include "sme_inside.h"
27 #include "mac_trace.h"
28
29 /**
30 * csr_msg_processor() - To process all csr msg
31 * @mac_ctx: mac context
32 * @msg_buf: message buffer
33 *
34 * This routine will handle all the message for csr to process
35 *
36 * Return: QDF_STATUS
37 */
csr_msg_processor(struct mac_context * mac_ctx,void * msg_buf)38 QDF_STATUS csr_msg_processor(struct mac_context *mac_ctx, void *msg_buf)
39 {
40 QDF_STATUS status = QDF_STATUS_SUCCESS;
41 tSirSmeRsp *sme_rsp = (tSirSmeRsp *) msg_buf;
42 uint8_t vdev_id = sme_rsp->vdev_id;
43 enum csr_roam_state cur_state;
44
45 cur_state = sme_get_current_roam_state(MAC_HANDLE(mac_ctx), vdev_id);
46 sme_debug("msg %d[0x%04X] recvd in curstate %s & substate %s id(%d)",
47 sme_rsp->messageType, sme_rsp->messageType,
48 mac_trace_getcsr_roam_state(cur_state),
49 mac_trace_getcsr_roam_sub_state(
50 mac_ctx->roam.curSubState[vdev_id]), vdev_id);
51
52 /* Process the message based on the state of the roaming states... */
53 switch (cur_state) {
54 case eCSR_ROAMING_STATE_JOINED:
55 /* are we in joined state */
56 csr_roam_joined_state_msg_processor(mac_ctx, msg_buf);
57 break;
58 case eCSR_ROAMING_STATE_JOINING:
59 /* are we in roaming states */
60 csr_roaming_state_msg_processor(mac_ctx, msg_buf);
61 break;
62
63 default:
64
65 if (sme_rsp->messageType ==
66 eWNI_SME_UPPER_LAYER_ASSOC_CNF) {
67 tSirSmeAssocIndToUpperLayerCnf *upper_layer_assoc_cnf =
68 (tSirSmeAssocIndToUpperLayerCnf *)msg_buf;
69 if (upper_layer_assoc_cnf->ies) {
70 qdf_mem_free(upper_layer_assoc_cnf->ies);
71 sme_debug("free ies");
72 }
73 break;
74 }
75
76 /*
77 * For all other messages, we ignore it
78 * To work-around an issue where checking for set/remove
79 * key base on connection state is no longer workable
80 * due to failure or finding the condition meets both
81 * SAP and infra requirement.
82 */
83 if (eWNI_SME_SETCONTEXT_RSP == sme_rsp->messageType ||
84 eWNI_SME_DISCONNECT_DONE_IND ==
85 sme_rsp->messageType) {
86 sme_warn("handling msg 0x%X CSR state is %d",
87 sme_rsp->messageType, cur_state);
88 csr_roam_check_for_link_status_change(mac_ctx,
89 sme_rsp);
90 } else {
91 sme_err("Message 0x%04X is not handled by CSR state is %d session Id %d",
92 sme_rsp->messageType, cur_state,
93 vdev_id);
94 }
95 break;
96 } /* switch */
97 return status;
98 }
99