2 ******************************************************************************
6 * @brief VHT Beamformer function definitions
8 * Copyright (C) ESWIN 2015-2020
10 ******************************************************************************
15 ******************************************************************************
18 #include <linux/slab.h>
19 #include "ecrnx_bfmer.h"
22 * FUNCTION DEFINITIONS
23 ******************************************************************************
26 int ecrnx_bfmer_report_add(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *ecrnx_sta,
30 struct ecrnx_bfmer_report *bfm_report ;
37 /* Allocate a structure that will contain the beamforming report */
38 bfm_report = kmalloc(sizeof(*bfm_report) + length, flags);
41 /* Check report allocation */
43 /* Do not use beamforming */
47 /* Store report length */
48 bfm_report->length = length;
51 * Need to provide a Virtual Address to the MAC so that it can
52 * upload the received Beamforming Report in driver memory
54 bfm_report->dma_addr = dma_map_single(ecrnx_hw->dev, &bfm_report->report[0],
55 length, DMA_FROM_DEVICE);
57 /* Check DMA mapping result */
58 if (dma_mapping_error(ecrnx_hw->dev, bfm_report->dma_addr)) {
59 /* Free allocated report */
65 /* Store report structure */
66 ecrnx_sta->bfm_report = bfm_report;
71 void ecrnx_bfmer_report_del(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *ecrnx_sta)
73 /* Verify if a report has been allocated */
74 if (ecrnx_sta->bfm_report) {
75 struct ecrnx_bfmer_report *bfm_report = ecrnx_sta->bfm_report;
77 /* Unmap DMA region */
78 dma_unmap_single(ecrnx_hw->dev, bfm_report->dma_addr,
79 bfm_report->length, DMA_BIDIRECTIONAL);
81 /* Free allocated report structure and clean the pointer */
83 ecrnx_sta->bfm_report = NULL;
87 #ifdef CONFIG_ECRNX_FULLMAC
88 u8 ecrnx_bfmer_get_rx_nss(const struct ieee80211_vht_cap *vht_capa)
92 u16 rx_mcs_map = le16_to_cpu(vht_capa->supp_mcs.rx_mcs_map);
94 for (i = 7; i >= 0; i--) {
95 u8 mcs = (rx_mcs_map >> (2 * i)) & 3;
97 if (mcs != IEEE80211_VHT_MCS_NOT_SUPPORTED) {
105 #endif /* CONFIG_ECRNX_FULLMAC */