1 /*
2 * Copyright (c) 2013-2019 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: wma_ocb.c
21 *
22 * WLAN Host Device Driver 802.11p OCB implementation
23 */
24
25 #include "wma_ocb.h"
26 #include "cds_utils.h"
27 #include "cds_api.h"
28 #include "wlan_ocb_ucfg_api.h"
29 #include "lim_utils.h"
30 #include "../../core/src/vdev_mgr_ops.h"
31
32 /**
33 * wma_start_ocb_vdev() - start OCB vdev
34 * @config: ocb channel config
35 *
36 * Return: QDF_STATUS_SUCCESS on success
37 */
wma_start_ocb_vdev(struct ocb_config * config)38 static QDF_STATUS wma_start_ocb_vdev(struct ocb_config *config)
39 {
40 QDF_STATUS status;
41 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
42 struct wlan_objmgr_vdev *vdev;
43 struct vdev_mlme_obj *mlme_obj;
44 struct wlan_channel *des_chan;
45 uint8_t dot11_mode;
46
47 vdev = wma->interfaces[config->vdev_id].vdev;
48 if (!vdev) {
49 wma_err("vdev is NULL");
50 return QDF_STATUS_E_FAILURE;
51 }
52
53 mlme_obj = wlan_vdev_mlme_get_cmpt_obj(vdev);
54 if (!mlme_obj) {
55 wma_err("vdev component object is NULL");
56 return QDF_STATUS_E_FAILURE;
57 }
58 des_chan = vdev->vdev_mlme.des_chan;
59
60 des_chan->ch_freq = config->channels[0].chan_freq;
61 if (wlan_reg_is_24ghz_ch_freq(des_chan->ch_freq))
62 dot11_mode = MLME_DOT11_MODE_11G;
63 else
64 dot11_mode = MLME_DOT11_MODE_11A;
65 des_chan->ch_ieee =
66 wlan_reg_freq_to_chan(wma->pdev, des_chan->ch_freq);
67
68 status = lim_set_ch_phy_mode(vdev, dot11_mode);
69 if (QDF_IS_STATUS_ERROR(status))
70 return QDF_STATUS_E_FAILURE;
71
72 mlme_obj->mgmt.chainmask_info.num_rx_chain = 2;
73 mlme_obj->mgmt.chainmask_info.num_tx_chain = 2;
74
75 status = wma_vdev_pre_start(config->vdev_id, false);
76 if (status != QDF_STATUS_SUCCESS)
77 return status;
78
79 status = vdev_mgr_start_send(mlme_obj, false);
80
81 return status;
82 }
83
wma_ocb_register_callbacks(tp_wma_handle wma_handle)84 QDF_STATUS wma_ocb_register_callbacks(tp_wma_handle wma_handle)
85 {
86 ucfg_ocb_register_vdev_start(wma_handle->pdev, wma_start_ocb_vdev);
87
88 return QDF_STATUS_SUCCESS;
89 }
90