mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
luci-app-mtk: fix stainfo
This commit is contained in:
parent
709884eaee
commit
7b216caf26
@ -940,6 +940,9 @@ function sta_info(ifname)
|
||||
local output = {}
|
||||
local stalist = c_StaInfo(ifname)
|
||||
|
||||
local ifname_t = {["ifname"] = ifname}
|
||||
table.insert(output, ifname_t)
|
||||
|
||||
local count = 0
|
||||
for _ in pairs(stalist) do count = count + 1 end
|
||||
|
||||
|
@ -204,20 +204,18 @@ local chipname
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<!--
|
||||
<h2><a id="content" name="content"><%:Station List%></a></h2>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<table class="cbi-section-table" style="margin:10px" id="iw-assoclist">
|
||||
<h2><a id="content" name="content">Station List</a></h2>
|
||||
<table class="cbi-section-table" style="margin: auto" id="iw-assoclist">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"></th>
|
||||
<th class="cbi-section-table-cell"><%:SSID%></th>
|
||||
<th class="cbi-section-table-cell"><%:MAC-Address%></th>
|
||||
<th class="cbi-section-table-cell"><%:IPv4-Address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Signal%></th>
|
||||
<th class="cbi-section-table-cell"><%:Noise%></th>
|
||||
<th class="cbi-section-table-cell"><%:RX Rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:TX Rate%></th>
|
||||
<th class="cbi-section-table-cell">Interface</th>
|
||||
<th class="cbi-section-table-cell">SSID</th>
|
||||
<th class="cbi-section-table-cell">MAC-Address</th>
|
||||
<!--th class="cbi-section-table-cell">IPv4-Address</th-->
|
||||
<th class="cbi-section-table-cell">Signal (dBm)</th>
|
||||
<th class="cbi-section-table-cell">TX Rate</th>
|
||||
<th class="cbi-section-table-cell">RX Rate</th>
|
||||
<th class="cbi-section-table-cell">Connected Time</th>
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-2">
|
||||
<td class="cbi-value-field" colspan="8">
|
||||
@ -226,9 +224,58 @@ local chipname
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
function clean_stalist_table()
|
||||
{
|
||||
var table = document.getElementById('iw-assoclist');
|
||||
//console.log("clean_aplist_table.aplist len=" + table.rows.length);
|
||||
while(table.rows.length > 1)
|
||||
table.deleteRow(-1);
|
||||
}
|
||||
|
||||
function insert_stalist_table(ifname, ssid, sta_list)
|
||||
{
|
||||
var i, tr_row, td_cell;
|
||||
var tableid = document.getElementById('iw-assoclist');
|
||||
|
||||
for (i = 0; sta_list[i] ; i++){
|
||||
//console.log(sta_list[i]);
|
||||
tr_row = tableid.insertRow(-1);
|
||||
|
||||
tr_row.align = "center";
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = ifname;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = ssid;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].MacAddr;
|
||||
|
||||
// FIXME: TODO
|
||||
/*
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = "IPv4 addr";
|
||||
*/
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].AvgRssi0 + ", " + sta_list[i].AvgRssi1 + ", " + sta_list[i].AvgRssi2;
|
||||
|
||||
//TxRate
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].TxRate + "Mbps," + sta_list[i].Bw+ "MHz" + "<br>" + sta_list[i].PhyMode + ", " + sta_list[i].Mcs + ", " + sta_list[i].Gi + "GI";
|
||||
|
||||
//RxRate
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].RxRate + "Mbps," + sta_list[i].LastBw + "MHz" + "<br>" + sta_list[i].LastPhyMode + ", " + sta_list[i].LastMcs + ", " + sta_list[i].LastGi + "GI";
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].Hr + ":" + sta_list[i].Min + ":" + sta_list[i].Sec;
|
||||
}
|
||||
}
|
||||
|
||||
function disable_all_buttons()
|
||||
{
|
||||
var inp = document.getElementsByTagName("INPUT");
|
||||
@ -296,6 +343,42 @@ local chipname
|
||||
}
|
||||
);
|
||||
}
|
||||
var stainfo = [];
|
||||
function staInfoHandler()
|
||||
{
|
||||
for (var i=0; stainfo[i]; i++) {
|
||||
//console.log(stainfo[i].ifname);
|
||||
XHR.poll(3, "<%=luci.dispatcher.build_url("admin", "network", "wifi", "sta_info")%>/" + stainfo[i].ifname, null,
|
||||
function(x)
|
||||
{
|
||||
this.idx = i;
|
||||
try{
|
||||
//console.log(x.responseText);
|
||||
response = JSON.parse(x.responseText);
|
||||
for (var j=0; stainfo[j]; j++) {
|
||||
if (response[0].ifname == stainfo[j].ifname) {
|
||||
response.shift(); //delete first item
|
||||
stainfo[j].sta = response;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function printstainfo()
|
||||
{
|
||||
//console.log(stainfo);
|
||||
clean_stalist_table();
|
||||
var stabuf = stainfo;
|
||||
for (var i=0; stabuf[i]; i++) {
|
||||
insert_stalist_table(stabuf[i].ifname, stabuf[i].ssid, stabuf[i].sta);
|
||||
}
|
||||
|
||||
setTimeout(printstainfo, 500);
|
||||
}
|
||||
|
||||
function apcliInfoTimerHandler(vifNameList,idx,remSec)
|
||||
{
|
||||
@ -396,6 +479,17 @@ local chipname
|
||||
window.onload = function(){
|
||||
get_apply_status();
|
||||
updateApCliInfo();
|
||||
<% for _,dev in ipairs(devs) do %>
|
||||
<% if dev.vifs then%>
|
||||
<% for _,vif in ipairs(dev.vifs) do %>
|
||||
<% if vif.state == "up" then %>
|
||||
stainfo.push({"ifname": "<%=vif.vifname%>", "ssid": "<%=vif.__ssid%>", "sta": ""});
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
staInfoHandler(stainfo);
|
||||
printstainfo();
|
||||
}
|
||||
</script>
|
||||
<%+footer%>
|
||||
|
@ -59,18 +59,11 @@ function hi(to, devname, vifname)
|
||||
<% end %>
|
||||
tables.push("vif-cfg-basic-AC");
|
||||
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
tables.push("vif-cfg-station");
|
||||
<% end %>
|
||||
|
||||
var tabs = new Array();
|
||||
tabs.push("vif-cfg-tab-basic");
|
||||
<% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>
|
||||
tabs.push("vif-cfg-tab-he_mu");
|
||||
<% end %>
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
tabs.push("vif-cfg-tab-station");
|
||||
<% end %>
|
||||
|
||||
document.getElementById("__activeTab").value = to;
|
||||
|
||||
@ -98,14 +91,6 @@ function hi(to, devname, vifname)
|
||||
a.className = "cbi-tab";
|
||||
}
|
||||
}
|
||||
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
//Clear station list timer
|
||||
XHR.halt();
|
||||
if(to == "station"){
|
||||
InitStaList(devname, vifname);
|
||||
}
|
||||
<% end %>
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -143,11 +128,6 @@ function hi(to, devname, vifname)
|
||||
<a href="javascript:hi('he_mu', <%="'"..devname.."', '"..vifname.."'"%>);this.blur(); ">HE_MU</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
<li class="cbi-tab-disabled" id="vif-cfg-tab-station">
|
||||
<a href="javascript:hi('station', <%="'"..devname.."', '"..vifname.."'"%>);this.blur(); ">Stations</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<input type="hidden" name="__activeTab" id="__activeTab" value="basic">
|
||||
<table class="cbi-section-table" id="vif-cfg-basic">
|
||||
@ -673,25 +653,6 @@ function hi(to, devname, vifname)
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
<table class="cbi-section-table" id="vif-cfg-station" name="vif-cfg-station" style="display:none" width="600" border="1" cellpadding="2" cellspacing="1">
|
||||
<tr>
|
||||
<td class="head" id="stalistMacAddr">MAC Addr</td>
|
||||
<td class="head">Aid</td>
|
||||
<td class="head">PSM</td>
|
||||
<td class="head">MIMO<br>PS</td>
|
||||
<td class="head">TX Rate</td>
|
||||
<td class="head">TxBF</td>
|
||||
<td class="head">RSSI</td>
|
||||
<td class="head">Stream<br>SNR</td>
|
||||
<td class="head">Snd Rsp<br>SNR</td>
|
||||
<td class="head">Last<br>RX Rate</td>
|
||||
<td class="head">Connect<br>Time</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
|
||||
<fieldset class="cbi-section" id="vif-cfg-basic-AC">
|
||||
<legend>Access Control - <%=vifname and devname.."@"..vifname or devname%> </legend>
|
||||
<table class="cbi-section-table">
|
||||
@ -732,7 +693,6 @@ AA:BB:CC:DD:EE:FF
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var sta_list;
|
||||
function disable_all_link_btns()
|
||||
{
|
||||
document.getElementById("vif_form_action_btns").style.display = "none";
|
||||
@ -764,82 +724,6 @@ AA:BB:CC:DD:EE:FF
|
||||
return ((imode >= 0) && (imode <= 4));
|
||||
}
|
||||
|
||||
/* Functions used for updating Stations tab must be written inside this check. */
|
||||
<% if request[4] == "vif_cfg_view" then%>
|
||||
function clean_stalist_table()
|
||||
{
|
||||
var table = document.getElementById('vif-cfg-station');
|
||||
//console.log("clean_aplist_table.aplist len=" + table.rows.length);
|
||||
while(table.rows.length > 1)
|
||||
table.deleteRow(-1);
|
||||
}
|
||||
|
||||
function insert_stalist_table()
|
||||
{
|
||||
var i, tr_row, td_cell;
|
||||
var tableid = document.getElementById('vif-cfg-station');
|
||||
|
||||
for (i = 0; sta_list[i] ; i++){
|
||||
console.log(sta_list[i]);
|
||||
tr_row = tableid.insertRow(-1);
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].MacAddr;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].Aid;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].Psm;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].MimoPs;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = "MCS "+ sta_list[i].Mcs + "<br>" + sta_list[i].Bw+ "M, " + sta_list[i].Gi + "GI<br>" + sta_list[i].PhyMode + ", " +sta_list[i].Stbc;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].iTxBF + " " + sta_list[i].eTxBF;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].AvgRssi0 + "<br>" + sta_list[i].AvgRssi1 + "<br>" + sta_list[i].AvgRssi2 + "<br>" + sta_list[i].AvgRssi3;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].StreamSnr0 + "<br>" + sta_list[i].StreamSnr1 + "<br>" + sta_list[i].StreamSnr2;
|
||||
|
||||
if (sta_list[i].eTxBF != "-")
|
||||
{
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].SoundingRespSnr0 + "<br>" + sta_list[i].SoundingRespSnr1 + "<br>" + sta_list[i].SoundingRespSnr2;
|
||||
}
|
||||
else{
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = "-<br>-<br>-";
|
||||
}
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = "MCS "+ sta_list[i].LastMcs + "<br>" + sta_list[i].LastBw+ "M, " + sta_list[i].LastGi + "GI<br>" + sta_list[i].LastPhyMode + ", " +sta_list[i].LastStbc;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].Hr + ":" + sta_list[i].Min + ":" + sta_list[i].Sec;
|
||||
}
|
||||
}
|
||||
|
||||
function InitStaList_cb(response)
|
||||
{
|
||||
sta_list = response;
|
||||
clean_stalist_table();
|
||||
insert_stalist_table();
|
||||
}
|
||||
|
||||
function InitStaList(devname, vifname)
|
||||
{
|
||||
XHR.poll(10, "<%=luci.dispatcher.build_url("admin", "network", "wifi", "sta_info")%>/" + vifname + '/' + devname, null,
|
||||
function(x)
|
||||
{
|
||||
try{
|
||||
var response = JSON.parse(x.responseText);
|
||||
console.log("Station List " + response);
|
||||
InitStaList_cb(response);
|
||||
}
|
||||
catch(e){}
|
||||
}
|
||||
);
|
||||
}
|
||||
<% end %>
|
||||
|
||||
function checkInjection(str)
|
||||
{
|
||||
var len = str.length;
|
||||
|
@ -1,4 +1,4 @@
|
||||
OBJ_IOCTL = ioctl_helper.o
|
||||
OBJ_IOCTL = ioctl_helper.o rate_calc.o
|
||||
CFLAGS += -I.
|
||||
CFLAGS += -I$(ROOTDIR)/user/luci/lua-5.1.5/src
|
||||
CFLAGS += -Wall -shared -fPIC
|
||||
|
@ -9,66 +9,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <lua.h> /* Always include this */
|
||||
#include <lauxlib.h> /* Always include this */
|
||||
#include <lualib.h> /* Always include this */
|
||||
|
||||
#define USHORT unsigned short
|
||||
#define UCHAR unsigned char
|
||||
|
||||
typedef union _HTTRANSMIT_SETTING {
|
||||
struct {
|
||||
USHORT MCS:6;
|
||||
USHORT ldpc:1;
|
||||
USHORT BW:2;
|
||||
USHORT ShortGI:1;
|
||||
USHORT STBC:1;
|
||||
USHORT eTxBF:1;
|
||||
USHORT iTxBF:1;
|
||||
USHORT MODE:3;
|
||||
} field;
|
||||
USHORT word;
|
||||
} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
|
||||
|
||||
typedef struct _RT_802_11_MAC_ENTRY {
|
||||
unsigned char ApIdx;
|
||||
unsigned char Addr[6];
|
||||
unsigned short Aid;
|
||||
unsigned char Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
|
||||
unsigned char MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
|
||||
signed char AvgRssi0;
|
||||
signed char AvgRssi1;
|
||||
signed char AvgRssi2;
|
||||
unsigned int ConnectedTime;
|
||||
HTTRANSMIT_SETTING TxRate;
|
||||
unsigned int LastRxRate;
|
||||
short StreamSnr[3];
|
||||
short SoundingRespSnr[3];
|
||||
//short TxPER;
|
||||
//short reserved;
|
||||
} RT_802_11_MAC_ENTRY;
|
||||
|
||||
#define MAX_NUMBER_OF_MAC 544
|
||||
|
||||
typedef struct _RT_802_11_MAC_TABLE {
|
||||
unsigned long Num;
|
||||
RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
|
||||
} RT_802_11_MAC_TABLE;
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
#define SIOCIWFIRSTPRIV 0x8BE0
|
||||
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)
|
||||
#define RTPRIV_IOCTL_GET_MAC_TABLE_STRUCT (SIOCIWFIRSTPRIV + 0x1F)
|
||||
#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
|
||||
#define OID_GET_WMODE 0x099E
|
||||
#define OID_GET_CPU_TEMPERATURE 0x09A1
|
||||
|
||||
int get_macaddr(lua_State *L);
|
||||
int convert_string_display(lua_State *L);
|
||||
int StaInfo(lua_State *L);
|
||||
int getWMOde(lua_State *L);
|
||||
int getTempature(lua_State *L);
|
||||
int scanResult(lua_State *L);
|
||||
#include "mtwifi.h"
|
||||
|
||||
int luaopen_ioctl_helper(lua_State *L)
|
||||
{
|
||||
@ -302,7 +244,7 @@ int StaInfo(lua_State *L)
|
||||
int i, s;
|
||||
struct iwreq iwr;
|
||||
RT_802_11_MAC_TABLE *table;
|
||||
char tmpBuff[128];
|
||||
char tmpBuff[128] = {0};
|
||||
char *phyMode[12] = {"CCK", "OFDM", "MM", "GF", "VHT", "HE",
|
||||
"HE5G", "HE2G", "HE_SU", "HE_EXT_SU", "HE_TRIG", "HE_MU"};
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
@ -340,20 +282,28 @@ int StaInfo(lua_State *L)
|
||||
lua_pushnumber(L, i);
|
||||
|
||||
RT_802_11_MAC_ENTRY *pe = &(table->Entry[i]);
|
||||
unsigned int lastRxRate = pe->LastRxRate;
|
||||
unsigned int mcs = pe->LastRxRate & 0x7F;
|
||||
unsigned int vht_nss;
|
||||
unsigned int vht_mcs = pe->TxRate.field.MCS;
|
||||
unsigned int vht_nss_r;
|
||||
unsigned int vht_mcs_r = pe->LastRxRate & 0x3F;
|
||||
|
||||
HTTRANSMIT_SETTING RxRate;
|
||||
RxRate.word = pe->LastRxRate;
|
||||
|
||||
/* vht tx mcs nss*/
|
||||
unsigned int mcs = pe->TxRate.field.MCS;
|
||||
unsigned int nss = 0;
|
||||
|
||||
/* vht rx mcs nss*/
|
||||
unsigned int mcs_r = RxRate.field.MCS;
|
||||
unsigned int nss_r = 0;
|
||||
|
||||
int hr, min, sec;
|
||||
unsigned long DataRate = 0;
|
||||
unsigned long DataRate_r = 0;
|
||||
|
||||
hr = pe->ConnectedTime/3600;
|
||||
min = (pe->ConnectedTime % 3600)/60;
|
||||
sec = pe->ConnectedTime - hr*3600 - min*60;
|
||||
|
||||
/*Creates first child table of size 28 non-array elements: */
|
||||
lua_createtable(L, 0, 28);
|
||||
lua_createtable(L, 0, 32);
|
||||
|
||||
// MAC Address
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%02X:%02X:%02X:%02X:%02X:%02X", pe->Addr[0], pe->Addr[1], pe->Addr[2], pe->Addr[3],
|
||||
@ -375,14 +325,15 @@ int StaInfo(lua_State *L)
|
||||
lua_setfield(L, -2, "MimoPs");
|
||||
|
||||
// TX Rate
|
||||
if (pe->TxRate.field.MODE == 4){
|
||||
vht_nss = ((vht_mcs & (0x3 << 4)) >> 4) + 1;
|
||||
vht_mcs = vht_mcs & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dS-M%d/", vht_nss, vht_mcs);
|
||||
if (pe->TxRate.field.MODE >= 4){
|
||||
nss = ((mcs & (0x3 << 4)) >> 4) + 1;
|
||||
mcs = mcs & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dSS-MCS%d", nss, mcs);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Mcs");
|
||||
} else{
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", pe->TxRate.field.MCS);
|
||||
mcs = mcs & 0x3f;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", pe->TxRate.field.MCS);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Mcs");
|
||||
}
|
||||
@ -399,9 +350,13 @@ int StaInfo(lua_State *L)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 80);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
} else if (pe->TxRate.field.BW == 3){
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 160);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", pe->TxRate.field.ShortGI? 'S': 'L');
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", pe->TxRate.field.ShortGI ? 'S': 'L');
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Gi");
|
||||
|
||||
@ -460,41 +415,76 @@ int StaInfo(lua_State *L)
|
||||
}
|
||||
|
||||
// Last RX Rate
|
||||
if (((lastRxRate>>13) & 0x7) == 4){
|
||||
vht_nss_r = ((vht_mcs_r & (0x3 << 4)) >> 4) + 1;
|
||||
vht_mcs_r = vht_mcs_r & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dS-M%d", vht_nss_r, vht_mcs_r);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastMcs");
|
||||
} else{
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", mcs);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastMcs");
|
||||
if (RxRate.field.MODE >= MODE_VHT) {
|
||||
nss_r = ((mcs_r & (0x3 << 4)) >> 4) + 1;
|
||||
mcs_r = mcs_r & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dSS-MCS%d", nss_r, mcs_r);
|
||||
} else if (RxRate.field.MODE == MODE_HTMIX) {
|
||||
mcs_r = mcs_r & 0x3f;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", mcs_r);
|
||||
} else if (RxRate.field.MODE == MODE_OFDM) {
|
||||
mcs_r = mcs_r & 0xF;
|
||||
if (mcs_r == TMI_TX_RATE_OFDM_6M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 0);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_9M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 1);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_12M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 2);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_18M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 3);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_24M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 4);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_36M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 5);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_48M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 6);
|
||||
else if (mcs_r == TMI_TX_RATE_OFDM_54M)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 7);
|
||||
else
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 0);
|
||||
} else if (RxRate.field.MODE == MODE_CCK) {
|
||||
mcs_r = mcs_r & 0x7;
|
||||
if (mcs_r == TMI_TX_RATE_CCK_1M_LP)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 0);
|
||||
else if (mcs_r == TMI_TX_RATE_CCK_2M_LP || mcs_r == TMI_TX_RATE_CCK_2M_SP)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 1);
|
||||
else if (mcs_r == TMI_TX_RATE_CCK_5M_LP || mcs_r == TMI_TX_RATE_CCK_5M_SP)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 2);
|
||||
else if (mcs_r == TMI_TX_RATE_CCK_11M_LP || mcs_r == TMI_TX_RATE_CCK_11M_SP)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 3);
|
||||
else
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", 0);
|
||||
}
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastMcs");
|
||||
|
||||
if (((lastRxRate>>7) & 0x3) == 0){
|
||||
if (RxRate.field.BW == 0){
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 20);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (((lastRxRate>>7) & 0x3) == 1){
|
||||
} else if (RxRate.field.BW == 1){
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 40);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (((lastRxRate>>7) & 0x3) == 2){
|
||||
} else if (RxRate.field.BW == 2){
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 80);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (RxRate.field.BW == 3){
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 160);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", ((lastRxRate>>8) & 0x1)? 'S': 'L');
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", RxRate.field.ShortGI ? 'S': 'L');
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastGi");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", phyMode[(lastRxRate>>13) & 0x7]);
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", phyMode[RxRate.field.MODE]);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastPhyMode");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", ((lastRxRate>>9) & 0x3)? "STBC": " ");
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", RxRate.field.STBC ? "STBC": " ");
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastStbc");
|
||||
|
||||
@ -511,6 +501,26 @@ int StaInfo(lua_State *L)
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Sec");
|
||||
|
||||
if (pe->TxRate.field.MODE >= MODE_HE) {
|
||||
get_rate_he((mcs & 0xf), pe->TxRate.field.BW, nss, 0, &DataRate);
|
||||
} else {
|
||||
getRate(pe->TxRate, &DataRate);
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%ld", DataRate);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "TxRate");
|
||||
|
||||
if (RxRate.field.MODE >= MODE_HE) {
|
||||
get_rate_he((mcs_r & 0xf), RxRate.field.BW, nss_r, 0, &DataRate_r);
|
||||
} else {
|
||||
getRate(RxRate, &DataRate_r);
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%ld", DataRate_r);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "RxRate");
|
||||
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
free(table);
|
||||
|
127
package/mtk/applications/luci-app-mtk/src/mtwifi.h
Normal file
127
package/mtk/applications/luci-app-mtk/src/mtwifi.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef __MTWIFI_H
|
||||
#define __MTWIFI_H
|
||||
|
||||
#define USHORT unsigned short
|
||||
#define UCHAR unsigned char
|
||||
#define ULONG unsigned long
|
||||
#define UINT8 unsigned char
|
||||
#define UINT16 unsigned short
|
||||
#define INT32 int
|
||||
#define INT int
|
||||
|
||||
#include <lua.h> /* Always include this */
|
||||
#include <lauxlib.h> /* Always include this */
|
||||
#include <lualib.h> /* Always include this */
|
||||
|
||||
typedef union _HTTRANSMIT_SETTING {
|
||||
struct {
|
||||
USHORT MCS:6;
|
||||
USHORT ldpc:1;
|
||||
USHORT BW:2;
|
||||
USHORT ShortGI:1;
|
||||
USHORT STBC:1;
|
||||
USHORT eTxBF:1;
|
||||
USHORT iTxBF:1;
|
||||
USHORT MODE:3;
|
||||
} field;
|
||||
USHORT word;
|
||||
} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
|
||||
|
||||
typedef struct _RT_802_11_MAC_ENTRY {
|
||||
unsigned char ApIdx;
|
||||
unsigned char Addr[6];
|
||||
unsigned short Aid;
|
||||
unsigned char Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
|
||||
unsigned char MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
|
||||
signed char AvgRssi0;
|
||||
signed char AvgRssi1;
|
||||
signed char AvgRssi2;
|
||||
unsigned int ConnectedTime;
|
||||
HTTRANSMIT_SETTING TxRate;
|
||||
unsigned int LastRxRate;
|
||||
short StreamSnr[3];
|
||||
short SoundingRespSnr[3];
|
||||
//short TxPER;
|
||||
//short reserved;
|
||||
} RT_802_11_MAC_ENTRY;
|
||||
|
||||
#define MAX_NUMBER_OF_MAC 544
|
||||
|
||||
typedef struct _RT_802_11_MAC_TABLE {
|
||||
unsigned long Num;
|
||||
RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
|
||||
} RT_802_11_MAC_TABLE;
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
#define SIOCIWFIRSTPRIV 0x8BE0
|
||||
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)
|
||||
#define RTPRIV_IOCTL_GET_MAC_TABLE_STRUCT (SIOCIWFIRSTPRIV + 0x1F)
|
||||
#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
|
||||
#define OID_GET_WMODE 0x099E
|
||||
#define OID_GET_CPU_TEMPERATURE 0x09A1
|
||||
|
||||
#define MODE_CCK 0
|
||||
#define MODE_OFDM 1
|
||||
#define MODE_HTMIX 2
|
||||
#define MODE_HTGREENFIELD 3
|
||||
#define MODE_VHT 4
|
||||
#define MODE_HE 5
|
||||
#define MODE_HE_5G 6
|
||||
#define MODE_HE_24G 7
|
||||
#define MODE_HE_SU 8
|
||||
#define MODE_HE_EXT_SU 9
|
||||
#define MODE_HE_TRIG 10
|
||||
#define MODE_HE_MU 11
|
||||
|
||||
#define TMI_TX_RATE_OFDM_6M 11
|
||||
#define TMI_TX_RATE_OFDM_9M 15
|
||||
#define TMI_TX_RATE_OFDM_12M 10
|
||||
#define TMI_TX_RATE_OFDM_18M 14
|
||||
#define TMI_TX_RATE_OFDM_24M 9
|
||||
#define TMI_TX_RATE_OFDM_36M 13
|
||||
#define TMI_TX_RATE_OFDM_48M 8
|
||||
#define TMI_TX_RATE_OFDM_54M 12
|
||||
|
||||
#define TMI_TX_RATE_CCK_1M_LP 0
|
||||
#define TMI_TX_RATE_CCK_2M_LP 1
|
||||
#define TMI_TX_RATE_CCK_5M_LP 2
|
||||
#define TMI_TX_RATE_CCK_11M_LP 3
|
||||
|
||||
#define TMI_TX_RATE_CCK_2M_SP 5
|
||||
#define TMI_TX_RATE_CCK_5M_SP 6
|
||||
#define TMI_TX_RATE_CCK_11M_SP 7
|
||||
|
||||
enum oid_bw {
|
||||
BAND_WIDTH_20,
|
||||
BAND_WIDTH_40,
|
||||
BAND_WIDTH_80,
|
||||
BAND_WIDTH_160,
|
||||
BAND_WIDTH_10,
|
||||
BAND_WIDTH_5,
|
||||
BAND_WIDTH_8080,
|
||||
BAND_WIDTH_BOTH,
|
||||
BAND_WIDTH_25,
|
||||
BAND_WIDTH_20_242TONE,
|
||||
BAND_WIDTH_NUM
|
||||
};
|
||||
|
||||
#define BW_20 BAND_WIDTH_20
|
||||
#define BW_40 BAND_WIDTH_40
|
||||
#define BW_80 BAND_WIDTH_80
|
||||
#define BW_160 BAND_WIDTH_160
|
||||
#define BW_10 BAND_WIDTH_10
|
||||
#define BW_5 BAND_WIDTH_5
|
||||
#define BW_8080 BAND_WIDTH_8080
|
||||
#define BW_25 BAND_WIDTH_25
|
||||
#define BW_20_242TONE BAND_WIDTH_20_242TONE
|
||||
#define BW_NUM BAND_WIDTH_NUM
|
||||
|
||||
int get_macaddr(lua_State *L);
|
||||
int convert_string_display(lua_State *L);
|
||||
int StaInfo(lua_State *L);
|
||||
int getWMOde(lua_State *L);
|
||||
int getTempature(lua_State *L);
|
||||
int scanResult(lua_State *L);
|
||||
void getRate(HTTRANSMIT_SETTING HTSetting, ULONG *fLastTxRxRate);
|
||||
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate);
|
||||
#endif
|
459
package/mtk/applications/luci-app-mtk/src/rate_calc.c
Normal file
459
package/mtk/applications/luci-app-mtk/src/rate_calc.c
Normal file
@ -0,0 +1,459 @@
|
||||
#include "mtwifi.h"
|
||||
|
||||
#define MAX_NUM_HE_BANDWIDTHS 4
|
||||
#define MAX_NUM_HE_SPATIAL_STREAMS 4
|
||||
#define MAX_NUM_HE_MCS_ENTRIES 12
|
||||
|
||||
static UINT16 he_mcs_phyrate_mapping_table[MAX_NUM_HE_BANDWIDTHS][MAX_NUM_HE_SPATIAL_STREAMS][MAX_NUM_HE_MCS_ENTRIES] = {
|
||||
{ /*20 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
8,
|
||||
17,
|
||||
25,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
77,
|
||||
86,
|
||||
103,
|
||||
114,
|
||||
129,
|
||||
143
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
17,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
154,
|
||||
172,
|
||||
206,
|
||||
229,
|
||||
258,
|
||||
286
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
25,
|
||||
51,
|
||||
77,
|
||||
103,
|
||||
154,
|
||||
206,
|
||||
232,
|
||||
258,
|
||||
309,
|
||||
344,
|
||||
387,
|
||||
430
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
34,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
309,
|
||||
344,
|
||||
412,
|
||||
458,
|
||||
516,
|
||||
573
|
||||
}
|
||||
},
|
||||
{ /*40 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
17,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
154,
|
||||
172,
|
||||
206,
|
||||
229,
|
||||
258,
|
||||
286
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
34,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
309,
|
||||
344,
|
||||
412,
|
||||
458,
|
||||
516,
|
||||
573
|
||||
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
51,
|
||||
103,
|
||||
154,
|
||||
206,
|
||||
309,
|
||||
412,
|
||||
464,
|
||||
516,
|
||||
619,
|
||||
688,
|
||||
774,
|
||||
860
|
||||
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
68,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
412,
|
||||
550,
|
||||
619,
|
||||
688,
|
||||
825,
|
||||
917,
|
||||
1032,
|
||||
1147
|
||||
}
|
||||
},
|
||||
{ /*80 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
36,
|
||||
72,
|
||||
108,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
324,
|
||||
360,
|
||||
432,
|
||||
480,
|
||||
540,
|
||||
600
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
72,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
648,
|
||||
720,
|
||||
864,
|
||||
960,
|
||||
1080,
|
||||
1201
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
108,
|
||||
216,
|
||||
324,
|
||||
432,
|
||||
648,
|
||||
864,
|
||||
972,
|
||||
1080,
|
||||
1297,
|
||||
1441,
|
||||
1621,
|
||||
1801
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
144,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1297,
|
||||
1141,
|
||||
1729,
|
||||
1921,
|
||||
2161,
|
||||
2401
|
||||
}
|
||||
},
|
||||
{ /*160 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
72,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
648,
|
||||
720,
|
||||
864,
|
||||
960,
|
||||
1080,
|
||||
1201
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
144,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1297,
|
||||
1441,
|
||||
1729,
|
||||
1921,
|
||||
2161,
|
||||
2401
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
216,
|
||||
432,
|
||||
648,
|
||||
864,
|
||||
1297,
|
||||
1729,
|
||||
1945,
|
||||
2161,
|
||||
2594,
|
||||
2882,
|
||||
3242,
|
||||
3602
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
288,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1729,
|
||||
2305,
|
||||
2594,
|
||||
2882,
|
||||
3458,
|
||||
3843,
|
||||
4323,
|
||||
4803
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate)
|
||||
{
|
||||
ULONG value = 0;
|
||||
|
||||
if (nss == 0)
|
||||
nss = 1;
|
||||
|
||||
if (mcs >= MAX_NUM_HE_MCS_ENTRIES)
|
||||
mcs = MAX_NUM_HE_MCS_ENTRIES - 1;
|
||||
|
||||
if (nss > MAX_NUM_HE_SPATIAL_STREAMS)
|
||||
nss = MAX_NUM_HE_SPATIAL_STREAMS;
|
||||
|
||||
if (bw >= MAX_NUM_HE_BANDWIDTHS)
|
||||
bw = MAX_NUM_HE_BANDWIDTHS - 1;
|
||||
|
||||
nss--;
|
||||
|
||||
value = he_mcs_phyrate_mapping_table[bw][nss][mcs];
|
||||
/*In spec data rate when DCM =1 is half of the data rate when DCM = 0*/
|
||||
if (dcm && value)
|
||||
value = value / 2 ;
|
||||
|
||||
*last_tx_rate = (ULONG)value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static INT32 getLegacyOFDMMCSIndex(UINT8 MCS)
|
||||
{
|
||||
INT32 mcs_index = MCS;
|
||||
|
||||
if (MCS == 0xb)
|
||||
mcs_index = 0;
|
||||
else if (MCS == 0xf)
|
||||
mcs_index = 1;
|
||||
else if (MCS == 0xa)
|
||||
mcs_index = 2;
|
||||
else if (MCS == 0xe)
|
||||
mcs_index = 3;
|
||||
else if (MCS == 0x9)
|
||||
mcs_index = 4;
|
||||
else if (MCS == 0xd)
|
||||
mcs_index = 5;
|
||||
else if (MCS == 0x8)
|
||||
mcs_index = 6;
|
||||
else if (MCS == 0xc)
|
||||
mcs_index = 7;
|
||||
|
||||
return mcs_index;
|
||||
}
|
||||
|
||||
static INT MCSMappingRateTable[] = {
|
||||
2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 109, 110, 111, 112,/* CCK and OFDM */
|
||||
13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260,
|
||||
39, 78, 117, 156, 234, 312, 351, 390, /* BW 20, 800ns GI, MCS 0~23 */
|
||||
27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
|
||||
81, 162, 243, 324, 486, 648, 729, 810, /* BW 40, 800ns GI, MCS 0~23 */
|
||||
14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288,
|
||||
43, 87, 130, 173, 260, 317, 390, 433, /* BW 20, 400ns GI, MCS 0~23 */
|
||||
30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
|
||||
90, 180, 270, 360, 540, 720, 810, 900, /* BW 40, 400ns GI, MCS 0~23 */
|
||||
|
||||
/*for 11ac:20 Mhz 800ns GI*/
|
||||
6, 13, 19, 26, 39, 52, 58, 65, 78, 90, /*1ss mcs 0~8*/
|
||||
13, 26, 39, 52, 78, 104, 117, 130, 156, 180, /*2ss mcs 0~8*/
|
||||
19, 39, 58, 78, 117, 156, 175, 195, 234, 260, /*3ss mcs 0~9*/
|
||||
26, 52, 78, 104, 156, 208, 234, 260, 312, 360, /*4ss mcs 0~8*/
|
||||
|
||||
/*for 11ac:40 Mhz 800ns GI*/
|
||||
13, 27, 40, 54, 81, 108, 121, 135, 162, 180, /*1ss mcs 0~9*/
|
||||
27, 54, 81, 108, 162, 216, 243, 270, 324, 360, /*2ss mcs 0~9*/
|
||||
40, 81, 121, 162, 243, 324, 364, 405, 486, 540, /*3ss mcs 0~9*/
|
||||
54, 108, 162, 216, 324, 432, 486, 540, 648, 720, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:80 Mhz 800ns GI*/
|
||||
29, 58, 87, 117, 175, 234, 263, 292, 351, 390, /*1ss mcs 0~9*/
|
||||
58, 117, 175, 243, 351, 468, 526, 585, 702, 780, /*2ss mcs 0~9*/
|
||||
87, 175, 263, 351, 526, 702, 0, 877, 1053, 1170, /*3ss mcs 0~9*/
|
||||
117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:160 Mhz 800ns GI*/
|
||||
58, 117, 175, 234, 351, 468, 526, 585, 702, 780, /*1ss mcs 0~9*/
|
||||
117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560, /*2ss mcs 0~9*/
|
||||
175, 351, 526, 702, 1053, 1404, 1579, 1755, 2160, 0, /*3ss mcs 0~8*/
|
||||
234, 468, 702, 936, 1404, 1872, 2106, 2340, 2808, 3120, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:20 Mhz 400ns GI*/
|
||||
7, 14, 21, 28, 43, 57, 65, 72, 86, 100, /*1ss mcs 0~8*/
|
||||
14, 28, 43, 57, 86, 115, 130, 144, 173, 200, /*2ss mcs 0~8*/
|
||||
21, 43, 65, 86, 130, 173, 195, 216, 260, 288, /*3ss mcs 0~9*/
|
||||
28, 57, 86, 115, 173, 231, 260, 288, 346, 400, /*4ss mcs 0~8*/
|
||||
|
||||
/*for 11ac:40 Mhz 400ns GI*/
|
||||
15, 30, 45, 60, 90, 120, 135, 150, 180, 200, /*1ss mcs 0~9*/
|
||||
30, 60, 90, 120, 180, 240, 270, 300, 360, 400, /*2ss mcs 0~9*/
|
||||
45, 90, 135, 180, 270, 360, 405, 450, 540, 600, /*3ss mcs 0~9*/
|
||||
60, 120, 180, 240, 360, 480, 540, 600, 720, 800, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:80 Mhz 400ns GI*/
|
||||
32, 65, 97, 130, 195, 260, 292, 325, 390, 433, /*1ss mcs 0~9*/
|
||||
65, 130, 195, 260, 390, 520, 585, 650, 780, 866, /*2ss mcs 0~9*/
|
||||
97, 195, 292, 390, 585, 780, 0, 975, 1170, 1300, /*3ss mcs 0~9*/
|
||||
130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:160 Mhz 400ns GI*/
|
||||
65, 130, 195, 260, 390, 520, 585, 650, 780, 866, /*1ss mcs 0~9*/
|
||||
130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733, /*2ss mcs 0~9*/
|
||||
195, 390, 585, 780, 1170, 1560, 1755, 1950, 2340, 0, /*3ss mcs 0~8*/
|
||||
260, 520, 780, 1040, 1560, 2080, 2340, 2600, 3120, 3466, /*4ss mcs 0~9*/
|
||||
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37
|
||||
}; /* 3*3 */
|
||||
|
||||
|
||||
void getRate(HTTRANSMIT_SETTING HTSetting, ULONG *fLastTxRxRate)
|
||||
{
|
||||
UINT8 Antenna = 0;
|
||||
UINT8 MCS = HTSetting.field.MCS;
|
||||
int rate_count = sizeof(MCSMappingRateTable) / sizeof(int);
|
||||
int rate_index = 0;
|
||||
int value = 0;
|
||||
|
||||
if (HTSetting.field.MODE >= MODE_VHT) {
|
||||
MCS = HTSetting.field.MCS & 0xf;
|
||||
Antenna = (HTSetting.field.MCS >> 4) + 1;
|
||||
|
||||
if (HTSetting.field.BW == BW_20) {
|
||||
rate_index = 112 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_40) {
|
||||
rate_index = 152 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_80) {
|
||||
rate_index = 192 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_160) {
|
||||
rate_index = 232 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
}
|
||||
} else {
|
||||
if (HTSetting.field.MODE >= MODE_HTMIX) {
|
||||
MCS = HTSetting.field.MCS;
|
||||
|
||||
if ((HTSetting.field.MODE == MODE_HTMIX)
|
||||
|| (HTSetting.field.MODE == MODE_HTGREENFIELD))
|
||||
Antenna = (MCS >> 3) + 1;
|
||||
|
||||
/* map back to 1SS MCS , multiply by antenna numbers later */
|
||||
if (MCS > 7)
|
||||
MCS %= 8;
|
||||
|
||||
rate_index = 16 + ((UCHAR)HTSetting.field.BW * 24) + ((UCHAR)HTSetting.field.ShortGI * 48) + ((UCHAR)MCS);
|
||||
} else {
|
||||
if (HTSetting.field.MODE == MODE_OFDM)
|
||||
rate_index = getLegacyOFDMMCSIndex(HTSetting.field.MCS) + 4;
|
||||
else if (HTSetting.field.MODE == MODE_CCK)
|
||||
rate_index = (UCHAR)(HTSetting.field.MCS);
|
||||
}
|
||||
}
|
||||
|
||||
if (rate_index < 0)
|
||||
rate_index = 0;
|
||||
|
||||
if (rate_index >= rate_count)
|
||||
rate_index = rate_count - 1;
|
||||
|
||||
if (HTSetting.field.MODE < MODE_VHT)
|
||||
value = (MCSMappingRateTable[rate_index] * 5) / 10;
|
||||
else
|
||||
value = MCSMappingRateTable[rate_index];
|
||||
|
||||
if (HTSetting.field.MODE >= MODE_HTMIX && HTSetting.field.MODE < MODE_VHT)
|
||||
value *= Antenna;
|
||||
|
||||
*fLastTxRxRate = (ULONG)value;
|
||||
return;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user