1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-14 09:55:31 +00:00
rtl8812au/hal/phydm/phydm_beamforming.c

2052 lines
64 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
2018-08-24 20:52:34 +00:00
* Copyright(c) 2007 - 2017 Realtek Corporation.
2018-06-22 16:48:32 +00:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2018-08-24 20:52:34 +00:00
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2018-06-22 16:48:32 +00:00
* more details.
*
2018-08-24 20:52:34 +00:00
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
2018-06-22 16:48:32 +00:00
*****************************************************************************/
#include "mp_precomp.h"
#include "phydm_precomp.h"
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
#if WPP_SOFTWARE_TRACE
#include "phydm_beamforming.tmh"
#endif
#endif
#if (BEAMFORMING_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
void
phydm_get_txbf_device_num(
void *dm_void,
u8 macid
)
{
#if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY)) /*For BDC*/
#if (DM_ODM_SUPPORT_TYPE == ODM_AP)
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct cmn_sta_info *sta = dm->phydm_sta_info[macid];
struct bf_cmn_info *bf = NULL;
struct _BF_DIV_COEX_ *dm_bdc_table = &dm->dm_bdc_table;
u8 act_as_bfer = 0;
u8 act_as_bfee = 0;
if (is_sta_active(sta)) {
bf = &(sta->bf_info);
} else {
PHYDM_DBG(dm, DBG_TXBF, "[Warning] %s invalid sta_info\n", __func__);
return;
}
if (sta->support_wireless_set & WIRELESS_VHT) {
if (bf->vht_beamform_cap & BEAMFORMING_VHT_BEAMFORMEE_ENABLE)
act_as_bfer = 1;
if (bf->vht_beamform_cap & BEAMFORMING_VHT_BEAMFORMER_ENABLE)
act_as_bfee = 1;
} else if (sta->support_wireless_set & WIRELESS_HT) {
if (bf->ht_beamform_cap & BEAMFORMING_HT_BEAMFORMEE_ENABLE)
act_as_bfer = 1;
if (bf->ht_beamform_cap & BEAMFORMING_HT_BEAMFORMER_ENABLE)
act_as_bfee = 1;
}
if (act_as_bfer)) { /* Our Device act as BFer */
dm_bdc_table->w_bfee_client[macid] = true;
dm_bdc_table->num_txbfee_client++;
} else
dm_bdc_table->w_bfee_client[macid] = false;
if (act_as_bfee)) { /* Our Device act as BFee */
dm_bdc_table->w_bfer_client[macid] = true;
dm_bdc_table->num_txbfer_client++;
} else
dm_bdc_table->w_bfer_client[macid] = false;
#endif
#endif
}
2018-06-22 16:48:32 +00:00
struct _RT_BEAMFORM_STAINFO *
phydm_sta_info_init(
2018-08-24 20:52:34 +00:00
struct dm_struct *dm,
2018-06-22 16:48:32 +00:00
u16 sta_idx
)
{
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_BEAMFORM_STAINFO *entry = &beam_info->beamform_sta_info;
struct sta_info *sta = dm->odm_sta_info[sta_idx];
struct cmn_sta_info *cmn_sta = dm->phydm_sta_info[sta_idx];
//void *adapter = dm->adapter;
PADAPTER adapter = (PADAPTER)dm->adapter;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
PMGNT_INFO p_MgntInfo = &((adapter)->MgntInfo);
2018-06-22 16:48:32 +00:00
PRT_HIGH_THROUGHPUT p_ht_info = GET_HT_INFO(p_MgntInfo);
PRT_VERY_HIGH_THROUGHPUT p_vht_info = GET_VHT_INFO(p_MgntInfo);
2018-08-24 20:52:34 +00:00
#endif
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!is_sta_active(cmn_sta)) {
PHYDM_DBG(dm, DBG_TXBF, "%s => sta_info(mac_id:%d) failed\n", __func__, sta_idx);
#if (DM_ODM_SUPPORT_TYPE == ODM_CE)
rtw_warn_on(1);
#endif
return entry;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
odm_move_memory(dm, (PVOID)(entry->my_mac_addr), (PVOID)(adapter->CurrentAddress), 6);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
odm_move_memory(dm, entry->my_mac_addr, adapter_mac_addr(sta->padapter), 6);
#endif
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->aid = cmn_sta->aid;
entry->ra = cmn_sta->mac_addr;
entry->mac_id = cmn_sta->mac_id;
entry->bw = cmn_sta->bw_mode;
entry->cur_beamform = cmn_sta->bf_info.ht_beamform_cap;
entry->ht_beamform_cap = cmn_sta->bf_info.ht_beamform_cap;
#if ODM_IC_11AC_SERIES_SUPPORT
if (cmn_sta->support_wireless_set & WIRELESS_VHT) {
entry->cur_beamform_vht = cmn_sta->bf_info.vht_beamform_cap;
entry->vht_beamform_cap = cmn_sta->bf_info.vht_beamform_cap;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
#endif
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) /*To Be Removed */
entry->ht_beamform_cap = p_ht_info->HtBeamformCap; /*To Be Removed*/
entry->vht_beamform_cap = p_vht_info->VhtBeamformCap; /*To Be Removed*/
if (sta_idx == 0) { /*client mode*/
#if ODM_IC_11AC_SERIES_SUPPORT
if (cmn_sta->support_wireless_set & WIRELESS_VHT)
entry->cur_beamform_vht = p_vht_info->VhtCurBeamform;
#endif
2018-06-22 16:48:32 +00:00
}
#endif
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "wireless_set = 0x%x, staidx = %d\n", cmn_sta->support_wireless_set, sta_idx);
PHYDM_DBG(dm, DBG_TXBF, "entry->cur_beamform = 0x%x, entry->cur_beamform_vht = 0x%x\n", entry->cur_beamform, entry->cur_beamform_vht);
return entry;
2018-06-22 16:48:32 +00:00
}
void phydm_sta_info_update(
2018-08-24 20:52:34 +00:00
struct dm_struct *dm,
2018-06-22 16:48:32 +00:00
u16 sta_idx,
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *beamform_entry
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct cmn_sta_info *sta = dm->phydm_sta_info[sta_idx];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!is_sta_active(sta))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
sta->bf_info.p_aid = beamform_entry->p_aid;
sta->bf_info.g_id = beamform_entry->g_id;
2018-06-22 16:48:32 +00:00
}
struct _RT_BEAMFORMEE_ENTRY *
phydm_beamforming_get_bfee_entry_by_addr(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_used && (eq_mac_addr(RA, beam_info->beamformee_entry[i].mac_addr))) {
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
return &beam_info->beamformee_entry[i];
2018-06-22 16:48:32 +00:00
}
}
return NULL;
}
struct _RT_BEAMFORMER_ENTRY *
phydm_beamforming_get_bfer_entry_by_addr(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *TA,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMER_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformer_entry[i].is_used && (eq_mac_addr(TA, beam_info->beamformer_entry[i].mac_addr))) {
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
return &beam_info->beamformer_entry[i];
2018-06-22 16:48:32 +00:00
}
}
return NULL;
}
struct _RT_BEAMFORMEE_ENTRY *
phydm_beamforming_get_entry_by_mac_id(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 mac_id,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_used && (mac_id == beam_info->beamformee_entry[i].mac_id)) {
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
return &beam_info->beamformee_entry[i];
2018-06-22 16:48:32 +00:00
}
}
return NULL;
}
enum beamforming_cap
phydm_beamforming_get_entry_beam_cap_by_mac_id(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 mac_id
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_entry_cap = BEAMFORMING_CAP_NONE;
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_used && (mac_id == beam_info->beamformee_entry[i].mac_id)) {
beamform_entry_cap = beam_info->beamformee_entry[i].beamform_entry_cap;
2018-06-22 16:48:32 +00:00
i = BEAMFORMEE_ENTRY_NUM;
}
}
return beamform_entry_cap;
}
struct _RT_BEAMFORMEE_ENTRY *
phydm_beamforming_get_free_bfee_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_used == false) {
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
return &beam_info->beamformee_entry[i];
2018-06-22 16:48:32 +00:00
}
}
return NULL;
}
struct _RT_BEAMFORMER_ENTRY *
phydm_beamforming_get_free_bfer_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 i = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s ===>\n", __func__);
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMER_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformer_entry[i].is_used == false) {
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
return &beam_info->beamformer_entry[i];
2018-06-22 16:48:32 +00:00
}
}
return NULL;
}
/*
* Description: Get the first entry index of MU Beamformee.
*
* Return value: index of the first MU sta.
*
* 2015.05.25. Created by tynli.
*
*/
u8
phydm_beamforming_get_first_mu_bfee_entry_idx(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 idx = 0xFF;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
boolean is_found = false;
for (idx = 0; idx < BEAMFORMEE_ENTRY_NUM; idx++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[idx].is_used && beam_info->beamformee_entry[idx].is_mu_sta) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] idx=%d!\n", __func__, idx);
2018-06-22 16:48:32 +00:00
is_found = true;
break;
}
}
if (!is_found)
idx = 0xFF;
return idx;
}
/*Add SU BFee and MU BFee*/
struct _RT_BEAMFORMEE_ENTRY *
beamforming_add_bfee_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORM_STAINFO *sta,
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_cap,
u8 num_of_sounding_dim,
u8 comp_steering_num_of_bfer,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMEE_ENTRY *entry = phydm_beamforming_get_free_bfee_entry(dm, idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (entry != NULL) {
entry->is_used = true;
entry->aid = sta->aid;
entry->mac_id = sta->mac_id;
entry->sound_bw = sta->bw;
odm_move_memory(dm, entry->my_mac_addr, sta->my_mac_addr, 6);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (phydm_acting_determine(dm, phydm_acting_as_ap)) {
2018-06-22 16:48:32 +00:00
/*BSSID[44:47] xor BSSID[40:43]*/
2018-08-24 20:52:34 +00:00
u16 bssid = ((sta->my_mac_addr[5] & 0xf0) >> 4) ^ (sta->my_mac_addr[5] & 0xf);
2018-06-22 16:48:32 +00:00
/*(dec(A) + dec(B)*32) mod 512*/
2018-08-24 20:52:34 +00:00
entry->p_aid = (sta->aid + bssid * 32) & 0x1ff;
entry->g_id = 63;
PHYDM_DBG(dm, DBG_TXBF, "%s: BFee P_AID addressed to STA=%d\n", __func__, entry->p_aid);
} else if (phydm_acting_determine(dm, phydm_acting_as_ibss)) {
2018-06-22 16:48:32 +00:00
/*ad hoc mode*/
2018-08-24 20:52:34 +00:00
entry->p_aid = 0;
entry->g_id = 63;
PHYDM_DBG(dm, DBG_TXBF, "%s: BFee P_AID as IBSS=%d\n", __func__, entry->p_aid);
2018-06-22 16:48:32 +00:00
} else {
/*client mode*/
2018-08-24 20:52:34 +00:00
entry->p_aid = sta->ra[5];
2018-06-22 16:48:32 +00:00
/*BSSID[39:47]*/
2018-08-24 20:52:34 +00:00
entry->p_aid = (entry->p_aid << 1) | (sta->ra[4] >> 7);
entry->g_id = 0;
PHYDM_DBG(dm, DBG_TXBF, "%s: BFee P_AID addressed to AP=0x%X\n", __func__, entry->p_aid);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
cp_mac_addr(entry->mac_addr, sta->ra);
entry->is_txbf = false;
entry->is_sound = false;
entry->sound_period = 400;
entry->beamform_entry_cap = beamform_cap;
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
/* entry->log_seq = 0xff; Move to beamforming_add_bfer_entry*/
/* entry->log_retry_cnt = 0; Move to beamforming_add_bfer_entry*/
/* entry->LogSuccessCnt = 0; Move to beamforming_add_bfer_entry*/
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->log_status_fail_cnt = 0;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->num_of_sounding_dim = num_of_sounding_dim;
entry->comp_steering_num_of_bfer = comp_steering_num_of_bfer;
2018-06-22 16:48:32 +00:00
if (beamform_cap & BEAMFORMER_CAP_VHT_MU) {
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformee_mu_cnt += 1;
entry->is_mu_sta = true;
dm->beamforming_info.first_mu_bfee_index = phydm_beamforming_get_first_mu_bfee_entry_idx(dm);
2018-06-22 16:48:32 +00:00
} else if (beamform_cap & (BEAMFORMER_CAP_VHT_SU | BEAMFORMER_CAP_HT_EXPLICIT)) {
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformee_su_cnt += 1;
entry->is_mu_sta = false;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
return entry;
2018-06-22 16:48:32 +00:00
} else
return NULL;
}
/*Add SU BFee and MU BFer*/
struct _RT_BEAMFORMER_ENTRY *
beamforming_add_bfer_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORM_STAINFO *sta,
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_cap,
u8 num_of_sounding_dim,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMER_ENTRY *entry = phydm_beamforming_get_free_bfer_entry(dm, idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (entry != NULL) {
entry->is_used = true;
odm_move_memory(dm, entry->my_mac_addr, sta->my_mac_addr, 6);
if (phydm_acting_determine(dm, phydm_acting_as_ap)) {
2018-06-22 16:48:32 +00:00
/*BSSID[44:47] xor BSSID[40:43]*/
2018-08-24 20:52:34 +00:00
u16 bssid = ((sta->my_mac_addr[5] & 0xf0) >> 4) ^ (sta->my_mac_addr[5] & 0xf);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->p_aid = (sta->aid + bssid * 32) & 0x1ff;
entry->g_id = 63;
2018-06-22 16:48:32 +00:00
/*(dec(A) + dec(B)*32) mod 512*/
2018-08-24 20:52:34 +00:00
} else if (phydm_acting_determine(dm, phydm_acting_as_ibss)) {
entry->p_aid = 0;
entry->g_id = 63;
2018-06-22 16:48:32 +00:00
} else {
2018-08-24 20:52:34 +00:00
entry->p_aid = sta->ra[5];
2018-06-22 16:48:32 +00:00
/*BSSID[39:47]*/
2018-08-24 20:52:34 +00:00
entry->p_aid = (entry->p_aid << 1) | (sta->ra[4] >> 7);
entry->g_id = 0;
PHYDM_DBG(dm, DBG_TXBF, "%s: P_AID addressed to AP=0x%X\n", __func__, entry->p_aid);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
cp_mac_addr(entry->mac_addr, sta->ra);
entry->beamform_entry_cap = beamform_cap;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->pre_log_seq = 0; /*Modified by Jeffery @2015-04-13*/
entry->log_seq = 0; /*Modified by Jeffery @2014-10-29*/
entry->log_retry_cnt = 0; /*Modified by Jeffery @2014-10-29*/
entry->log_success = 0; /*log_success is NOT needed to be accumulated, so LogSuccessCnt->log_success, 2015-04-13, Jeffery*/
entry->clock_reset_times = 0; /*Modified by Jeffery @2015-04-13*/
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->num_of_sounding_dim = num_of_sounding_dim;
2018-06-22 16:48:32 +00:00
if (beamform_cap & BEAMFORMEE_CAP_VHT_MU) {
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformer_mu_cnt += 1;
entry->is_mu_ap = true;
entry->aid = sta->aid;
2018-06-22 16:48:32 +00:00
} else if (beamform_cap & (BEAMFORMEE_CAP_VHT_SU | BEAMFORMEE_CAP_HT_EXPLICIT)) {
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformer_su_cnt += 1;
entry->is_mu_ap = false;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
return entry;
2018-06-22 16:48:32 +00:00
} else
return NULL;
}
#if 0
boolean
beamforming_remove_entry(
2018-08-24 20:52:34 +00:00
void *adapter,
2018-06-22 16:48:32 +00:00
u8 *RA,
u8 *idx
)
{
2018-08-24 20:52:34 +00:00
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));
struct dm_struct *dm = &hal_data->DM_OutSrc;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMER_ENTRY *bfer_entry = phydm_beamforming_get_bfer_entry_by_addr(dm, RA, idx);
struct _RT_BEAMFORMEE_ENTRY *entry = phydm_beamforming_get_bfee_entry_by_addr(dm, RA, idx);
2018-06-22 16:48:32 +00:00
boolean ret = false;
RT_DISP(FBEAM, FBEAM_FUN, ("[Beamforming]@%s Start!\n", __func__));
2018-08-24 20:52:34 +00:00
RT_DISP(FBEAM, FBEAM_FUN, ("[Beamforming]@%s, bfer_entry=0x%x\n", __func__, bfer_entry));
RT_DISP(FBEAM, FBEAM_FUN, ("[Beamforming]@%s, entry=0x%x\n", __func__, entry));
if (entry != NULL) {
entry->is_used = false;
entry->beamform_entry_cap = BEAMFORMING_CAP_NONE;
/*entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;*/
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
ret = true;
}
2018-08-24 20:52:34 +00:00
if (bfer_entry != NULL) {
bfer_entry->is_used = false;
bfer_entry->beamform_entry_cap = BEAMFORMING_CAP_NONE;
2018-06-22 16:48:32 +00:00
ret = true;
}
return ret;
}
#endif
/* Used for beamforming_start_v1 */
void
phydm_beamforming_ndpa_rate(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
enum channel_width BW,
u8 rate
)
{
u16 ndpa_rate = rate;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
if (ndpa_rate == 0) {
2018-08-24 20:52:34 +00:00
if (dm->rssi_min > 30) /* link RSSI > 30% */
2018-06-22 16:48:32 +00:00
ndpa_rate = ODM_RATE24M;
else
ndpa_rate = ODM_RATE6M;
}
if (ndpa_rate < ODM_RATEMCS0)
BW = (enum channel_width)CHANNEL_WIDTH_20;
ndpa_rate = (ndpa_rate << 8) | BW;
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_RATE, (u8 *)&ndpa_rate);
2018-06-22 16:48:32 +00:00
}
/* Used for beamforming_start_sw and beamforming_start_fw */
void
phydm_beamforming_dym_ndpa_rate(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
u16 ndpa_rate = ODM_RATE6M, BW;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
ndpa_rate = ODM_RATE6M;
BW = CHANNEL_WIDTH_20;
ndpa_rate = ndpa_rate << 8 | BW;
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_RATE, (u8 *)&ndpa_rate);
PHYDM_DBG(dm, DBG_TXBF, "%s End, NDPA rate = 0x%X\n", __func__, ndpa_rate);
2018-06-22 16:48:32 +00:00
}
/*
* SW Sounding : SW Timer unit 1ms
* HW Timer unit (1/32000) s 32k is clock.
* FW Sounding : FW Timer unit 10ms
*/
void
beamforming_dym_period(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 status
)
{
u8 idx;
boolean is_change_period = false;
u16 sound_period_sw, sound_period_fw;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *beamform_entry;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_SOUNDING_INFO *sound_info = &beam_info->sounding_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *entry = &beam_info->beamformee_entry[beam_info->beamformee_cur_idx];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] Start!\n", __func__);
2018-06-22 16:48:32 +00:00
/* 3 TODO per-client throughput caculation. */
2018-08-24 20:52:34 +00:00
if ((*dm->current_tx_tp + *dm->current_rx_tp > 2) && ((entry->log_status_fail_cnt <= 20) || status)) {
2018-06-22 16:48:32 +00:00
sound_period_sw = 40; /* 40ms */
sound_period_fw = 40; /* From H2C cmd, unit = 10ms */
} else {
sound_period_sw = 4000;/* 4s */
sound_period_fw = 400;
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s]sound_period_sw=%d, sound_period_fw=%d\n", __func__, sound_period_sw, sound_period_fw);
2018-06-22 16:48:32 +00:00
for (idx = 0; idx < BEAMFORMEE_ENTRY_NUM; idx++) {
2018-08-24 20:52:34 +00:00
beamform_entry = beam_info->beamformee_entry + idx;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beamform_entry->default_csi_cnt > 20) {
2018-06-22 16:48:32 +00:00
/*Modified by David*/
sound_period_sw = 4000;
sound_period_fw = 400;
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] period = %d\n", __func__, sound_period_sw);
if ((beamform_entry->beamform_entry_cap & (BEAMFORMER_CAP_HT_EXPLICIT | BEAMFORMER_CAP_VHT_SU)) == 0)
continue;
if (sound_info->sound_mode == SOUNDING_FW_VHT_TIMER || sound_info->sound_mode == SOUNDING_FW_HT_TIMER) {
if (beamform_entry->sound_period != sound_period_fw) {
beamform_entry->sound_period = sound_period_fw;
is_change_period = true; /*Only FW sounding need to send H2C packet to change sound period. */
}
} else if (beamform_entry->sound_period != sound_period_sw)
beamform_entry->sound_period = sound_period_sw;
2018-06-22 16:48:32 +00:00
}
if (is_change_period)
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_FW_NDPA, (u8 *)&idx);
2018-06-22 16:48:32 +00:00
}
boolean
beamforming_send_ht_ndpa_packet(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA,
enum channel_width BW,
u8 q_idx
)
{
boolean ret = true;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
if (q_idx == BEACON_QUEUE)
2018-08-24 20:52:34 +00:00
ret = send_fw_ht_ndpa_packet(dm, RA, BW);
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
ret = send_sw_ht_ndpa_packet(dm, RA, BW);
2018-06-22 16:48:32 +00:00
return ret;
}
boolean
beamforming_send_vht_ndpa_packet(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA,
u16 AID,
enum channel_width BW,
u8 q_idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
boolean ret = true;
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_GET_TX_RATE, NULL);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if ((beam_info->tx_bf_data_rate >= ODM_RATEVHTSS3MCS7) && (beam_info->tx_bf_data_rate <= ODM_RATEVHTSS3MCS9) && (!beam_info->snding3ss))
PHYDM_DBG(dm, DBG_TXBF, "@%s: 3SS VHT 789 don't sounding\n", __func__);
2018-06-22 16:48:32 +00:00
else {
if (q_idx == BEACON_QUEUE) /* Send to reserved page => FW NDPA */
2018-08-24 20:52:34 +00:00
ret = send_fw_vht_ndpa_packet(dm, RA, AID, BW);
2018-06-22 16:48:32 +00:00
else {
#ifdef SUPPORT_MU_BF
#if (SUPPORT_MU_BF == 1)
2018-08-24 20:52:34 +00:00
beam_info->is_mu_sounding = true;
ret = send_sw_vht_mu_ndpa_packet(dm, BW);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
beam_info->is_mu_sounding = false;
ret = send_sw_vht_ndpa_packet(dm, RA, AID, BW);
2018-06-22 16:48:32 +00:00
#endif
#else
2018-08-24 20:52:34 +00:00
beam_info->is_mu_sounding = false;
ret = send_sw_vht_ndpa_packet(dm, RA, AID, BW);
2018-06-22 16:48:32 +00:00
#endif
}
}
return ret;
}
enum beamforming_notify_state
phydm_beamfomring_is_sounding(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info,
2018-06-22 16:48:32 +00:00
u8 *idx
)
{
enum beamforming_notify_state is_sounding = BEAMFORMING_NOTIFY_NONE;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_OID_INFO beam_oid_info = beam_info->beamforming_oid_info;
struct dm_struct *dm = (struct dm_struct *)dm_void;
u8 i;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
/*if(( Beamforming_GetBeamCap(beam_info) & BEAMFORMER_CAP) == 0)*/
2018-06-22 16:48:32 +00:00
/*is_sounding = BEAMFORMING_NOTIFY_RESET;*/
2018-08-24 20:52:34 +00:00
if (beam_oid_info.sound_oid_mode == sounding_stop_all_timer) {
2018-06-22 16:48:32 +00:00
is_sounding = BEAMFORMING_NOTIFY_RESET;
2018-08-24 20:52:34 +00:00
goto out;
}
2018-06-22 16:48:32 +00:00
for (i = 0 ; i < BEAMFORMEE_ENTRY_NUM ; i++) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "@%s: BFee Entry %d is_used=%d, is_sound=%d\n", __func__, i, beam_info->beamformee_entry[i].is_used, beam_info->beamformee_entry[i].is_sound);
if (beam_info->beamformee_entry[i].is_used && (!beam_info->beamformee_entry[i].is_sound)) {
PHYDM_DBG(dm, DBG_TXBF, "%s: Add BFee entry %d\n", __func__, i);
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_mu_sta)
2018-06-22 16:48:32 +00:00
is_sounding = BEAMFORMEE_NOTIFY_ADD_MU;
else
is_sounding = BEAMFORMEE_NOTIFY_ADD_SU;
}
2018-08-24 20:52:34 +00:00
if ((!beam_info->beamformee_entry[i].is_used) && beam_info->beamformee_entry[i].is_sound) {
PHYDM_DBG(dm, DBG_TXBF, "%s: Delete BFee entry %d\n", __func__, i);
2018-06-22 16:48:32 +00:00
*idx = i;
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_mu_sta)
2018-06-22 16:48:32 +00:00
is_sounding = BEAMFORMEE_NOTIFY_DELETE_MU;
else
is_sounding = BEAMFORMEE_NOTIFY_DELETE_SU;
}
}
2018-08-24 20:52:34 +00:00
out:
PHYDM_DBG(dm, DBG_TXBF, "%s End, is_sounding = %d\n", __func__, is_sounding);
2018-06-22 16:48:32 +00:00
return is_sounding;
}
/* This function is unused */
u8
phydm_beamforming_sounding_idx(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info
2018-06-22 16:48:32 +00:00
)
{
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_OID_INFO beam_oid_info = beam_info->beamforming_oid_info;
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
if (beam_oid_info.sound_oid_mode == SOUNDING_SW_HT_TIMER || beam_oid_info.sound_oid_mode == SOUNDING_SW_VHT_TIMER ||
beam_oid_info.sound_oid_mode == SOUNDING_HW_HT_TIMER || beam_oid_info.sound_oid_mode == SOUNDING_HW_VHT_TIMER)
idx = beam_oid_info.sound_oid_idx;
else {
u8 i;
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_entry[i].is_used && (!beam_info->beamformee_entry[i].is_sound)) {
2018-06-22 16:48:32 +00:00
idx = i;
break;
}
}
}
return idx;
}
enum sounding_mode
phydm_beamforming_sounding_mode(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info,
2018-06-22 16:48:32 +00:00
u8 idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
u8 support_interface = dm->support_interface;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY beam_entry = beam_info->beamformee_entry[idx];
struct _RT_BEAMFORMING_OID_INFO beam_oid_info = beam_info->beamforming_oid_info;
2018-06-22 16:48:32 +00:00
enum sounding_mode mode = beam_oid_info.sound_oid_mode;
if (beam_oid_info.sound_oid_mode == SOUNDING_SW_VHT_TIMER || beam_oid_info.sound_oid_mode == SOUNDING_HW_VHT_TIMER) {
if (beam_entry.beamform_entry_cap & BEAMFORMER_CAP_VHT_SU)
mode = beam_oid_info.sound_oid_mode;
else
mode = sounding_stop_all_timer;
} else if (beam_oid_info.sound_oid_mode == SOUNDING_SW_HT_TIMER || beam_oid_info.sound_oid_mode == SOUNDING_HW_HT_TIMER) {
if (beam_entry.beamform_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT)
mode = beam_oid_info.sound_oid_mode;
else
mode = sounding_stop_all_timer;
} else if (beam_entry.beamform_entry_cap & BEAMFORMER_CAP_VHT_SU) {
2018-08-24 20:52:34 +00:00
if ((support_interface == ODM_ITRF_USB) && !(dm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B)))
2018-06-22 16:48:32 +00:00
mode = SOUNDING_FW_VHT_TIMER;
else
mode = SOUNDING_SW_VHT_TIMER;
} else if (beam_entry.beamform_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT) {
2018-08-24 20:52:34 +00:00
if ((support_interface == ODM_ITRF_USB) && !(dm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B)))
2018-06-22 16:48:32 +00:00
mode = SOUNDING_FW_HT_TIMER;
else
mode = SOUNDING_SW_HT_TIMER;
} else
mode = sounding_stop_all_timer;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] support_interface=%d, mode=%d\n", __func__, support_interface, mode);
2018-06-22 16:48:32 +00:00
return mode;
}
u16
phydm_beamforming_sounding_time(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info,
2018-06-22 16:48:32 +00:00
enum sounding_mode mode,
u8 idx
)
{
u16 sounding_time = 0xffff;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY beam_entry = beam_info->beamformee_entry[idx];
struct _RT_BEAMFORMING_OID_INFO beam_oid_info = beam_info->beamforming_oid_info;
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
if (mode == SOUNDING_HW_HT_TIMER || mode == SOUNDING_HW_VHT_TIMER)
sounding_time = beam_oid_info.sound_oid_period * 32;
else if (mode == SOUNDING_SW_HT_TIMER || mode == SOUNDING_SW_VHT_TIMER)
/*Modified by David*/
sounding_time = beam_entry.sound_period; /*beam_oid_info.sound_oid_period;*/
else
sounding_time = beam_entry.sound_period;
return sounding_time;
}
enum channel_width
phydm_beamforming_sounding_bw(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info,
2018-06-22 16:48:32 +00:00
enum sounding_mode mode,
u8 idx
)
{
enum channel_width sounding_bw = CHANNEL_WIDTH_20;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY beam_entry = beam_info->beamformee_entry[idx];
struct _RT_BEAMFORMING_OID_INFO beam_oid_info = beam_info->beamforming_oid_info;
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
if (mode == SOUNDING_HW_HT_TIMER || mode == SOUNDING_HW_VHT_TIMER)
sounding_bw = beam_oid_info.sound_oid_bw;
else if (mode == SOUNDING_SW_HT_TIMER || mode == SOUNDING_SW_VHT_TIMER)
/*Modified by David*/
sounding_bw = beam_entry.sound_bw; /*beam_oid_info.sound_oid_bw;*/
else
sounding_bw = beam_entry.sound_bw;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s, sounding_bw=0x%X\n", __func__, sounding_bw);
2018-06-22 16:48:32 +00:00
return sounding_bw;
}
boolean
phydm_beamforming_select_beam_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct _RT_SOUNDING_INFO *sound_info = &beam_info->sounding_info;
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
/*entry.is_sound is different between first and latter NDPA, and should not be used as BFee entry selection*/
2018-06-22 16:48:32 +00:00
/*BTW, latter modification should sync to the selection mechanism of AP/ADSL instead of the fixed sound_idx.*/
2018-08-24 20:52:34 +00:00
sound_info->sound_idx = phydm_beamforming_sounding_idx(dm, beam_info);
/*sound_info->sound_idx = 0;*/
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (sound_info->sound_idx < BEAMFORMEE_ENTRY_NUM)
sound_info->sound_mode = phydm_beamforming_sounding_mode(dm, beam_info, sound_info->sound_idx);
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
sound_info->sound_mode = sounding_stop_all_timer;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (sounding_stop_all_timer == sound_info->sound_mode) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] Return because of sounding_stop_all_timer\n", __func__);
2018-06-22 16:48:32 +00:00
return false;
} else {
2018-08-24 20:52:34 +00:00
sound_info->sound_bw = phydm_beamforming_sounding_bw(dm, beam_info, sound_info->sound_mode, sound_info->sound_idx);
sound_info->sound_period = phydm_beamforming_sounding_time(dm, beam_info, sound_info->sound_mode, sound_info->sound_idx);
2018-06-22 16:48:32 +00:00
return true;
}
}
/*SU BFee Entry Only*/
boolean
phydm_beamforming_start_period(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
boolean ret = true;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_SOUNDING_INFO *sound_info = &beam_info->sounding_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
phydm_beamforming_dym_ndpa_rate(dm);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
phydm_beamforming_select_beam_entry(dm, beam_info); /* Modified */
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (sound_info->sound_mode == SOUNDING_SW_VHT_TIMER || sound_info->sound_mode == SOUNDING_SW_HT_TIMER)
odm_set_timer(dm, &beam_info->beamforming_timer, sound_info->sound_period);
else if (sound_info->sound_mode == SOUNDING_HW_VHT_TIMER || sound_info->sound_mode == SOUNDING_HW_HT_TIMER ||
sound_info->sound_mode == SOUNDING_AUTO_VHT_TIMER || sound_info->sound_mode == SOUNDING_AUTO_HT_TIMER) {
2018-06-22 16:48:32 +00:00
HAL_HW_TIMER_TYPE timer_type = HAL_TIMER_TXBF;
2018-08-24 20:52:34 +00:00
u32 val = (sound_info->sound_period | (timer_type << 16));
2018-06-22 16:48:32 +00:00
/* HW timer stop: All IC has the same setting */
2018-08-24 20:52:34 +00:00
phydm_set_hw_reg_handler_interface(dm, HW_VAR_HW_REG_TIMER_STOP, (u8 *)(&timer_type));
/* odm_write_1byte(dm, 0x15F, 0); */
2018-06-22 16:48:32 +00:00
/* HW timer init: All IC has the same setting, but 92E & 8812A only write 2 bytes */
2018-08-24 20:52:34 +00:00
phydm_set_hw_reg_handler_interface(dm, HW_VAR_HW_REG_TIMER_INIT, (u8 *)(&val));
/* odm_write_1byte(dm, 0x164, 1); */
/* odm_write_4byte(dm, 0x15C, val); */
2018-06-22 16:48:32 +00:00
/* HW timer start: All IC has the same setting */
2018-08-24 20:52:34 +00:00
phydm_set_hw_reg_handler_interface(dm, HW_VAR_HW_REG_TIMER_START, (u8 *)(&timer_type));
/* odm_write_1byte(dm, 0x15F, 0x5); */
} else if (sound_info->sound_mode == SOUNDING_FW_VHT_TIMER || sound_info->sound_mode == SOUNDING_FW_HT_TIMER)
ret = beamforming_start_fw(dm, sound_info->sound_idx);
2018-06-22 16:48:32 +00:00
else
ret = false;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] sound_idx=%d, sound_mode=%d, sound_bw=%d, sound_period=%d\n", __func__,
sound_info->sound_idx, sound_info->sound_mode, sound_info->sound_bw, sound_info->sound_period);
2018-06-22 16:48:32 +00:00
return ret;
}
/* Used after beamforming_leave, and will clear the setting of the "already deleted" entry
*SU BFee Entry Only*/
void
phydm_beamforming_end_period_sw(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
/*void *adapter = dm->adapter;*/
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_SOUNDING_INFO *sound_info = &beam_info->sounding_info;
2018-06-22 16:48:32 +00:00
HAL_HW_TIMER_TYPE timer_type = HAL_TIMER_TXBF;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (sound_info->sound_mode == SOUNDING_SW_VHT_TIMER || sound_info->sound_mode == SOUNDING_SW_HT_TIMER)
odm_cancel_timer(dm, &beam_info->beamforming_timer);
else if (sound_info->sound_mode == SOUNDING_HW_VHT_TIMER || sound_info->sound_mode == SOUNDING_HW_HT_TIMER ||
sound_info->sound_mode == SOUNDING_AUTO_VHT_TIMER || sound_info->sound_mode == SOUNDING_AUTO_HT_TIMER)
2018-06-22 16:48:32 +00:00
/*HW timer stop: All IC has the same setting*/
2018-08-24 20:52:34 +00:00
phydm_set_hw_reg_handler_interface(dm, HW_VAR_HW_REG_TIMER_STOP, (u8 *)(&timer_type));
/*odm_write_1byte(dm, 0x15F, 0);*/
2018-06-22 16:48:32 +00:00
}
void
phydm_beamforming_end_period_fw(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 idx = 0;
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_FW_NDPA, (u8 *)&idx);
PHYDM_DBG(dm, DBG_TXBF, "[%s]\n", __func__);
2018-06-22 16:48:32 +00:00
}
/*SU BFee Entry Only*/
void
phydm_beamforming_clear_entry_sw(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
boolean is_delete,
u8 delete_idx
)
{
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *beamform_entry = NULL;
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
if (is_delete) {
if (delete_idx < BEAMFORMEE_ENTRY_NUM) {
2018-08-24 20:52:34 +00:00
beamform_entry = beam_info->beamformee_entry + delete_idx;
if (!((!beamform_entry->is_used) && beamform_entry->is_sound)) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] SW delete_idx is wrong!!!!!\n", __func__);
2018-06-22 16:48:32 +00:00
return;
}
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] SW delete BFee entry %d\n", __func__, delete_idx);
if (beamform_entry->beamform_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSING) {
beamform_entry->is_beamforming_in_progress = false;
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
} else if (beamform_entry->beamform_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) {
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS, (u8 *)&delete_idx);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
beamform_entry->is_sound = false;
return;
}
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
for (idx = 0; idx < BEAMFORMEE_ENTRY_NUM; idx++) {
beamform_entry = beam_info->beamformee_entry + idx;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
/*Used after is_sounding=RESET, and will clear the setting of "ever sounded" entry, which is not necessarily be deleted.*/
/*This function is mainly used in case "beam_oid_info.sound_oid_mode == sounding_stop_all_timer".*/
/*However, setting oid doesn't delete entries (is_used is still true), new entries may fail to be added in.*/
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!beamform_entry->is_sound)
continue;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] SW reset BFee entry %d\n", __func__, idx);
/*
* If End procedure is
* 1. Between (Send NDPA, C2H packet return), reset state to initialized.
* After C2H packet return , status bit will be set to zero.
*
* 2. After C2H packet, then reset state to initialized and clear status bit.
*/
if (beamform_entry->beamform_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSING)
phydm_beamforming_end_sw(dm, 0);
else if (beamform_entry->beamform_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) {
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS, (u8 *)&idx);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
beamform_entry->is_sound = false;
2018-06-22 16:48:32 +00:00
}
}
void
phydm_beamforming_clear_entry_fw(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
boolean is_delete,
u8 delete_idx
)
{
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *beamform_entry = NULL;
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
if (is_delete) {
if (delete_idx < BEAMFORMEE_ENTRY_NUM) {
2018-08-24 20:52:34 +00:00
beamform_entry = beam_info->beamformee_entry + delete_idx;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!((!beamform_entry->is_used) && beamform_entry->is_sound)) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] FW delete_idx is wrong!!!!!\n", __func__);
2018-06-22 16:48:32 +00:00
return;
}
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: FW delete BFee entry %d\n", __func__, delete_idx);
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
beamform_entry->is_sound = false;
2018-06-22 16:48:32 +00:00
} else {
for (idx = 0; idx < BEAMFORMEE_ENTRY_NUM; idx++) {
2018-08-24 20:52:34 +00:00
beamform_entry = beam_info->beamformee_entry + idx;
2018-06-22 16:48:32 +00:00
/*Used after is_sounding=RESET, and will clear the setting of "ever sounded" entry, which is not necessarily be deleted.*/
/*This function is mainly used in case "beam_oid_info.sound_oid_mode == sounding_stop_all_timer".*/
/*However, setting oid doesn't delete entries (is_used is still true), new entries may fail to be added in.*/
2018-08-24 20:52:34 +00:00
if (beamform_entry->is_sound) {
PHYDM_DBG(dm, DBG_TXBF, "[%s]FW reset BFee entry %d\n", __func__, idx);
2018-06-22 16:48:32 +00:00
/*
* If End procedure is
* 1. Between (Send NDPA, C2H packet return), reset state to initialized.
* After C2H packet return , status bit will be set to zero.
*
* 2. After C2H packet, then reset state to initialized and clear status bit.
*/
2018-08-24 20:52:34 +00:00
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;
beamform_entry->is_sound = false;
2018-06-22 16:48:32 +00:00
}
}
}
}
/*
* Called :
* 1. Add and delete entry : beamforming_enter/beamforming_leave
* 2. FW trigger : Beamforming_SetTxBFen
* 3. Set OID_RT_BEAMFORMING_PERIOD : beamforming_control_v2
*/
void
phydm_beamforming_notify(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
u8 idx = BEAMFORMEE_ENTRY_NUM;
enum beamforming_notify_state is_sounding = BEAMFORMING_NOTIFY_NONE;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_SOUNDING_INFO *sound_info = &beam_info->sounding_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
is_sounding = phydm_beamfomring_is_sounding(dm, beam_info, &idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s, Before notify, is_sounding=%d, idx=%d\n", __func__, is_sounding, idx);
PHYDM_DBG(dm, DBG_TXBF, "%s: beam_info->beamformee_su_cnt = %d\n", __func__, beam_info->beamformee_su_cnt);
2018-06-22 16:48:32 +00:00
switch (is_sounding) {
case BEAMFORMEE_NOTIFY_ADD_SU:
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: BEAMFORMEE_NOTIFY_ADD_SU\n", __func__);
phydm_beamforming_start_period(dm);
2018-06-22 16:48:32 +00:00
break;
case BEAMFORMEE_NOTIFY_DELETE_SU:
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: BEAMFORMEE_NOTIFY_DELETE_SU\n", __func__);
if (sound_info->sound_mode == SOUNDING_FW_HT_TIMER || sound_info->sound_mode == SOUNDING_FW_VHT_TIMER) {
phydm_beamforming_clear_entry_fw(dm, true, idx);
if (beam_info->beamformee_su_cnt == 0) { /* For 2->1 entry, we should not cancel SW timer */
phydm_beamforming_end_period_fw(dm);
PHYDM_DBG(dm, DBG_TXBF, "%s: No BFee left\n", __func__);
2018-06-22 16:48:32 +00:00
}
} else {
2018-08-24 20:52:34 +00:00
phydm_beamforming_clear_entry_sw(dm, true, idx);
if (beam_info->beamformee_su_cnt == 0) { /* For 2->1 entry, we should not cancel SW timer */
phydm_beamforming_end_period_sw(dm);
PHYDM_DBG(dm, DBG_TXBF, "%s: No BFee left\n", __func__);
2018-06-22 16:48:32 +00:00
}
}
break;
case BEAMFORMEE_NOTIFY_ADD_MU:
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: BEAMFORMEE_NOTIFY_ADD_MU\n", __func__);
if (beam_info->beamformee_mu_cnt == 2) {
/*if (sound_info->sound_mode == SOUNDING_SW_VHT_TIMER || sound_info->sound_mode == SOUNDING_SW_HT_TIMER)
odm_set_timer(dm, &beam_info->beamforming_timer, sound_info->sound_period);*/
odm_set_timer(dm, &beam_info->beamforming_timer, 1000); /*Do MU sounding every 1sec*/
} else {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: Less or larger than 2 MU STAs, not to set timer\n", __func__);
}
2018-06-22 16:48:32 +00:00
break;
case BEAMFORMEE_NOTIFY_DELETE_MU:
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: BEAMFORMEE_NOTIFY_DELETE_MU\n", __func__);
if (beam_info->beamformee_mu_cnt == 1) {
/*if (sound_info->sound_mode == SOUNDING_SW_VHT_TIMER || sound_info->sound_mode == SOUNDING_SW_HT_TIMER)*/{
odm_cancel_timer(dm, &beam_info->beamforming_timer);
PHYDM_DBG(dm, DBG_TXBF, "%s: Less than 2 MU STAs, stop sounding\n", __func__);
2018-06-22 16:48:32 +00:00
}
}
break;
case BEAMFORMING_NOTIFY_RESET:
2018-08-24 20:52:34 +00:00
if (sound_info->sound_mode == SOUNDING_FW_HT_TIMER || sound_info->sound_mode == SOUNDING_FW_VHT_TIMER) {
phydm_beamforming_clear_entry_fw(dm, false, idx);
phydm_beamforming_end_period_fw(dm);
2018-06-22 16:48:32 +00:00
} else {
2018-08-24 20:52:34 +00:00
phydm_beamforming_clear_entry_sw(dm, false, idx);
phydm_beamforming_end_period_sw(dm);
2018-06-22 16:48:32 +00:00
}
break;
default:
break;
}
}
boolean
beamforming_init_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u16 sta_idx,
u8 *bfer_bfee_idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct cmn_sta_info *cmn_sta = dm->phydm_sta_info[sta_idx];
struct _RT_BEAMFORMEE_ENTRY *beamform_entry = NULL;
struct _RT_BEAMFORMER_ENTRY *beamformer_entry = NULL;
struct _RT_BEAMFORM_STAINFO *sta = NULL;
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_cap = BEAMFORMING_CAP_NONE;
u8 bfer_idx = 0xF, bfee_idx = 0xF;
u8 num_of_sounding_dim = 0, comp_steering_num_of_bfer = 0;
2018-08-24 20:52:34 +00:00
sta = phydm_sta_info_init(dm, sta_idx);
2018-06-22 16:48:32 +00:00
/*The current setting does not support Beaforming*/
2018-08-24 20:52:34 +00:00
if (BEAMFORMING_CAP_NONE == sta->ht_beamform_cap && BEAMFORMING_CAP_NONE == sta->vht_beamform_cap) {
PHYDM_DBG(dm, DBG_TXBF, "The configuration disabled Beamforming! Skip...\n");
2018-06-22 16:48:32 +00:00
return false;
}
2018-08-24 20:52:34 +00:00
if (!(cmn_sta->support_wireless_set & (WIRELESS_VHT | WIRELESS_HT)))
2018-06-22 16:48:32 +00:00
return false;
else {
2018-08-24 20:52:34 +00:00
if (cmn_sta->support_wireless_set & WIRELESS_HT) {/*HT*/
if (TEST_FLAG(sta->cur_beamform, BEAMFORMING_HT_BEAMFORMER_ENABLE)) {/*We are Beamformee because the STA is Beamformer*/
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMEE_CAP_HT_EXPLICIT);
num_of_sounding_dim = (sta->cur_beamform & BEAMFORMING_HT_BEAMFORMEE_CHNL_EST_CAP) >> 6;
2018-06-22 16:48:32 +00:00
}
/*We are Beamformer because the STA is Beamformee*/
2018-08-24 20:52:34 +00:00
if (TEST_FLAG(sta->cur_beamform, BEAMFORMING_HT_BEAMFORMEE_ENABLE) ||
TEST_FLAG(sta->ht_beamform_cap, BEAMFORMING_HT_BEAMFORMER_TEST)) {
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMER_CAP_HT_EXPLICIT);
comp_steering_num_of_bfer = (sta->cur_beamform & BEAMFORMING_HT_BEAMFORMER_STEER_NUM) >> 4;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] HT cur_beamform=0x%X, beamform_cap=0x%X\n", __func__, sta->cur_beamform, beamform_cap);
PHYDM_DBG(dm, DBG_TXBF, "[%s] HT num_of_sounding_dim=%d, comp_steering_num_of_bfer=%d\n", __func__, num_of_sounding_dim, comp_steering_num_of_bfer);
2018-06-22 16:48:32 +00:00
}
#if (ODM_IC_11AC_SERIES_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (cmn_sta->support_wireless_set & WIRELESS_VHT) { /*VHT*/
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
/* We are Beamformee because the STA is SU Beamformer*/
if (TEST_FLAG(sta->cur_beamform_vht, BEAMFORMING_VHT_BEAMFORMER_ENABLE)) {
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMEE_CAP_VHT_SU);
num_of_sounding_dim = (sta->cur_beamform_vht & BEAMFORMING_VHT_BEAMFORMEE_SOUND_DIM) >> 12;
}
/* We are Beamformer because the STA is SU Beamformee*/
if (TEST_FLAG(sta->cur_beamform_vht, BEAMFORMING_VHT_BEAMFORMEE_ENABLE) ||
TEST_FLAG(sta->vht_beamform_cap, BEAMFORMING_VHT_BEAMFORMER_TEST)) {
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMER_CAP_VHT_SU);
comp_steering_num_of_bfer = (sta->cur_beamform_vht & BEAMFORMING_VHT_BEAMFORMER_STS_CAP) >> 8;
}
/* We are Beamformee because the STA is MU Beamformer*/
if (TEST_FLAG(sta->cur_beamform_vht, BEAMFORMING_VHT_MU_MIMO_AP_ENABLE)) {
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMEE_CAP_VHT_MU);
num_of_sounding_dim = (sta->cur_beamform_vht & BEAMFORMING_VHT_BEAMFORMEE_SOUND_DIM) >> 12;
}
/* We are Beamformer because the STA is MU Beamformee*/
if (phydm_acting_determine(dm, phydm_acting_as_ap)) { /* Only AP mode supports to act an MU beamformer */
if (TEST_FLAG(sta->cur_beamform_vht, BEAMFORMING_VHT_MU_MIMO_STA_ENABLE) ||
TEST_FLAG(sta->vht_beamform_cap, BEAMFORMING_VHT_BEAMFORMER_TEST)) {
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMER_CAP_VHT_MU);
comp_steering_num_of_bfer = (sta->cur_beamform_vht & BEAMFORMING_VHT_BEAMFORMER_STS_CAP) >> 8;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
}
PHYDM_DBG(dm, DBG_TXBF, "[%s]VHT cur_beamform_vht=0x%X, beamform_cap=0x%X\n", __func__, sta->cur_beamform_vht, beamform_cap);
PHYDM_DBG(dm, DBG_TXBF, "[%s]VHT num_of_sounding_dim=0x%X, comp_steering_num_of_bfer=0x%X\n", __func__, num_of_sounding_dim, comp_steering_num_of_bfer);
2018-06-22 16:48:32 +00:00
}
#endif
}
if (beamform_cap == BEAMFORMING_CAP_NONE)
return false;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] Self BF Entry Cap = 0x%02X\n", __func__, beamform_cap);
2018-06-22 16:48:32 +00:00
/*We are BFee, so the entry is BFer*/
if (beamform_cap & (BEAMFORMEE_CAP_VHT_MU | BEAMFORMEE_CAP_VHT_SU | BEAMFORMEE_CAP_HT_EXPLICIT)) {
2018-08-24 20:52:34 +00:00
beamformer_entry = phydm_beamforming_get_bfer_entry_by_addr(dm, sta->ra, &bfer_idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beamformer_entry == NULL) {
beamformer_entry = beamforming_add_bfer_entry(dm, sta, beamform_cap, num_of_sounding_dim, &bfer_idx);
if (beamformer_entry == NULL) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s]Not enough BFer entry!!!!!\n", __func__);
}
2018-06-22 16:48:32 +00:00
}
}
/*We are BFer, so the entry is BFee*/
if (beamform_cap & (BEAMFORMER_CAP_VHT_MU | BEAMFORMER_CAP_VHT_SU | BEAMFORMER_CAP_HT_EXPLICIT)) {
2018-08-24 20:52:34 +00:00
beamform_entry = phydm_beamforming_get_bfee_entry_by_addr(dm, sta->ra, &bfee_idx);
2018-06-22 16:48:32 +00:00
/*<2A>p<EFBFBD>GBFeeIdx = 0xF <20>h<EFBFBD>N<EFBFBD><4E><EFBFBD>ثeentry<72><79><EFBFBD><EFBFBD><EFBFBD>S<EFBFBD><53><EFBFBD>ۦP<DBA6><50>MACID<49>b<EFBFBD><62>*/
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] Get BFee entry 0x%X by address\n", __func__, bfee_idx);
if (beamform_entry == NULL) {
beamform_entry = beamforming_add_bfee_entry(dm, sta, beamform_cap, num_of_sounding_dim, comp_steering_num_of_bfer, &bfee_idx);
PHYDM_DBG(dm, DBG_TXBF, "[%s]: sta->AID=%d, sta->mac_id=%d\n", __func__, sta->aid, sta->mac_id);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s]: Add BFee entry %d\n", __func__, bfee_idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beamform_entry == NULL)
2018-06-22 16:48:32 +00:00
return false;
else
2018-08-24 20:52:34 +00:00
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZEING;
2018-06-22 16:48:32 +00:00
} else {
/*Entry has been created. If entry is initialing or progressing then errors occur.*/
2018-08-24 20:52:34 +00:00
if (beamform_entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_INITIALIZED &&
beamform_entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_PROGRESSED)
2018-06-22 16:48:32 +00:00
return false;
else
2018-08-24 20:52:34 +00:00
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZEING;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
beamform_entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;
phydm_sta_info_update(dm, sta_idx, beamform_entry);
2018-06-22 16:48:32 +00:00
}
*bfer_bfee_idx = (bfer_idx << 4) | bfee_idx;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] End: bfer_idx=0x%X, bfee_idx=0x%X, bfer_bfee_idx=0x%X\n", __func__, bfer_idx, bfee_idx, *bfer_bfee_idx);
2018-06-22 16:48:32 +00:00
return true;
}
void
beamforming_deinit_entry(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMER_ENTRY *bfer_entry = phydm_beamforming_get_bfer_entry_by_addr(dm, RA, &idx);
struct _RT_BEAMFORMEE_ENTRY *bfee_entry = phydm_beamforming_get_bfee_entry_by_addr(dm, RA, &idx);
2018-06-22 16:48:32 +00:00
boolean ret = false;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (bfee_entry != NULL) {
PHYDM_DBG(dm, DBG_TXBF, "%s, bfee_entry\n", __func__);
bfee_entry->is_used = false;
bfee_entry->beamform_entry_cap = BEAMFORMING_CAP_NONE;
bfee_entry->is_beamforming_in_progress = false;
if (bfee_entry->is_mu_sta) {
dm->beamforming_info.beamformee_mu_cnt -= 1;
dm->beamforming_info.first_mu_bfee_index = phydm_beamforming_get_first_mu_bfee_entry_idx(dm);
2018-06-22 16:48:32 +00:00
} else
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformee_su_cnt -= 1;
2018-06-22 16:48:32 +00:00
ret = true;
}
2018-08-24 20:52:34 +00:00
if (bfer_entry != NULL) {
PHYDM_DBG(dm, DBG_TXBF, "%s, bfer_entry\n", __func__);
bfer_entry->is_used = false;
bfer_entry->beamform_entry_cap = BEAMFORMING_CAP_NONE;
if (bfer_entry->is_mu_ap)
dm->beamforming_info.beamformer_mu_cnt -= 1;
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
dm->beamforming_info.beamformer_su_cnt -= 1;
2018-06-22 16:48:32 +00:00
ret = true;
}
if (ret == true)
2018-08-24 20:52:34 +00:00
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_LEAVE, (u8 *)&idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s End, idx = 0x%X\n", __func__, idx);
2018-06-22 16:48:32 +00:00
}
boolean
beamforming_start_v1(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA,
boolean mode,
enum channel_width BW,
u8 rate
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *entry;
2018-06-22 16:48:32 +00:00
boolean ret = true;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry = phydm_beamforming_get_bfee_entry_by_addr(dm, RA, &idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (entry->is_used == false) {
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
} else {
2018-08-24 20:52:34 +00:00
if (entry->is_beamforming_in_progress)
2018-06-22 16:48:32 +00:00
return false;
2018-08-24 20:52:34 +00:00
entry->is_beamforming_in_progress = true;
2018-06-22 16:48:32 +00:00
if (mode == 1) {
2018-08-24 20:52:34 +00:00
if (!(entry->beamform_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT)) {
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
}
} else if (mode == 0) {
2018-08-24 20:52:34 +00:00
if (!(entry->beamform_entry_cap & BEAMFORMER_CAP_VHT_SU)) {
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
}
}
2018-08-24 20:52:34 +00:00
if (entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_INITIALIZED && entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_PROGRESSED) {
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
} else {
2018-08-24 20:52:34 +00:00
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_PROGRESSING;
entry->is_sound = true;
2018-06-22 16:48:32 +00:00
}
}
2018-08-24 20:52:34 +00:00
entry->sound_bw = BW;
beam_info->beamformee_cur_idx = idx;
phydm_beamforming_ndpa_rate(dm, BW, rate);
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS, (u8 *)&idx);
2018-06-22 16:48:32 +00:00
if (mode == 1)
2018-08-24 20:52:34 +00:00
ret = beamforming_send_ht_ndpa_packet(dm, RA, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
ret = beamforming_send_vht_ndpa_packet(dm, RA, entry->aid, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
if (ret == false) {
2018-08-24 20:52:34 +00:00
beamforming_leave(dm, RA);
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s idx %d\n", __func__, idx);
2018-06-22 16:48:32 +00:00
return true;
}
boolean
beamforming_start_sw(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 idx,
u8 mode,
enum channel_width BW
)
{
u8 *ra = NULL;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMEE_ENTRY *entry;
2018-06-22 16:48:32 +00:00
boolean ret = true;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
#ifdef SUPPORT_MU_BF
#if (SUPPORT_MU_BF == 1)
u8 i, poll_sta_cnt = 0;
boolean is_get_first_bfee = false;
#endif
#endif
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beam_info->is_mu_sounding) {
beam_info->is_mu_sounding_in_progress = true;
entry = &beam_info->beamformee_entry[idx];
ra = entry->mac_addr;
2018-06-22 16:48:32 +00:00
} else {
2018-08-24 20:52:34 +00:00
entry = &beam_info->beamformee_entry[idx];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (entry->is_used == false) {
PHYDM_DBG(dm, DBG_TXBF, "Skip Beamforming, no entry for idx =%d\n", idx);
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
2018-08-24 20:52:34 +00:00
}
if (entry->is_beamforming_in_progress) {
PHYDM_DBG(dm, DBG_TXBF, "is_beamforming_in_progress, skip...\n");
return false;
}
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry->is_beamforming_in_progress = true;
ra = entry->mac_addr;
if (mode == SOUNDING_SW_HT_TIMER || mode == SOUNDING_HW_HT_TIMER || mode == SOUNDING_AUTO_HT_TIMER) {
if (!(entry->beamform_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT)) {
entry->is_beamforming_in_progress = false;
PHYDM_DBG(dm, DBG_TXBF, "%s Return by not support BEAMFORMER_CAP_HT_EXPLICIT <==\n", __func__);
return false;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
} else if (mode == SOUNDING_SW_VHT_TIMER || mode == SOUNDING_HW_VHT_TIMER || mode == SOUNDING_AUTO_VHT_TIMER) {
if (!(entry->beamform_entry_cap & BEAMFORMER_CAP_VHT_SU)) {
entry->is_beamforming_in_progress = false;
PHYDM_DBG(dm, DBG_TXBF, "%s Return by not support BEAMFORMER_CAP_VHT_SU <==\n", __func__);
2018-06-22 16:48:32 +00:00
return false;
}
}
2018-08-24 20:52:34 +00:00
if (entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_INITIALIZED && entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_PROGRESSED) {
entry->is_beamforming_in_progress = false;
PHYDM_DBG(dm, DBG_TXBF, "%s Return by incorrect beamform_entry_state(%d) <==\n", __func__, entry->beamform_entry_state);
return false;
} else {
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_PROGRESSING;
entry->is_sound = true;
}
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
beam_info->beamformee_cur_idx = idx;
2018-06-22 16:48:32 +00:00
}
/*2014.12.22 Luke: Need to be checked*/
/*GET_TXBF_INFO(adapter)->fTxbfSet(adapter, TXBF_SET_SOUNDING_STATUS, (u8*)&idx);*/
if (mode == SOUNDING_SW_HT_TIMER || mode == SOUNDING_HW_HT_TIMER || mode == SOUNDING_AUTO_HT_TIMER)
2018-08-24 20:52:34 +00:00
ret = beamforming_send_ht_ndpa_packet(dm, ra, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
ret = beamforming_send_vht_ndpa_packet(dm, ra, entry->aid, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
if (ret == false) {
2018-08-24 20:52:34 +00:00
beamforming_leave(dm, ra);
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
return false;
}
/*--------------------------
* Send BF Report Poll for MU BF
--------------------------*/
#ifdef SUPPORT_MU_BF
#if (SUPPORT_MU_BF == 1)
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_mu_cnt <= 1)
goto out;
/* More than 1 MU STA*/
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
entry = &beam_info->beamformee_entry[i];
if (!entry->is_mu_sta)
continue;
if (!is_get_first_bfee) {
is_get_first_bfee = true;
continue;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
poll_sta_cnt++;
if (poll_sta_cnt == (beam_info->beamformee_mu_cnt - 1))/* The last STA*/
send_sw_vht_bf_report_poll(dm, entry->mac_addr, true);
else
send_sw_vht_bf_report_poll(dm, entry->mac_addr, false);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
out:
2018-06-22 16:48:32 +00:00
#endif
#endif
return true;
}
boolean
beamforming_start_fw(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMEE_ENTRY *entry;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry = &beam_info->beamformee_entry[idx];
if (entry->is_used == false) {
PHYDM_DBG(dm, DBG_TXBF, "Skip Beamforming, no entry for idx =%d\n", idx);
2018-06-22 16:48:32 +00:00
return false;
}
2018-08-24 20:52:34 +00:00
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_PROGRESSING;
entry->is_sound = true;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_FW_NDPA, (u8 *)&idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] End, idx=0x%X\n", __func__, idx);
2018-06-22 16:48:32 +00:00
return true;
}
void
beamforming_check_sounding_success(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
boolean status
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_BEAMFORMEE_ENTRY *entry = &beam_info->beamformee_entry[beam_info->beamformee_cur_idx];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[David]@%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
if (status == 1) {
2018-08-24 20:52:34 +00:00
if (entry->log_status_fail_cnt == 21)
beamforming_dym_period(dm, status);
entry->log_status_fail_cnt = 0;
} else if (entry->log_status_fail_cnt <= 20) {
entry->log_status_fail_cnt++;
PHYDM_DBG(dm, DBG_TXBF, "%s log_status_fail_cnt %d\n", __func__, entry->log_status_fail_cnt);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
if (entry->log_status_fail_cnt > 20) {
entry->log_status_fail_cnt = 21;
PHYDM_DBG(dm, DBG_TXBF, "%s log_status_fail_cnt > 20, Stop SOUNDING\n", __func__);
beamforming_dym_period(dm, status);
2018-06-22 16:48:32 +00:00
}
}
void
phydm_beamforming_end_sw(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
boolean status
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_BEAMFORMEE_ENTRY *entry = &beam_info->beamformee_entry[beam_info->beamformee_cur_idx];
if (beam_info->is_mu_sounding) {
PHYDM_DBG(dm, DBG_TXBF, "%s: MU sounding done\n", __func__);
beam_info->is_mu_sounding_in_progress = false;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS,
(u8 *)&beam_info->beamformee_cur_idx);
2018-06-22 16:48:32 +00:00
} else {
2018-08-24 20:52:34 +00:00
if (entry->beamform_entry_state != BEAMFORMING_ENTRY_STATE_PROGRESSING) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] BeamformStatus %d\n", __func__, entry->beamform_entry_state);
2018-06-22 16:48:32 +00:00
return;
}
2018-08-24 20:52:34 +00:00
if ((beam_info->tx_bf_data_rate >= ODM_RATEVHTSS3MCS7) && (beam_info->tx_bf_data_rate <= ODM_RATEVHTSS3MCS9) && (!beam_info->snding3ss)) {
PHYDM_DBG(dm, DBG_TXBF, "[%s] VHT3SS 7,8,9, do not apply V matrix.\n", __func__);
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS,
(u8 *)&beam_info->beamformee_cur_idx);
2018-06-22 16:48:32 +00:00
} else if (status == 1) {
2018-08-24 20:52:34 +00:00
entry->log_status_fail_cnt = 0;
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_PROGRESSED;
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_STATUS,
(u8 *)&beam_info->beamformee_cur_idx);
2018-06-22 16:48:32 +00:00
} else {
2018-08-24 20:52:34 +00:00
entry->log_status_fail_cnt++;
entry->beamform_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;
hal_com_txbf_set(dm, TXBF_SET_TX_PATH_RESET,
(u8 *)&beam_info->beamformee_cur_idx);
PHYDM_DBG(dm, DBG_TXBF, "[%s] log_status_fail_cnt %d\n", __func__, entry->log_status_fail_cnt);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
if (entry->log_status_fail_cnt > 50) {
PHYDM_DBG(dm, DBG_TXBF, "%s log_status_fail_cnt > 50, Stop SOUNDING\n", __func__);
entry->is_sound = false;
beamforming_deinit_entry(dm, entry->mac_addr);
2018-06-22 16:48:32 +00:00
/*Modified by David - Every action of deleting entry should follow by Notify*/
2018-08-24 20:52:34 +00:00
phydm_beamforming_notify(dm);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
entry->is_beamforming_in_progress = false;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s: status=%d\n", __func__, status);
2018-06-22 16:48:32 +00:00
}
void
beamforming_timer_callback(
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
void *context
2018-06-22 16:48:32 +00:00
#endif
)
{
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
void *adapter = (void *)context;
PHAL_DATA_TYPE hal_data = GET_HAL_DATA(((PADAPTER)adapter));
struct dm_struct *dm = &hal_data->odmpriv;
2018-06-22 16:48:32 +00:00
#endif
boolean ret = false;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMING_INFO *beam_info = &(dm->beamforming_info);
struct _RT_BEAMFORMEE_ENTRY *entry = &(beam_info->beamformee_entry[beam_info->beamformee_cur_idx]);
struct _RT_SOUNDING_INFO *sound_info = &(beam_info->sounding_info);
2018-06-22 16:48:32 +00:00
boolean is_beamforming_in_progress;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beam_info->is_mu_sounding)
is_beamforming_in_progress = beam_info->is_mu_sounding_in_progress;
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
is_beamforming_in_progress = entry->is_beamforming_in_progress;
2018-06-22 16:48:32 +00:00
if (is_beamforming_in_progress) {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "is_beamforming_in_progress, reset it\n");
phydm_beamforming_end_sw(dm, 0);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
ret = phydm_beamforming_select_beam_entry(dm, beam_info);
2018-06-22 16:48:32 +00:00
#if (SUPPORT_MU_BF == 1)
2018-08-24 20:52:34 +00:00
if (ret && beam_info->beamformee_mu_cnt > 1)
2018-06-22 16:48:32 +00:00
ret = 1;
else
ret = 0;
#endif
if (ret) {
2018-08-24 20:52:34 +00:00
ret = beamforming_start_sw(dm, sound_info->sound_idx, sound_info->sound_mode, sound_info->sound_bw);
} else {
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s, Error value return from BeamformingStart_V2\n", __func__);
}
2018-08-24 20:52:34 +00:00
if ((beam_info->beamformee_su_cnt != 0) || (beam_info->beamformee_mu_cnt > 1)) {
if (sound_info->sound_mode == SOUNDING_SW_VHT_TIMER || sound_info->sound_mode == SOUNDING_SW_HT_TIMER)
odm_set_timer(dm, &beam_info->beamforming_timer, sound_info->sound_period);
2018-06-22 16:48:32 +00:00
else {
2018-08-24 20:52:34 +00:00
u32 val = (sound_info->sound_period << 16) | HAL_TIMER_TXBF;
phydm_set_hw_reg_handler_interface(dm, HW_VAR_HW_REG_TIMER_RESTART, (u8 *)(&val));
2018-06-22 16:48:32 +00:00
}
}
}
void
beamforming_sw_timer_callback(
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
struct phydm_timer_list *timer
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
void *function_context
#endif
)
{
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
void *adapter = (void *)timer->Adapter;
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));
struct dm_struct *dm = &hal_data->DM_OutSrc;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] Start!\n", __func__);
beamforming_timer_callback(dm);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)function_context;
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (*(dm->is_net_closed) == true)
2018-06-22 16:48:32 +00:00
return;
rtw_run_in_thread_cmd(adapter, beamforming_timer_callback, adapter);
#endif
}
void
phydm_beamforming_init(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_BEAMFORMING_OID_INFO *beam_oid_info = &beam_info->beamforming_oid_info;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));
2018-06-22 16:48:32 +00:00
#ifdef BEAMFORMING_VERSION_1
2018-08-24 20:52:34 +00:00
if (hal_data->beamforming_version != BEAMFORMING_VERSION_1) {
2018-06-22 16:48:32 +00:00
return;
}
#endif
#endif
2018-08-24 20:52:34 +00:00
beam_oid_info->sound_oid_mode = SOUNDING_STOP_OID_TIMER;
PHYDM_DBG(dm, DBG_TXBF, "%s mode (%d)\n", __func__, beam_oid_info->sound_oid_mode);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
beam_info->beamformee_su_cnt = 0;
beam_info->beamformer_su_cnt = 0;
beam_info->beamformee_mu_cnt = 0;
beam_info->beamformer_mu_cnt = 0;
beam_info->beamformee_mu_reg_maping = 0;
beam_info->mu_ap_index = 0;
beam_info->is_mu_sounding = false;
beam_info->first_mu_bfee_index = 0xFF;
beam_info->apply_v_matrix = true;
beam_info->snding3ss = false;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
beam_info->source_adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
#endif
2018-08-24 20:52:34 +00:00
hal_com_txbf_beamform_init(dm);
2018-06-22 16:48:32 +00:00
}
boolean
phydm_acting_determine(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
enum phydm_acting_type type
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
boolean ret = false;
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
PADAPTER adapter = (PADAPTER)dm->beamforming_info.source_adapter;
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
struct _ADAPTER *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
#endif
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
if (type == phydm_acting_as_ap)
ret = ACTING_AS_AP(adapter);
else if (type == phydm_acting_as_ibss)
2018-08-24 20:52:34 +00:00
ret = ACTING_AS_IBSS(((PADAPTER)(adapter)));
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
2018-06-22 16:48:32 +00:00
if (type == phydm_acting_as_ap)
ret = check_fwstate(pmlmepriv, WIFI_AP_STATE);
else if (type == phydm_acting_as_ibss)
ret = check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
#endif
return ret;
}
void
beamforming_enter(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u16 sta_idx
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 bfer_bfee_idx = 0xff;
2018-08-24 20:52:34 +00:00
if (beamforming_init_entry(dm, sta_idx, &bfer_bfee_idx))
hal_com_txbf_set(dm, TXBF_SET_SOUNDING_ENTER, (u8 *)&bfer_bfee_idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] End!\n", __func__);
2018-06-22 16:48:32 +00:00
}
void
beamforming_leave(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
if (RA != NULL) {
2018-08-24 20:52:34 +00:00
beamforming_deinit_entry(dm, RA);
phydm_beamforming_notify(dm);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] End!!\n", __func__);
2018-06-22 16:48:32 +00:00
}
#if 0
/* Nobody calls this function */
void
phydm_beamforming_set_txbf_en(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 mac_id,
boolean is_txbf
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u8 idx = 0;
2018-08-24 20:52:34 +00:00
struct _RT_BEAMFORMEE_ENTRY *entry;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
entry = phydm_beamforming_get_entry_by_mac_id(dm, mac_id, &idx);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (entry == NULL)
2018-06-22 16:48:32 +00:00
return;
else
2018-08-24 20:52:34 +00:00
entry->is_txbf = is_txbf;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s mac_id %d TxBF %d\n", __func__, entry->mac_id, entry->is_txbf);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
phydm_beamforming_notify(dm);
2018-06-22 16:48:32 +00:00
}
#endif
enum beamforming_cap
phydm_beamforming_get_beam_cap(
2018-08-24 20:52:34 +00:00
void *dm_void,
struct _RT_BEAMFORMING_INFO *beam_info
2018-06-22 16:48:32 +00:00
)
{
u8 i;
boolean is_self_beamformer = false;
boolean is_self_beamformee = false;
struct _RT_BEAMFORMEE_ENTRY beamformee_entry;
struct _RT_BEAMFORMER_ENTRY beamformer_entry;
enum beamforming_cap beamform_cap = BEAMFORMING_CAP_NONE;
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] Start!\n", __func__);
2018-06-22 16:48:32 +00:00
for (i = 0; i < BEAMFORMEE_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
beamformee_entry = beam_info->beamformee_entry[i];
2018-06-22 16:48:32 +00:00
if (beamformee_entry.is_used) {
is_self_beamformer = true;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s] BFee entry %d is_used=true\n", __func__, i);
2018-06-22 16:48:32 +00:00
break;
}
}
for (i = 0; i < BEAMFORMER_ENTRY_NUM; i++) {
2018-08-24 20:52:34 +00:00
beamformer_entry = beam_info->beamformer_entry[i];
2018-06-22 16:48:32 +00:00
if (beamformer_entry.is_used) {
is_self_beamformee = true;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "[%s]: BFer entry %d is_used=true\n", __func__, i);
2018-06-22 16:48:32 +00:00
break;
}
}
if (is_self_beamformer)
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMER_CAP);
if (is_self_beamformee)
beamform_cap = (enum beamforming_cap)(beamform_cap | BEAMFORMEE_CAP);
return beamform_cap;
}
boolean
beamforming_control_v1(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 *RA,
u8 AID,
u8 mode,
enum channel_width BW,
u8 rate
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
boolean ret = true;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "AID (%d), mode (%d), BW (%d)\n", AID, mode, BW);
2018-06-22 16:48:32 +00:00
switch (mode) {
case 0:
2018-08-24 20:52:34 +00:00
ret = beamforming_start_v1(dm, RA, 0, BW, rate);
2018-06-22 16:48:32 +00:00
break;
case 1:
2018-08-24 20:52:34 +00:00
ret = beamforming_start_v1(dm, RA, 1, BW, rate);
2018-06-22 16:48:32 +00:00
break;
case 2:
2018-08-24 20:52:34 +00:00
phydm_beamforming_ndpa_rate(dm, BW, rate);
ret = beamforming_send_vht_ndpa_packet(dm, RA, AID, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
break;
case 3:
2018-08-24 20:52:34 +00:00
phydm_beamforming_ndpa_rate(dm, BW, rate);
ret = beamforming_send_ht_ndpa_packet(dm, RA, BW, NORMAL_QUEUE);
2018-06-22 16:48:32 +00:00
break;
}
return ret;
}
/*Only OID uses this function*/
boolean
phydm_beamforming_control_v2(
2018-08-24 20:52:34 +00:00
void *dm_void,
2018-06-22 16:48:32 +00:00
u8 idx,
u8 mode,
enum channel_width BW,
u16 period
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
struct _RT_BEAMFORMING_OID_INFO *beam_oid_info = &beam_info->beamforming_oid_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
PHYDM_DBG(dm, DBG_TXBF, "idx (%d), mode (%d), BW (%d), period (%d)\n", idx, mode, BW, period);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
beam_oid_info->sound_oid_idx = idx;
beam_oid_info->sound_oid_mode = (enum sounding_mode) mode;
beam_oid_info->sound_oid_bw = BW;
beam_oid_info->sound_oid_period = period;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
phydm_beamforming_notify(dm);
2018-06-22 16:48:32 +00:00
return true;
}
void
phydm_beamforming_watchdog(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_TXBF, "%s Start!\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (beam_info->beamformee_su_cnt == 0)
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
beamforming_dym_period(dm, 0);
2018-06-22 16:48:32 +00:00
}
enum beamforming_cap
phydm_get_beamform_cap(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct cmn_sta_info *sta = NULL;
struct bf_cmn_info *bf_info = NULL;
struct _RT_BEAMFORMING_INFO *beam_info = &dm->beamforming_info;
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_cap = BEAMFORMING_CAP_NONE;
u8 macid;
u8 ht_curbeamformcap = 0;
u16 vht_curbeamformcap = 0;
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
PMGNT_INFO p_MgntInfo = &(((PADAPTER)(adapter))->MgntInfo);
2018-06-22 16:48:32 +00:00
PRT_VERY_HIGH_THROUGHPUT p_vht_info = GET_VHT_INFO(p_MgntInfo);
PRT_HIGH_THROUGHPUT p_ht_info = GET_HT_INFO(p_MgntInfo);
ht_curbeamformcap = p_ht_info->HtCurBeamform;
vht_curbeamformcap = p_vht_info->VhtCurBeamform;
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_ANT_DIV, "[%s] WIN ht_curcap = %d ; vht_curcap = %d\n", __func__, ht_curbeamformcap, vht_curbeamformcap);
2018-06-22 16:48:32 +00:00
if (TEST_FLAG(ht_curbeamformcap, BEAMFORMING_HT_BEAMFORMER_ENABLE)) /*We are Beamformee because the STA is Beamformer*/
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_HT_EXPLICIT | BEAMFORMEE_CAP));
/*We are Beamformer because the STA is Beamformee*/
if (TEST_FLAG(ht_curbeamformcap, BEAMFORMING_HT_BEAMFORMEE_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMER_CAP_HT_EXPLICIT | BEAMFORMER_CAP));
#if (ODM_IC_11AC_SERIES_SUPPORT == 1)
/* We are Beamformee because the STA is SU Beamformer*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_BEAMFORMER_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_VHT_SU | BEAMFORMEE_CAP));
/* We are Beamformer because the STA is SU Beamformee*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_BEAMFORMEE_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMER_CAP_VHT_SU | BEAMFORMER_CAP));
/* We are Beamformee because the STA is MU Beamformer*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_MU_MIMO_AP_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_VHT_MU | BEAMFORMEE_CAP));
#endif
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++) {
2018-08-24 20:52:34 +00:00
sta = dm->phydm_sta_info[macid];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (!is_sta_active(sta))
2018-06-22 16:48:32 +00:00
continue;
2018-08-24 20:52:34 +00:00
bf_info = &sta->bf_info;
vht_curbeamformcap = bf_info->vht_beamform_cap;
ht_curbeamformcap = bf_info->ht_beamform_cap;
2018-06-22 16:48:32 +00:00
if (TEST_FLAG(ht_curbeamformcap, BEAMFORMING_HT_BEAMFORMER_ENABLE)) /*We are Beamformee because the STA is Beamformer*/
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_HT_EXPLICIT | BEAMFORMEE_CAP));
/*We are Beamformer because the STA is Beamformee*/
if (TEST_FLAG(ht_curbeamformcap, BEAMFORMING_HT_BEAMFORMEE_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMER_CAP_HT_EXPLICIT | BEAMFORMER_CAP));
#if (ODM_IC_11AC_SERIES_SUPPORT == 1)
/* We are Beamformee because the STA is SU Beamformer*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_BEAMFORMER_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_VHT_SU | BEAMFORMEE_CAP));
/* We are Beamformer because the STA is SU Beamformee*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_BEAMFORMEE_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMER_CAP_VHT_SU | BEAMFORMER_CAP));
/* We are Beamformee because the STA is MU Beamformer*/
if (TEST_FLAG(vht_curbeamformcap, BEAMFORMING_VHT_MU_MIMO_AP_ENABLE))
beamform_cap = (enum beamforming_cap)(beamform_cap | (BEAMFORMEE_CAP_VHT_MU | BEAMFORMEE_CAP));
#endif
}
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_ANT_DIV, "[%s] CE ht_curcap = %d ; vht_curcap = %d\n", __func__, ht_curbeamformcap, vht_curbeamformcap);
2018-06-22 16:48:32 +00:00
#endif
return beamform_cap;
}
#endif