package: mtk: add applications and drivers

This commit is contained in:
hanwckf 2022-11-13 01:39:10 +08:00
parent f7d434c528
commit f54003f7c6
55 changed files with 24417 additions and 1 deletions

6
.gitignore vendored
View File

@ -2,7 +2,7 @@
.DS_Store
.*.swp
/env
/dl
/dl/*
/.config
/.config.old
/bin
@ -30,3 +30,7 @@ git-src
.cproject
.ccache
.vscode
!/dl/datconf*
!/dl/mt798*
!/dl/warp*

View File

@ -205,6 +205,9 @@ define Package/base-files/install
$(if $(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE), \
rm -f $(1)/etc/banner.failsafe,)
$(if $(CONFIG_PACKAGE_wifi-profile), \
rm -f $(1)/sbin/wifi)
endef
ifneq ($(DUMP),1)

View File

@ -0,0 +1,92 @@
#
# Copyright (C) 2019
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=datconf
PKG_REVISION:=6bb733f7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_REVISION).tar.bz2
PKG_RELEASE:=1
PKG_USE_NINJA:=0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_MAINTAINER:=Weijie Gao <weijie.gao@mediatek.com>
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
include $(INCLUDE_DIR)/kernel.mk
define Package/libkvcutil
SECTION:=libs
CATEGORY:=Libraries
TITLE:=C library for Key-value based config files
endef
define Package/kvcedit
SECTION:=util
CATEGORY:=Utilities
DEPENDS:=+libkvcutil
TITLE:=Utility for editing key-value based config files
endef
define Package/datconf
SECTION:=MTK Properties
CATEGORY:=MTK Properties
SUBMENU:=Applications
DEPENDS:=+kvcedit
TITLE:=Utility for editing dat files used by MediaTek Wi-Fi drivers
endef
define Package/datconf-lua
SECTION:=MTK Properties
CATEGORY:=MTK Properties
SUBMENU:=Applications
DEPENDS:=+datconf +liblua
TITLE:=Lua plugin for datconf
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
CMAKE_OPTIONS = \
-DLUAPATH=/usr/lib/lua
define Package/libkvcutil/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.so* $(1)/lib/
endef
define Package/kvcedit/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/kvcutil/kvcedit $(1)/usr/bin/
endef
define Package/datconf/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/datconf/datconf $(1)/usr/bin/
endef
define Package/datconf-lua/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(CP) $(PKG_BUILD_DIR)/datconf/lua/datconf.so $(1)/usr/lib/lua/
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.h $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/datconf/libdatconf.h $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.so* $(1)/usr/lib
-$(CP) $(PKG_BUILD_DIR)/datconf/libdatconf.a $(1)/usr/lib
endef
$(eval $(call BuildPackage,libkvcutil))
$(eval $(call BuildPackage,kvcedit))
$(eval $(call BuildPackage,datconf))
$(eval $(call BuildPackage,datconf-lua))

View File

@ -0,0 +1,21 @@
#
# Copyright (C) Hua Shao <nossiac@163.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=MediaTek Proprietary Configuration.
LUCI_DEPENDS:=+datconf-lua
LUCI_MK_PATH_OLD:=$(shell test -e ../luci.mk && echo "old")
LUCI_MK_PATH_FEEDS:=$(shell test -e $(TOPDIR)/feeds/luci/luci.mk && echo "feeds")
ifeq ($(LUCI_MK_PATH_OLD),old)
include ../luci.mk
else ifeq ($(LUCI_MK_PATH_FEEDS),feeds)
include $(TOPDIR)/feeds/luci/luci.mk
else
include $(TOPDIR)/package/luci/luci.mk
endif
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,198 @@
Copyright (C) 2016 Gion Kunz
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
<%#
File name : mtk_wifi_apply_reboot.htm
This file is used in WebUI based on LuCI to handle the reboot event.
%>
<%+header%>
<h2><a>Reboot Device</a><h2>
<div id="div_reboot_warn">
<p class="alert-message">
As the driver does not support addition or deletion of interfaces on the fly,
the settings which were changed during addition or deletion of interfaces have not been applied yet!
<br /><br />
<strong>
The changed settings will be applied only after reboot of the device.
Please click on the Reboot button.
</strong>
<br /><br />
<strong>Tip:</strong><br />
Add or delete as many interfaces as required before reboot so that you do not have to reboot the device again.<br />
Please follow below instructions to add or delete an interface;</em><br />
1. Go to <a href='<%=luci.dispatcher.build_url("admin", "mtk", "wifi")%>'>Wireless Overview</a> web-page.<br />
2. Click on Add button to add a new interface or click on Remove button to delete an existing interface.<br />
3. If you are are adding a new interface, then, click on <em>Save</em> button after filling out all the required fields such as SSID etc.<br />
4. Once you are done with addition/deletion of interfaces, then please click on <em>Reload</em> button or
<em>Save and Apply</em> button on any web-page which will redirect to this web-page to perform the reboot of the device.</br>
</p>
<input class="cbi-button cbi-button-apply" type="button" value="Reboot" onclick="init_reboot()" />
</div>
<h4 id="msg_on_reboot" class="alert-message warning" style="display:none">
<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" />
Please wait while the reboot of the device is on progress.
</h4>
<h4 id="unreach_msg" class="alert-message error" style="display:none">Device has not come on-line yet!</h4>
<script type="text/javascript">
function online()
{
location = '<%=controller%>';
}
function ping(numPings)
{
var loadingImg = document.createElement('IMG');
loadingImg.onload = online;
loadingImg.src = '<%=resource%>/icons/loading.gif?' + Math.random();
numPings -= 1;
if(numPings <= 0){
document.getElementById("msg_on_reboot").style.display = 'none';
document.getElementById("unreach_msg").style.display = '';
}
else{
window.setTimeout(ping, 10000, numPings);
}
}
function init_reboot_cb()
{
window.setTimeout(ping, 10000, 18);
}
function init_reboot()
{
document.getElementById('div_reboot_warn').style.display = 'none';
document.getElementById('msg_on_reboot').style.display = '';
(new XHR()).post('<%=controller%>/admin/mtk/wifi/reboot', { token: '<%=token%>' }, init_reboot_cb);
}
</script>
<%+footer%>

View File

@ -0,0 +1,546 @@
<%+header%>
<!--
This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com>
-->
<%
local disp = require "luci.dispatcher"
-- local request = disp.context.path
local request = disp.context.request
local mtkwifi = require("mtkwifi")
local devname = request[5]
local devs = mtkwifi.get_all_devs()
local dev = {}
for _,v in ipairs(devs) do
if v.devname == devname then
dev = v
end
end
local cfgs = mtkwifi.load_profile(dev.profile)
local map_cfgs
local first_card_cfgs
local appliedMapModeDiff
%>
<script src="/luci-static/resources/monCon.js"></script>
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-17.250.41546-90ac861"></script>
<script type="text/javascript">
function hi(to) {
var a;
var x;
var tabs = new Array();
tabs.push("basic");
<% if cfgs["VOW_Airtime_Fairness_En"] then %>
tabs.push("vow");
<% end %>
for (x in tabs)
{
if (tabs[x] != to) {
a = document.getElementById('dev-cfg' + '-tab-' + tabs[x]);
a.className = "cbi-tab-disabled";
a = document.getElementById('dev-cfg' + '-' + tabs[x]);
a.style.display = "none";
}
}
a = document.getElementById('dev-cfg' + '-tab-' + to);
a.className = "cbi-tab";
a = document.getElementById('dev-cfg' + '-' + to);
a.style.display = "";
}
</script>
<form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "chip_cfg", devname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!') && ValidateAllSettings()" autocomplete="false">
<fieldset class="cbi-section">
<legend> Chip Configurations - <%=string.split(devname,".")[1]%>
<%local diff = mtkwifi.diff_profile(dev.profile)%>
<%if next(diff) ~= nil then%>
<span style="color:red;">( <a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "reload", dev.devname)%>'">Click here</a> to apply changes)</span>
<%end%>
</legend>
<ul class="cbi-tabmenu">
<li class="cbi-tab" id="dev-cfg-tab-basic">
<a href="javascript:hi('basic');this.blur(); ">Basic</a>
</li>
<% if cfgs["VOW_Airtime_Fairness_En"] then %>
<li class="cbi-tab-disabled" id="dev-cfg-tab-vow">
<a href="javascript:this.blur(); hi('vow')">VoW</a>
</li>
<% end %>
</ul>
<table id="dev-cfg-basic" class="cbi-section-table">
<tr>
<td>Decline BA Request</td>
<td>
<input type="radio" name="HT_BADecline" value="1" <% if cfgs.HT_BADecline == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="HT_BADecline" value="0" <% if cfgs.HT_BADecline == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<tr>
<td>Reverse Direction Grant (RDG)</td>
<td>
<input type="radio" name="HT_RDG" value="1" <% if cfgs.HT_RDG == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="HT_RDG" value="0" <% if cfgs.HT_RDG == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<tr>
<td>BA Win size</td>
<td>
<input name="HT_BAWinSize" id="HT_BAWinSize" value="<%=cfgs.HT_BAWinSize%>"/><% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %> (range 1-256) <% else %> (range 1-64) <% end %>
</td>
<td></td>
</tr>
<tr>
<td>HT Disallow TKIP</td>
<td>
<input type="radio" name="HT_DisallowTKIP" value="1" <% if cfgs.HT_DisallowTKIP == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="HT_DisallowTKIP" value="0" <% if cfgs.HT_DisallowTKIP == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<% if cfgs.WHNAT then %>
<tr>
<td>Wi-Fi HW NAT</td>
<td>
<select style="width:auto" name="WHNAT">
<option value="1" <% if cfgs.WHNAT == "1" then %> selected="selected"<% end%>> Enable</option>
<option value="0" <% if cfgs.WHNAT ~= "1" then %> selected="selected"<% end%>> Disable</option>
</select>
</td>
<td>Supported by MT7615</td>
</tr>
<% end %>
<% if cfgs.E2pAccessMode then %>
<tr>
<td>E2pAccessMode</td>
<td>
<select style="width:auto" name="E2pAccessMode">
<option value="1" <% if cfgs.E2pAccessMode == "1" then %> selected="selected"<% end%>>EFUSE</option>
<option value="2" <% if cfgs.E2pAccessMode == "2" then %> selected="selected"<% end%>>FLASH</option>
</select>
</td>
<td></td>
</tr>
<% end %>
<tr>
<td>Beacon Interval</td>
<td>
<input name="BeaconPeriod" id="BeaconPeriod" value="<%=cfgs.BeaconPeriod%>" />tu(range 20-999, default 100)
</td>
<td></td>
</tr>
<tr>
<td>Data Beacon Rate (DTIM)</td>
<td>
<input name="DtimPeriod" id="DtimPeriod" value="<%=cfgs.DtimPeriod%>" />Beacon interval(range 1-255, default 1)
</td>
<td></td>
</tr>
<tr>
<td>BG Protection Mode</td>
<td>
<select name="BGProtection" style="width:auto">
<option value="0" <% if cfgs.BGProtection == "0" then %>selected="selected"<% end %>>Auto</option>
<option value="1" <% if cfgs.BGProtection == "1" then %>selected="selected"<% end %>>Always On</option>
<option value="2" <% if cfgs.BGProtection == "2" then %>selected="selected"<% end %>>Always Off</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td>Short Preamble</td>
<td>
<input type="radio" name="TxPreamble" value="1" <% if cfgs.TxPreamble == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="TxPreamble" value="0" <% if cfgs.TxPreamble == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<tr>
<td>TX Burst</td>
<td>
<input type="radio" name="TxBurst" value="1" <% if cfgs.TxBurst == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="TxBurst" value="0" <% if cfgs.TxBurst == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<tr>
<td>Packet Aggregate</td>
<td>
<input type="radio" name="PktAggregate" value="1" <% if cfgs.PktAggregate == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="PktAggregate" value="0" <% if cfgs.PktAggregate == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
<tr>
<td>Short Slot</td>
<td>
<input type="radio" name="ShortSlot" value="1" <% if cfgs.ShortSlot == "1" then %> checked="checked"<% end %>/> Enable
<input type="radio" name="ShortSlot" value="0" <% if cfgs.ShortSlot == "0" then %> checked="checked"<% end %>/> Disable
</td>
<td></td>
</tr>
</table>
<% if cfgs["VOW_Airtime_Fairness_En"] then %>
<div id="dev-cfg-vow" style="display:none">
<fieldset class="cbi-section">
<legend> <a name="apcli_scan_section">Air-time Fairness (ATF)</a></legend>
<p><b>This allows you to control how the stations assiciated with a SSID share the air-time. So it is a sort of QoS scheme for wireless stations.</b></p>
<p>There are 2 modes available:</p>
<ol>
<li>All stations share air-time equally.</li>
<li>Stations will be divide into several groups, and we cab assign different air-time ration to those groups.</li>
</ol>
<input type="hidden" id="VOW_Airtime_Fairness_En" name="VOW_Airtime_Fairness_En" value="<%=cfgs.VOW_Airtime_Fairness_En or 0%>"/>
<% if cfgs.VOW_Airtime_Fairness_En == "1" then %>
<div class="cbi-button cbi-button-remove" value="1" style="width:200px" onclick="toggle_atf(this);">
Disable ATF
</div>
<% else %>
<div class="cbi-button cbi-button-add" value="0" style="width:200px" onclick="toggle_atf(this);">
Enable ATF
</div>
<% end %>
<!-- <p>
<button class="cbi-button cbi-button-add" style="width:200px" onclick="return false;">
Weighted Airtime Fairness
</button>
</p> -->
</fieldset>
<fieldset class="cbi-section">
<legend> <a name="apcli_scan_section">Air-time Control (ATC)</a></legend>
<p><b>When you have multiple SSID enabled, this allows you to control how these SSIDs share airtime. So this is a sort of QoS scheme for SSID.</b></p>
<p>There are 2 aspects you can control, If you enable both, the rules will merge togehter:</p>
<ol>
<li>by Throughput Quota</li>
<li>by Airtime Ratio</li>
</ol>
<input type="hidden" id="VOW_BW_Ctrl" name="VOW_BW_Ctrl" value="<%=cfgs.VOW_BW_Ctrl or 0%>"/>
<% if cfgs.VOW_BW_Ctrl == "1" then %>
<p class="cbi-button cbi-button-remove" style="width:200px" value="1" onclick="toggle_atc(this);">
Disable ATC
</p>
<% else %>
<p class="cbi-button cbi-button-add" style="width:200px" value="0" onclick="toggle_atc(this);">
Enable ATC
</p>
<% end %>
<br/>
<!--
VOW_Rate_Ctrl_En
VOW_Group_Min_Rate
VOW_Group_Max_Rate
VOW_Airtime_Ctrl_En
VOW_Group_Min_Ratio
VOW_Group_Max_Ratio
-->
<table id="atc-table" <% if cfgs.VOW_BW_Ctrl ~= "1" then %>style="display: none;" <% end %>>
<tr>
<th>SSID</th>
<th>ATC</th>
<th>Min</th>
<th>Max</th>
</tr>
<%
for _,vif in ipairs(dev.vifs) do
%>
<tr>
<td rowspan="2"><img src="/luci-static/resources/icons/wifi_big.png" style="float:left; margin-right:10px"><%=vif.__ssid%></td>
<td>
<input type="checkbox" name="__atc_vif<%=vif.vifidx%>_tp" value="1"
<% if vif.__atc_tp == "1" then %>checked="checked"<% end %>>
<label style="margin: 0 1em;">TP
</td>
<td>
<input type="text" class="shortinput" name="__atc_vif<%=vif.vifidx%>_min_tp" value="<%=vif.__atc_min_tp%>"> Mbps
</td>
<td>
<input type="text" class="shortinput" name="__atc_vif<%=vif.vifidx%>_max_tp" value="<%=vif.__atc_max_tp%>"> Mbps
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="__atc_vif<%=vif.vifidx%>_at" value="1"
<% if vif.__atc_at == "1" then %>checked="checked"<% end %>>
<label style="margin: 0 1em;">AT</label>
</td>
<td>
<input type="text" class="shortinput" name="__atc_vif<%=vif.vifidx%>_min_at" value="<%=vif.__atc_min_at%>"> %
</td>
<td>
<input type="text" class="shortinput" name="__atc_vif<%=vif.vifidx%>_max_at" value="<%=vif.__atc_max_at%>"> %
</td>
</tr>
<%
end
%>
</table>
</fieldset>
<fieldset class="cbi-section">
<legend> <a name="apcli_scan_section">Apply to RX</a></legend>
<p>a
<b>By default, ATF and ATC only work for TX(transmit). This option will apply ATF and ATC to RX (receive).</b>
</p>
<p>
<input type="checkbox" name="VOW_RX_En" value="1" <% if cfgs.VOW_RX_En == "1" then %> checked="checked"<%end%>> Apply both ATC &amp; ATF to RX
</p>
</fieldset>
</div>
<% end %>
<div class="cbi-page-actions">
<input class="cbi-button cbi-button-apply" name="__apply" value="Save and Apply" type="submit">
<input class="cbi-button cbi-button-apply" value="Save" type="submit">
<input class="cbi-button cbi-button-reset" value="Reset" type="reset">
</div>
</form>
<script type="text/javascript">
function ValidateAdvancedSettings()
{
var tmpVal = document.getElementById("HT_BAWinSize").value;
<% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>
if(isNaN(tmpVal) || !/^\d{1,3}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 256){
alert("BA Win SIze is incorrect!\nPlease enter an integer number between 1 to 256 inclusive.");
document.getElementById("HT_BAWinSize").focus();
document.getElementById("HT_BAWinSize").select();
return false;
}
<% else %>
if(isNaN(tmpVal) || !/^\d{1,2}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 64){
alert("BA Win Size is incorrect!\nPlease enter an integer number between 1 to 64 inclusive.");
document.getElementById("HT_BAWinSize").focus();
document.getElementById("HT_BAWinSize").select();
return false;
}
<% end %>
tmpVal = document.getElementById("BeaconPeriod").value;
if(isNaN(tmpVal) || !/^\d{2,3}$/.test(tmpVal) || parseInt(tmpVal) < 20 || parseInt(tmpVal) > 999){
alert("Beacon Interval is incorrect!\nPlease enter an integer number between 20 to 999 inclusive.");
document.getElementById("BeaconPeriod").focus();
document.getElementById("BeaconPeriod").select();
return false;
}
tmpVal = document.getElementById("DtimPeriod").value;
if(isNaN(tmpVal) || !/^\d{1,3}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 255){
alert("Data Beacon Rate (DTIM) is incorrect!\nPlease enter an integer number between 1 to 255 inclusive.");
document.getElementById("DtimPeriod").focus();
document.getElementById("DtimPeriod").select();
return false;
}
return true;
}
function ValidateAllSettings(){
if( !ValidateAdvancedSettings() ){
return false;
}
return true;
}
function toggle_atf(o) {
if (o.getAttribute("value") == "1") {
document.getElementById("VOW_Airtime_Fairness_En").value = "0";
o.setAttribute("value", "0");
o.className = "cbi-button cbi-button-add";
o.innerHTML = "Enable ATC";
} else {
document.getElementById("VOW_Airtime_Fairness_En").value = "1";
o.setAttribute("value", "1");
o.className = "cbi-button cbi-button-remove";
o.innerHTML = "Disable ATC";
}
}
function toggle_atc(o) {
if (o.getAttribute("value") == "1") {
document.getElementById("VOW_BW_Ctrl").value = "0";
o.setAttribute("value", "0");
o.className = "cbi-button cbi-button-add";
o.innerHTML = "Enable ATC";
document.getElementById("atc-table").style.display = "none";
} else {
document.getElementById("VOW_BW_Ctrl").value = "1";
o.setAttribute("value", "1");
o.className = "cbi-button cbi-button-remove";
o.innerHTML = "Disable ATC";
document.getElementById("atc-table").style.display = "";
}
}
function update_easymesh_profile_fields(obj_1905)
{
var vifsMacList=[];
var WirelessModeListJS = {};
<% for _,vif in ipairs(dev.vifs) do %>
<% if vif.state == "up" then%>
<% local bssid = vif.__bssid and vif.__bssid:sub(1,17) or ""%>
<% if bssid and bssid ~= "" then %>
vifsMacList.push("<%=bssid%>");
WirelessModeListJS['<%=bssid%>'] = {};
<% for wModeIdx, wModeStr in pairs(dev.WirelessModeList) do %>
WirelessModeListJS['<%=bssid%>']['<%=wModeIdx%>'] = "<%=wModeStr%>";
<% end %>
<% end %>
<% end %>
<% end %>
if(!obj_1905.hasOwnProperty('Radio Info')){
console.log("Topology does not have Radio Info Property!",obj_1905);
return;
}
var wmode_span = document.getElementById("EASY_MESH_WMODE_SPAN");
wmode_span.innerHTML = document.getElementById("WirelessMode").value;
var channel_span = document.getElementById("EASY_MESH_CHANNEL_SPAN");
if (!channel_span){
console.log("Failed to update EasyMesh channel field! Could not find the channel to update!");
return;
}
for (var vifIdx = 0; vifIdx < vifsMacList.length; vifIdx++){
var radioIdx;
for (radioIdx=0; radioIdx < obj_1905['Radio Info'].length; radioIdx++){
var radioInfoObj = obj_1905['Radio Info'][radioIdx];
var bssInfoArr = radioInfoObj['BSSINFO'];
var bssIdx;
for(bssIdx=0; bssIdx < bssInfoArr.length; bssIdx++){
var bssInfo = bssInfoArr[bssIdx];
if(bssInfo.hasOwnProperty('BSSID') && (bssInfo['BSSID'].toUpperCase() == vifsMacList[vifIdx].toUpperCase())){
channel_span.innerHTML = radioInfoObj['channel'];
document.getElementById("DEV_CFG_BASIC_SETTINGS").style.display = "none";
document.getElementById("EASY_MESH_DEV_SETTINGS_TBODY").style.display = "";
break;
}
}
if(bssIdx < bssInfoArr.length){
break;
}
}
if(radioIdx < obj_1905['Radio Info'].length){
break;
}
}
}
function find_own_topo_info(devRole, jsTopoInfo, alMac)
{
var tree_info = [];
var topoInfoArr = jsTopoInfo['topology information'];
if(!(topoInfoArr instanceof Array)){
console.log("Incorrect TopologyInfo: Value of topology information is not an Array!");
return;
}
for(var idx_1905=0; idx_1905 < topoInfoArr.length; idx_1905++){
var obj_1905 = topoInfoArr[idx_1905];
if (obj_1905.hasOwnProperty('AL MAC') && (obj_1905['AL MAC'].toUpperCase() == alMac.toUpperCase())){
update_easymesh_profile_fields(obj_1905);
return;
}
}
console.log(alMac," AL-MAC NOT FOUND in Topology! Topology: ",jsTopoInfo);
}
function get_al_mac(devRole, jsTopoInfo)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "multi_ap", "get_al_mac")%>' + '/' + devRole, null,
function(x)
{
console.log(x);
try{
var r = JSON.parse(x.response);
var mac_reg_exp = /[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}/;
if (r['status'] == "SUCCESS" && mac_reg_exp.test(r['al_mac'])) {
find_own_topo_info(devRole, jsTopoInfo, r['al_mac']);
}
else{
console.log("Incorrect AL-MAC received!",r['status'],r['al_mac']);
}
}
catch(e){
console.log("Incorrect response received for get AL-MAC request!",e.name,e.message);
}
}
);
}
function get_run_time_topology(devRole)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "multi_ap", "get_runtime_topology")%>', null,
function(x)
{
try{
var r = JSON.parse(x.response);
if(r.status == "SUCCESS"){
var jsTopoInfo = JSON.parse(r['luaTopologyInfo']);
get_al_mac(devRole, jsTopoInfo);
}
else{
console.log("Failed to get Topology Info!\nStatus: ",r.status);
}
}
catch(e){
console.log("Incorrect response! Failed to get Topology Info!",e.name,e.message);
}
}
);
}
function get_apply_status_cb(rsp)
{
try{
var r = JSON.parse(rsp);
}
catch(e){
return;
}
if(r.status == "ON_PROGRESS"){
var u = confirm("Device is applying the saved settings now!\n" +
"It is recommended to wait until all the saved settings are applied.\n" +
"Please click on 'OK' button to wait for the device.\n" +
"or click on 'Cancel' button to configure the settings available in current web-page.");
if (u == true) {
location = '<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "loading")%>' + window.location.pathname;
}
}
}
function get_apply_status()
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "get_apply_status")%>', null,
function(x)
{
console.log(x);
get_apply_status_cb(x.response);
}
);
}
window.onload = function() {
MonCon.ping();
get_apply_status();
}
</script>
<%+footer%>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
<%#
File name : mtk_wifi_loading.htm
This file is used in WebUI based on LuCI to handle the loading event.
%>
<%+header%>
<%
local disp = require "luci.dispatcher"
local request = disp.context.request
local url = "/"..table.concat(request,'/',5)
%>
<h2><a>Applying Settings</a></h2>
<div class="alert-message" id="BusyMsg">
<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" />
<big><strong>Please wait while the settings are being applied.</strong></big>
</div>
<div class="alert-message error" id="TimeoutMsgDiv" style="display:none">
<big><strong id="TimeoutMsg">Device is taking too much time to apply the settings!</strong></big>
</div>
<script type="text/javascript">
function visit_url(url)
{
window.onbeforeunload = function() {};
if(url && url.indexOf('<%=controller%>') != -1){
location = url;
}
else{
location = '<%=luci.dispatcher.build_url("admin", "mtk", "wifi")%>';
}
}
function get_apply_status_cb(rsp, remNumTries)
{
try{
var r = JSON.parse(rsp);
if(r.status == "DONE"){
visit_url('<%=url%>');
return;
}
else if(r.status == "REBOOT"){
visit_url('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apply_reboot")%>');
return;
}
}
catch(e){}
finally{
remNumTries -= 1;
if(remNumTries > 0){
window.setTimeout(get_apply_status, 5000, remNumTries);
}
else{
show_header();
document.getElementById("TimeoutMsgDiv").style.display = '';
document.getElementById("BusyMsg").style.display = 'none';
}
}
}
function get_apply_status(remNumTries)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "get_apply_status")%>', null,
function(x)
{
console.log(x);
get_apply_status_cb(x.response, remNumTries);
}
);
}
function show_header()
{
document.getElementsByTagName("HEADER")[0].style.display = "block";
}
function hide_header()
{
document.getElementsByTagName("HEADER")[0].style.display = "none";
}
window.onload = function(){
hide_header();
window.setTimeout(get_apply_status, 5000, 180);
}
window.onbeforeunload = function(evt) {
evt.returnValue = "Saved data have not been applied yet! Are you sure?";
return evt.returnValue;
}
</script>
<%+footer%>

View File

@ -0,0 +1,510 @@
<%+header%>
<!--
This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com>
-->
<script src="/luci-static/resources/monCon.js"></script>
<%
local mtkwifi = require("mtkwifi")
local devs = mtkwifi.get_all_devs()
local l1dat, l1 = mtkwifi.__get_l1dat()
local dridx = l1.DEV_RINDEX
local main_ifname
local map_cfgs
local first_card_cfgs
local appliedMapModeDiff
local chipname
%>
<style>
table,td,th
{
border-top:1px solid ;
border-spacing: 0;
border-color:#E0E0E0;
}
</style>
<h2><a name="content">Wireless Overview</a></h2>
<% if #devs == 0 then %>
<div class="alert-message">
<big><strong>No wireless device found!</strong></big>
</div>
<% end %>
<% for _,dev in ipairs(devs) do %>
<% main_ifname = l1dat and l1dat[dridx][dev.devname].main_ifname or dbdc_prefix[mainidx][subidx].."0" %>
<% if mtkwifi.exists("/sys/class/net/"..main_ifname) then %>
<fieldset class="cbi-section">
<table class="cbi-section-table" style="margin:10px; empty-cells:hide">
<!-- physical device -->
<tbody>
<% if chipname ~= string.split(dev.devname,".")[1].."."..(dev.mainidx) then %>
<% chipname = string.split(dev.devname,".")[1].."."..(dev.mainidx) %>
<tr style="height:45px">
<td style="width:34px">
<img src="/luci-static/resources/icons/wifi.png" style="float:left; margin-right:10px" width="30px" height="30px">
</td>
<td colspan="2" style="text-align:left">
<big><strong title="<%=dev.profile%>"> <%=string.split(dev.devname,".")[1]%></strong></big>
<%if not dev.vifs then%>
<span style="color:red;">* FATAL ERROR: Incorrect Profile Settings</span>
<%end%>
<br>
<span> Driver version: <%=dev.version%></span>
</td>
<td style="width:310px;text-align:left">
<div id="ActionBtns_<%=string.split(dev.devname,".")[1]%>">
<input class="cbi-button cbi-button-edit" style="width:100px" title="Configure WiFi device" value="Config" type="button" onclick="visit_url('<%=string.split(dev.devname,".")[1]%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "chip_cfg_view", dev.devname)%>')">
</div>
<div id="BusyText_<%=string.split(dev.devname,".")[1]%>" style="display:none">
<big><strong>Processing request.</strong></big>
</div>
</td>
</tr>
<% end %>
<tr>
<td style="width:34px"></td>
<td colspan="2" style="text-align:left;padding-left:25px;">
<big><strong title="<%=dev.profile%>"><%=dev.devname%></strong></big>
<%local diff = mtkwifi.diff_profile(dev.profile)%>
<%if next(diff) ~= nil then%>
<span style="color:red;">* need reload to apply changes</span>
<%end%>
<br>
<span> Work mode: <% if dev.ApCliEnable == "1" then %> APCli <% else %> AP <% end %></span>
</td>
<td style="width:310px;text-align:right">
<div id="ActionBtns_<%=dev.devname%>">
<%if not dev.vifs then%>
<input class="cbi-button cbi-button-apply" id="reset" value="Restore Profile to Factory Settings" type="button" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "reset_to_defaults", dev.devname)%>')">
<%else%>
<input class="cbi-button cbi-button-reload" style="width:100px" title="Reload WiFi network" value="Reload" type="button" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "reload", dev.devname)%>')">
<input class="cbi-button cbi-button-edit" style="width:100px" title="Configure WiFi device" value="Config" type="button" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view", dev.devname)%>')">
<input class="cbi-button cbi-button-add" style="width:100px" title="Add WiFi network" value="Add" type="button" onclick='add_vif("<%=dev.devname%>","<%=dev.vifs.__prefix%>","<%=dev.maxVif%>")'>
<%end%>
</div>
<div id="BusyText_<%=dev.devname%>" style="display:none">
<big><strong>Processing request.</strong></big>
</div>
</td>
</tr>
<!-- /physical device -->
<% if dev.vifs then%>
<!-- network list -->
<% for _,vif in ipairs(dev.vifs) do %>
<tr class="cbi-section-table-row cbi-rowstyle-1">
<td></td>
<td class="cbi-value-field" style="width:16px; padding:3px;padding-left:40px;">
<% if vif.state == "up" then %>
<img src="/luci-static/resources/icons/signal-75-100.png">
<% else %>
<img src="/luci-static/resources/icons/signal-none.png">
<% end %>
</td>
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
<strong>Interface:</strong> <%=vif.vifname%> |
<strong>Type:</strong> AP |
<strong>SSID:</strong>
<span id="SSID_<%=vif.vifname%>">
<% if vif.__ssid == "" then %>
<span style="color:red;"> Error: value not present in dat file </span>
<% else %>
<span> <%=vif.__ssid and vif.__ssid:gsub(" ","&nbsp;") or nil%> <% end %> </span>
</span> |
<strong>Channel:</strong>
<span id="CHANNEL_<%=vif.vifname%>"><%=vif.__channel or dev.Channel%></span>
<br>
<% if vif.state == "up" then %>
<strong>BSSID:</strong> <span id="BSSID_<%=vif.vifname%>"><%=vif.__bssid%></span> | <strong>Mode:</strong> <span><%=dev.WirelessModeList[tonumber(vif.__wirelessmode)]%></span>
<% else %>
Wireless is disabled or not associated
<% end %>
</td>
<td class="cbi-value-field" style="text-align:right">
<div id="ActionBtns_<%=vif.vifname%>">
<% if not vif.state then %>
<input class="cbi-button cbi-button-apply" style="width:100px" title="Enable this network" value="Enable" type="button" onclick="alert('Please click on Reload button of ' + '<%=dev.devname%>' + ' device to enable this interface.')">
<% elseif vif.state == "up" then %>
<input class="cbi-button cbi-button-reset" style="width:100px" title="Disable this network" value="Disable" type="button" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_disable", vif.vifname)%>')">
<% else %>
<input class="cbi-button cbi-button-apply" style="width:100px" title="Enable this network" value="Enable" type="button" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_enable", vif.vifname)%>')">
<% end %>
<input class="cbi-button cbi-button-edit" style="width:100px" title="Edit this network" value="Config" type="button" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>')">
<input class="cbi-button cbi-button-remove" style="width:100px" title="Delete this network" value="Remove" type="button" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_del", dev.devname, vif.vifname)%>')">
</div>
<div id="BusyText_<%=vif.vifname%>" style="display:none">
<big><strong>Processing request.</strong></big>
</div>
</td>
</tr>
<% end %>
<!-- /network list -->
<!-- apcli list -->
<% if dev.apcli then %>
<tr>
<td></td>
<td class="cbi-value-field" style="width:16px; padding:3px;padding-left:40px;">
<% if dev.apcli.state == "up" then %>
<img src="/luci-static/resources/icons/signal-75-100.png">
<% else %>
<img src="/luci-static/resources/icons/signal-none.png">
<% end %>
</td>
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong>Interface:</strong> <%=dev.apcli.devname%> | <strong>Type:</strong> STA | <strong>Status:</strong> <span id="ConnStatus_<%=dev.apcli.devname%>"><% if dev.ApCliEnable ~= "1" then %> Disconnected <% end %></span>
<br>
<div id="LoadingBar_<%=dev.apcli.devname%>" <% if dev.ApCliEnable ~= "1" then %> style="display:none" <% end %>>
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="width:20px;height:20px;vertical-align:middle;"/> <cite>&nbsp;Loading connection information of <%=dev.apcli.devname%></cite>
</div>
<div id="ConnInfo_<%=dev.apcli.devname%>" style="display:none">
<strong>BSSID:</strong> <span id="ApCliBssid_<%=dev.apcli.devname%>"></span> |
<strong>SSID:</strong> <span id="ApCliSsid_<%=dev.apcli.devname%>"></span>
</div>
<span id="DisConnMsg_<%=dev.apcli.devname%>" <% if dev.ApCliEnable == "1" then %> style="display:none" <% end %>>Wireless is disabled or not associated</span>
</td>
<td style="text-align:right">
<div id="ActionBtns_<%=dev.apcli.devname%>">
<% if dev.ApCliEnable ~= "1" then %>
<% if dev.apcli.state == "up" then %>
<input class="cbi-button cbi-button-reset" style="width:100px" title="Disable this network" value="Disable" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_disable", dev.apcli.vifname)%>')">
<% else %>
<input class="cbi-button cbi-button-apply" style="width:100px" title="Enable this network" value="Enable" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_enable", dev.apcli.vifname)%>')">
<% end %>
<input class="cbi-button cbi-button-reload" style="width:100px" title="Reload WiFi network" value="Connect" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')">
<input class="cbi-button cbi-button-edit" style="width:100px" title="Configure WiFi device" value="Config" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')">
<% else %>
<input class="cbi-button cbi-button-reset" id="ApCliDownBtn_<%=dev.apcli.devname%>" style="width:100px;display:none" title="Disable this network" value="Disable" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_disable", dev.apcli.vifname)%>')">
<input class="cbi-button cbi-button-apply" id="ApCliUpBtn_<%=dev.apcli.devname%>" style="width:100px;display:none" title="Enable this network" value="Enable" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_enable", dev.apcli.vifname)%>')">
<input class="cbi-button cbi-button-remove" id="ApCliDisConnBtn_<%=dev.apcli.devname%>" style="width:100px;display:none" title="Reload WiFi network" value="Disconnect" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>')">
<input class="cbi-button cbi-button-reload" id="ApCliConnBtn_<%=dev.apcli.devname%>" style="width:100px;display:none" title="Reload WiFi network" value="Connect" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')">
<input class="cbi-button cbi-button-edit" id="ApCliCfgBtn_<%=dev.apcli.devname%>" style="width:100px;display:none" title="Configure WiFi device" value="Config" type="button" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')">
<% end %>
</div>
<div id="BusyText_<%=dev.apcli.devname%>" style="display:none">
<big><strong>Processing request.</strong></big>
</div>
</td>
</tr>
<% end %>
<!-- /apcli list -->
<% end %>
</tbody>
</table>
</fieldset>
<% 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">
<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>
</tr>
<tr class="cbi-section-table-row cbi-rowstyle-2">
<td class="cbi-value-field" colspan="8">
<em><%:Collecting data...%></em>
</td>
</tr>
</table>
</fieldset>
-->
<script>
function disable_all_buttons()
{
var inp = document.getElementsByTagName("INPUT");
for(var idx=0; idx < inp.length; idx++){
inp[idx].disabled = true;
}
}
function enable_all_buttons()
{
var inp = document.getElementsByTagName("INPUT");
for(var idx=0; idx < inp.length; idx++){
inp[idx].disabled = false;
}
}
function visit_url(idSuffix,to)
{
disable_all_buttons();
document.getElementById("ActionBtns_"+idSuffix).style.display = "none";
document.getElementById("BusyText_"+idSuffix).style.display = "";
location.href = to;
}
function add_vif(devName, vifPrefix, maxVif)
{
disable_all_buttons();
document.getElementById("ActionBtns_"+devName).style.display = "none";
document.getElementById("BusyText_"+devName).style.display = "";
if(isNaN(maxVif) || !/^\d{1,}$/.test(maxVif)){
alert("Failed to add a new interface!\nERROR: Incorrect maximum supported VIF setting!\nmaxVif = " + maxVif);
location.reload(true);
return;
}
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "get_bssid_num")%>/' + devName, null,
function(x)
{
try{
var resp = JSON.parse(x.response);
if(resp["status"] == "SUCCESS"){
if(isNaN(resp["bssidNum"]) || !/^\d{1,}$/.test(resp["bssidNum"]) || parseInt(resp["bssidNum"]) > parseInt(maxVif)){
alert("Failed to add a new interface!\nERROR: Device settings have been corrupted!\nBssidNum in Response is: " + resp["bssidNum"]);
location.reload(true);
}
else if(parseInt(resp["bssidNum"]) == parseInt(maxVif)){
alert("As the Device " + devName + " supports maximum " + maxVif + " virtual interfaces, no more virtual interfaces can be added!");
}
else{
location.href = '<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_add_view")%>/' + devName + '/' + vifPrefix;
}
}
else{
alert("Failed to add a new interface!\nERROR: " + resp["status"]);
}
}
catch(e){
alert("Failed to add a new interface!\nERROR: Incorrect response received!");
console.log("Failed to add a new interface!\nERROR: [" + e.name + "] " + e.message);
}
finally{
enable_all_buttons();
document.getElementById("ActionBtns_"+devName).style.display = "";
document.getElementById("BusyText_"+devName).style.display = "none";
}
}
);
}
function apcliInfoTimerHandler(vifNameList,idx,remSec)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "get_apcli_conn_info")%>/' + vifNameList[idx], null,
function(x)
{
try{
updateApCliInfoCb(vifNameList,idx,remSec,JSON.parse(x.response));
}
catch(e){
var y={conn_state:"Disconnected"};
updateApCliInfoCb(vifNameList,idx,0,y);
}
}
);
}
function updateApCliInfoCb(vifNameList,idx,remSec,connInfo)
{
var vifName = vifNameList[idx];
if(connInfo.hasOwnProperty("conn_state") && connInfo["conn_state"] == "Connected"){
document.getElementById("ConnStatus_"+vifName).innerHTML = connInfo["conn_state"];
document.getElementById("ApCliBssid_"+vifName).innerHTML = (connInfo.hasOwnProperty("bssid")) ? connInfo["bssid"] : "?";
document.getElementById("ApCliSsid_"+vifName).innerHTML = (connInfo.hasOwnProperty("ssid")) ? connInfo["ssid"].replace(/ /g,"&nbsp;") : "";
document.getElementById("LoadingBar_"+vifName).style.display = "none";
document.getElementById("ApCliDownBtn_"+vifName).style.display = "";
document.getElementById("ApCliDisConnBtn_"+vifName).style.display = "";
document.getElementById("ApCliCfgBtn_"+vifName).style.display = "";
document.getElementById("ConnInfo_"+vifName).style.display = "";
if(idx < vifNameList.length - 1){
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx+1,5);
}
}
else{
if(remSec > 1){
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx,remSec - 1);
}
else{
document.getElementById("ConnStatus_"+vifName).innerHTML = (connInfo.hasOwnProperty("conn_state")) ? connInfo["conn_state"] : "Disconnected";
document.getElementById("LoadingBar_"+vifName).style.display = "none";
document.getElementById("DisConnMsg_"+vifName).style.display = "";
if (connInfo.hasOwnProperty("infc_state") && connInfo["infc_state"] == "up"){
document.getElementById("ApCliDownBtn_"+vifName).style.display = "";
}
else{
document.getElementById("ApCliUpBtn_"+vifName).style.display = "";
}
document.getElementById("ApCliConnBtn_"+vifName).style.display = "";
document.getElementById("ApCliCfgBtn_"+vifName).style.display = "";
if(idx < vifNameList.length - 1){
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx+1,5);
}
}
}
}
function updateApCliInfo()
{
var apCliInfcList=[];
<% for _,dev in ipairs(devs) do %>
<% if dev.apcli and dev.ApCliEnable == "1" then %>
apCliInfcList.push("<%=dev.apcli.devname%>");
<% end %>
<% end %>
if (apCliInfcList.length >= 1 ){
setTimeout(apcliInfoTimerHandler,1000,apCliInfcList,0,5);
}
}
function update_displayed_profile_fields(obj_1905)
{
var vifInfcList=[];
var WirelessModeListJS = {};
<% for _,dev in ipairs(devs) do %>
<% if dev.vifs then%>
<% for _,vif in ipairs(dev.vifs) do %>
<% if vif.state == "up" then%>
vifInfcList.push("<%=vif.vifname%>");
WirelessModeListJS['<%=vif.vifname%>'] = {};
<% for wModeIdx, wModeStr in pairs(dev.WirelessModeList) do %>
WirelessModeListJS['<%=vif.vifname%>']['<%=wModeIdx%>'] = "<%=wModeStr%>";
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
if(!obj_1905.hasOwnProperty('Radio Info')){
console.log("Topology does not have Radio Info Property!",obj_1905);
return;
}
for (var vifIdx = 0; vifIdx < vifInfcList.length; vifIdx++){
var ssid_span = document.getElementById("SSID_"+vifInfcList[vifIdx]);
var channel_span = document.getElementById("CHANNEL_"+vifInfcList[vifIdx]);
var bssid_span = document.getElementById("BSSID_"+vifInfcList[vifIdx]);
if (!ssid_span || !channel_span || !bssid_span ){
continue;
}
for (var radioIdx=0; radioIdx < obj_1905['Radio Info'].length; radioIdx++){
var radioInfoObj = obj_1905['Radio Info'][radioIdx];
var bssInfoArr = radioInfoObj['BSSINFO'];
var bssIdx;
for(bssIdx=0; bssIdx < bssInfoArr.length; bssIdx++){
var bssInfo = bssInfoArr[bssIdx];
if(bssInfo.hasOwnProperty('BSSID') && (bssInfo['BSSID'].toUpperCase() == bssid_span.innerHTML.toUpperCase())){
ssid_span.innerHTML = bssInfo['SSID'];
channel_span.innerHTML = radioInfoObj['channel'];
break;
}
}
if(bssIdx < bssInfoArr.length){
break;
}
}
}
}
function find_own_topo_info(devRole, jsTopoInfo, alMac)
{
var tree_info = [];
var topoInfoArr = jsTopoInfo['topology information'];
if(!(topoInfoArr instanceof Array)){
console.log("Incorrect TopologyInfo: Value of topology information is not an Array!");
return;
}
for(var idx_1905=0; idx_1905 < topoInfoArr.length; idx_1905++){
var obj_1905 = topoInfoArr[idx_1905];
if (obj_1905.hasOwnProperty('AL MAC') && (obj_1905['AL MAC'].toUpperCase() == alMac.toUpperCase())){
update_displayed_profile_fields(obj_1905);
return;
}
}
console.log(alMac," AL-MAC NOT FOUND in Topology! Topology: ",jsTopoInfo);
}
function get_al_mac(devRole, jsTopoInfo)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "multi_ap", "get_al_mac")%>' + '/' + devRole, null,
function(x)
{
console.log(x);
try{
var r = JSON.parse(x.response);
var mac_reg_exp = /[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}/;
if (r['status'] == "SUCCESS" && mac_reg_exp.test(r['al_mac'])) {
find_own_topo_info(devRole, jsTopoInfo, r['al_mac']);
}
else{
console.log("Incorrect AL-MAC received!",r['status'],r['al_mac']);
}
}
catch(e){
console.log("Incorrect response received for get AL-MAC request!",e.name,e.message);
}
}
);
}
function get_run_time_topology(devRole)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "multi_ap", "get_runtime_topology")%>', null,
function(x)
{
try{
var r = JSON.parse(x.response);
if(r.status == "SUCCESS"){
var jsTopoInfo = JSON.parse(r['luaTopologyInfo']);
get_al_mac(devRole, jsTopoInfo);
}
else{
console.log("Failed to get Topology Info!\nStatus: ",r.status);
}
}
catch(e){
console.log("Incorrect response! Failed to get Topology Info!",e.name,e.message);
}
}
);
}
function get_apply_status_cb(rsp)
{
try{
var r = JSON.parse(rsp);
}
catch(e){
return;
}
if(r.status == "ON_PROGRESS"){
var u = confirm("Device is applying the saved settings now!\n" +
"It is recommended to wait until all the saved settings are applied.\n" +
"Please click on 'OK' button to wait for the device.\n" +
"or click on 'Cancel' button to configure the settings available in current web-page.");
if (u == true) {
location = '<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "loading")%>' + window.location.pathname;
}
}
}
function get_apply_status()
{
XHR.get('<%=luci.dispatcher.build_url("admin", "mtk", "wifi", "get_apply_status")%>', null,
function(x)
{
console.log(x);
get_apply_status_cb(x.response);
}
);
}
window.onload = function(){
MonCon.ping();
get_apply_status();
updateApCliInfo();
}
</script>
<%+footer%>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,177 @@
#!/usr/bin/lua
-- Constant Definition
local FW_PATH = "/lib/firmware/"
local MTD_PATH = "/dev/"
local MTD_TABLE = "/proc/mtd"
local E2P_PART_NAME = "Factory"
local E2P_FILE_NAME = "e2p"
function show_usage()
print("Usage: l1dat genconfig | dbg | idx2if idx | if2zone ifname | if2dat ifname | zone2if zone | if2dbdcidx ifname")
end
function print_err(msg)
io.stderr:write("[ERR][l1dat] "..msg)
end
if not pcall(require, "l1dat_parser") then
if arg[1] == "dbg" then
print_err("Load l1dat_parser module failed\n")
end
return
end
local l1parser = require("l1dat_parser")
local l1dat = l1parser.load_l1_profile(l1parser.L1_DAT_PATH)
if not l1dat then
if arg[1] == "dbg" then
print_err("l1profile.dat is ivalid\n")
end
return
end
function read_pipe(pipe)
local fp = io.popen(pipe)
local txt = fp:read("*a")
fp:close()
return txt
end
function eeprom_extract(part, offset, size, bin_name)
local part_name = part or E2P_PART_NAME
local dump_name = bin_name or E2P_FILE_NAME
if not offset or not size or tonumber(offset) < 0 or tonumber(size) < 0 then
print_err("Invalid offset or size value")
return
end
local offset_decimal = string.format("%d", offset)
local size_decimal = string.format("%d", size)
local cmd = "cat "..MTD_TABLE.." | grep "..part_name
local mtd = read_pipe(cmd)
if not mtd or mtd == "" then
print_err("mtd partition "..part_name.." not found")
return
end
cmd = "[ -e "..FW_PATH.." ] || mkdir "..FW_PATH
os.execute(cmd)
local mtd_node = "/dev/"..string.match(mtd, "(mtd[%d]+)")
cmd = "dd if="..mtd_node.." of="..FW_PATH..dump_name.." bs=1 skip="..offset_decimal.." count="..size_decimal.." seek="..offset_decimal.." conv=notrunc 2>/dev/null"
os.execute(cmd)
end
local action0 = {
["dbg"] = function()
show_usage()
end,
["genconfig"] = function()
local seen = {}
local dridx = l1parser.DEV_RINDEX
local cmd = ""
local dir = ""
for name, dev in pairs(l1dat[dridx]) do
if not seen[dev] then
seen[dev] = true
dir = string.match(dev["profile_path"], "^(.+)/")
--print("mkdir -p "..dir)
os.execute("mkdir -p "..dir)
cmd = "ralink_init gen "..dev["nvram_zone"].." "..dev["profile_path"]
--print(cmd)
os.execute(cmd)
eeprom_extract(E2P_PART_NAME, dev.EEPROM_offset, dev.EEPROM_size, dev.EEPROM_name)
end
end
end,
["if2zone"] = function(ifname)
if not ifname then return end
local zone = l1parser.l1_ifname_to_zone(ifname) or ""
print(zone);
end,
["if2dat"] = function(ifname)
if not ifname then return end
local dat_path = l1parser.l1_ifname_to_datpath(ifname) or ""
print(dat_path)
end,
["zone2if"] = function(zone)
if not zone then return end
local main_if, ext_if, apcli, wds, mesh = l1parser.l1_zone_to_ifname(zone)
if main_if then
print(main_if.." "..ext_if.." "..apcli.." "..wds.." "..mesh)
end
end,
["idx2if"] = function(idx)
if not idx then return end
idx = tonumber(idx)
local band_num = l1parser.MAX_NUM_DBDC_BAND
local dbdc_if
local count = 0
for k, v in pairs(l1dat) do
-- check if last dbdc exists
dbdc_if = l1parser.token_get(v.main_ifname, band_num, nil)
if dbdc_if then
count = count + band_num;
else
count = count + 1
end
if not dbdc_if and count == idx then
print(v.main_ifname)
break
end
if count >= idx then -- dbdc case
local token_num = band_num - ( count - idx )
print(l1parser.token_get(v.main_ifname, token_num, nil))
break
end
end
end,
["if2dbdcidx"] = function(ifname)
if not ifname then return end
local ridx = l1parser.IF_RINDEX
if not l1dat[ridx][ifname] then return end
print(l1dat[ridx][ifname]["subidx"] or "0")
end
}
if #arg == 0 then
show_usage()
return
end
if action0[arg[1]] then
if #arg == 1 then
--print("#arg == 1", arg[1])
action0[arg[1]]()
elseif #arg == 2 then
--print("#arg == 1", arg[1], arg[2])
action0[arg[1]](arg[2])
end
else
print_err("invalid arg \""..arg[1].."\"\n");
end

View File

@ -0,0 +1,337 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
local inspect = {Options = {}, }
inspect._VERSION = 'inspect.lua 3.1.0'
inspect._URL = 'http://github.com/kikito/inspect.lua'
inspect._DESCRIPTION = 'human-readable representations of tables'
inspect._LICENSE = [[
MIT LICENSE
Copyright (c) 2022 Enrique García Cota
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end })
inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end })
local tostring = tostring
local rep = string.rep
local match = string.match
local char = string.char
local gsub = string.gsub
local fmt = string.format
local function rawpairs(t)
return next, t, nil
end
local function smartQuote(str)
if match(str, '"') and not match(str, "'") then
return "'" .. str .. "'"
end
return '"' .. gsub(str, '"', '\\"') .. '"'
end
local shortControlCharEscapes = {
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127",
}
local longControlCharEscapes = { ["\127"] = "\127" }
for i = 0, 31 do
local ch = char(i)
if not shortControlCharEscapes[ch] then
shortControlCharEscapes[ch] = "\\" .. i
longControlCharEscapes[ch] = fmt("\\%03d", i)
end
end
local function escape(str)
return (gsub(gsub(gsub(str, "\\", "\\\\"),
"(%c)%f[0-9]", longControlCharEscapes),
"%c", shortControlCharEscapes))
end
local function isIdentifier(str)
return type(str) == "string" and not not str:match("^[_%a][_%a%d]*$")
end
local flr = math.floor
local function isSequenceKey(k, sequenceLength)
return type(k) == "number" and
flr(k) == k and
1 <= (k) and
k <= sequenceLength
end
local defaultTypeOrders = {
['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
['function'] = 5, ['userdata'] = 6, ['thread'] = 7,
}
local function sortKeys(a, b)
local ta, tb = type(a), type(b)
if ta == tb and (ta == 'string' or ta == 'number') then
return (a) < (b)
end
local dta = defaultTypeOrders[ta] or 100
local dtb = defaultTypeOrders[tb] or 100
return dta == dtb and ta < tb or dta < dtb
end
local function getKeys(t)
local seqLen = 1
while rawget(t, seqLen) ~= nil do
seqLen = seqLen + 1
end
seqLen = seqLen - 1
local keys, keysLen = {}, 0
for k in rawpairs(t) do
if not isSequenceKey(k, seqLen) then
keysLen = keysLen + 1
keys[keysLen] = k
end
end
table.sort(keys, sortKeys)
return keys, keysLen, seqLen
end
local function countCycles(x, cycles)
if type(x) == "table" then
if cycles[x] then
cycles[x] = cycles[x] + 1
else
cycles[x] = 1
for k, v in rawpairs(x) do
countCycles(k, cycles)
countCycles(v, cycles)
end
countCycles(getmetatable(x), cycles)
end
end
end
local function makePath(path, a, b)
local newPath = {}
local len = #path
for i = 1, len do newPath[i] = path[i] end
newPath[len + 1] = a
newPath[len + 2] = b
return newPath
end
local function processRecursive(process,
item,
path,
visited)
if item == nil then return nil end
if visited[item] then return visited[item] end
local processed = process(item, path)
if type(processed) == "table" then
local processedCopy = {}
visited[item] = processedCopy
local processedKey
for k, v in rawpairs(processed) do
processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
if processedKey ~= nil then
processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
end
end
local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
if type(mt) ~= 'table' then mt = nil end
setmetatable(processedCopy, mt)
processed = processedCopy
end
return processed
end
local function puts(buf, str)
buf.n = buf.n + 1
buf[buf.n] = str
end
local Inspector = {}
local Inspector_mt = { __index = Inspector }
local function tabify(inspector)
puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level))
end
function Inspector:getId(v)
local id = self.ids[v]
local ids = self.ids
if not id then
local tv = type(v)
id = (ids[tv] or 0) + 1
ids[v], ids[tv] = id, id
end
return tostring(id)
end
function Inspector:putValue(v)
local buf = self.buf
local tv = type(v)
if tv == 'string' then
puts(buf, smartQuote(escape(v)))
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
tv == 'cdata' or tv == 'ctype' then
puts(buf, tostring(v))
elseif tv == 'table' and not self.ids[v] then
local t = v
if t == inspect.KEY or t == inspect.METATABLE then
puts(buf, tostring(t))
elseif self.level >= self.depth then
puts(buf, '{...}')
else
if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end
local keys, keysLen, seqLen = getKeys(t)
puts(buf, '{')
self.level = self.level + 1
for i = 1, seqLen + keysLen do
if i > 1 then puts(buf, ',') end
if i <= seqLen then
puts(buf, ' ')
self:putValue(t[i])
else
local k = keys[i - seqLen]
tabify(self)
if isIdentifier(k) then
puts(buf, k)
else
puts(buf, "[")
self:putValue(k)
puts(buf, "]")
end
puts(buf, ' = ')
self:putValue(t[k])
end
end
local mt = getmetatable(t)
if type(mt) == 'table' then
if seqLen + keysLen > 0 then puts(buf, ',') end
tabify(self)
puts(buf, '<metatable> = ')
self:putValue(mt)
end
self.level = self.level - 1
if keysLen > 0 or type(mt) == 'table' then
tabify(self)
elseif seqLen > 0 then
puts(buf, ' ')
end
puts(buf, '}')
end
else
puts(buf, fmt('<%s %d>', tv, self:getId(v)))
end
end
function inspect.inspect(root, options)
options = options or {}
local depth = options.depth or (math.huge)
local newline = options.newline or '\n'
local indent = options.indent or ' '
local process = options.process
if process then
root = processRecursive(process, root, {}, {})
end
local cycles = {}
countCycles(root, cycles)
local inspector = setmetatable({
buf = { n = 0 },
ids = {},
cycles = cycles,
depth = depth,
level = 0,
newline = newline,
indent = indent,
}, Inspector_mt)
inspector:putValue(root)
return table.concat(inspector.buf)
end
setmetatable(inspect, {
__call = function(_, root, options)
return inspect.inspect(root, options)
end,
})
return inspect

View File

@ -0,0 +1,349 @@
#!/usr/bin/env lua
--[[
* A lua library to manipulate mtk's wifi driver. used in luci-app-mtk.
*
* Copyright (C) 2016 MTK <support@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* 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 FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
]]
local l1dat_parser = {
L1_DAT_PATH = "/etc/wireless/l1profile.dat",
IF_RINDEX = "ifname_ridx",
DEV_RINDEX = "devname_ridx",
MAX_NUM_APCLI = 1,
MAX_NUM_WDS = 4,
MAX_NUM_MESH = 1,
MAX_NUM_EXTIF = 16,
MAX_NUM_DBDC_BAND = 2,
}
local l1cfg_options = {
ext_ifname="",
apcli_ifname="apcli",
wds_ifname="wds",
mesh_ifname="mesh"
}
function l1dat_parser.__trim(s)
if s then return (s:gsub("^%s*(.-)%s*$", "%1")) end
end
function l1dat_parser.__cfg2list(str)
-- delimeter == ";"
local i = 1
local list = {}
for k in string.gmatch(str, "([^;]+)") do
list[i] = k
i = i + 1
end
return list
end
function l1dat_parser.token_get(str, n, v)
-- n starts from 1
-- v is the backup in case token n is nil
if not str then return v end
local tmp = l1dat_parser.__cfg2list(str)
return tmp[tonumber(n)] or v
end
function l1dat_parser.add_default_value(l1cfg)
for k, v in ipairs(l1cfg) do
for opt, default in pairs(l1cfg_options) do
if ( opt == "ext_ifname" ) then
v[opt] = v[opt] or v["main_ifname"].."_"
else
v[opt] = v[opt] or default..k.."_"
end
end
end
return l1cfg
end
function l1dat_parser.get_value_by_idx(devidx, mainidx, subidx, key)
--print("Enter l1dat_parser.get_value_by_idx("..devidx..","..mainidx..", "..subidx..", "..key..")<br>")
if not devidx or not mainidx or not key then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local dev_ridx = l1dat_parser.DEV_RINDEX
local sidx = subidx or 1
local devname1 = devidx.."."..mainidx
local devname2 = devidx.."."..mainidx.."."..sidx
--print("devnam1=", devname1, "devname2=", devname2, "<br>")
return devs[dev_ridx][devname2] and devs[dev_ridx][devname2][key]
or devs[dev_ridx][devname1] and devs[dev_ridx][devname1][key]
end
-- path to zone is 1 to 1 mapping
function l1dat_parser.l1_path_to_zone(path)
--print("Enter l1dat_parser.l1_path_to_zone("..path..")<br>")
if not path then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
for _, dev in pairs(devs[l1dat_parser.IF_RINDEX]) do
if dev.profile_path == path then
return dev.nvram_zone
end
end
return
end
-- zone to path is 1 to n mapping
function l1dat_parser.l1_zone_to_path(zone)
if not zone then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local plist = {}
for _, dev in pairs(devs[l1dat_parser.IF_RINDEX]) do
if dev.nvram_zone == zone then
if not next(plist) then
table.insert(plist,dev.profile_path)
else
local plist_str = table.concat(plist)
if not plist_str:match(dev.profile_path) then
table.insert(plist,dev.profile_path)
end
end
end
end
return next(plist) and plist or nil
end
function l1dat_parser.l1_ifname_to_datpath(ifname)
if not ifname then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local ridx = l1dat_parser.IF_RINDEX
return devs[ridx][ifname] and devs[ridx][ifname].profile_path
end
function l1dat_parser.l1_ifname_to_zone(ifname)
if not ifname then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local ridx = l1dat_parser.IF_RINDEX
return devs[ridx][ifname] and devs[ridx][ifname].nvram_zone
end
function l1dat_parser.l1_zone_to_ifname(zone)
if not zone then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local zone_dev
for _, dev in pairs(devs[l1dat_parser.DEV_RINDEX]) do
if dev.nvram_zone == zone then
zone_dev = dev
end
end
if not zone_dev then
return nil
else
return zone_dev.main_ifname, zone_dev.ext_ifname, zone_dev.apcli_ifname, zone_dev.wds_ifname, zone_dev.mesh_ifname
end
end
-- input: L1 profile path.
-- output A table, devs, contains
-- 1. devs[%d] = table of each INDEX# in the L1 profile
-- 2. devs.ifname_ridx[ifname]
-- = table of each ifname and point to relevant contain in dev[$d]
-- 3. devs.devname_ridx[devname] similar to devs.ifnameridx, but use devname.
-- devname = INDEX#_value.mainidx(.subidx)
-- Using *_ridx do not need to handle name=k1;k2 case of DBDC card.
function l1dat_parser.load_l1_profile(path)
local devs = setmetatable({}, {__index=
function(tbl, key)
local util = require("luci.util")
--print("metatable function:", util.serialize_data(tbl), key)
--print("-----------------------------------------------")
if ( string.match(key, "^%d+")) then
tbl[key] = {}
return tbl[key]
end
end
})
local nixio = require("nixio")
local chipset_num = {}
local dir = io.popen("ls /etc/wireless/")
if not dir then return end
local fd = io.open(path, "r")
if not fd then return end
-- convert l1 profile into lua table
for line in fd:lines() do
line = l1dat_parser.__trim(line)
if string.byte(line) ~= string.byte("#") then
local i = string.find(line, "=")
if i then
local k, v, k1, k2
k = l1dat_parser.__trim( string.sub(line, 1, i-1) )
v = l1dat_parser.__trim( string.sub(line, i+1) )
k1, k2 = string.match(k, "INDEX(%d+)_(.+)")
if k1 then
k1 = tonumber(k1) + 1
if devs[k1][k2] then
nixio.syslog("warning", "skip repeated key"..line)
end
devs[k1][k2] = v or ""
else
k1 = string.match(k, "INDEX(%d+)")
k1 = tonumber(k1) + 1
devs[k1]["INDEX"] = v
chipset_num[v] = (not chipset_num[v] and 1) or chipset_num[v] + 1
devs[k1]["mainidx"] = chipset_num[v]
end
--else
-- nixio.syslog("warning", "skip line without '=' "..line)
end
--else
-- nixio.syslog("warning", "skip comment line "..line)
end
end
l1dat_parser.add_default_value(devs)
--local util = require("luci.util")
--local seen2 = {}
-- print("Before setup ridx", util.serialize_data(devs, seen2))
-- Force to setup reverse indice for quick search.
-- Benifit:
-- 1. O(1) search with ifname, devname
-- 2. Seperate DBDC name=k1;k2 format in the L1 profile into each
-- ifname, devname.
local dbdc_if = {}
local ridx = l1dat_parser.IF_RINDEX
local dridx = l1dat_parser.DEV_RINDEX
local band_num = l1dat_parser.MAX_NUM_DBDC_BAND
local k, v, dev, i , j, last
local devname
devs[ridx] = {}
devs[dridx] = {}
for _, dev in ipairs(devs) do
dbdc_if[band_num] = l1dat_parser.token_get(dev.main_ifname, band_num, nil)
if dbdc_if[band_num] then
for i = 1, band_num - 1 do
dbdc_if[i] = l1dat_parser.token_get(dev.main_ifname, i, nil)
end
for i = 1, band_num do
devs[ridx][dbdc_if[i]] = {}
devs[ridx][dbdc_if[i]]["subidx"] = i
for k, v in pairs(dev) do
if k == "INDEX" or k == "EEPROM_offset" or k == "EEPROM_size"
or k == "mainidx" then
devs[ridx][dbdc_if[i]][k] = v
else
devs[ridx][dbdc_if[i]][k] = l1dat_parser.token_get(v, i, "")
end
end
devname = dev.INDEX.."."..dev.mainidx.."."..devs[ridx][dbdc_if[i]]["subidx"]
devs[dridx][devname] = devs[ridx][dbdc_if[i]]
end
local apcli_if, wds_if, ext_if, mesh_if = {}, {}, {}, {}
for i = 1, band_num do
ext_if[i] = l1dat_parser.token_get(dev.ext_ifname, i, nil)
apcli_if[i] = l1dat_parser.token_get(dev.apcli_ifname, i, nil)
wds_if[i] = l1dat_parser.token_get(dev.wds_ifname, i, nil)
mesh_if[i] = l1dat_parser.token_get(dev.mesh_ifname, i, nil)
end
for i = 1, l1dat_parser.MAX_NUM_EXTIF - 1 do -- ifname idx is from 0
for j = 1, band_num do
devs[ridx][ext_if[j]..i] = devs[ridx][dbdc_if[j]]
end
end
for i = 0, l1dat_parser.MAX_NUM_APCLI - 1 do
for j = 1, band_num do
devs[ridx][apcli_if[j]..i] = devs[ridx][dbdc_if[j]]
end
end
for i = 0, l1dat_parser.MAX_NUM_WDS - 1 do
for j = 1, band_num do
devs[ridx][wds_if[j]..i] = devs[ridx][dbdc_if[j]]
end
end
for i = 0, l1dat_parser.MAX_NUM_MESH - 1 do
for j = 1, band_num do
if mesh_if[j] then
devs[ridx][mesh_if[j]..i] = devs[ridx][dbdc_if[j]]
end
end
end
else
devs[ridx][dev.main_ifname] = dev
devname = dev.INDEX.."."..dev.mainidx
devs[dridx][devname] = dev
for i = 1, l1dat_parser.MAX_NUM_EXTIF - 1 do -- ifname idx is from 0
devs[ridx][dev.ext_ifname..i] = dev
end
for i = 0, l1dat_parser.MAX_NUM_APCLI - 1 do -- ifname idx is from 0
devs[ridx][dev.apcli_ifname..i] = dev
end
for i = 0, l1dat_parser.MAX_NUM_WDS - 1 do -- ifname idx is from 0
devs[ridx][dev.wds_ifname..i] = dev
end
for i = 0, l1dat_parser.MAX_NUM_MESH - 1 do -- ifname idx is from 0
devs[ridx][dev.mesh_ifname..i] = dev
end
end
end
fd:close()
return devs
end
function l1dat_parser.creat_link_for_nvram( )
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
for devname, dev in pairs(devs.devname_ridx) do
local dev = devs.devname_ridx[devname]
profile = dev.profile_path
os.execute("mkdir -p /tmp/mtk/wifi/")
if dev.nvram_zone == "dev1" then
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/2860")
elseif dev.nvram_zone == "dev2" then
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/rtdev")
elseif dev.nvram_zone == "dev3" then
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/wifi3")
end
end
end
return l1dat_parser

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
#!/usr/bin/env lua
--[[
* A pure lua library to translate between:
* lua table <--> uci config
*
* For UCI: http://wiki.openwrt.org/doc/techref/uci
* http://wiki.openwrt.org/doc/uci
*
* Copyright (C) 2015 Hua Shao <nossiac@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* 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 FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
]]
local shuci = {}
function shuci.decode(path)
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local function linebreaker(str)
local i,_ = string.find(str, "([^%s])")
if not i then return nil end
if string.find(str, "config%s+%w+") then
local i,j,k,v = string.find(str, "config%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
return "section", k, v
elseif string.find(str, "option%s+%w+") then
local i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]")
if not k or not v then
i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
end
return "option", k, v
elseif string.find(str, "list%s+%w+") then
local i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]")
if not k or not v then
i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
end
return "list", k, v
end
end
if not file_exists(path) then
return
end
local _sect_ = nil
local t = {}
for line in io.lines(path) do
local _type, _name, _value = linebreaker(line)
if _type == "section" then
if not t[_name] then
t[_name] = {}
end
t[_name][#t[_name]+1] = {}
_sect_ = t[_name][#t[_name]]
if _value then
_sect_[".name"] = _value
end
end
if _type == "option" then
if _name and _value then
_sect_[_name] = _value
end
end
if _type == "list" and _name and _value then
local idx
if not _sect_[_name] then
_sect_[_name] = {}
_sect_[_name][1] = _value
else
idx = #_sect_[_name]
_sect_[_name][idx+1] = _value
end
end
end
return t
end
function shuci.encode(t, path)
local dump = io.write
if path then
local fp = io.open(path, "w")
dump = function(str) fp:write(str) end
end
for stype,ss in pairs(t) do
if #ss > 0 then
for _,s in ipairs(ss) do
dump(string.format("config\t%s\t'%s'\n", stype, s[".name"] or ""))
for k,v in pairs(s) do
if type(v) == "table" then
for _,vv in ipairs(v) do
dump(string.format("\tlist\t%s\t'%s'\n",k,vv))
end
elseif type(v) == "string" and k ~= ".name" then
dump(string.format("\toption\t%s\t'%s'\n",k,v))
elseif type(v) == "number" and k ~= ".name" then
dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v)))
end
end
dump("\n")
end
else
dump(string.format("config\t%s\t'%s'\n", stype, ss[".name"] or ""))
for k,v in pairs(ss) do
if type(v) == "table" then
for _,vv in ipairs(v) do
dump(string.format("\tlist\t%s\t'%s'\n",k,vv))
end
elseif type(v) == "string" and k ~= ".name" then
dump(string.format("\toption\t%s\t'%s'\n",k,v))
elseif type(v) == "number" and k ~= ".name" then
dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v)))
end
end
end
end
end
return shuci

View File

@ -0,0 +1,28 @@
MonCon = function()
{
this.conOk = function()
{
window.setTimeout(MonCon.ping, 5000);
}
this.ping = function()
{
var img = document.createElement('img');
img.onload = this.conOk;
img.onerror = this.conErr;
img.src = '/luci-static/resources/icons/loading.gif?' + Math.random();
}
this.conErr = function()
{
alert('Device unreachable!');
window.location.reload(true);
}
}
MonCon.ping = function()
{
(new MonCon()).ping();
}

View File

@ -0,0 +1,24 @@
OBJ_IOCTL = ioctl_helper.o
CFLAGS += -I.
CFLAGS += -I$(ROOTDIR)/user/luci/lua-5.1.5/src
CFLAGS += -Wall -shared -fPIC
LUCI_APP_MTK_TARGET = ioctl_helper
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: $(LUCI_APP_MTK_TARGET)
ioctl_helper: $(OBJ_IOCTL)
$(CC) -o $@.so $^ $(CFLAGS)
compile: $(LUCI_APP_MTK_TARGET)
install: compile
mkdir -p $(DESTDIR)/usr/lib/lua
cp -pR ioctl_helper.so $(DESTDIR)/usr/lib/lua/
clean:
rm -f *.o *.so
romfs:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
#
# hua.shao@mediatek.com
#
# MTK Property Software.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mii_mgr
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
define Package/mii_mgr
SECTION:=MTK Properties
CATEGORY:=MTK Properties
TITLE:=mii_mgr/mii_mgr_cl45
SUBMENU:=Applications
endef
define Package/mii_mgr/description
An mdio r/w phy regs program.
endef
define Package/mii_mgr/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mii_mgr $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mii_mgr $(1)/usr/sbin/mii_mgr_cl45
endef
$(eval $(call BuildPackage,mii_mgr))

View File

@ -0,0 +1,16 @@
EXEC = mii_mgr
CFLAGS += -Wall -Werror
all: $(EXEC)
mii_mgr: mii_mgr.o
$(CC) $(LDFLAGS) -o $@ $^
romfs:
$(ROMFSINST) /bin/mii_mgr
clean:
-rm -f $(EXEC) *.elf *.gdb *.o

View File

@ -0,0 +1,188 @@
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/ethtool.h>
#include <linux/mdio.h>
#include <linux/sockios.h>
#include "mii_mgr.h"
void show_usage(void)
{
printf("mii_mgr -g -i [ifname] -p [phy number] -r [register number]\n");
printf(" Get: mii_mgr -g -p 3 -r 4\n\n");
printf("mii_mgr -s -p [phy number] -r [register number] -v [0xvalue]\n");
printf(" Set: mii_mgr -s -p 4 -r 1 -v 0xff11\n");
printf("#NOTE: Without -i , eth0 is default ifname!\n");
printf("----------------------------------------------------------------------------------------\n");
printf("Get: mii_mgr_cl45 -g -p [port number] -d [dev number] -r [register number]\n");
printf("Example: mii_mgr_cl45 -g -p 3 -d 0x5 -r 0x4\n\n");
printf("Set: mii_mgr_cl45 -s -p [port number] -d [dev number] -r [register number] -v [value]\n");
printf("Example: mii_mgr_cl45 -s -p 4 -d 0x6 -r 0x1 -v 0xff11\n\n");
}
static void fill_mii_ioctl(struct mii_ioctl_data *mii, uint16_t phy_id,
uint16_t reg_num, uint16_t *val)
{
mii->phy_id = phy_id;
mii->reg_num = reg_num;
mii->val_in = *val;
mii->val_out = 0;
}
static void fill_mtk_mii_ioctl(struct mtk_mii_ioctl_data *mtk_mii, uint16_t phy_id,
uint16_t reg_num, unsigned int *val)
{
mtk_mii->phy_id = phy_id;
mtk_mii->reg_num = reg_num;
mtk_mii->val_in = *val;
mtk_mii->val_out = 0;
}
static int __phy_op(char *ifname, uint16_t phy_id, uint16_t reg_num, unsigned int *val, uint16_t cmd, int is_priv)
{
static int sd = -1;
struct ifreq ifr;
struct mii_ioctl_data mii;
struct mtk_mii_ioctl_data mtk_mii;
int err;
if (sd < 0)
sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0)
return sd;
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
if (is_priv) {
fill_mtk_mii_ioctl(&mtk_mii, phy_id, reg_num, val);
ifr.ifr_data = (char *)&mtk_mii;
} else {
fill_mii_ioctl(&mii, phy_id, reg_num, (uint16_t *)val);
ifr.ifr_data = (char *)&mii;
}
err = ioctl(sd, cmd, &ifr);
if (err)
return -errno;
if ((cmd == MTKETH_MII_WRITE) || (cmd == MTKETH_MII_WRITE_CL45) ||
(cmd == SIOCSMIIREG))
*val = (is_priv) ? mtk_mii.val_in : mii.val_in;
else
*val = (is_priv) ? mtk_mii.val_out : mii.val_out;
return 0;
}
int main(int argc, char *argv[])
{
int opt;
char options[] = "gsui:p:d:r:v:?t";
int is_write = 0,is_cl45 = 0;
int is_priv = 1;
unsigned int port=0, dev=0,reg_num=0,val=0;
char ifname[IFNAMSIZ]="eth0";
uint16_t phy_id=0;
uint16_t cmd;
if (argc < 6) {
show_usage();
return 0;
}
while ((opt = getopt(argc, argv, options)) != -1) {
switch (opt) {
case 'g':
is_write=0;
break;
case 's':
is_write=1;
break;
case 'u':
is_priv = 0;
break;
case 'i':
strncpy(ifname, optarg, 5);
ifname[IFNAMSIZ - 1] = '\0';
break;
case 'p':
port = strtoul(optarg, NULL, 16);
if (port > INT_MAX)
return -EINVAL;
break;
case 'd':
dev = strtoul(optarg, NULL, 16);
if (dev > INT_MAX)
return -EINVAL;
is_cl45 = 1;
break;
case 'r':
reg_num = strtoul(optarg, NULL, 16);
if (reg_num > INT_MAX)
return -EINVAL;
break;
case 'v':
val = strtoul(optarg, NULL, 16);
if (val > INT_MAX)
return -EINVAL;
break;
case '?':
show_usage();
break;
}
}
if(is_cl45)
phy_id = mdio_phy_id_c45(port, dev);
else
phy_id = port;
if(is_write) {
if (is_priv)
cmd = (is_cl45) ? MTKETH_MII_WRITE_CL45 :
MTKETH_MII_WRITE;
else
cmd = SIOCSMIIREG;
__phy_op(ifname,phy_id,reg_num, &val, cmd, is_priv);
if(is_cl45)
printf("Set: port%x dev%Xh_reg%Xh = 0x%04X\n",port, dev, reg_num, val);
else
printf("Set: phy[%x].reg[%x] = %04x\n",port, reg_num, val);
}
else {
if (is_priv)
cmd = (is_cl45) ? MTKETH_MII_READ_CL45 :
MTKETH_MII_READ;
else
cmd = SIOCGMIIREG;
__phy_op(ifname,phy_id,reg_num, &val, cmd, is_priv);
if(is_cl45)
printf("Get: port%x dev%Xh_reg%Xh = 0x%04X\n",port, dev, reg_num, val);
else
printf("Get: phy[%x].reg[%x] = %04x\n",port, reg_num, val);
}
return 0;
}

View File

@ -0,0 +1,20 @@
/*
* switch_ioctl.h: switch(ioctl) set API
*/
#ifndef MII_MGR_H
#define MII_MGR_H
#define MTKETH_MII_READ 0x89F3
#define MTKETH_MII_WRITE 0x89F4
#define MTKETH_MII_READ_CL45 0x89FC
#define MTKETH_MII_WRITE_CL45 0x89FD
struct mtk_mii_ioctl_data {
__u16 phy_id;
__u16 reg_num;
__u32 val_in;
__u32 val_out;
};
#endif /* MII_MGR_H */

View File

@ -0,0 +1,39 @@
#
# hua.shao@mediatek.com
#
# MTK Property Software.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=regs
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
define Package/regs
SECTION:=MTK Properties
CATEGORY:=MTK Properties
TITLE:=an program to read/write from/to a pci device from userspace.
SUBMENU:=Applications
DEPENDS:=+@KERNEL_DEVMEM
endef
define Package/regs/description
Simple program to read/write from/to a pci device from userspace.
endef
define Build/Configure
endef
define Package/regs/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/regs $(1)/usr/bin
endef
$(eval $(call BuildPackage,regs))

View File

@ -0,0 +1,13 @@
EXEC = regs
all: $(EXEC)
$(EXEC): $(EXEC).c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
romfs:
$(ROMFSINST) /bin/$(EXEC)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o

View File

@ -0,0 +1,170 @@
/*
* pcimem.c: Simple program to read/write from/to a pci device from userspace.
*
* Copyright (C) 2010, Bill Farrow (bfarrow@beyondelectronics.us)
*
* Based on the devmem2.c code
* Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
#define PRINT_ERROR \
do { \
fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); \
} while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
void dump_page(uint32_t *vaddr, uint32_t *vbase, uint32_t *pbase)
{
int i =0;
uint32_t *end = vaddr + (MAP_SIZE >> 6);
uint32_t *start = vaddr;
while(start < end) {
printf("%p:%08x %08x %08x %08x\n",
start - vbase + pbase, start[0], start[1] , start[2], start[3]);
start+=4;
}
}
void reg_mod_bits(uint32_t *virt_addr, int data, int start_bit, int data_len)
{
int mask=0;
int value;
int i;
if ((start_bit < 0) || (start_bit > 31) ||
(data_len < 1) || (data_len > 32) ||
(start_bit + data_len > 32)) {
fprintf(stderr, "Startbit range[0~31], and DataLen range[1~32], and Startbit + DataLen <= 32\n");
return;
}
for (i = 0; i < data_len; i++) {
if (start_bit + i > 31)
break;
mask |= 1 << (start_bit + i);
}
value = *((volatile uint32_t *) virt_addr);
value &= ~mask;
value |= (data << start_bit) & mask;;
*((uint32_t *) virt_addr) = value;
printf("Modify 0x%X[%d:%d]; ", data, start_bit + data_len - 1, start_bit);
}
void usage(void)
{
fprintf(stderr, "\nUsage:\tregs [Type] [ Offset:Hex ] [ Data:Hex ] [StartBit:Dec] [DataLen:Dec]\n"
"\tType : access operation type : [m]odify, [w]wite, [d]ump\n"
"\tOffset : offset into memory region to act upon\n"
"\tData : data to be written\n"
"\tStartbit: Startbit of Addr that want to be modified. Range[0~31]\n"
"\tDataLen : Data length of Data. Range[1~32], and Startbit + DataLen <= 32\n\n"
"Example:\tRead/Write/Modify register \n"
"\tRead : regs d 0x1b100000 //dump 0x1b100000~0x1b1000f0 \n"
"\tWrite : regs w 0x1b100000 0x1234 //write 0x1b100000=0x1234\n"
"\tModify : regs m 0x1b100000 0x0 29 3 //modify 0x1b100000[29:31]=0\n");
}
int main(int argc, char **argv) {
int fd;
void *map_base = NULL;
void *virt_addr = NULL;
uint32_t read_result =0;
uint32_t writeval = 0;
uint32_t startbit = 0;
uint32_t datalen = 0;
char *filename = NULL;
off_t offset = 0;
int access_type = 0;
if(argc < 3) {
usage();
exit(1);
}
access_type = tolower(argv[1][0]);
if ((access_type == 'w' && argc < 4) || (access_type == 'm' && argc < 6)) {
usage();
exit(1);
}
filename = "/dev/mem";
if((fd = open(filename, O_RDWR | O_SYNC)) == -1)
PRINT_ERROR;
/* Map one page */
offset = strtoul(argv[2], NULL, 16);
map_base = mmap(0, 2*MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset & ~MAP_MASK);
if(map_base == (void *) -1)
PRINT_ERROR;
virt_addr = map_base + (offset & MAP_MASK);
read_result = *((volatile uint32_t *) virt_addr);
printf("Value at 0x%llX (%p): 0x%X\n",
(unsigned long long)offset, virt_addr, read_result);
switch(access_type) {
case 'm':
writeval = strtoul(argv[3], 0, 16);
startbit = strtoul(argv[4], 0, 10);
datalen = strtoul(argv[5], 0, 10);
reg_mod_bits((uint32_t *)virt_addr, writeval, startbit, datalen);
break;
case 'w':
writeval = strtoul(argv[3], 0, 16);
*((uint32_t *) virt_addr) = writeval;
printf("Written 0x%X; ", writeval);
break;
case 'd':
dump_page(virt_addr, map_base, (uint32_t *)(offset & ~MAP_MASK));
goto out;
default:
fprintf(stderr, "Illegal data type '%c'.\n", access_type);
goto out;
}
read_result = *((volatile uint32_t *) virt_addr);
printf("Readback 0x%X\n", read_result);
out:
if(munmap(map_base, MAP_SIZE) == -1)
PRINT_ERROR;
close(fd);
return 0;
}

View File

@ -0,0 +1,48 @@
#
# hua.shao@mediatek.com
#
# MTK Property Software.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=switch
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
define Package/switch
SECTION:=MTK Properties
CATEGORY:=MTK Properties
DEPENDS:=+libnl-tiny
TITLE:=Command to config switch
SUBMENU:=Applications
endef
define Package/switch/description
An program to config switch.
endef
TARGET_CPPFLAGS := \
-D_GNU_SOURCE \
-I$(LINUX_DIR)/user_headers/include \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
-I$(PKG_BUILD_DIR) \
$(TARGET_CPPFLAGS) \
define Build/Compile
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
LIBS="$(TARGET_LDFLAGS) -lnl-tiny -lm"
endef
define Package/switch/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/lib/network
$(INSTALL_BIN) $(PKG_BUILD_DIR)/switch $(1)/usr/sbin
endef
$(eval $(call BuildPackage,switch))

View File

@ -0,0 +1,14 @@
EXEC = switch
SRC=switch_fun.c switch_753x.c switch_ioctl.c switch_netlink.c
all: $(EXEC)
switch: $(SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) $(LDLIBS) $(LIBS)
romfs:
$(ROMFSINST) /bin/switch
clean:
-rm -f $(EXEC) *.elf *.gdb *.o

View File

@ -0,0 +1,202 @@
MediaTek (C) 2011
The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU
General Public License is intended to guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to most of the Free Software Foundation's
software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is
covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make
sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you
receive source code or can get it if you want it, that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to
surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all
the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them
these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty
for this free software. If the software is modified by someone else and passed on, we want its recipients to know that
what they have is not the original, so that any problems introduced by others will not reflect on the original authors'
reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors
of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this,
we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it
may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or
work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to
say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into
another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is
addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its
scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made by running the Program). Whether that is true
depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided
that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of
warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other
recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection
in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and
copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of
these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any
change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the
Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for
such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright
notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may
redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if
the Program itself is interactive but does not normally print such an announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the
Program, and can be reasonably considered independent and separate works in themselves, then this License, and its
terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same
sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part
regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you;
rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the
Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the
Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms
of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than
your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source
code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange;
or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This
alternative is allowed only for noncommercial distribution and only if you received the program in object code or
executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work,
complete source code means all the source code for all modules it contains, plus any associated interface definition
files, plus the scripts used to control compilation and installation of the executable. However, as a special exception,
the source code distributed need not include anything that is normally distributed (in either source or binary form)
with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless
that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering
equivalent access to copy the source code from the same place counts as distribution of the source code, even though
third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your
rights under this License. However, parties who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you
permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do
not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you
indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or
modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a
license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You
may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not
responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to
patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as
to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence
you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy
both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the
section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest
validity of any such claims; this section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many people have made generous contributions to
the wide range of software distributed through that system in reliance on consistent application of that system; it is
up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee
cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted
interfaces, the original copyright holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time.
Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or
concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which
applies to it and "any later version", you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are
different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two
goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of
software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY
WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -0,0 +1,708 @@
/*
* switch_753x.c: set for 753x switch
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if.h>
#include "switch_netlink.h"
#include "switch_ioctl.h"
#include "switch_fun.h"
struct mt753x_attr *attres;
int chip_name;
bool nl_init_flag;
static void usage(char *cmd)
{
printf("==================Usage===============================================================================================================================\n");
/* 1. basic operations */
printf("1) mt753x switch Basic operations=================================================================================================================>>>>\n");
printf(" 1.1) %s devs - list switch device id and model name \n", cmd);
printf(" 1.2) %s sysctl - show the ways to access kenerl driver: netlink or ioctl \n", cmd);
printf(" 1.3) %s reset - sw reset switch fsm and registers\n", cmd);
printf(" 1.4) %s reg r [offset] - read the reg with default switch \n", cmd);
printf(" 1.5) %s reg w [offset] [value] - write the reg with default switch \n", cmd);
printf(" 1.6) %s reg d [offset] - dump the reg with default switch\n", cmd);
printf(" 1.7) %s dev [devid] reg r [addr] - read the reg with the switch devid \n", cmd);
printf(" 1.8) %s dev [devid] reg w [addr] [value] - write the regs with the switch devid \n", cmd);
printf(" 1.9) %s dev [devid] reg d [addr] - dump the regs with the switch devid \n", cmd);
printf(" \n");
/* 2. phy operations */
printf("2) mt753x switch PHY operations===================================================================================================================>>>>\n");
printf(" 2.1) %s phy - dump all phy registers (clause 22)\n", cmd);
printf(" 2.2) %s phy [phy_addr] - dump phy register of specific port (clause 22)\n", cmd);
printf(" 2.3) %s phy cl22 r [port_num] [phy_reg] - read specific phy register of specific port by clause 22\n", cmd);
printf(" 2.4) %s phy cl22 w [port_num] [phy_reg] [value] - write specific phy register of specific port by clause 22\n", cmd);
printf(" 2.5) %s phy cl45 r [port_num] [dev_num] [phy_reg] - read specific phy register of specific port by clause 45\n", cmd);
printf(" 2.6) %s phy cl45 w [port_num] [dev_num] [phy_reg] [value] - write specific phy register of specific port by clause 45\n", cmd);
printf(" 2.7) %s phy fc [port_num] [enable 0|1] - set switch phy flow control, port is 0~4, enable is 1, disable is 0 \n", cmd);
printf(" 2.8) %s phy an [port_num] [enable 0|1] - set switch phy auto-negotiation, port is 0~4, enable is 1, disable is 0 \n", cmd);
printf(" 2.9) %s trreg r [port_num] [ch_addr] [node_addr] [data_addr] - read phy token-ring of specific port\n", cmd);
printf(" 2.10) %s trreg w [port_num] [ch_addr] [node_addr] [data_addr] - write phy token-ring of specific port\n", cmd);
printf(" [high_value] [low_value] \n");
printf(" 2.11) %s crossover [port_num] [mode auto|mdi|mdix] - switch auto or force mdi/mdix mode for crossover cable\n", cmd);
printf(" \n");
/* 3. mac operations */
printf("3) mt753x switch MAC operations====================================================================================================================>>>>\n");
printf(" 3.1) %s dump - dump switch mac table\n", cmd);
printf(" 3.2) %s clear - clear switch mac table\n", cmd);
printf(" 3.3) %s add [mac] [portmap] - add an entry (with portmap) to switch mac table\n", cmd);
printf(" 3.4) %s add [mac] [portmap] [vlan id] - add an entry (with portmap, vlan id) to switch mac table\n", cmd);
printf(" 3.5) %s add [mac] [portmap] [vlan id] [age] - add an entry (with portmap, vlan id, age out time) to switch mac table\n", cmd);
printf(" 3.6) %s del mac [mac] vid [vid] - delete an entry from switch mac table\n", cmd);
printf(" 3.7) %s del mac [mac] fid [fid] - delete an entry from switch mac table\n", cmd);
printf(" 3.8) %s search mac [mac] vid [vid] - search an entry with specific mac and vid\n", cmd);
printf(" 3.9) %s search mac [mac] fid [fid] - search an entry with specific mac and fid\n", cmd);
printf(" 3.10) %s filt [mac] - add a SA filtering entry (with portmap 1111111) to switch mac table\n", cmd);
printf(" 3.11) %s filt [mac] [portmap] - add a SA filtering entry (with portmap)to switch mac table\n", cmd);
printf(" 3.12) %s filt [mac] [portmap] [vlan id - add a SA filtering entry (with portmap, vlan id)to switch mac table\n", cmd);
printf(" 3.13) %s filt [mac] [portmap] [vlan id] [age] - add a SA filtering entry (with portmap, vlan id, age out time) to switch table\n", cmd);
printf(" 3.14) %s arl aging [active:0|1] [time:1~65536] - set switch arl aging timeout value \n", cmd);
printf(" 3.15) %s macctl fc [enable|disable] - set switch mac global flow control,enable is 1, disable is 0 \n", cmd);
printf(" \n");
/* 4. mib counter operations */
printf("4) mt753x switch mib counter operations============================================================================================================>>>>\n");
printf(" 4.1) %s esw_cnt get -get switch mib counters \n", cmd);
printf(" 4.2) %s esw_cnt clear -clear switch mib counters \n", cmd);
printf(" 4.3) %s output_queue_cnt get -get switch output queue counters \n", cmd);
printf(" 4.4) %s free_page get -get switch system free page counters \n", cmd);
printf(" \n");
/* 5. acl function operations */
printf("5) mt753x switch acl function operations============================================================================================================>>>>\n");
printf(" 5.1) %s acl enable [port] [port_enable:0|1] - set switch acl function enabled, port is 0~6,enable is 1, disable is 0 \n", cmd);
printf(" 5.2) %s acl etype add [ethtype] [portmap] - drop L2 ethertype packets \n", cmd);
printf(" 5.3) %s acl dmac add [mac] [portmap] - drop L2 dest-Mac packets \n", cmd);
printf(" 5.4) %s acl dip add [dip] [portmap] - drop dip packets \n", cmd);
printf(" 5.5) %s acl port add [sport] [portmap] - drop L4 UDP/TCP source port packets\n", cmd);
printf(" 5.6) %s acl L4 add [2byes] [portmap] - drop L4 packets with 2bytes payload\n", cmd);
printf(" 5.7) %s acl acltbl-add [tbl_idx:0~63/255] [vawd1] [vawd2] - set switch acl table new entry, max index-7530:63,7531:255 \n", cmd);
printf(" 5.8) %s acl masktbl-add [tbl_idx:0~31/127] [vawd1] [vawd2] - set switch acl mask table new entry, max index-7530:31,7531:127 \n", cmd);
printf(" 5.9) %s acl ruletbl-add [tbl_idx:0~31/127] [vawd1] [vawd2] - set switch acl rule table new entry, max index-7530:31,7531:127 \n", cmd);
printf(" 5.10) %s acl ratetbl-add [tbl_idx:0~31] [vawd1] [vawd2] - set switch acl rate table new entry \n", cmd);
printf(" 5.11) %s acl dip meter [dip] [portmap][meter:kbps] - rate limit dip packets \n", cmd);
printf(" 5.12) %s acl dip trtcm [dip] [portmap][CIR:kbps][CBS][PIR][PBS]- TrTCM dip packets \n", cmd);
printf(" 5.13) %s acl dip modup [dip] [portmap][usr_pri] - modify usr priority from ACL \n", cmd);
printf(" 5.14) %s acl dip pppoe [dip] [portmap] - pppoe header removal \n", cmd);
printf(" \n");
/* 6. dip table operations */
printf("6) mt753x switch dip table operations=================================================================================================================>>>>\n");
printf(" 6.1) %s dip dump - dump switch dip table\n", cmd);
printf(" 6.2) %s dip clear - clear switch dip table\n", cmd);
printf(" 6.3) %s dip add [dip] [portmap] - add a dip entry to switch table\n", cmd);
printf(" 6.4) %s dip del [dip] - del a dip entry to switch table\n", cmd);
printf(" \n");
/* 7. sip table operations */
printf("7) mt753x switch sip table operations=================================================================================================================>>>>\n");
printf(" 7.1) %s sip dump - dump switch sip table\n", cmd);
printf(" 7.2) %s sip clear - clear switch sip table\n", cmd);
printf(" 7.3) %s sip add [sip] [dip] [portmap] - add a sip entry to switch table\n", cmd);
printf(" 7.4) %s sip del [sip] [dip] - del a sip entry to switch table\n", cmd);
printf(" \n");
/* 8. vlan table operations */
printf("8) mt753x switch sip table operations====================================================================================================================>>>>\n");
printf(" 8.1) %s vlan dump (egtag) - dump switch vlan table (with per port eg_tag setting)\n", cmd);
printf(" 8.2) %s vlan set [fid:0~7] [vid] [portmap] - set vlan id and associated member at switch vlan table\n", cmd);
printf(" ([stag:0~4095] [eg_con:0|1] [egtagPortMap 0:untagged 2:tagged]) \n");
printf(" Full Example: %s vlan set 0 3 10000100 0 0 20000200\n", cmd);
printf(" 8.3) %s vlan vid [vlan idx] [active:0|1] [vid] [portMap] - set switch vlan vid elements \n", cmd);
printf(" [egtagPortMap] [ivl_en] [fid] [stag] \n");
printf(" 8.4) %s vlan pvid [port] [pvid] - set switch vlan pvid \n", cmd);
printf(" 8.5) %s vlan acc-frm [port] [acceptable_frame_type:0~3] - set switch vlan acceptable_frame type : admit all frames: 0, \n", cmd);
printf(" admit only vlan-taged frames: 1,admit only untagged or priority-tagged frames: 2, reserved:3 \n");
printf(" 8.6) %s vlan port-attr [port] [attr:0~3] - set switch vlan port attribute: user port: 0, statck port: 1, \n", cmd);
printf(" translation port: 2, transparent port:3 \n");
printf(" 8.7) %s vlan port-mode [port] [mode:0~3] - set switch vlan port mode : port matrix mode: 0, fallback mode: 1, \n", cmd);
printf(" check mode: 2, security mode:3 \n");
printf(" 8.8) %s vlan eg-tag-pvc [port] [eg_tag:0~7] - set switch vlan eg tag pvc : disable: 0, consistent: 1, reserved: 2, \n", cmd);
printf(" reserved:3,untagged:4,swap:5,tagged:6, stack:7 \n");
printf(" 8.9) %s vlan eg-tag-pcr [port] [eg_tag:0~3] - set switch vlan eg tag pcr : untagged: 0, swap: 1, tagged: 2, stack:3 \n", cmd);
printf(" \n");
/* 9. rate limit operations */
printf("9) mt753x switch rate limit operations=================================================================================================================>>>>\n");
printf(" 9.1) %s ratectl [in_ex_gress:0|1] [port] [rate] - set switch port ingress(1) or egress(0) rate \n", cmd);
printf(" 9.2) %s ingress-rate on [port] [Kbps] - set ingress rate limit on port n (n= 0~ switch max port) \n", cmd);
printf(" 9.3) %s egress-rate on [port] [Kbps] - set egress rate limit on port n (n= 0~ switch max port) \n", cmd);
printf(" 9.4) %s ingress-rate off [port] - disable ingress rate limit on port n (n= 0~ switch max port) \n", cmd);
printf(" 9.5) %s egress-rate off [port] - disable egress rate limit on port n (n= 0~ switch max port)\n", cmd);
printf(" \n");
/* 10. igmp operations */
printf("10) mt753x igmp operations===============================================================================================================================>>>>\n");
printf(" 10.1) %s igmpsnoop on [leaky_en] [wan_num] - turn on IGMP snoop and router port learning\n", cmd);
printf(" leaky_en: 1 or 0. default 0; wan_num: 0 or 4. default 4\n");
printf(" 10.2) %s igmpsnoop off - turn off IGMP snoop and router port learning\n", cmd);
printf(" 10.3) %s igmpsnoop enable [port#] - enable IGMP HW leave/join/Squery/Gquery\n", cmd);
printf(" 10.4) %s igmpsnoop disable [port#] - disable IGMP HW leave/join/Squery/Gquery\n", cmd);
printf(" \n");
/* 11. QoS operations */
printf("11) mt753x QoS operations================================================================================================================================>>>>\n");
printf(" 11.1) %s qos sch [port:0~6] [queue:0~7] [shaper:min|max] [type:rr:0|sp:1|wfq:2] - set switch qos sch type\n", cmd);
printf(" 11.2) %s qos base [port:0~6] [base] - set switch qos base(UPW); port-based:0, tag-based:1, \n", cmd);
printf(" dscp-based:2, acl-based:3, arl-based:4, stag-based:5 \n");
printf(" 11.3) %s qos port-weight [port:0~6] [q0] [q1][q2][q3] - set switch qos port queue weight; \n", cmd);
printf(" [q4][q5][q6][q7] [qn]: the weight of queue n, range: 1~16 \n");
printf(" 11.4) %s qos port-prio [port:0~6] [prio:0~7] - set switch port qos user priority; port is 0~6, priority is 0~7 \n", cmd);
printf(" 11.5) %s qos dscp-prio [dscp:0~63] [prio:0~7] - set switch qos dscp user priority; dscp is 0~63, priority is 0~7 \n", cmd);
printf(" 11.6) %s qos prio-qmap [port:0~6] [prio:0~7] [queue:0~7] - set switch qos priority queue map; priority is 0~7,queue is 0~7 \n", cmd);
printf(" \n");
/*12. port mirror operations*/
printf(" 12) mt753x port mirror operations========================================================================================================================>>>>\n");
printf(" 12.1) %s mirror monitor [port] - enable port mirror and indicate monitor port number\n", cmd);
printf(" 12.2) %s mirror target [port] - set port mirror target\n", cmd);
printf(" [direction| 0:off, 1:rx, 2:tx, 3:all] \n");
printf(" 12.3) %s mirror enable [mirror_en:0|1] [mirror_port: 0-6] - set switch mirror function enable(1) or disabled(0) for port 0~6 \n", cmd);
printf(" 12.4) %s mirror port-based [port] [port_tx_mir:0|1] - set switch mirror port: target tx/rx/acl/vlan/igmp\n", cmd);
printf(" [port_rx_mir:0|1] [acl_mir:0|1] \n");
printf(" [vlan_mis:0|1] [igmp_mir:0|1] \n");
printf(" \n");
/*13. stp function*/
printf(" 13) mt753x stp operations===============================================================================================================================>>>>\n");
printf(" 13.1) %s stp [port] [fid] [state] - set switch spanning tree state, port is 0~6, fid is 0~7, \n", cmd);
printf(" state is 0~3(Disable/Discarding:0,Blocking/Listening/Discarding:1,) \n");
printf(" Learning:2,Forwarding:3 \n");
printf(" \n");
/*14. collision pool operations*/
printf("14) mt753x collision pool operations========================================================================================================================>>>>\n");
printf(" 14.1) %s collision-pool enable [enable 0|1] - enable or disable collision pool\n", cmd);
printf(" 14.2) %s collision-pool mac dump - dump collision pool mac table\n", cmd);
printf(" 14.3) %s collision-pool dip dump - dump collision pool dip table\n", cmd);
printf(" 14.4) %s collision-pool sip dump - dump collision pool sip table\n", cmd);
printf(" \n");
/*15. pfc(priority flow control) operations*/
printf("15) mt753x pfc(priority flow control) operations==============================================================================================================>>>>\n");
printf(" 15.1) %s pfc enable [port] [enable 0|1] - enable or disable port's pfc \n", cmd);
printf(" 15.2) %s pfc rx_counter [port] - get port n pfc 8 up rx counter \n", cmd);
printf(" 15.3) %s pfc tx_counter [port] - get port n pfc 8 up rx counter \n", cmd);
printf(" \n");
/*15. pfc(priority flow control) operations*/
printf("16) mt753x EEE(802.3az) operations==============================================================================================================>>>>\n");
printf(" 16.1) %s eee enable [enable 0|1] ([portMap]) - enable or disable EEE (by portMap)\n", cmd);
printf(" 16.2) %s eee dump ([port]) - dump EEE capability (by port)\n", cmd);
printf(" \n");
exit_free();
exit(0);
}
static void parse_reg_cmd(int argc, char *argv[], int len)
{
unsigned int val;
unsigned int off;
int i, j;
if (!strncmp(argv[len - 3], "reg", 4)) {
if (argv[len - 2][0] == 'r') {
off = strtoul(argv[len - 1], NULL, 16);
reg_read(off, &val);
printf(" Read reg=%x, value=%x\n", off, val);
} else if (argv[len - 2][0] == 'w') {
off = strtoul(argv[len - 1], NULL, 16);
if (argc != len + 1)
usage(argv[0]);
val = strtoul(argv[len], NULL, 16);
reg_write(off, val);
printf(" Write reg=%x, value=%x\n", off, val);
} else if (argv[len - 2][0] == 'd') {
off = strtoul(argv[len - 1], NULL, 16);
for (i = 0; i < 16; i++) {
printf("0x%08x: ", off + 0x10 * i);
for (j = 0; j < 4; j++) {
reg_read(off + i * 0x10 + j * 0x4, &val);
printf(" 0x%08x", val);
}
printf("\n");
}
} else
usage(argv[0]);
} else
usage(argv[0]);
}
static int get_chip_name()
{
int temp;
FILE *fp = NULL;
char buff[255];
/*judge 7530*/
reg_read((0x7ffc), &temp);
temp = temp >> 16;
if (temp == 0x7530)
return temp;
/*judge 7531*/
reg_read(0x781c, &temp);
temp = temp >> 16;
if (temp == 0x7531)
return temp;
/*judge jaguar embedded switch*/
fp = fopen("/proc/device-tree/compatible", "r");
if (fp != NULL) {
temp = -1;
if (fgets(buff, 255, (FILE *)fp) && strstr(buff, "mt7988"))
temp = 0x7988;
fclose(fp);
return temp;
}
return -1;
}
static int phy_operate(int argc, char *argv[])
{
unsigned int port_num;
unsigned int dev_num;
unsigned int value, cl_value;
unsigned int reg;
int ret = 0, cl_ret = 0;
char op;
if (strncmp(argv[2], "cl22", 4) && strncmp(argv[2], "cl45", 4))
usage(argv[0]);
op = argv[3][0];
switch(op) {
case 'r':
reg = strtoul(argv[argc-1], NULL, 0);
if (argc == 6) {
port_num = strtoul(argv[argc-2], NULL, 0);
ret = mii_mgr_read(port_num, reg, &value);
if (ret < 0)
printf(" Phy read reg fail\n");
else
printf(" Phy read reg=0x%x, value=0x%x\n", reg, value);
} else if (argc == 7) {
dev_num = strtoul(argv[argc-2], NULL, 0);
port_num = strtoul(argv[argc-3], NULL, 0);
ret = mii_mgr_c45_read(port_num, dev_num, reg, &value);
if (ret < 0)
printf(" Phy read reg fail\n");
else
printf(" Phy read reg=0x%x, value=0x%x\n", reg, value);
} else
ret = phy_dump(32);
break;
case 'w':
reg = strtoul(argv[argc-2], NULL, 0);
value = strtoul(argv[argc-1], NULL, 0);
if (argc == 7) {
port_num = strtoul(argv[argc-3], NULL, 0);
ret = mii_mgr_write(port_num, reg, value);
cl_ret = mii_mgr_read(port_num, reg, &cl_value);
if (cl_ret < 0)
printf(" Phy read reg fail\n");
else
printf(" Phy read reg=0x%x, value=0x%x\n", reg, cl_value);
}
else if (argc == 8) {
dev_num = strtoul(argv[argc-3], NULL, 0);
port_num = strtoul(argv[argc-4], NULL, 0);
ret = mii_mgr_c45_write(port_num, dev_num, reg, value);
cl_ret = mii_mgr_c45_read(port_num, dev_num, reg, &cl_value);
if (cl_ret < 0)
printf(" Phy read reg fail\n");
else
printf(" Phy read reg=0x%x, value=0x%x\n", reg, cl_value);
}
else
usage(argv[0]);
break;
default:
break;
}
return ret;
}
int main(int argc, char *argv[])
{
int err;
attres = (struct mt753x_attr *)malloc(sizeof(struct mt753x_attr));
attres->dev_id = -1;
attres->port_num = -1;
attres->phy_dev = -1;
nl_init_flag = true;
/* dsa netlink family might not be enabled. Try gsw netlink family. */
err = mt753x_netlink_init(MT753X_DSA_GENL_NAME);
if (!err)
chip_name = get_chip_name();
if (err < 0) {
err = mt753x_netlink_init(MT753X_GENL_NAME);
if (!err)
chip_name = get_chip_name();
}
if (err < 0) {
err = switch_ioctl_init();
if (!err) {
nl_init_flag = false;
chip_name = get_chip_name();
if (chip_name < 0) {
printf("no chip unsupport or chip id is invalid!\n");
exit_free();
exit(0);
}
}
}
if (argc < 2)
usage(argv[0]);
if (!strcmp(argv[1], "dev")) {
attres->dev_id = strtoul(argv[2], NULL, 0);
argv += 2;
argc -= 2;
if (argc < 2)
usage(argv[0]);
}
if (argc == 2) {
if (!strcmp(argv[1], "devs")) {
attres->type = MT753X_ATTR_TYPE_MESG;
mt753x_list_swdev(attres, MT753X_CMD_REQUEST);
} else if (!strncmp(argv[1], "dump", 5)) {
table_dump();
} else if (!strncmp(argv[1], "clear", 6)) {
table_clear();
printf("done.\n");
} else if (!strncmp(argv[1], "reset", 5)) {
switch_reset(argc, argv);
} else if (!strncmp(argv[1], "phy", 4)) {
phy_dump(32); //dump all phy register
} else if (!strncmp(argv[1], "sysctl", 7)) {
if (nl_init_flag)
printf("netlink(%s)\n",MT753X_GENL_NAME);
else
printf("ioctl(%s)\n",ETH_DEVNAME);
} else
usage(argv[0]);
} else if (!strncmp(argv[1], "arl", 4)) {
if (!strncmp(argv[2], "aging", 6))
doArlAging(argc, argv);
} else if (!strncmp(argv[1], "esw_cnt", 8)) {
if (!strncmp(argv[2], "get", 4))
read_mib_counters();
else if (!strncmp(argv[2], "clear", 6))
clear_mib_counters();
else
usage(argv[0]);
}else if (!strncmp(argv[1], "output_queue_cnt", 17)) {
if (!strncmp(argv[2], "get", 4))
read_output_queue_counters();
else
usage(argv[0]);
}else if (!strncmp(argv[1], "free_page", 10)) {
if (!strncmp(argv[2], "get", 4))
read_free_page_counters();
else
usage(argv[0]);
}
else if (!strncmp(argv[1], "ratectl", 8))
rate_control(argc, argv);
else if (!strncmp(argv[1], "add", 4))
table_add(argc, argv);
else if (!strncmp(argv[1], "filt", 5))
table_add(argc, argv);
else if (!strncmp(argv[1], "del", 4)) {
if (!strncmp(argv[4], "fid", 4))
table_del_fid(argc, argv);
else if (!strncmp(argv[4], "vid", 4))
table_del_vid(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "search", 7)) {
if (!strncmp(argv[4], "fid", 4))
table_search_mac_fid(argc, argv);
else if (!strncmp(argv[4], "vid", 4))
table_search_mac_vid(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "phy", 4)) {
if (argc == 3) {
int phy_addr = strtoul(argv[2], NULL, 0);
if (phy_addr < 0 || phy_addr > 31)
usage(argv[0]);
phy_dump(phy_addr);
} else if (argc == 5) {
if (!strncmp(argv[2], "fc", 2))
phy_set_fc(argc, argv);
else if (!strncmp(argv[2], "an", 2))
phy_set_an(argc, argv);
else
phy_dump(32);
} else
phy_operate(argc, argv);
} else if (!strncmp(argv[1], "trreg", 4)) {
if (rw_phy_token_ring(argc, argv) < 0)
usage(argv[0]);
} else if (!strncmp(argv[1], "macctl", 7)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "fc", 3))
global_set_mac_fc(argc, argv);
else if (!strncmp(argv[2], "pfc", 4))
set_mac_pfc(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "qos", 4)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "sch", 4))
qos_sch_select(argc, argv);
else if (!strncmp(argv[2], "base", 5))
qos_set_base(argc, argv);
else if (!strncmp(argv[2], "port-weight", 12))
qos_wfq_set_weight(argc, argv);
else if (!strncmp(argv[2], "port-prio", 10))
qos_set_portpri(argc, argv);
else if (!strncmp(argv[2], "dscp-prio", 10))
qos_set_dscppri(argc, argv);
else if (!strncmp(argv[2], "prio-qmap", 10))
qos_pri_mapping_queue(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "stp", 3)) {
if (argc < 3)
usage(argv[0]);
else
doStp(argc, argv);
} else if (!strncmp(argv[1], "sip", 5)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "dump", 5))
sip_dump();
else if (!strncmp(argv[2], "add", 4))
sip_add(argc, argv);
else if (!strncmp(argv[2], "del", 4))
sip_del(argc, argv);
else if (!strncmp(argv[2], "clear", 6))
sip_clear();
else
usage(argv[0]);
} else if (!strncmp(argv[1], "dip", 4)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "dump", 5))
dip_dump();
else if (!strncmp(argv[2], "add", 4))
dip_add(argc, argv);
else if (!strncmp(argv[2], "del", 4))
dip_del(argc, argv);
else if (!strncmp(argv[2], "clear", 6))
dip_clear();
else
usage(argv[0]);
} else if (!strncmp(argv[1], "mirror", 7)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "monitor", 8))
set_mirror_to(argc, argv);
else if (!strncmp(argv[2], "target", 7))
set_mirror_from(argc, argv);
else if (!strncmp(argv[2], "enable", 7))
doMirrorEn(argc, argv);
else if (!strncmp(argv[2], "port-based", 11))
doMirrorPortBased(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "acl", 4)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "dip", 4)) {
if (!strncmp(argv[3], "add", 4))
acl_dip_add(argc, argv);
else if (!strncmp(argv[3], "modup", 6))
acl_dip_modify(argc, argv);
else if (!strncmp(argv[3], "pppoe", 6))
acl_dip_pppoe(argc, argv);
else if (!strncmp(argv[3], "trtcm", 4))
acl_dip_trtcm(argc, argv);
else if (!strncmp(argv[3], "meter", 6))
acl_dip_meter(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[2], "dmac", 6)) {
if (!strncmp(argv[3], "add", 4))
acl_mac_add(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[2], "etype", 6)) {
if (!strncmp(argv[3], "add", 4))
acl_ethertype(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[2], "port", 5)) {
if (!strncmp(argv[3], "add", 4))
acl_sp_add(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[2], "L4", 5)) {
if (!strncmp(argv[3], "add", 4))
acl_l4_add(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[2], "enable", 7))
acl_port_enable(argc, argv);
else if (!strncmp(argv[2], "acltbl-add", 11))
acl_table_add(argc, argv);
else if (!strncmp(argv[2], "masktbl-add", 12))
acl_mask_table_add(argc, argv);
else if (!strncmp(argv[2], "ruletbl-add", 12))
acl_rule_table_add(argc, argv);
else if (!strncmp(argv[2], "ratetbl-add", 12))
acl_rate_table_add(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "vlan", 5)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "dump", 5))
vlan_dump(argc, argv);
else if (!strncmp(argv[2], "set", 4))
vlan_set(argc, argv);
else if (!strncmp(argv[2], "clear", 6))
vlan_clear(argc, argv);
else if (!strncmp(argv[2], "vid", 4))
doVlanSetVid(argc, argv);
else if (!strncmp(argv[2], "pvid", 5))
doVlanSetPvid(argc, argv);
else if (!strncmp(argv[2], "acc-frm", 8))
doVlanSetAccFrm(argc, argv);
else if (!strncmp(argv[2], "port-attr", 10))
doVlanSetPortAttr(argc, argv);
else if (!strncmp(argv[2], "port-mode", 10))
doVlanSetPortMode(argc, argv);
else if (!strncmp(argv[2], "eg-tag-pcr", 11))
doVlanSetEgressTagPCR(argc, argv);
else if (!strncmp(argv[2], "eg-tag-pvc", 11))
doVlanSetEgressTagPVC(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "reg", 4)) {
parse_reg_cmd(argc, argv, 4);
} else if (!strncmp(argv[1], "ingress-rate", 6)) {
int port = 0, bw = 0;
if (argv[2][1] == 'n') {
port = strtoul(argv[3], NULL, 0);
bw = strtoul(argv[4], NULL, 0);
if (ingress_rate_set(1, port, bw) == 0)
printf("switch port=%d, bw=%d\n", port, bw);
}
else if (argv[2][1] == 'f') {
if (argc != 4)
usage(argv[0]);
port = strtoul(argv[3], NULL, 0);
if (ingress_rate_set(0, port, bw) == 0)
printf("switch port=%d ingress rate limit off\n", port);
} else
usage(argv[0]);
} else if (!strncmp(argv[1], "egress-rate", 6)) {
int port = 0, bw = 0;
if (argv[2][1] == 'n') {
port = strtoul(argv[3], NULL, 0);
bw = strtoul(argv[4], NULL, 0);
if (egress_rate_set(1, port, bw) == 0)
printf("switch port=%d, bw=%d\n", port, bw);
} else if (argv[2][1] == 'f') {
if (argc != 4)
usage(argv[0]);
port = strtoul(argv[3], NULL, 0);
if (egress_rate_set(0, port, bw) == 0)
printf("switch port=%d egress rate limit off\n", port);
} else
usage(argv[0]);
} else if (!strncmp(argv[1], "igmpsnoop", 10)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "on", 3))
igmp_on(argc, argv);
else if (!strncmp(argv[2], "off", 4))
igmp_off();
else if (!strncmp(argv[2], "enable", 7))
igmp_enable(argc, argv);
else if (!strncmp(argv[2], "disable", 8))
igmp_disable(argc, argv);
else
usage(argv[0]);
} else if (!strncmp(argv[1], "collision-pool", 15)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "enable", 7))
collision_pool_enable(argc, argv);
else if (!strncmp(argv[2], "mac", 4)){
if (!strncmp(argv[3], "dump", 5))
collision_pool_mac_dump();
else
usage(argv[0]);
} else if (!strncmp(argv[2], "dip", 4)){
if (!strncmp(argv[3], "dump", 5))
collision_pool_dip_dump();
else
usage(argv[0]);
} else if (!strncmp(argv[2], "sip", 4)){
if (!strncmp(argv[3], "dump", 5))
collision_pool_sip_dump();
else
usage(argv[0]);
}
else
usage(argv[0]);
} else if (!strncmp(argv[1], "pfc", 15)) {
if (argc < 4 || argc > 5)
usage(argv[0]);
if (!strncmp(argv[2], "enable", 7))
set_mac_pfc(argc, argv);
else if (!strncmp(argv[2], "rx_counter", 11)){
pfc_get_rx_counter(argc, argv);
} else if (!strncmp(argv[2], "tx_counter", 11)){
pfc_get_tx_counter(argc, argv);
} else
usage(argv[0]);
} else if (!strncmp(argv[1], "crossover", 10)) {
if (argc < 4)
usage(argv[0]);
else
phy_crossover(argc, argv);
} else if (!strncmp(argv[1], "eee", 4)) {
if (argc < 3)
usage(argv[0]);
if (!strncmp(argv[2], "enable", 7) ||
!strncmp(argv[2], "disable", 8))
eee_enable(argc, argv);
else if (!strncmp(argv[2], "dump", 5))
eee_dump(argc, argv);
else
usage(argv[0]);
} else
usage(argv[0]);
exit_free();
return 0;
}

View File

@ -0,0 +1,342 @@
#define atoi(x) strtoul(x, NULL,10)
#define EXTEND_SETVID_PARAM 1
#define SQA_VERIFY 1
#define ETHCMD_DBG 1
#define ACTIVED (1<<0)
#define SWITCH_MAX_PORT 7
#define GENERAL_TABLE 0
#define COLLISION_TABLE 1
#define GSW_BASE 0x0
#define GSW_ARL_BASE (GSW_BASE + 0x0000)
#define GSW_BMU_BASE (GSW_BASE + 0x1000)
#define GSW_PORT_BASE (GSW_BASE + 0x2000)
#define GSW_MAC_BASE (GSW_BASE + 0x3000)
#define GSW_MIB_BASE (GSW_BASE + 0x4000)
#define GSW_CFG_BASE (GSW_BASE + 0x7000)
#define GSW_PCR(n) (GSW_PORT_BASE + (n)*0x100 + 0x04)
#define GSW_MFC (GSW_ARL_BASE + 0x10)
#define GSW_UPW(n) (GSW_PORT_BASE + (n)*0x100 + 0x40)
//#define GSW_PEM(n) (GSW_ARL_BASE + (n)*0x4 + 0x48)
#define GSW_PEM(n) (GSW_PORT_BASE + (n)*0x4 + 0x44)
#define GSW_MMSCR0_Q(n) (GSW_BMU_BASE + (n)*0x8)
#define GSW_MMSCR1_Q(n) (GSW_BMU_BASE + (n)*0x8 + 0x04)
#define GSW_PMCR(n) (GSW_MAC_BASE + (n)*0x100)
#define GSW_PMSR(n) (GSW_MAC_BASE + (n)*0x100 + 0x08)
#define GSW_PINT_EN(n) (GSW_MAC_BASE + (n)*0x100 + 0x10)
#define GSW_SMACCR0 (GSW_MAC_BASE + 0xe4)
#define GSW_SMACCR1 (GSW_MAC_BASE + 0xe8)
#define GSW_CKGCR (GSW_MAC_BASE + 0xf0)
#define GSW_ESR(n) (GSW_MIB_BASE + (n)*0x100 + 0x00)
#define GSW_INTS(n) (GSW_MIB_BASE + (n)*0x100 + 0x04)
#define GSW_TGPC(n) (GSW_MIB_BASE + (n)*0x100 + 0x10)
#define GSW_TBOC(n) (GSW_MIB_BASE + (n)*0x100 + 0x14)
#define GSW_TGOC(n) (GSW_MIB_BASE + (n)*0x100 + 0x18)
#define GSW_TEPC(n) (GSW_MIB_BASE + (n)*0x100 + 0x1C)
#define GSW_RGPC(n) (GSW_MIB_BASE + (n)*0x100 + 0x20)
#define GSW_RBOC(n) (GSW_MIB_BASE + (n)*0x100 + 0x24)
#define GSW_RGOC(n) (GSW_MIB_BASE + (n)*0x100 + 0x28)
#define GSW_REPC1(n) (GSW_MIB_BASE + (n)*0x100 + 0x2C)
#define GSW_REPC2(n) (GSW_MIB_BASE + (n)*0x100 + 0x30)
#define GSW_MIBCNTEN (GSW_MIB_BASE + 0x800)
#define GSW_AECNT1 (GSW_MIB_BASE + 0x804)
#define GSW_AECNT2 (GSW_MIB_BASE + 0x808)
#define GSW_CFG_PPSC (GSW_CFG_BASE + 0x0)
#define GSW_CFG_PIAC (GSW_CFG_BASE + 0x4)
#define GSW_CFG_GPC (GSW_CFG_BASE + 0x14)
#define MAX_VID_VALUE (4095)
#define MAX_VLAN_RULE (16)
#define REG_MFC_ADDR (0x0010)
#define REG_ISC_ADDR (0x0018)
#define REG_CFC_ADDR (0x0004)
#define REG_CFC_MIRROR_PORT_OFFT (16)
#define REG_CFC_MIRROR_PORT_LENG (3)
#define REG_CFC_MIRROR_PORT_RELMASK (0x00000007)
#define REG_CFC_MIRROR_PORT_MASK (REG_CFC_MIRROR_PORT_RELMASK << REG_CFC_MIRROR_PORT_OFFT)
#define REG_CFC_MIRROR_EN_OFFT (19)
#define REG_CFC_MIRROR_EN_LENG (1)
#define REG_CFC_MIRROR_EN_RELMASK (0x00000001)
#define REG_CFC_MIRROR_EN_MASK (REG_CFC_MIRROR_EN_RELMASK << REG_CFC_MIRROR_EN_OFFT)
#define REG_ATA1_ADDR (0x0074)
#define REG_ATA2_ADDR (0x0078)
#define REG_ATWD_ADDR (0x007C)
#define REG_ATWD_STATUS_OFFT (2)
#define REG_ATWD_STATUS_LENG (2)
#define REG_ATWD_STATUS_RELMASK (0x00000003)
#define REG_ATWD_STATUS_MASK (REG_ATWD_STATUS_RELMASK << REG_ATWD_STATUS_OFFT)
#define REG_ATWD_PORT_OFFT (4)
#define REG_ATWD_PORT_LENG (8)
#define REG_ATWD_PORT_RELMASK (0x000000FF)
#define REG_ATWD_PORT_MASK (REG_ATWD_PORT_RELMASK << REG_ATWD_PORT_OFFT)
#define REG_ATWD_LEAKY_EN_OFFT (12)
#define REG_ATWD_LEAKY_EN_LENG (1)
#define REG_ATWD_LEAKY_EN_RELMASK (0x00000001)
#define REG_ATWD_LEAKY_EN_MASK (REG_ATWD_LEAKY_EN_RELMASK << REG_ATWD_LEAKY_EN_OFFT)
#define REG_ATWD_EG_TAG_OFFT (13)
#define REG_ATWD_EG_TAG_LENG (3)
#define REG_ATWD_EG_TAG_RELMASK (0x00000007)
#define REG_ATWD_EG_TAG_MASK (REG_ATWD_EG_TAG_RELMASK << REG_ATWD_EG_TAG_OFFT)
#define REG_ATWD_USR_PRI_OFFT (16)
#define REG_ATWD_USR_PRI_LENG (3)
#define REG_ATWD_USR_PRI_RELMASK (0x00000007)
#define REG_ATWD_USR_PRI_MASK (REG_ATWD_USR_PRI_RELMASK << REG_ATWD_USR_PRI_OFFT)
#define REG_ATWD_SA_MIR_EN_OFFT (19)
#define REG_ATWD_SA_MIR_EN_LENG (1)
#define REG_ATWD_SA_MIR_EN_RELMASK (0x00000001)
#define REG_ATWD_SA_MIR_EN_MASK (REG_ATWD_SA_MIR_EN_RELMASK << REG_ATWD_SA_MIR_EN_OFFT)
#define REG_ATWD_SA_PORT_FW_OFFT (20)
#define REG_ATWD_SA_PORT_FW_LENG (3)
#define REG_ATWD_SA_PORT_FW_RELMASK (0x00000007)
#define REG_ATWD_SA_PORT_FW_MASK (REG_ATWD_SA_PORT_FW_RELMASK << REG_ATWD_SA_PORT_FW_OFFT)
#define REG_ATC_ADDR (0x0080)
#define REG_ATC_AC_CMD_OFFT (0)
#define REG_ATC_AC_CMD_LENG (3)
#define REG_ATC_AC_CMD_RELMASK (0x00000007)
#define REG_ATC_AC_CMD_MASK (REG_ATC_AC_CMD_RELMASK << REG_ATC_AC_CMD_OFFT)
#define REG_ATC_AC_SAT_OFFT (4)
#define REG_ATC_AC_SAT_LENG (2)
#define REG_ATC_AC_SAT_RELMASK (0x00000003)
#define REG_ATC_AC_SAT_MASK (REG_ATC_AC_SAT_RELMASK << REG_ATC_AC_SAT_OFFT)
#define REG_ATC_AC_MAT_OFFT (8)
#define REG_ATC_AC_MAT_LENG (4)
#define REG_ATC_AC_MAT_RELMASK (0x0000000F)
#define REG_ATC_AC_MAT_MASK (REG_ATC_AC_MAT_RELMASK << REG_ATC_AC_MAT_OFFT)
#define REG_AT_SRCH_HIT_OFFT (13)
#define REG_AT_SRCH_HIT_RELMASK (0x00000001)
#define REG_AT_SRCH_HIT_MASK (REG_AT_SRCH_HIT_RELMASK << REG_AT_SRCH_HIT_OFFT)
#define REG_AT_SRCH_END_OFFT (14)
#define REG_AT_SRCH_END_RELMASK (0x00000001)
#define REG_AT_SRCH_END_MASK (REG_AT_SRCH_END_RELMASK << REG_AT_SRCH_END_OFFT)
#define REG_ATC_BUSY_OFFT (15)
#define REG_ATC_BUSY_LENG (1)
#define REG_ATC_BUSY_RELMASK (0x00000001)
#define REG_ATC_BUSY_MASK (REG_ATC_BUSY_RELMASK << REG_ATC_BUSY_OFFT)
#define REG_AT_ADDR_OFFT (16)
#define REG_AT_ADDR_LENG (12)
#define REG_AT_ADDR_RELMASK (0x00000FFF)
#define REG_AT_ADDR_MASK (REG_AT_ADDR_RELMASK << REG_AT_ADDR_OFFT)
#define REG_TSRA1_ADDR (0x0084)
#define REG_TSRA2_ADDR (0x0088)
#define REG_ATRD_ADDR (0x008C)
#define REG_VTCR_ADDR (0x0090)
#define REG_VTCR_VID_OFFT (0)
#define REG_VTCR_VID_LENG (12)
#define REG_VTCR_VID_RELMASK (0x00000FFF)
#define REG_VTCR_VID_MASK (REG_VTCR_VID_RELMASK << REG_VTCR_VID_OFFT)
#define REG_VTCR_FUNC_OFFT (12)
#define REG_VTCR_FUNC_LENG (4)
#define REG_VTCR_FUNC_RELMASK (0x0000000F)
#define REG_VTCR_FUNC_MASK (REG_VTCR_FUNC_RELMASK << REG_VTCR_FUNC_OFFT)
#define REG_VTCR_IDX_INVLD_OFFT (16)
#define REG_VTCR_IDX_INVLD_RELMASK (0x00000001)
#define REG_VTCR_IDX_INVLD_MASK (REG_VTCR_IDX_INVLD_RELMASK << REG_VTCR_IDX_INVLD_OFFT)
#define REG_VTCR_BUSY_OFFT (31)
#define REG_VTCR_BUSY_RELMASK (0x00000001)
#define REG_VTCR_BUSY_MASK (REG_VTCR_BUSY_RELMASK << REG_VTCR_BUSY_OFFT)
#define REG_VAWD1_ADDR (0x0094)
#define REG_VAWD2_ADDR (0x0098)
#define REG_VLAN_ID_BASE (0x0100)
#define REG_CPGC_ADDR (0xB0)
#define REG_CPCG_COL_EN_OFFT (0)
#define REG_CPCG_COL_EN_RELMASK (0x00000001)
#define REG_CPCG_COL_EN_MASK (REG_CPCG_COL_EN_RELMASK << REG_CPCG_COL_EN_OFFT)
#define REG_CPCG_COL_CLK_EN_OFFT (1)
#define REG_CPCG_COL_CLK_EN_RELMASK (0x00000001)
#define REG_CPCG_COL_CLK_EN_MASK (REG_CPCG_COL_CLK_EN_RELMASK << REG_CPCG_COL_CLK_EN_OFFT)
#define REG_CPCG_COL_RST_N_OFFT (2)
#define REG_CPCG_COL_RST_N_RELMASK (0x00000001)
#define REG_CPCG_COL_RST_N_MASK (REG_CPCG_COL_RST_N_RELMASK << REG_CPCG_COL_RST_N_OFFT)
#define REG_GFCCR0_ADDR (0x1FE0)
#define REG_FC_EN_OFFT (31)
#define REG_FC_EN_RELMASK (0x00000001)
#define REG_FC_EN_MASK (REG_FC_EN_RELMASK << REG_FC_EN_OFFT)
#define REG_PFC_CTRL_ADDR (0x30b0)
#define PFC_RX_COUNTER_L(n) (0x3030 + (n)*0x100)
#define PFC_RX_COUNTER_H(n) (0x3034 + (n)*0x100)
#define PFC_TX_COUNTER_L(n) (0x3040 + (n)*0x100)
#define PFC_TX_COUNTER_H(n) (0x3044 + (n)*0x100)
#define PMSR_P(n) (0x3008 + (n)*0x100)
#define REG_SSC_P0_ADDR (0x2000)
#define REG_PCR_P0_ADDR (0x2004)
#define REG_PCR_VLAN_MIS_OFFT (2)
#define REG_PCR_VLAN_MIS_LENG (1)
#define REG_PCR_VLAN_MIS_RELMASK (0x00000001)
#define REG_PCR_VLAN_MIS_MASK (REG_PCR_VLAN_MIS_RELMASK << REG_PCR_VLAN_MIS_OFFT)
#define REG_PCR_ACL_MIR_OFFT (7)
#define REG_PCR_ACL_MIR_LENG (1)
#define REG_PCR_ACL_MIR_RELMASK (0x00000001)
#define REG_PCR_ACL_MIR_MASK (REG_PCR_ACL_MIR_RELMASK << REG_PCR_ACL_MIR_OFFT)
#define REG_PORT_RX_MIR_OFFT (8)
#define REG_PORT_RX_MIR_LENG (1)
#define REG_PORT_RX_MIR_RELMASK (0x00000001)
#define REG_PORT_RX_MIR_MASK (REG_PORT_RX_MIR_RELMASK << REG_PORT_RX_MIR_OFFT)
#define REG_PORT_TX_MIR_OFFT (9)
#define REG_PORT_TX_MIR_LENG (1)
#define REG_PORT_TX_MIR_RELMASK (0x00000001)
#define REG_PORT_TX_MIR_MASK (REG_PORT_TX_MIR_RELMASK << REG_PORT_TX_MIR_OFFT)
#define REG_PORT_ACL_EN_OFFT (10)
#define REG_PORT_ACL_EN_LENG (1)
#define REG_PORT_ACL_EN_RELMASK (0x00000001)
#define REG_PORT_ACL_EN_MASK (REG_PORT_ACL_EN_RELMASK << REG_PORT_ACL_EN_OFFT)
#define REG_PCR_EG_TAG_OFFT (28)
#define REG_PCR_EG_TAG_LENG (2)
#define REG_PCR_EG_TAG_RELMASK (0x00000003)
#define REG_PCR_EG_TAG_MASK (REG_PCR_EG_TAG_RELMASK << REG_PCR_EG_TAG_OFFT)
#define REG_PIC_P0_ADDR (0x2008)
#define REG_PIC_IGMP_MIR_OFFT (19)
#define REG_PIC_IGMP_MIR_LENG (1)
#define REG_PIC_IGMP_MIR_RELMASK (0x00000001)
#define REG_PIC_IGMP_MIR_MASK (REG_PIC_IGMP_MIR_RELMASK << REG_PIC_IGMP_MIR_OFFT)
#define REG_PSC_P0_ADDR (0x200C)
#define REG_PVC_P0_ADDR (0x2010)
#define REG_PVC_ACC_FRM_OFFT (0)
#define REG_PVC_ACC_FRM_LENG (2)
#define REG_PVC_ACC_FRM_RELMASK (0x00000003)
#define REG_PVC_ACC_FRM_MASK (REG_PVC_ACC_FRM_RELMASK << REG_PVC_ACC_FRM_OFFT)
#define REG_PVC_EG_TAG_OFFT (8)
#define REG_PVC_EG_TAG_LENG (3)
#define REG_PVC_EG_TAG_RELMASK (0x00000007)
#define REG_PVC_EG_TAG_MASK (REG_PVC_EG_TAG_RELMASK << REG_PVC_EG_TAG_OFFT)
#define REG_PPBV1_P0_ADDR (0x2014)
#define REG_PPBV2_P0_ADDR (0x2018)
#define REG_BSR_P0_ADDR (0x201C)
#define REG_STAG01_P0_ADDR (0x2020)
#define REG_STAG23_P0_ADDR (0x2024)
#define REG_STAG45_P0_ADDR (0x2028)
#define REG_STAG67_P0_ADDR (0x202C)
#define REG_CMACCR_ADDR (0x30E0)
#define REG_MTCC_LMT_OFFT (9)
#define REG_MTCC_LMT_LENG (4)
#define REG_MTCC_LMT_RELMASK (0x0000000F)
#define REG_MTCC_LMT_MASK (REG_MTCC_LMT_RELMASK << REG_MTCC_LMT_OFFT)
#define ETHCMD_ENABLE "enable"
#define ETHCMD_DISABLE "disable"
#define HELP_VLAN_PVID "vlan pvid <port> <pvid>"
#if defined(EXTEND_SETVID_PARAM) || defined(SQA_VERIFY)
#define HELP_VLAN_VID "vlan vid <index> <active:0|1> <vid> <portMap> <egtagPortMap>\n" \
" <ivl_en> <fid> <stag>\n"
#else
#define HELP_VLAN_VID "vlan vid <index> <active:0|1> <vid> <portMap> <tagPortMap>\n"
#endif //SQA_VERIFY
//#if defined(SQA_VERIFY)
#define MT7530_UPW_REG_UPDATE 1
#define HELP_QOS_TYPE "qos type <rr:0|sp:1|wfq:2>\n"
#ifdef MT7530_UPW_REG_UPDATE
#define HELP_QOS_BASE "qos base <port-based:0|tag-based:1|dscp-based:2|acl-based:3|arl-based:4|stag-based:5>\n"
#else
#define HELP_QOS_BASE "qos base <port-based:0|tag-based:1|dscp-based:2|acl-based:3|arl-based:4>\n"
#endif
#define HELP_QOS_PRIO_QMAP "qos prio-qmap <prio:0~7> <queue:0~7>\n"
#define HELP_QOS_PRIO_TAGMAP "qos prio-tagmap <prio:0~7> <tag:0~7>\n"
#define HELP_QOS_PRIO_DSCPMAP "qos prio-dscpmap <prio:0~7> <dscp:0~63>\n"
//#define HELP_QOS_VPRI_QMAP "qos vprio-qmap <prio:0~7> <queue:0~7>\n"
#define HELP_QOS_PORT_PRIO "qos port-prio <port> <prio:0~7>\n"
#define HELP_QOS_PORT_WEIGHT "qos port-weight <port:0~7> <q0> <q1> <q2> <q3> <q4> <q5> <q6> <q7>\n" \
" <qn>: the weight of queue n, range: 1~16\n"
#define HELP_QOS_DSCP_PRIO "qos dscp-prio <dscp:0~63> <prio:0~7> : for ingress\n"
#define HELP_ARL_L2LEN_CHK "arl l2len-chk <active:0|1>\n"
#define HELP_ARL_AGING "arl aging <active:0|1> <time:1~65536>\n"
#define HELP_ARL_MAC_TBL_ADD "arl mactbl-add <MacAddr> <DestPortMap>\n"\
" ** optional : <leaky_en:0|1> <eg_tag:0~7> <usr_pri:0~7> <sa_mir_en:0|1> <sa_port_fw:0~7>\n"
#define HELP_ARL_DIP_TBL_ADD "arl diptbl-add <DIP> <DestPortMap> <leaky_en:0|1> <eg_tag:0~7> <usr_pri:0~7> <status:0~3>\n"
#define HELP_ARL_SIP_TBL_ADD "arl siptbl-add <DIP> <SIP> <DestPortMap> <status:0~3>\n"
#define HELP_ACL_SETPORTEN "acl enable <port> <port_enable:0|1>\n"
#define HELP_ACL_ACL_TBL_ADD "arl acltbl-add <tbl_idx:0~63/255> <vawd1> <vawd2>\n"
#define HELP_ACL_MASK_TBL_ADD "arl masktbl-add <tbl_idx:0~31/127> <vawd1> <vawd2>\n"
#define HELP_ACL_RULE_TBL_ADD "arl ruletbl-add <tbl_idx:0~31/127> <vawd1> <vawd2>\n"
#define HELP_ACL_RATE_TBL_ADD "arl ratetbl-add <tbl_idx:0~31> <vawd1> <vawd2>\n"
#define HELP_ACL_TRTCM_TBL_ADD "arl trTCMtbl-add <tbl_idx:0~31> <vawd1> <vawd2>\n"
#define HELP_VLAN_PORT_MODE "vlan port-mode <port> <mode:0~3>\n" \
"<mode>: 0: port matrix mode\n" \
" 1: fallback mode\n" \
" 2: check mode\n" \
" 3: security mode\n"\
#define HELP_VLAN_PORT_ATTR "vlan port-attr <port> <attr:0~3>\n" \
"<attr>: 0: user port\n" \
" 1: statck port\n" \
" 2: translation port\n" \
" 3: transparent port\n"
#define HELP_VLAN_EGRESS_TAG_PVC "vlan eg-tag-pvc <port> <eg_tag:0~7>\n" \
"<eg_tag>: 0: disable\n" \
" 1: consistent\n" \
" 2: reserved\n" \
" 3: reserved\n" \
" 4: untagged\n" \
" 5: swap\n" \
" 6: tagged\n" \
" 7: stack\n"
#define HELP_VLAN_EGRESS_TAG_PCR "vlan eg-tag-pcr <port> <eg_tag:0~3>\n" \
"<eg_tag>: 0: untagged\n" \
" 1: swap\n" \
" 2: tagged\n" \
" 3: stack\n"
#define HELP_VLAN_ACC_FRM "vlan acc-frm <port> <acceptable_frame_type:0~3>\n" \
"<type>: 0: admit all frames\n" \
" 1: admit only vlan-taged frames\n" \
" 2: admit only untagged or priority-tagged frames\n" \
" 3: reserved\n"
#define HELP_SWITCH_RESET "switch software reset\n"
#define HELP_MACCTL_FC "macctl fc <enable:0|1>\n"
#define HELP_MIRROR_EN "mirror enable <mirror_en:0|1> <mirror_port: 0-6>\n"
#define HELP_MIRROR_PORTBASED "mirror port-based <port> <port_tx_mir:0|1> <port_rx_mir:0|1> <acl_mir:0|1> <vlan_mis:0|1> <igmp_mir:0|1>\n"
#define HELP_PHY_AN_EN "phyctl an <port> <auto_negotiation_en:0|1>\n"
#define HELP_PHY_FC_EN "phyctl fc <port> <full_duplex_pause_capable:0|1>\n"
#define HELP_STP "stp <port> <fid> <state>\n" \
"<state>: 0: Disable/Discarding\n" \
" 1: Blocking/Listening/Discarding\n" \
" 2: Learning\n" \
" 3: Forwarding\n"
#define HELP_COLLISION_POOL_EN "collision-pool enable [enable 0|1] \n"
#define HELP_EEE_EN "eee [enable|disable] ([port|portMap]) \n"
//#endif //SQA_VERIFY

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,144 @@
/*
* switch_fun.h: switch function sets
*/
#ifndef SWITCH_FUN_H
#define SWITCH_FUN_H
#include <stdbool.h>
#define MT7530_T10_TEST_CONTROL 0x145
#define MAX_PORT 6
#define MAX_PHY_PORT 5
#define CONFIG_MTK_7531_DVT 1
extern int chip_name;
extern struct mt753x_attr *attres;
extern bool nl_init_flag;
/*basic operation*/
int reg_read(unsigned int offset, unsigned int *value);
int reg_write(unsigned int offset, unsigned int value);
int mii_mgr_read(unsigned int port_num, unsigned int reg, unsigned int *value);
int mii_mgr_write(unsigned int port_num, unsigned int reg, unsigned int value);
int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int *value);
int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int value);
/*phy setting*/
int phy_dump(int phy_addr);
void phy_crossover(int argc, char *argv[]);
int rw_phy_token_ring(int argc, char *argv[]);
/*arl setting*/
void doArlAging(int argc, char *argv[]);
/*acl setting*/
void acl_mac_add(int argc, char *argv[]);
void acl_dip_meter(int argc, char *argv[]);
void acl_dip_trtcm(int argc, char *argv[]);
void acl_ethertype(int argc, char *argv[]);
void acl_ethertype(int argc, char *argv[]);
void acl_dip_modify(int argc, char *argv[]);
void acl_dip_pppoe(int argc, char *argv[]);
void acl_dip_add(int argc, char *argv[]);
void acl_l4_add(int argc, char *argv[]);
void acl_sp_add(int argc, char *argv[]);
void acl_port_enable(int argc, char *argv[]);
void acl_table_add(int argc, char *argv[]);
void acl_mask_table_add(int argc, char *argv[]);
void acl_rule_table_add(int argc, char *argv[]);
void acl_rate_table_add(int argc, char *argv[]);
/*dip table*/
void dip_dump(void);
void dip_add(int argc, char *argv[]);
void dip_del(int argc, char *argv[]);
void dip_clear(void);
/*sip table*/
void sip_dump(void);
void sip_add(int argc, char *argv[]);
void sip_del(int argc, char *argv[]);
void sip_clear(void);
/*stp*/
void doStp(int argc, char *argv[]);
/*mac table*/
void table_dump(void);
void table_add(int argc, char *argv[]);
void table_search_mac_vid(int argc, char *argv[]);
void table_search_mac_fid(int argc, char *argv[]);
void table_del_fid(int argc, char *argv[]);
void table_del_vid(int argc, char *argv[]);
void table_clear(void);
/*vlan table*/
void vlan_dump(int argc, char *argv[]);
void vlan_clear(int argc, char *argv[]);
void vlan_set(int argc, char *argv[]);
void doVlanSetPvid(int argc, char *argv[]);
void doVlanSetVid(int argc, char *argv[]);
void doVlanSetAccFrm(int argc, char *argv[]);
void doVlanSetPortAttr(int argc, char *argv[]);
void doVlanSetPortMode(int argc, char *argv[]);
void doVlanSetEgressTagPCR(int argc, char *argv[]);
void doVlanSetEgressTagPVC(int argc, char *argv[]);
/*igmp function*/
void igmp_on(int argc, char *argv[]);
void igmp_off();
void igmp_disable(int argc, char *argv[]);
void igmp_enable(int argc, char *argv[]);
/*mirror function*/
void set_mirror_to(int argc, char *argv[]);
void set_mirror_from(int argc, char *argv[]);
void doMirrorPortBased(int argc, char *argv[]);
void doMirrorEn(int argc, char *argv[]);
/*rate control*/
void rate_control(int argc, char *argv[]);
int ingress_rate_set(int on_off, unsigned int port, unsigned int bw);
int egress_rate_set(int on_off, int port, int bw);
/*QoS*/
int qos_sch_select(int argc, char *argv[]);
void qos_set_base(int argc, char *argv[]);
void qos_wfq_set_weight(int argc, char *argv[]);
void qos_set_portpri(int argc, char *argv[]);
void qos_set_dscppri(int argc, char *argv[]);
void qos_pri_mapping_queue(int argc, char *argv[]);
/*flow control*/
int global_set_mac_fc(int argc, char *argv[]);
int phy_set_fc(int argc, char *argv[]);
int phy_set_an(int argc, char *argv[]);
/* collision pool functions */
int collision_pool_enable(int argc, char *argv[]);
void collision_pool_mac_dump();
void collision_pool_dip_dump();
void collision_pool_sip_dump();
/*pfc functions*/
int set_mac_pfc(int argc, char *argv[]);
void pfc_get_rx_counter(int argc, char *argv[]);
void pfc_get_tx_counter(int argc, char *argv[]);
/*switch reset*/
int switch_reset(int argc, char *argv[]);
/* EEE(802.3az) function */
void eee_enable(int argc, char *argv[]);
void eee_dump(int argc, char *argv[]);
void read_mib_counters();
void clear_mib_counters();
void read_output_queue_counters();
void read_free_page_counters();
void phy_crossover(int argc, char *argv[]);
void exit_free();
#endif

View File

@ -0,0 +1,478 @@
/*
* switch_ioctl.c: switch(ioctl) set API
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if.h>
#include "switch_fun.h"
#include "switch_ioctl.h"
static int esw_fd;
int switch_ioctl_init(void)
{
esw_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (esw_fd < 0) {
perror("socket");
return -EINVAL;
}
return 0;
}
void switch_ioctl_fini(void)
{
close(esw_fd);
}
int reg_read_ioctl(unsigned int offset, unsigned int *value)
{
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
mii.phy_id = 0x1f;
mii.reg_num = offset;
if (-1 == ioctl(esw_fd, RAETH_MII_READ, &ifr)) {
perror("ioctl");
close(esw_fd);
exit(0);
}
*value = mii.val_out;
return 0;
}
int reg_read_tr(int offset, int *value)
{
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
mii.phy_id = 0;
mii.reg_num = offset;
if (-1 == ioctl(esw_fd, RAETH_MII_READ, &ifr)) {
perror("ioctl");
close(esw_fd);
exit(0);
}
*value = mii.val_out;
return 0;
}
int reg_write_ioctl(unsigned int offset, unsigned int value)
{
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
mii.phy_id = 0x1f;
mii.reg_num = offset;
mii.val_in = value;
if (-1 == ioctl(esw_fd, RAETH_MII_WRITE, &ifr)) {
perror("ioctl");
close(esw_fd);
exit(0);
}
return 0;
}
int reg_write_tr(int offset, int value)
{
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
mii.phy_id = 0;
mii.reg_num = offset;
mii.val_in = value;
if (-1 == ioctl(esw_fd, RAETH_MII_WRITE, &ifr)) {
perror("ioctl");
close(esw_fd);
exit(0);
}
return 0;
}
int phy_dump_ioctl(unsigned int phy_addr)
{
struct ifreq ifr;
struct esw_reg reg;
reg.val = phy_addr;
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &reg;
if (-1 == ioctl(esw_fd, RAETH_ESW_PHY_DUMP, &ifr)) {
perror("ioctl");
close(esw_fd);
exit(0);
}
return 0;
}
int mii_mgr_cl22_read_ioctl(unsigned int port_num, unsigned int reg, unsigned int *value)
{
unsigned int reg_value;
int loop_cnt;
int op_busy;
loop_cnt = 0;
/*Change to indirect access mode*/
/*if you need to use direct access mode, please change back manually by reset bit5*/
if (chip_name == 0x7530) {
reg_read(0x7804, &reg_value);
if (((reg_value >> 5) & 0x1) == 0) {
reg_value |= 1 << 5;
reg_write(0x7804, reg_value);
printf("Change to indirect access mode:0x%x\n",
reg_value);
}
}
reg_value = 0x80090000 | (port_num << 20) | (reg << 25);
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy) {
reg_value = reg_value & 0xFFFF;
break;
} else if (loop_cnt < 10)
loop_cnt++;
else {
printf("MDIO read opeartion timeout\n");
reg_value = 0;
break;
}
}
//printf(" PHY Indirect Access Control(0x701c) register read value =0x%x \n", reg_value);
*value = reg_value;
return 0;
}
int mii_mgr_cl22_write_ioctl(unsigned int port_num, unsigned int reg, unsigned int value)
{
unsigned int reg_value;
int loop_cnt;
int op_busy;
loop_cnt = 0;
/*Change to indirect access mode*/
/*if you need to use direct access mode, please change back manually by reset bit5*/
if (chip_name == 0x7530) {
reg_read(0x7804, &reg_value);
if (((reg_value >> 5) & 0x1) == 0) {
reg_value |= 1 << 5;
reg_write(0x7804, reg_value);
printf("Change to indirect access mode:0x%x\n",
reg_value);
}
}
reg_value = 0x80050000 | (port_num << 20) | (reg << 25) | value;
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy)
break;
else if (loop_cnt < 10)
loop_cnt++;
else {
printf("MDIO write opeartion timeout\n");
break;
}
}
//printf(" PHY Indirect Access Control(0x701c) register write value =0x%x \n", reg_value);
return 0;
}
int mii_mgr_cl45_read_indirect(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int *value)
{
int sk, method, ret;
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
if (!value)
return -1;
sk = socket(AF_INET, SOCK_DGRAM, 0);
if (sk < 0) {
printf("Open socket failed\n");
return -1;
}
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 13;
mii.val_in = dev;
ret = ioctl(sk, method, &ifr);
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 14;
mii.val_in = reg;
ret = ioctl(sk, method, &ifr);
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 13;
mii.val_in = (0x6000 | dev);
ret = ioctl(sk, method, &ifr);
usleep(1000);
method = RAETH_MII_READ;
mii.phy_id = port_num;
mii.reg_num = 14;
ret = ioctl(sk, method, &ifr);
close(sk);
*value = mii.val_out;
return ret;
}
int mii_mgr_cl45_write_indirect(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int value)
{
int sk, method, ret;
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
sk = socket(AF_INET, SOCK_DGRAM, 0);
if (sk < 0) {
printf("Open socket failed\n");
return -1;
}
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 13;
mii.val_in = dev;
ret = ioctl(sk, method, &ifr);
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 14;
mii.val_in = reg;
ret = ioctl(sk, method, &ifr);
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 13;
mii.val_in = (0x6000 | dev);
ret = ioctl(sk, method, &ifr);
usleep(1000);
method = RAETH_MII_WRITE;
mii.phy_id = port_num;
mii.reg_num = 14;
mii.val_in = value;
ret = ioctl(sk, method, &ifr);
close(sk);
return ret;
}
int mii_mgr_cl45_read(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int *value)
{
unsigned int reg_value;
int loop_cnt;
int op_busy;
int ret = 0;
loop_cnt = 0;
reg_value = 0x80000000 | (port_num << 20) | (dev << 25) | reg;
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy) {
break;
} else if (loop_cnt < 10) {
loop_cnt++;
} else {
printf("MDIO cl45 set dev opeartion timeout\n");
reg_value = 0;
ret = -1;
goto out;
}
}
reg_value = 0x800c0000 | (port_num << 20) | (dev << 25);
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy) {
reg_value = reg_value & 0xFFFF;
break;
} else if (loop_cnt < 10) {
loop_cnt++;
} else {
printf("MDIO cl45 read reg opeartion timeout\n");
reg_value = 0;
ret = -1;
break;
}
}
out:
//printf(" PHY Indirect Access Control(0x701c) register read value =0x%x \n", reg_value);
*value = reg_value;
return ret;
}
int mii_mgr_cl45_write(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int value)
{
unsigned int reg_value;
int loop_cnt;
int op_busy;
int ret = 0;
loop_cnt = 0;
reg_value = 0x80000000 | (port_num << 20) | (dev << 25) | reg;
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy)
break;
else if (loop_cnt < 10)
loop_cnt++;
else {
printf("MDIO cl45 set dev opeartion timeout\n");
ret = -1;
goto out;
}
}
reg_value = 0x80040000 | (port_num << 20) | (dev << 25) | value;
reg_write(0x701c, reg_value);
while (1)
{
reg_read(0x701c, &reg_value);
op_busy = reg_value & (1 << 31);
if (!op_busy)
break;
else if (loop_cnt < 10)
loop_cnt++;
else {
printf("MDIO cl45 write reg opeartion timeout\n");
ret = -1;
break;
}
}
out:
//printf(" PHY Indirect Access Control(0x701c) register write value =0x%x \n", reg_value);
return ret;
}
int mii_mgr_cl45_read_ioctl(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int *value)
{
if (chip_name == 0x7531 || chip_name == 0x7988)
return mii_mgr_cl45_read(port_num, dev, reg, value);
else if (chip_name == 0x7530)
return mii_mgr_cl45_read_indirect(port_num, dev, reg, value);
else
return -1;
}
int mii_mgr_cl45_write_ioctl(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int value)
{
if (chip_name == 0x7531 || chip_name == 0x7988)
return mii_mgr_cl45_write(port_num, dev, reg, value);
else if (chip_name == 0x7530)
return mii_mgr_cl45_write_indirect(port_num, dev, reg, value);
else
return -1;
}
int dump_gphy(void)
{
int cl22_reg[6] = {0x00, 0x01, 0x04, 0x05, 0x09, 0x0A};
int cl45_start_reg = 0x9B;
int cl45_end_reg = 0xA2;
unsigned int value;
int port_num = 5;
int i, j, ret;
int sk, method;
struct ifreq ifr;
struct ra_mii_ioctl_data mii;
sk = socket(AF_INET, SOCK_DGRAM, 0);
if (sk < 0) {
printf("Open socket failed\n");
return -1;
}
strncpy(ifr.ifr_name, ETH_DEVNAME, 5);
ifr.ifr_data = &mii;
/* dump CL45 reg first*/
for (i = 0; i < port_num; i++) {
printf("== Port %d ==\n", i);
for (j = cl45_start_reg; j < (cl45_end_reg + 1); j++) {
ret = mii_mgr_cl45_read_ioctl(i, 0x1E, j, &value);
if (ret)
continue;
printf("dev1Eh_reg%xh = 0x%x\n", j, value);
}
}
printf("== Global ==\n");
for (i = 0; i < sizeof(cl22_reg) / sizeof(cl22_reg[0]); i++) {
method = RAETH_MII_READ;
mii.phy_id = 0;
mii.reg_num = cl22_reg[i];
ret = ioctl(sk, method, &ifr);
printf("Reg%xh = 0x%x\n", cl22_reg[i], mii.val_out);
}
close(sk);
return ret;
}

View File

@ -0,0 +1,70 @@
/*
* switch_ioctl.h: switch(ioctl) set API
*/
#ifndef SWITCH_IOCTL_H
#define SWITCH_IOCTL_H
#define ETH_DEVNAME "eth0"
#define BR_DEVNAME "br-lan"
#define RAETH_MII_READ 0x89F3
#define RAETH_MII_WRITE 0x89F4
#define RAETH_ESW_PHY_DUMP 0x89F7
struct esw_reg {
unsigned int off;
unsigned int val;
};
struct ra_mii_ioctl_data {
__u16 phy_id;
__u16 reg_num;
__u32 val_in;
__u32 val_out;
/*
__u32 port_num;
__u32 dev_addr;
__u32 reg_addr;
*/
};
struct ra_switch_ioctl_data {
unsigned int cmd;
unsigned int on_off;
unsigned int port;
unsigned int bw;
unsigned int vid;
unsigned int fid;
unsigned int port_map;
unsigned int rx_port_map;
unsigned int tx_port_map;
unsigned int igmp_query_interval;
unsigned int reg_addr;
unsigned int reg_val;
unsigned int mode;
unsigned int qos_queue_num;
unsigned int qos_type;
unsigned int qos_pri;
unsigned int qos_dscp;
unsigned int qos_table_idx;
unsigned int qos_weight;
unsigned char mac[6];
};
extern int chip_name;
int switch_ioctl_init(void);
void switch_ioctl_fini(void);
int reg_read_ioctl(unsigned int offset, unsigned int *value);
int reg_write_ioctl(unsigned int offset, unsigned int value);
int phy_dump_ioctl(unsigned int phy_addr);
int mii_mgr_cl22_read_ioctl(unsigned int port_num, unsigned int reg,
unsigned int *value);
int mii_mgr_cl22_write_ioctl(unsigned int port_num, unsigned int reg,
unsigned int value);
int mii_mgr_cl45_read_ioctl(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int *value);
int mii_mgr_cl45_write_ioctl(unsigned int port_num, unsigned int dev,
unsigned int reg, unsigned int value);
#endif

View File

@ -0,0 +1,445 @@
/*
* switch_netlink.c: switch(netlink) set API
*
* Author: Sirui Zhao <Sirui.Zhao@mediatek.com>
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include "switch_netlink.h"
static struct nl_sock *user_sock;
static struct nl_cache *cache;
static struct genl_family *family;
static struct nlattr *attrs[MT753X_ATTR_TYPE_MAX + 1];
static int wait_handler(struct nl_msg *msg, void *arg)
{
int *finished = arg;
*finished = 1;
return NL_STOP;
}
static int list_swdevs(struct nl_msg *msg, void *arg)
{
struct mt753x_attr *val = arg;
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
if (nla_parse(attrs, MT753X_ATTR_TYPE_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL) < 0)
goto done;
if (gnlh->cmd == MT753X_CMD_REPLY) {
if (attrs[MT753X_ATTR_TYPE_MESG]) {
val->dev_info =
nla_get_string(attrs[MT753X_ATTR_TYPE_MESG]);
printf("register switch dev:\n%s", val->dev_info);
}
else {
fprintf(stderr, "ERROR:No switch dev now\n");
goto done;
}
} else
goto done;
return 0;
done:
return NL_SKIP;
}
static int construct_attrs(struct nl_msg *msg, void *arg)
{
struct mt753x_attr *val = arg;
int type = val->type;
if (val->dev_id > -1)
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_DEV_ID, val->dev_id);
if (val->op == 'r') {
if (val->phy_dev != -1)
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV, val->phy_dev);
if (val->port_num >= 0)
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY, val->port_num);
NLA_PUT_U32(msg, type, val->reg);
} else if (val->op == 'w') {
if (val->phy_dev != -1)
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV, val->phy_dev);
if (val->port_num >= 0)
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY, val->port_num);
NLA_PUT_U32(msg, type, val->reg);
NLA_PUT_U32(msg, MT753X_ATTR_TYPE_VAL, val->value);
} else {
printf("construct_attrs_message\n");
NLA_PUT_STRING(msg, type, "hello");
}
return 0;
nla_put_failure:
return -1;
}
static int spilt_attrs(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
struct mt753x_attr *val = arg;
char *str;
if (nla_parse(attrs, MT753X_ATTR_TYPE_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL) < 0)
goto done;
if ((gnlh->cmd == MT753X_CMD_WRITE) || (gnlh->cmd == MT753X_CMD_READ)) {
if (attrs[MT753X_ATTR_TYPE_MESG]) {
str = nla_get_string(attrs[MT753X_ATTR_TYPE_MESG]);
printf(" %s\n", str);
if (!strncmp(str, "No", 2))
goto done;
}
if (attrs[MT753X_ATTR_TYPE_REG]) {
val->reg =
nla_get_u32(attrs[MT753X_ATTR_TYPE_REG]);
}
if (attrs[MT753X_ATTR_TYPE_VAL]) {
val->value =
nla_get_u32(attrs[MT753X_ATTR_TYPE_VAL]);
}
}
else
goto done;
return 0;
done:
return NL_SKIP;
}
static int mt753x_request_callback(int cmd, int (*spilt)(struct nl_msg *, void *),
int (*construct)(struct nl_msg *, void *),
void *arg)
{
struct nl_msg *msg;
struct nl_cb *callback = NULL;
int finished;
int flags = 0;
int err;
/*Allocate an netllink message buffer*/
msg = nlmsg_alloc();
if (!msg) {
fprintf(stderr, "Failed to allocate netlink message\n");
exit(1);
}
if (!construct) {
if (cmd == MT753X_CMD_REQUEST)
flags |= NLM_F_REQUEST;
else
flags |= NLM_F_DUMP;
}
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, genl_family_get_id(family),
0, flags, cmd, 0);
/*Fill attaribute of netlink message by construct function*/
if (construct) {
err = construct(msg, arg);
if (err < 0) {
fprintf(stderr, "attributes error\n");
goto nal_put_failure;
}
}
/*Allocate an new callback handler*/
callback = nl_cb_alloc(NL_CB_CUSTOM);
if (!callback) {
fprintf(stderr, "Failed to allocate callback handler\n");
exit(1);
}
/*Send netlink message*/
err = nl_send_auto_complete(user_sock, msg);
if (err < 0) {
fprintf(stderr, "nl_send_auto_complete failied:%d\n", err);
goto out;
}
finished = 0;
if (spilt)
nl_cb_set(callback, NL_CB_VALID, NL_CB_CUSTOM, spilt, arg);
if (construct)
nl_cb_set(callback, NL_CB_ACK, NL_CB_CUSTOM, wait_handler,
&finished);
else
nl_cb_set(callback, NL_CB_FINISH, NL_CB_CUSTOM, wait_handler,
&finished);
/*receive message from kernel request*/
err = nl_recvmsgs(user_sock, callback);
if (err < 0)
goto out;
/*wait until an ACK is received for the latest not yet acknowledge*/
if (!finished)
err = nl_wait_for_ack(user_sock);
out:
if (callback)
nl_cb_put(callback);
nal_put_failure:
nlmsg_free(msg);
return err;
}
void mt753x_netlink_free(void)
{
if (family)
nl_object_put((struct nl_object *)family);
if (cache)
nl_cache_free(cache);
if (user_sock)
nl_socket_free(user_sock);
user_sock = NULL;
cache = NULL;
family = NULL;
}
int mt753x_netlink_init(const char *name)
{
int ret;
user_sock = NULL;
cache = NULL;
family = NULL;
/*Allocate an new netlink socket*/
user_sock = nl_socket_alloc();
if (!user_sock) {
fprintf(stderr, "Failed to create user socket\n");
goto err;
}
/*Connetct the genl controller*/
if (genl_connect(user_sock)) {
fprintf(stderr, "Failed to connetct to generic netlink\n");
goto err;
}
/*Allocate an new nl_cache*/
ret = genl_ctrl_alloc_cache(user_sock, &cache);
if (ret < 0) {
fprintf(stderr, "Failed to allocate netlink cache\n");
goto err;
}
if (name == NULL)
return -EINVAL;
/*Look up generic netlik family by "mt753x" in the provided cache*/
family = genl_ctrl_search_by_name(cache, name);
if (!family) {
//fprintf(stderr,"switch(mt753x) API not be prepared\n");
goto err;
}
return 0;
err:
mt753x_netlink_free();
return -EINVAL;
}
void mt753x_list_swdev(struct mt753x_attr *arg, int cmd)
{
int err;
err = mt753x_request_callback(cmd, list_swdevs, NULL, arg);
if (err < 0)
fprintf(stderr, "mt753x list dev error\n");
}
static int mt753x_request(struct mt753x_attr *arg, int cmd)
{
int err;
err = mt753x_request_callback(cmd, spilt_attrs, construct_attrs, arg);
if (err < 0) {
fprintf(stderr, "mt753x deal request error\n");
return err;
}
return 0;
}
static int phy_operate_netlink(char op, struct mt753x_attr *arg,
unsigned int port_num, unsigned int phy_dev,
unsigned int offset, unsigned int *value)
{
int ret = 0;
struct mt753x_attr *attr = arg;
attr->port_num = port_num;
attr->phy_dev = phy_dev;
attr->reg = offset;
attr->value = -1;
attr->type = MT753X_ATTR_TYPE_REG;
switch (op)
{
case 'r':
attr->op = 'r';
ret = mt753x_request(attr, MT753X_CMD_READ);
*value = attr->value;
break;
case 'w':
attr->op = 'w';
attr->value = *value;
ret = mt753x_request(attr, MT753X_CMD_WRITE);
break;
default:
break;
}
return ret;
}
int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset,
unsigned int *value)
{
int ret;
ret = phy_operate_netlink('r', arg, -1, -1, offset, value);
return ret;
}
int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset,
unsigned int value)
{
int ret;
ret = phy_operate_netlink('w', arg, -1, -1, offset, &value);
return ret;
}
int phy_cl22_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_addr, unsigned int *value)
{
int ret;
ret = phy_operate_netlink('r', arg, port_num, -1, phy_addr, value);
return ret;
}
int phy_cl22_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_addr, unsigned int value)
{
int ret;
ret = phy_operate_netlink('w', arg, port_num, -1, phy_addr, &value);
return ret;
}
int phy_cl45_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_dev, unsigned int phy_addr,
unsigned int *value)
{
int ret;
ret = phy_operate_netlink('r', arg, port_num, phy_dev, phy_addr, value);
return ret;
}
int phy_cl45_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_dev, unsigned int phy_addr,
unsigned int value)
{
int ret;
ret = phy_operate_netlink('w', arg, port_num, phy_dev, phy_addr, &value);
return ret;
}
void dump_extend_phy_reg(struct mt753x_attr *arg, int port_no, int from,
int to, int is_local, int page_no)
{
unsigned int temp = 0;
int r31 = 0;
int i = 0;
if (is_local == 0) {
printf("\n\nGlobal Register Page %d\n",page_no);
printf("===============");
r31 |= 0 << 15; //global
r31 |= ((page_no&0x7) << 12); //page no
phy_cl22_write_netlink(arg, port_no, 31, r31); //select global page x
for (i = 16; i < 32; i++) {
if(i%8 == 0)
printf("\n");
phy_cl22_read_netlink(arg, port_no, i, &temp);
printf("%02d: %04X ", i, temp);
}
} else {
printf("\n\nLocal Register Port %d Page %d\n",port_no, page_no);
printf("===============");
r31 |= 1 << 15; //local
r31 |= ((page_no&0x7) << 12); //page no
phy_cl22_write_netlink(arg, port_no, 31, r31); //select global page x
for (i = 16; i < 32; i++) {
if (i%8 == 0) {
printf("\n");
}
phy_cl22_read_netlink(arg, port_no, i, &temp);
printf("%02d: %04X ",i, temp);
}
}
printf("\n");
}
int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr)
{
int i;
int ret;
unsigned int offset, value;
if (phy_addr == 32) {
/*dump all phy register*/
for (i = 0; i < 5; i++) {
printf("\n[Port %d]=============", i);
for (offset = 0; offset < 16; offset++) {
if (offset % 8 == 0)
printf("\n");
ret = phy_cl22_read_netlink(arg, i, offset, &value);
printf("%02d: %04X ", offset, value);
}
}
} else {
printf("\n[Port %d]=============", phy_addr);
for (offset = 0; offset < 16; offset++) {
if (offset % 8 == 0)
printf("\n");
ret = phy_cl22_read_netlink(arg, phy_addr, offset, &value);
printf("%02d: %04X ", offset, value);
}
}
printf("\n");
for (offset = 0; offset < 5; offset++) { //global register page 0~4
if (phy_addr == 32) //dump all phy register
dump_extend_phy_reg(arg, 0, 16, 31, 0, offset);
else
dump_extend_phy_reg(arg, phy_addr, 16, 31, 0, offset);
}
if (phy_addr == 32) { //dump all phy register
for (offset = 0; offset < 5; offset++) { //local register port 0-port4
dump_extend_phy_reg(arg, offset, 16, 31, 1, 0); //dump local page 0
dump_extend_phy_reg(arg, offset, 16, 31, 1, 1); //dump local page 1
dump_extend_phy_reg(arg, offset, 16, 31, 1, 2); //dump local page 2
dump_extend_phy_reg(arg, offset, 16, 31, 1, 3); //dump local page 3
}
} else {
dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 0); //dump local page 0
dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 1); //dump local page 1
dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 2); //dump local page 2
dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 3); //dump local page 3
}
return ret;
}

View File

@ -0,0 +1,70 @@
/*
* switch_netlink.h: switch(netlink) set API
*
* Author: Sirui Zhao <Sirui.Zhao@mediatek.com>
*/
#ifndef MT753X_NETLINK_H
#define MT753X_NETLINK_H
#define MT753X_GENL_NAME "mt753x"
#define MT753X_DSA_GENL_NAME "mt753x_dsa"
#define MT753X_GENL_VERSION 0X1
/*add your cmd to here*/
enum {
MT753X_CMD_UNSPEC = 0, /*Reserved*/
MT753X_CMD_REQUEST, /*user->kernelrequest/get-response*/
MT753X_CMD_REPLY, /*kernel->user event*/
MT753X_CMD_READ,
MT753X_CMD_WRITE,
__MT753X_CMD_MAX,
};
#define MT753X_CMD_MAX (__MT753X_CMD_MAX - 1)
/*define attar types */
enum
{
MT753X_ATTR_TYPE_UNSPEC = 0,
MT753X_ATTR_TYPE_MESG, /*MT753X message*/
MT753X_ATTR_TYPE_PHY,
MT753X_ATTR_TYPE_PHY_DEV,
MT753X_ATTR_TYPE_REG,
MT753X_ATTR_TYPE_VAL,
MT753X_ATTR_TYPE_DEV_NAME,
MT753X_ATTR_TYPE_DEV_ID,
__MT753X_ATTR_TYPE_MAX,
};
#define MT753X_ATTR_TYPE_MAX (__MT753X_ATTR_TYPE_MAX - 1)
struct mt753x_attr {
int port_num;
int phy_dev;
int reg;
int value;
int type;
char op;
char *dev_info;
int dev_name;
int dev_id;
};
int mt753x_netlink_init(const char *name);
void mt753x_netlink_free(void);
void mt753x_list_swdev(struct mt753x_attr *arg, int cmd);
int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset,
unsigned int *value);
int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset,
unsigned int value);
int phy_cl22_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_addr, unsigned int *value);
int phy_cl22_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_addr, unsigned int value);
int phy_cl45_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_dev, unsigned int phy_addr,
unsigned int *value);
int phy_cl45_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
unsigned int phy_dev, unsigned int phy_addr,
unsigned int value);
int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr);
#endif

View File

@ -0,0 +1,112 @@
#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=conninfra
PKG_VERSION:=
PKG_SOURCE:=mt7981_conninfra_20220425-bbf588-obj.tar.xz
PKG_SOURCE_URL:=
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
PKG_MAINTAINER:=Kun-Ze Syue<kun-ze.syue@mediatek.com>
PKG_KCONFIG:= \
MTK_CONNINFRA_APSOC \
MTK_CONNINFRA_APSOC_MT7986 \
MTK_CONNINFRA_APSOC_MT7981 \
CONNINFRA_EMI_SUPPORT \
FPGA_EARLY_PORTING \
CONNINFRA_AUTO_UP
include $(INCLUDE_DIR)/package.mk
# Specify package information for this program.
define KernelPackage/conninfra
CATEGORY:=MTK Properties
TITLE:= Conninfra driver
FILES:=$(PKG_BUILD_DIR)/conninfra.ko
AUTOLOAD:=$(call AutoLoad,10,conninfra,1)
SUBMENU:=Drivers
MENU:=1
endef
define KernelPackage/conninfra/description
Support for connectivity conninfra driver.
endef
define KernelPackage/conninfra/config
if PACKAGE_kmod-conninfra
config MTK_CONNINFRA_APSOC
bool "Conninfra APSOC Only"
default n
if MTK_CONNINFRA_APSOC
choice
prompt "Choose APSOC Chip"
config MTK_CONNINFRA_APSOC_MT7986
bool "MT7986"
default n
config MTK_CONNINFRA_APSOC_MT7981
bool "MT7981"
default n
endchoice
config CONNINFRA_EMI_SUPPORT
bool "EMI Support"
default n
config FPGA_EARLY_PORTING
bool "Only for FPGA Stage"
default n
config CONNINFRA_AUTO_UP
bool "Conninfra Up by Self"
default n
endif
endif
endef
# Specify what needs to be done to prepare for building the package.
# Specify where and how to install the program.
#define Package/kmod-conninfra/install
# true
#endef
# Transfer local kernel config to compile option
KCONFIG_FLAGS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$(c))))
$(info $$KCONFIG_FLAGS is [${KCONFIG_FLAGS}])
# Transfer local kernel config to compile option
EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(KCONFIG_FLAGS)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(KCONFIG_FLAGS)))) \
$(patsubst CONFIG_%, -DCONFIG_%=0, $(patsubst %=n,%,$(filter %=n,$(KCONFIG_FLAGS)))) \
EXTRA_CFLAGS+=-DEEPROM_NAME=${CONFIG_first_card_EEPROM_name}
$(info EXTRA_CFLAGS=${EXTRA_CFLAGS})
MAKE_OPTS:= \
$(KERNEL_MAKE_FLAGS) \
SUBDIRS="$(PKG_BUILD_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
M="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(KCONFIG_FLAGS)
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,conninfra))

View File

@ -0,0 +1,332 @@
# All rights reserved.
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mt_wifi
P4REV:=
PKG_VERSION:=7.6.4.1
PKG_SOURCE:=mt7981_20220425-4c770b-obj.tar.xz
PKG_BUILD_PARALLEL:=1
PKG_SOURCE_URL:=
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
PKG_KCONFIG:= \
AP_SUPPORT \
RT_FIRST_CARD \
RT_SECOND_CARD \
RT_FIRST_IF_RF_OFFSET \
RT_SECOND_IF_RF_OFFSET \
MT_WIFI \
WIFI_BASIC_FUNC \
MT_WIFI_PATH \
FIRST_IF_NONE \
FIRST_IF_EEPROM_FLASH \
FIRST_IF_EEPROM_EFUSE \
RT_FIRST_CARD_EEPROM \
SECOND_IF_NONE \
SECOND_IF_EEPROM_FLASH \
SECOND_IF_EEPROM_PROM \
SECOND_IF_EEPROM_EFUSE \
RT_SECOND_CARD_EEPROM \
MULTI_INF_SUPPORT \
WIFI_BASIC_FUNC \
WIRELESS_EXT \
WEXT_SPY \
WEXT_PRIV \
DOT11_N_SUPPORT \
DOT11_VHT_AC \
DOT11_HE_AX \
CFG_SUPPORT_FALCON_MURU \
CFG_SUPPORT_FALCON_TXCMD_DBG \
CFG_SUPPORT_FALCON_SR \
CFG_SUPPORT_FALCON_PP \
WIFI_DRIVER \
G_BAND_256QAM_SUPPORT \
BRCM_256QAM_SUPPORT \
ICAP_SUPPORT \
MT_AP_SUPPORT \
BACKGROUND_SCAN_SUPPORT \
SMART_CARRIER_SENSE_SUPPORT \
SCS_FW_OFFLOAD \
THERMAL_PROTECT_SUPPORT \
MT_DFS_SUPPORT \
HDR_TRANS_TX_SUPPORT \
CHIP_MT7615E \
HDR_TRANS_RX_SUPPORT \
DBDC_MODE \
MULTI_PROFILE_SUPPORT \
DEFAULT_5G_PROFILE \
SUPPORT_DYNAMIC_TXOP \
WSC_INCLUDED \
MT_STA_SUPPORT \
WSC_V2_SUPPORT \
DOT11W_PMF_SUPPORT \
PASSPOINT_R2 \
TXBF_SUPPORT \
IGMP_SNOOP_SUPPORT \
RATE_ADAPTION \
RATE_ADAPT_AGBS_SUPPORT \
RTMP_FLASH_SUPPORT \
ATE_SUPPORT \
WLAN_SERVICE \
UAPSD \
RLT_MAC \
RLT_BBP \
RLT_RF \
RTMP_MAC \
RTMP_BBP \
RTMP_RF \
RTMP_PCI_SUPPORT \
RTMP_USB_SUPPORT \
RTMP_RBUS_SUPPORT \
WIFI_MODE_AP \
WIFI_MODE_STA \
WIRELESS_EXT \
WEXT_SPY \
WEXT_PRIV \
WDS_SUPPORT \
MBSS_SUPPORT \
APCLI_SUPPORT \
APCLI_CERT_SUPPORT \
APCLI_CONNECTION_TRIAL \
MAC_REPEATER_SUPPORT \
RALINK_RT6352 \
RALINK_MT7620 \
RALINK_MT7603E \
CON_WPS_SUPPORT \
VOW_SUPPORT \
BAND_STEERING \
TXOP_ARBITER \
CFG_SUPPORT_DYNAMIC_TXOP \
WIFI_MODE_BOTH \
WIFI_RLT_MAC \
RLT_MAC \
WIFI_RTMP_MAC \
RTMP_MAC \
WIFI_MT_MAC \
CHIP_MT7603E \
CHIP_MT7615E \
MT_MAC \
RATE_ADAPTION \
SUPPORT_OPENWRT \
SDK_USER_LIGHTY \
MUMIMO_SUPPORT \
MU_RA_SUPPORT \
LED_CONTROL_SUPPORT \
RA_HW_NAT \
RA_HW_NAT_WIFI_NEW_ARCH \
CFG80211_SUPPORT \
SER_SUPPORT \
GREENAP_SUPPORT \
RADIUS_ACCOUNTING_SUPPORT \
TPC_SUPPORT \
RLM_CAL_CACHE_SUPPORT \
CAL_BIN_FILE_SUPPORT \
RF_LOCKDOWN_SUPPORT \
PASSPOINT_R2 \
RED_SUPPORT \
FIRST_IF_EPAELNA \
FIRST_IF_IPAILNA \
FIRST_IF_IPAELNA \
FIRST_IF_EPAILNA \
SECOND_IF_EPAELNA \
SECOND_IF_IPAILNA \
SECOND_IF_IPAELNA \
SECOND_IF_EPAILNA \
THIRD_IF_EPAELNA \
THIRD_IF_IPAILNA \
THIRD_IF_IPAELNA \
THIRD_IF_EPAILNA \
WIFI_PKT_FWD \
DOT11K_RRM_SUPPORT \
DOT11R_FT_SUPPORT \
ENTERPRISE_AP_SUPPORT \
WIFI_EAP_FEATURE \
TXRX_STAT_SUPPORT \
ANTENNA_CONTROL_SUPPORT \
MGMT_TXPWR_CTRL \
TXD_MGMT_TXPWR_CTRL \
CHUTIL_SUPPORT \
NF_SUPPORT \
RA_PHY_RATE_SUPPORT \
MBSS_DTIM_SUPPORT \
AMPDU_CONF_SUPPORT \
ACK_CTS_TIMEOUT_SUPPORT \
HIGHPRI_RATE_SPECIFIC \
RADIUS_MAC_AUTH_SUPPORT \
ZERO_LOSS_CSA_SUPPORT \
VLAN_SUPPORT \
DYNAMIC_VLAN_SUPPORT \
CUSTOMISED_HOSTAPD_SUPPORT \
HOSTAPD_WPA3_SUPPORT \
HOSTAPD_WPA3R3_SUPPORT \
DBDC_ONE_BAND_SUPPORT \
APCLI_STA_SUPPORT \
WDS_STA_SUPPORT \
MBSS_AS_WDS_AP_SUPPORT \
MBO_SUPPORT \
MAP_SUPPORT \
MAP_R2_VER_SUPPORT \
MAP_R3_VER_SUPPORT \
QOS_R1_SUPPORT \
WPA3_SUPPORT \
OWE_SUPPORT \
WIFI_PKT_FWD_V1 \
FIRST_IF_MT7615E \
FIRST_IF_MT7622 \
FIRST_IF_MT7626 \
FIRST_IF_AXE \
FIRST_IF_MT7915 \
FIRST_IF_MT7916 \
FIRST_IF_MT7986 \
FIRST_IF_MT7981 \
SECOND_IF_MT7915 \
SECOND_IF_MT7916 \
SECOND_IF_MT7615E \
SECOND_IF_AXE \
THIRD_IF_NONE \
THIRD_IF_MT7615E \
THIRD_IF_MT7916 \
CHIP_AXE \
CHIP_MT7915 \
CHIP_MT7916 \
CHIP_MT7986 \
CHIP_MT7981 \
RT_THIRD_CARD \
RT_THIRD_IF_RF_OFFSET \
THIRD_IF_EEPROM_FLASH \
THIRD_IF_EEPROM_PROM \
THIRD_IF_EEPROM_EFUSE \
RT_THIRD_CARD_EEPROM \
SPECTRUM_SUPPORT \
PHY_ICS_SUPPORT \
MULTI_PROFILE_SUPPORT \
PRE_CAL_TRX_SET1_SUPPORT \
MWDS \
MCAST_RATE_SPECIFIC \
WLAN_HOOK \
COEX_SUPPORT \
EASY_SETUP_SUPPORT \
EVENT_NOTIFIER_SUPPORT \
AIR_MONITOR \
OFFCHANNEL_SCAN_FEATURE \
WNM_SUPPORT \
INTERWORKING \
LINUX_NET_TXQ_SUPPORT \
CHIP_MT7622 \
CHIP_MT7626 \
MEMORY_SHRINK \
MEMORY_SHRINK_AGGRESS \
RPS_EFFICIENCY \
WHNAT_SUPPORT \
FAST_NAT_SUPPORT \
PRE_CAL_TRX_SET2_SUPPORT \
LINK_TEST_SUPPORT \
TCP_RACK_SUPPORT \
FQ_SCH_SUPPORT \
BRCM_256QAM_SUPPORT \
VHT_TXBF_2G_EPIGRAM_IE_SUPPORT \
DSCP_QOS_MAP_SUPPORT \
DSCP_PRI_SUPPORT \
PCIE_ASPM_DYM_CTRL_SUPPORT \
MIN_PHY_RATE_SUPPORT \
FAST_UP_RATE_SUPPORT \
TXRX_STAT_SUPPORT \
VENDOR_FEATURE11_SUPPORT \
WIFI_TWT_SUPPORT \
CTXD_MEM_CPY_SUPPORT \
CTXD_SCATTER_AND_GATHER_SUPPORT \
SINGLE_SKU \
SNIFFER_SUPPORT \
SNIFFER_RADIOTAP_SUPPORT \
WF_RESET_SUPPORT \
WIFI_SYSDVT \
WARP_V2 \
OCE_SUPPORT \
6G_SUPPORT \
WIFI_FW_BIN_LOAD \
CONNINFRA_APSOC \
MLME_MULTI_QUEUE_SUPPORT \
WIFI_SKU_TYPE \
MAP_R2_6E_SUPPORT \
WIFI_SKB_USES_SLAB \
WIFI_CSI_CN_INFO_SUPPORT \
PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)))
include $(INCLUDE_DIR)/package.mk
TAR_CMD=$(HOST_TAR) -C $(1)/ $(TAR_OPTIONS)
define KernelPackage/mt_wifi
CATEGORY:=MTK Properties
TITLE:=MTK wifi AP driver
DEPENDS:=+wifi-profile
DEPENDS+=+kmod-conninfra
DEPENDS+=+kmod-mediatek_hnat
FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko \
$(PKG_BUILD_DIR)/mt_wifi_ap/mtk_warp_proxy.ko
DEPENDS+=+kmod-warp
AUTOLOAD:=$(call AutoProbe,mt_wifi mtk_warp_proxy)
SUBMENU:=Drivers
MENU:=1
endef
define KernelPackage/mt_wifi/config
source "$(SOURCE)/config.in"
endef
define Build/Compile
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)/mt_wifi_ap" \
LINUX_DIR="$(KERNEL_BUILD_DIR)" \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)=$(CONFIG_MTK_$(c)))) \
modules
endef
define KernelPackage/mt_wifi/install
if [ "$$(CONFIG_MTK_WIFI_FW_BIN_LOAD)" = "y" ]; then \
rm -rf $(1)/lib/firmware/; \
$(INSTALL_DIR) $(1)/lib/firmware/; \
if [ "$$(CONFIG_MTK_CHIP_MT7986)" = "y" ] ; then \
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986_TESTMODE.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986_TESTMODE_MT7975.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr_testmode.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr_testmode_mt7975.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986_MT7975.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr_mt7975.bin \
$(PKG_BUILD_DIR)/bin/mt7986/rebb/7986_WACPU_RAM_CODE_release.bin $(1)/lib/firmware/; \
if [ "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX6000" -o "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX8400" ] ; then \
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_iPAiLNA_EEPROM_AX6000.bin $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_ePAeLNA_EEPROM_AX6000.bin \
$(1)/lib/firmware/; \
fi; \
if [ "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX4200" ] ; then \
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_ePAeLNA_EEPROM_ONEADIE_DBDC.bin \
$(1)/lib/firmware/; \
fi; \
fi; \
if [ "$$(CONFIG_MTK_CHIP_MT7916)" = "y" ] ; then \
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7916/rebb/* $(1)/lib/firmware/; \
fi; \
if [ "$$(CONFIG_MTK_CHIP_MT7981)" = "y" ] ; then \
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7981/rebb/WIFI_RAM_CODE_MT7981.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/7981_WACPU_RAM_CODE_release.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/mt7981_patch_e1_hdr.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/WIFI_RAM_CODE_MT7981_TESTMODE.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/mt7981_patch_e1_hdr_testmode.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/MT7981_iPAiLNA_EEPROM.bin \
$(PKG_BUILD_DIR)/bin/mt7981/rebb/MT7981_ePAeLNA_EEPROM.bin \
$(1)/lib/firmware/; \
fi; \
fi
endef
$(eval $(call KernelPackage,mt_wifi))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
# All rights reserved.
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=warp
P4REV:=
PKG_VERSION:=
PKG_SOURCE:=warp_20220425-d15d0a-obj.tar.xz
PKG_SOURCE_URL:=
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
PKG_KCONFIG:= \
WARP_VERSION \
WARP_ATC_SUPPORT \
WARP_DBG_SUPPORT \
WARP_WDMA_RECYCLE_SUPPORT \
WED_HW_RRO_SUPPORT \
MTK_MEMORY_SHRINK \
WARP_CHIPSET \
WARP_WO_EMBEDDED_LOAD \
WARP_MEMORY_LEAK_DBG
PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)))
include $(INCLUDE_DIR)/package.mk
TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
define KernelPackage/warp
CATEGORY:=MTK Properties
TITLE:=MTK warp driver
DEPENDS:= +kmod-mediatek_hnat
FILES:=$(PKG_BUILD_DIR)/mtk_warp.ko
AUTOLOAD:=$(call AutoLoad,60,mtk_warp,1)
SUBMENU:=Drivers
MENU:=1
endef
define KernelPackage/warp/config
source "$(SOURCE)/config.in"
endef
MTK_WIFI_DIR:=$(TOPDIR)/../ko_module/wlan_driver/jedi
USE_BIN_DIR:=$(MTK_WIFI_DIR)/warp_driver/bin
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" V=1 \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)" \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$(c)))) \
modules
endef
TARGET_CFLAGS += \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),-DCONFIG_$(c)=$(CONFIG_$c)))
MAKE_FLAGS += \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$c)))
TARGET_CFLAGS += -DCONFIG_SUPPORT_OPENWRT
MAKE_FLAGS += CONFIG_SUPPORT_OPENWRT=y
define KernelPackage/warp/install
$(INSTALL_DIR) $(1)/lib/firmware
cp $(PKG_BUILD_DIR)/bin/*WOCPU*_RAM_CODE_release.bin $(1)/lib/firmware/;
endef
$(eval $(call KernelPackage,warp))

View File

@ -0,0 +1,47 @@
if PACKAGE_kmod-warp
config WARP_VERSION
int "WARP Driver HW Version Support"
range 1 2
default 1 if TARGET_mediatek_mt7622
default 2 if TARGET_mediatek_mt7627
config WARP_ATC_SUPPORT
bool "WARP Driver Address Translate Support for CR mirror"
default y
config WARP_DBG_SUPPORT
bool "WARP Driver Debug Info Support"
default y
config WARP_WDMA_RECYCLE_SUPPORT
bool "WARP WDMA Recycle Support"
default n
config WED_HW_RRO_SUPPORT
bool "WED HW RRO Support"
default n
config MTK_MEMORY_SHRINK
bool "Memory Shrink"
default n
config WARP_MEMORY_LEAK_DBG
bool "Memory leak debug"
depends on !MTK_MEMORY_SHRINK && WARP_DBG_SUPPORT
default y
config WARP_CHIPSET
string "WARP target chipset"
default colgin
help
For colgin: colgin, for panther: mt7986
config WARP_WO_EMBEDDED_LOAD
bool "Emebedded MCU firmware support"
default n
help
Once enabled, firmware download flow try embedded version once externel version being invalid.
endif

View File

@ -0,0 +1,47 @@
menuconfig first_card
bool "1st card"
default y
if first_card
config first_card_name
string "1st card name"
default "MT7622"
endif
menuconfig second_card
bool "2nd card"
default n
if second_card
config second_card_name
string "2nd card name"
default "MT7615"
endif
menuconfig third_card
bool "3rd card"
default n
if third_card
config third_card_name
string "3rd card name"
default "MT7615"
endif
choice
prompt "WiFi Setting"
default WIFI_NORMAL_SETTING
config WIFI_NORMAL_SETTING
bool "normal setting"
config WIFI_QUICK_SETTING
bool "quick setting"
help
This is a way to configure wifi after wifi reload(Save & Apply from UI).
Normal setting means reloading dat file which will execute "wifi down; wifi up"
Quick setting means executing iwpriv commands corresponding to your operation on UI.
endchoice

View File

@ -0,0 +1,65 @@
#
# Copyright (C) 2016 MediaTek
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=wifi-profile
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
define Package/wifi-profile
SECTION:=MTK Properties
CATEGORY:=MTK Properties
SUBMENU:=Drivers
DEPENDS:=
TITLE:=WiFi l1 & l2 profile
VERSION:=$(PKG_RELEASE)
MENU:=1
endef
define Package/wifi-profile/description
This package install wifi l1 and l2 profile.
endef
define Package/wifi-profile/config
if PACKAGE_wifi-profile
source "$(SOURCE)/Config.in"
endif
endef
define Build/Compile
endef
define Package/wifi-profile/install
$(INSTALL_DIR) $(1)/etc/wireless/
$(INSTALL_DIR) $(1)/lib/wifi/
$(INSTALL_DIR) $(1)/etc/wireless/mediatek/
$(INSTALL_DIR) $(1)/sbin/
$(INSTALL_BIN) ./files/common/wifi_jedi $(1)/sbin/wifi
$(INSTALL_BIN) ./files/common/mtwifi.lua $(1)/lib/wifi/
if [ "$$(CONFIG_WIFI_QUICK_SETTING)" = "y" ] ; then \
$(INSTALL_BIN) ./files/common/quick_setting.lua $(1)/lib/wifi/; \
fi
if [ "$$(CONFIG_first_card_name)" = "MT7986" -o "$$(CONFIG_second_card_name)" = "MT7986" ] ; then \
$(INSTALL_DATA) ./files/mt7986/* $(1)/etc/wireless/mediatek/; \
fi
if [ "$$(CONFIG_first_card_name)" = "MT7981" -o "$$(CONFIG_second_card_name)" = "MT7981" ] ; then \
$(INSTALL_DATA) ./files/mt7981/* $(1)/etc/wireless/mediatek/; \
fi
if [ -f "$(1)/etc/wireless/mediatek/l1profile.dat" ]; then \
mv $(1)/etc/wireless/mediatek/l1profile.dat $(1)/etc/wireless/l1profile.dat ; \
fi
endef
$(eval $(call BuildPackage,wifi-profile))

View File

@ -0,0 +1,331 @@
#!/usr/bin/lua
-- Alternative for OpenWrt's /sbin/wifi.
-- Copyright Not Reserved.
-- Hua Shao <nossiac@163.com>
package.path = '/lib/wifi/?.lua;'..package.path
local function esc(x)
return (x:gsub('%%', '%%%%')
:gsub('^%^', '%%^')
:gsub('%$$', '%%$')
:gsub('%(', '%%(')
:gsub('%)', '%%)')
:gsub('%.', '%%.')
:gsub('%[', '%%[')
:gsub('%]', '%%]')
:gsub('%*', '%%*')
:gsub('%+', '%%+')
:gsub('%-', '%%-')
:gsub('%?', '%%?'))
end
function add_vif_into_lan(vif)
local mtkwifi = require("mtkwifi")
local brvifs = mtkwifi.__trim( mtkwifi.read_pipe("uci get network.lan.ifname"))
if not string.match(brvifs, esc(vif)) then
nixio.syslog("debug", "add "..vif.." into lan")
brvifs = brvifs.." "..vif
--os.execute("uci set network.lan.ifname=\""..brvifs.."\"") --netifd will down vif form /etc/config/network
--os.execute("uci commit")
--os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"")
os.execute("brctl addif br-lan "..vif) -- double insurance for rare failure
if mtkwifi.exists("/proc/sys/net/ipv6/conf/"..vif.."/disable_ipv6") then
os.execute("echo 1 > /proc/sys/net/ipv6/conf/"..vif.."/disable_ipv6")
end
else
nixio.syslog("debug", vif.." is already added into lan")
end
brvifs = string.split(mtkwifi.__trim((mtkwifi.read_pipe("ls /sys/class/net/br-lan/brif/"))))
for _,vif in ipairs(brvifs) do
nixio.syslog("debug", "brvif = "..vif)
end
end
function del_vif_from_lan(vif)
local mtkwifi = require("mtkwifi")
local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname"))
if string.match(brvifs, esc(vif)) then
brvifs = mtkwifi.__trim(string.gsub(brvifs, esc(vif), ""))
nixio.syslog("debug", "del "..vif.." from lan")
--os.execute("uci set network.lan.ifname=\""..brvifs.."\"")
--os.execute("uci commit")
--os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"")
if mtkwifi.exists("/proc/sys/net/ipv6/conf/"..vif.."/disable_ipv6") then
os.execute("echo 0 > /proc/sys/net/ipv6/conf/"..vif.."/disable_ipv6")
end
os.execute("brctl delif br-lan "..vif)
end
end
function mtwifi_up(devname)
local nixio = require("nixio")
local mtkwifi = require("mtkwifi")
nixio.syslog("debug", "mtwifi called!")
local devs, l1parser = mtkwifi.__get_l1dat()
-- l1 profile present, good!
if l1parser and devs then
dev = devs.devname_ridx[devname]
if not dev then
nixio.syslog("err", "mtwifi: dev "..devname.." not found!")
return
end
local profile = mtkwifi.search_dev_and_profile()[devname]
local cfgs = mtkwifi.load_profile(profile)
-- we have to bring up main_ifname first, main_ifname will create all other vifs.
if mtkwifi.exists("/sys/class/net/"..dev.main_ifname) then
nixio.syslog("debug", "mtwifi_up: ifconfig "..dev.main_ifname.." up")
os.execute("ifconfig "..dev.main_ifname.." up")
add_vif_into_lan(dev.main_ifname)
else
nixio.syslog("err", "mtwifi_up: main_ifname "..dev.main_ifname.." missing, quit!")
return
end
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if vif ~= dev.main_ifname and
( string.match(vif, esc(dev.ext_ifname).."[0-9]+")
or (string.match(vif, esc(dev.apcli_ifname).."[0-9]+") and
cfgs.ApCliEnable ~= "0" and cfgs.ApCliEnable ~= "")
or (string.match(vif, esc(dev.wds_ifname).."[0-9]+") and
cfgs.WdsEnable ~= "0" and cfgs.WdsEnable ~= "")
or string.match(vif, esc(dev.mesh_ifname).."[0-9]+"))
then
nixio.syslog("debug", "mtwifi_up: ifconfig "..vif.." up")
os.execute("ifconfig "..vif.." up")
add_vif_into_lan(vif)
-- else nixio.syslog("debug", "mtwifi_up: skip "..vif..", prefix not match "..pre)
end
end
else nixio.syslog("debug", "mtwifi_up: skip "..devname..", config(l1profile) not exist")
end
os.execute(" rm -rf /tmp/mtk/wifi/mtwifi*.need_reload")
end
function mtwifi_down(devname)
local nixio = require("nixio")
local mtkwifi = require("mtkwifi")
nixio.syslog("debug", "mtwifi_down called!")
-- M.A.N service
if mtkwifi.exists("/etc/init.d/man") then
os.execute("/etc/init.d/man stop")
end
local devs, l1parser = mtkwifi.__get_l1dat()
-- l1 profile present, good!
if l1parser and devs then
dev = devs.devname_ridx[devname]
if not dev then
nixio.syslog("err", "mtwifi_down: dev "..devname.." not found!")
return
end
if not mtkwifi.exists("/sys/class/net/"..dev.main_ifname) then
nixio.syslog("err", "mtwifi_down: main_ifname "..dev.main_ifname.." missing, quit!")
return
end
os.execute("iwpriv "..dev.main_ifname.." set hw_nat_register=0")
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if vif == dev.main_ifname
or string.match(vif, esc(dev.ext_ifname).."[0-9]+")
or string.match(vif, esc(dev.apcli_ifname).."[0-9]+")
or string.match(vif, esc(dev.wds_ifname).."[0-9]+")
or string.match(vif, esc(dev.mesh_ifname).."[0-9]+")
then
nixio.syslog("debug", "mtwifi_down: ifconfig "..vif.." down")
os.execute("ifconfig "..vif.." down")
del_vif_from_lan(vif)
-- else nixio.syslog("debug", "mtwifi_down: skip "..vif..", prefix not match "..pre)
end
end
else nixio.syslog("debug", "mtwifi_down: skip "..devname..", config not exist")
end
os.execute(" rm -rf /tmp/mtk/wifi/mtwifi*.need_reload")
end
function mtwifi_reload(devname)
local nixio = require("nixio")
local mtkwifi = require("mtkwifi")
local normal_reload = true
local qsetting = false
local path, profiles
local devs, l1parser = mtkwifi.__get_l1dat()
nixio.syslog("debug", "mtwifi_reload called!")
if mtkwifi.exists("/lib/wifi/quick_setting.lua") then
qsetting = true
profiles = mtkwifi.search_dev_and_profile()
end
-- For one card , all interface should be down, then up
if not devname then
for devname, dev in pairs(devs.devname_ridx) do
mtwifi_down(devname)
end
for devname, dev in mtkwifi.__spairs(devs.devname_ridx) do
if qsetting then
-- Create devname.last for quick setting
path = profiles[devname]
if not mtkwifi.exists("/tmp/mtk/wifi/"..string.match(path, "([^/]+)\.dat")..".applied") then
os.execute("cp -f "..path.." "..mtkwifi.__profile_previous_settings_path(path))
else
os.execute("cp -f "..mtkwifi.__profile_applied_settings_path(path)..
" "..mtkwifi.__profile_previous_settings_path(path))
end
end
mtwifi_up(devname)
end
else
if qsetting then
path = profiles[devname]
normal_reload = quick_settings(devname, path)
end
if normal_reload then
local dev = devs.devname_ridx[devname]
assert(mtkwifi.exists(dev.init_script))
local compatname = dev.init_compatible
-- Different cards do not affect each other
if not string.find(dev.profile_path, "dbdc") then
if dev.init_compatible == compatname then
mtwifi_down(devname)
mtwifi_up(devname)
end
--If the reloaded device belongs to dbdc, then another device on dbdc also need to be reloaded
else
for devname, dev in pairs(devs.devname_ridx) do
if dev.init_compatible == compatname then
mtwifi_down(devname)
end
end
for devname, dev in mtkwifi.__spairs(devs.devname_ridx) do
if dev.init_compatible == compatname then
mtwifi_up(devname)
end
end
end
else mtwifi_up(devname) end
end
-- for ax7800 project, close the ra0.
if string.find(dev.profile_path, "ax7800") then
os.execute("ifconfig ra0 down")
end
end
function mtwifi_restart(devname)
local nixio = require("nixio")
local uci = require "luci.model.uci".cursor()
local mtkwifi = require("mtkwifi")
local devs, l1parser = mtkwifi.__get_l1dat()
nixio.syslog("debug", "mtwifi_restart called!")
-- if wifi driver is built-in, it's necessary action to reboot the device
if mtkwifi.exists("/sys/module/mt_wifi") == false then
os.execute("echo reboot_required > /tmp/mtk/wifi/reboot_required")
return
end
if devname then
local dev = devs.devname_ridx[devname]
assert(mtkwifi.exists(dev.init_script))
local compatname = dev.init_compatible
for devname, dev in pairs(devs.devname_ridx) do
if dev.init_compatible == compatname then
mtwifi_down(devname)
end
end
else
for devname, dev in pairs(devs.devname_ridx) do
mtwifi_down(devname)
end
end
os.execute("rmmod mt_whnat")
if mtkwifi.exists("/etc/init.d/fwdd") then
os.execute("/etc/init.d/fwdd stop")
end
os.execute("rmmod mtfwd")
os.execute("rmmod mtk_warp_proxy")
os.execute("rmmod mtk_warp")
-- mt7915_mt_wifi is for dual ko only
os.execute("rmmod mt7915_mt_wifi")
os.execute("rmmod mt_wifi")
os.execute("modprobe mt_wifi")
os.execute("modprobe mt7915_mt_wifi")
os.execute("modprobe mtk_warp")
os.execute("modprobe mtk_warp_proxy")
os.execute("modprobe mtfwd")
if mtkwifi.exists("/etc/init.d/fwdd") then
os.execute("/etc/init.d/fwdd start")
end
os.execute("modprobe mt_whnat")
if devname then
local dev = devs.devname_ridx[devname]
assert(mtkwifi.exists(dev.init_script))
local compatname = dev.init_compatible
for devname, dev in pairs(devs.devname_ridx) do
if dev.init_compatible == compatname then
mtwifi_up(devname)
end
end
else
for devname, dev in pairs(devs.devname_ridx) do
mtwifi_up(devname)
end
end
end
function mtwifi_reset(devname)
local nixio = require("nixio")
local mtkwifi = require("mtkwifi")
nixio.syslog("debug", "mtwifi_reset called!")
if mtkwifi.exists("/rom/etc/wireless/mediatek/") then
os.execute("rm -rf /etc/wireless/mediatek/")
os.execute("cp -rf /rom/etc/wireless/mediatek/ /etc/wireless/")
mtwifi_reload(devname)
else
nixio.syslog("debug", "mtwifi_reset: /rom"..profile.." missing, unable to reset!")
end
end
function mtwifi_status(devname)
return wifi_common_status()
end
function mtwifi_hello(devname)
os.execute("echo mtwifi_hello: "..devname)
end
function mtwifi_detect(devname)
local nixio = require("nixio")
local mtkwifi = require("mtkwifi")
nixio.syslog("debug", "mtwifi_detect called!")
for _,dev in ipairs(mtkwifi.get_all_devs()) do
local relname = string.format("%s%d%d",dev.maindev,dev.mainidx,dev.subidx)
print([[
config wifi-device ]]..relname.."\n"..[[
option type mtwifi
option vendor ralink
]])
for _,vif in ipairs(dev.vifs) do
print([[
config wifi-iface
option device ]]..relname.."\n"..[[
option ifname ]]..vif.vifname.."\n"..[[
option network lan
option mode ap
option ssid ]]..vif.__ssid.."\n")
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,222 @@
#!/usr/bin/env lua
-- Alternative for OpenWrt's /sbin/wifi.
-- Copyright Not Reserved.
-- Hua Shao <nossiac@163.com>
package.path = '/lib/wifi/?.lua;'..package.path
local mtkwifi = require("mtkwifi")
local nixio = require("nixio")
function usage()
print("wifi <up|down|reset|reload|restart|status> [devname]")
end
function wifi_common_up(devname)
nixio.syslog("debug", "wifi_common_up "..tostring(devname))
-- need to find out the vif prefix for this device
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if string.match(vif, "ra%a-%d+") then
os.execute("ifconfig "..vif.." up")
end
end
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if string.match(vif, "apcli%a-%d+") then
os.execute("ifconfig "..vif.." up")
end
end
if devname then
os.execute("rm -f /tmp/mtk/wifi/"..devname.."*.need_reload")
else
os.execute("rm -f /tmp/mtk/wifi/*.need_reload")
end
end
function wifi_common_down(devname)
nixio.syslog("debug", "wifi_common_down "..tostring(devname))
-- need to find out the vif prefix for this device
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if string.match(vif, "apcli%d+")
or string.match(vif, "apclii%d+") then
os.execute("ifconfig "..vif.." down")
end
end
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), " "))
do
if string.match(vif, "ra%d+")
or string.match(vif, "rai%d+")
or string.match(vif, "rae%d+")
or string.match(vif, "rax%d+") then
os.execute("ifconfig "..vif.." down")
end
end
end
function wifi_common_restart(devname)
nixio.syslog("debug", "wifi_common_restart "..tostring(devname))
wifi_common_up()
wifi_common_down()
end
function wifi_common_reload(devname)
nixio.syslog("debug", "wifi_common_reload "..tostring(devname))
wifi_common_up()
wifi_common_down()
end
function wifi_common_reset(devname)
nixio.syslog("debug", "wifi_common_reset called!")
local curpath = "/etc/wireless/"
if devname then
curpath = curpath..devname.."/"
end
local defpath = "/rom"..defpath
if mtkwifi.exists(defpath) then
os.execute("rm -rf "..curpath)
os.execute("cp -rf "..defpath.." "..curpath)
wifi_common_reload()
else
nixio.syslog("debug", defpath.." missing, unable to reset!")
end
end
function wifi_common_status(devname)
nixio.syslog("debug", "wifi_common_status "..tostring(devname))
print(mtkwifi.read_pipe("iwconfig"))
print(mtkwifi.read_pipe("ifconfig -a"))
end
function wifi_common_detect(devname)
nixio.syslog("debug", "wifi_common_detect "..tostring(devname))
local devs = mtkwifi.getdevs()
for _,dev in ipairs(devs) do
print("config wifi-device "..dev.devname..
"\n\toption type "..dev.devname..
"\n\toption vendor ralink"..
"\n\toption channel "..dev.Channel)
for _,vif in ipairs(dev.vifs) do
print("\nconfig wifi-iface"..
"\n\toption device"..dev.devname..
"\n\toption ifname"..vif.vifname..
"\n\toption network lan"..
"\n\toption mode ap")
end
end
end
for _,f in ipairs(string.split(mtkwifi.read_pipe("find /lib/wifi/ -name \"*.lua\" 2>/dev/null"), "\n")) do
dofile(f)
end
function wifi(cmd, devname)
local mtkwifi = require("mtkwifi")
local devs, l1parser = mtkwifi.__get_l1dat()
l1parser.creat_link_for_nvram()
if not devs or not l1parser then
return wifi_orig(cmd, devname)
end
if devname then
local dev = devs.devname_ridx[devname]
local compatname = dev.init_compatible
assert(compatname)
if _G[compatname.."_"..cmd] then
nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")")
_G[compatname.."_"..cmd](devname)
end
else
-- if devname not specified
if cmd == "restart" or cmd == "reload" then
local tab_compatname = {}
for key, dev in pairs(devs.devname_ridx) do
tab_compatname[key] = dev.init_compatible
end
local tab_rp = {}
for key,val in pairs(tab_compatname) do
tab_rp[val] = true
end
for dev, val in pairs(tab_rp) do
nixio.syslog("info", "call "..dev.."_"..cmd)
_G[dev.."_"..cmd]()
end
else
for devname, dev in mtkwifi.__spairs(devs.devname_ridx) do
local compatname = dev.init_compatible
nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")")
_G[compatname.."_"..cmd](devname)
end
end
end
end
function wifi_orig(cmd,devname)
print("wifi_orig",cmd,devname)
local relname = nil
if devname then
relname = string.split(devname,".")[1]
end
if relname then
if _G[relname.."_"..cmd] then
nixio.syslog("info", "call "..relname.."_"..cmd.."("..devname..")")
_G[relname.."_"..cmd](devname)
end
else
local devinfo = mtkwifi.search_dev_and_profile()
local done = {}
for __devname in pairs(devinfo) do
local __relname = string.split(__devname,".")[1]
repeat
-- common case
if done[__relname] then break else done[__relname] = true end
if _G[__relname.."_"..cmd] then
nixio.syslog("info", "call "..__relname.."_"..cmd.."("..__devname..")")
_G[__relname.."_"..cmd](__devname)
break
end
-- try shell
local dev_shell = "/lib/wifi/"..__relname..".sh"
if mtkwifi.exists(dev_shell) then
local cmd = "source "..dev_shell.."; "..__relname.."_"..cmd.." > /dev/null"
nixio.syslog("info", cmd)
if os.execute(cmd) ~= 0 then
nixio.syslog("err", cmd)
end
break
end
-- fall back on common api
nixio.syslog("info", "no scripts for "..__relname.." found, fall back on common api!")
_G["wifi_common_"..cmd](__devname)
until true
end
end
end
cmd = arg[1]
dev = arg[2]
if cmd == "up"
or cmd == "down"
or cmd == "status"
or cmd == "detect"
or cmd == "reload"
or cmd == "restart"
or cmd == "reset" then
wifi(cmd, dev)
elseif cmd == "reload_legacy" then
nixio.syslog("info", "legacy command "..cmd)
wifi("reload", dev)
else
usage()
end

View File

@ -0,0 +1,16 @@
Default
INDEX0=MT7981
INDEX0_profile_path=/etc/wireless/mediatek/mt7981.dbdc.b0.dat;/etc/wireless/mediatek/mt7981.dbdc.b1.dat
INDEX0_init_script=/lib/wifi/mtwifi.lua;/lib/wifi/mtwifi.lua
INDEX0_init_compatible=mtwifi;mtwifi
INDEX0_EEPROM_offset=0x0
INDEX0_EEPROM_size=0x5000
INDEX0_EEPROM_name=e2p
INDEX0_main_ifname=ra0;rax0
INDEX0_ext_ifname=ra;rax
INDEX0_wds_ifname=wds;wdsx
INDEX0_apcli_ifname=apcli;apclix
INDEX0_mesh_ifname=mesh;meshx
INDEX0_nvram_zone=dev1;dev2
INDEX0_single_sku_path=/etc/wireless/mediatek/mt7981-sku.dat
INDEX0_bf_sku_path=/etc/wireless/mediatek/mt7981-sku-bf.dat

View File

@ -0,0 +1,71 @@
# Single SKU Max Power Table (unit is 1 dBm)
# 2.4G Channel
Band: 2.4G MaxPower_4T MaxPower_3T MaxPower_2T
Ch1 14 14 13
Ch2 12 11 17
Ch3 16 11 12
Ch4 7 11 7
Ch5 12 15 13
Ch6 11 14 9
Ch7 10 15 6
Ch8 15 17 14
Ch9 6 9 6
Ch10 16 13 8
Ch11 14 14 7
Ch12 11 9 8
Ch13 6 11 14
Ch14 17 13 16
# 5G Channel
Band: 5G MaxPower_4T MaxPower_3T MaxPower_2T
Ch184 15 10 14
Ch188 10 17 15
Ch192 6 12 8
Ch196 13 6 8
Ch8 12 13 11
Ch12 11 10 16
Ch16 12 13 11
Ch36 9 9 12
Ch40 7 15 7
Ch44 17 15 13
Ch48 8 7 8
Ch52 8 11 10
Ch56 11 10 11
Ch60 7 6 15
Ch64 13 16 11
Ch68 6 9 13
Ch72 13 16 17
Ch76 12 13 6
Ch80 17 14 6
Ch84 11 7 7
Ch88 9 8 17
Ch92 16 8 12
Ch96 16 13 6
Ch100 8 7 13
Ch104 13 14 10
Ch108 14 8 6
Ch112 16 17 12
Ch116 16 13 12
Ch120 7 10 7
Ch124 14 13 9
Ch128 17 10 17
Ch132 12 6 11
Ch136 17 17 10
Ch140 6 15 6
Ch144 12 7 10
Ch149 9 12 16
Ch153 10 15 11
Ch157 8 8 14
Ch161 11 6 7
Ch165 11 7 15
Ch169 17 6 13
Ch173 8 15 12
Ch177 10 15 7
Ch181 13 11 10

View File

@ -0,0 +1,64 @@
# Single SKU Max Power Table (unit is 1 dBm)
# 2.4G Channel CCK OFDM VHT20 VHT40 TxStreamCapability_Delta TxSpatialStream_Delta
Band: 2.4G CCK_1M CCK_2M CCK_5.5M CCK_11M OFDM_6M OFDM_9M OFDM_12M OFDM_18M OFDM_24M OFDM_36M OFDM_48M OFDM_54M VHT20_MCS0 VHT20_MCS1 VHT20_MCS2 VHT20_MCS3 VHT20_MCS4 VHT20_MCS5 VHT20_MCS6 VHT20_MCS7 VHT20_MCS8 VHT20_MCS9 VHT40_MCS0 VHT40_MCS1 VHT40_MCS2 VHT40_MCS3 VHT40_MCS4 VHT40_MCS5 VHT40_MCS6 VHT40_MCS7 VHT40_MCS8 VHT40_MCS9 Txstream_3T Txstream_2T Txstream_1T Txstream_1SS Txstream_2SS Txstream_3SS Txstream_4SS
Ch1 16 12 15 17 18 11 10 15 15 15 18 15 10 16 20 11 17 13 9 8 20 1 3 6 6 3 1 0
Ch2 11 19 19 11 15 18 17 16 20 14 13 11 14 10 19 17 18 9 15 18 8 1 3 6 6 3 1 0
Ch3 13 11 14 12 11 12 9 18 14 14 19 17 11 16 20 17 20 8 18 8 18 1 3 6 6 3 1 0
Ch4 13 14 15 10 18 9 10 10 20 13 8 13 8 10 20 17 18 13 17 19 20 1 3 6 6 3 1 0
Ch5 10 12 14 12 9 15 19 9 8 17 11 13 8 17 9 20 16 11 16 13 8 1 3 6 6 3 1 0
Ch6 20 9 15 11 10 17 16 8 18 17 13 9 18 13 15 9 13 14 14 12 17 1 3 6 6 3 1 0
Ch7 11 19 20 17 15 16 17 9 19 20 12 14 15 11 14 11 16 12 8 20 18 1 3 6 6 3 1 0
Ch8 13 9 15 14 14 10 11 13 13 12 10 18 10 15 12 9 19 15 18 14 13 1 3 6 6 3 1 0
Ch9 18 9 19 20 15 15 8 9 18 14 17 8 10 13 12 11 8 14 10 13 11 1 3 6 6 3 1 0
Ch10 9 9 20 20 19 11 17 18 19 11 20 18 18 18 9 19 10 8 12 17 16 1 3 6 6 3 1 0
Ch11 15 11 8 8 12 9 18 18 8 9 17 13 15 9 9 11 19 10 11 14 20 1 3 6 6 3 1 0
Ch12 11 13 11 15 20 8 11 19 19 9 9 15 17 11 17 20 17 12 16 16 8 1 3 6 6 3 1 0
Ch13 8 9 18 12 9 12 15 14 13 15 18 13 15 13 20 14 19 12 20 17 9 1 3 6 6 3 1 0
Ch14 12 19 8 16 12 8 15 9 14 13 16 10 11 17 20 9 14 10 9 13 16 1 3 6 6 3 1 0
# 5G Channel OFDM VHT20 VHT40 VHT80 VHT160 Txstream_Delta TxSpatialStream_Delta
Band: 5G OFDM_6M OFDM_9M OFDM_12M OFDM_18M OFDM_24M OFDM_36M OFDM_48M OFDM_54M VHT20_MCS0 VHT20_MCS1 VHT20_MCS2 VHT20_MCS3 VHT20_MCS4 VHT20_MCS5 VHT20_MCS6 VHT20_MCS7 VHT20_MCS8 VHT20_MCS9 VHT40_MCS0 VHT40_MCS1 VHT40_MCS2 VHT40_MCS3 VHT40_MCS4 VHT40_MCS5 VHT40_MCS6 VHT40_MCS7 VHT40_MCS8 VHT40_MCS9 VHT80_MCS0 VHT80_MCS1 VHT80_MCS2 VHT80_MCS3 VHT80_MCS4 VHT80_MCS5 VHT80_MCS6 VHT80_MCS7 VHT80_MCS8 VHT80_MCS9 VHT160_MCS0 VHT160_MCS1 VHT160_MCS2 VHT160_MCS3 VHT160_MCS4 VHT160_MCS5 VHT160_MCS6 VHT160_MCS7 VHT160_MCS8 VHT160_MCS9 Txstream_3T Txstream_2T Txstream_1T Txstream_1SS Txstream_2SS Txstream_3SS Txstream_4SS
Ch184 9 8 12 18 16 17 13 12 16 10 17 9 10 16 16 10 10 14 9 13 13 19 16 16 12 9 15 18 18 10 18 11 9 1 3 6 6 3 1 0
Ch188 8 18 9 13 9 11 16 20 20 14 12 9 13 13 8 20 12 17 13 9 9 14 15 19 16 9 12 13 17 14 19 9 12 1 3 6 6 3 1 0
Ch192 15 9 10 9 17 17 20 19 13 18 11 18 16 12 8 16 18 9 20 12 12 17 17 19 12 9 10 16 13 15 18 9 9 1 3 6 6 3 1 0
Ch196 13 10 17 19 8 15 19 12 18 12 10 16 16 12 15 11 19 17 12 10 10 19 20 18 8 16 10 20 8 19 15 13 8 1 3 6 6 3 1 0
Ch8 15 16 10 19 8 15 19 11 11 15 17 19 13 8 16 12 10 9 12 16 14 13 13 12 18 8 12 20 14 14 20 9 15 1 3 6 6 3 1 0
Ch12 12 12 19 19 12 20 17 19 18 18 19 17 13 16 15 17 13 11 9 13 11 19 13 13 14 20 13 17 14 19 18 15 11 1 3 6 6 3 1 0
Ch16 15 8 18 15 11 14 14 9 17 18 16 19 19 11 8 11 13 20 16 17 17 14 18 13 14 16 20 14 15 15 18 11 20 1 3 6 6 3 1 0
Ch36 8 14 8 17 9 14 20 10 8 11 15 9 13 8 16 14 20 9 14 17 11 9 20 16 20 12 13 17 18 20 16 8 12 1 3 6 6 3 1 0
Ch40 14 13 12 16 12 11 15 10 11 12 10 12 11 12 15 8 14 11 14 14 19 8 9 8 15 9 10 17 18 19 16 10 11 1 3 6 6 3 1 0
Ch44 16 20 20 9 12 12 10 11 18 16 9 13 13 16 8 9 9 10 10 11 12 18 11 8 8 12 9 14 15 17 19 13 16 1 3 6 6 3 1 0
Ch48 17 14 14 8 18 15 11 12 19 9 12 10 19 20 20 14 14 15 18 9 8 11 12 17 20 13 18 12 12 9 14 19 17 1 3 6 6 3 1 0
Ch52 10 17 8 12 10 15 16 11 20 14 12 17 17 17 10 20 9 18 11 13 20 18 15 10 20 12 11 18 19 9 15 13 9 1 3 6 6 3 1 0
Ch56 9 13 11 13 18 12 15 17 11 11 8 8 9 19 9 11 17 19 12 17 10 13 19 10 19 19 12 15 8 20 14 15 15 1 3 6 6 3 1 0
Ch60 14 8 18 8 17 19 18 16 12 15 14 15 15 19 18 12 17 19 11 17 8 10 19 9 16 17 13 11 14 18 14 8 16 1 3 6 6 3 1 0
Ch64 9 20 10 13 13 19 11 20 13 8 11 12 12 12 11 12 8 18 11 12 15 16 11 10 15 20 10 12 14 15 12 8 17 1 3 6 6 3 1 0
Ch68 8 20 9 19 12 14 8 18 14 15 20 12 10 8 10 12 15 20 14 8 13 16 15 11 13 12 14 20 11 11 10 16 20 1 3 6 6 3 1 0
Ch72 14 18 15 14 17 15 20 16 18 16 12 17 16 18 12 20 13 14 8 8 13 18 8 13 16 8 18 9 14 8 17 13 17 1 3 6 6 3 1 0
Ch76 8 11 17 15 15 16 10 11 12 13 11 14 20 17 18 12 11 17 13 11 13 16 15 18 11 11 13 17 13 9 11 17 14 1 3 6 6 3 1 0
Ch80 16 19 19 11 15 8 13 20 13 17 11 15 14 19 14 20 16 8 15 10 12 16 16 17 8 8 19 20 13 11 14 16 11 1 3 6 6 3 1 0
Ch84 9 11 13 11 16 16 13 20 8 15 19 16 17 11 11 10 16 16 19 19 13 15 12 9 19 13 19 19 18 18 12 17 13 1 3 6 6 3 1 0
Ch88 14 14 14 9 16 13 16 17 12 19 8 19 12 12 10 12 17 10 13 19 15 12 10 14 9 17 8 10 19 10 11 9 11 1 3 6 6 3 1 0
Ch92 11 20 9 19 18 15 11 9 11 20 13 15 9 10 10 12 17 20 13 9 20 12 17 15 17 17 19 9 20 13 16 13 20 1 3 6 6 3 1 0
Ch96 13 20 13 11 17 8 18 8 17 14 18 9 13 16 19 13 20 11 19 19 17 12 8 20 9 14 18 10 8 20 13 14 16 1 3 6 6 3 1 0
Ch100 13 20 11 13 20 14 15 13 20 20 13 16 14 9 20 10 18 18 14 12 20 17 20 8 12 14 19 20 15 17 20 10 9 1 3 6 6 3 1 0
Ch104 9 19 10 17 12 9 12 14 17 10 13 14 15 16 19 8 10 8 9 17 11 13 10 16 17 20 10 11 17 18 10 8 17 1 3 6 6 3 1 0
Ch108 15 14 16 17 12 11 13 16 14 10 12 16 17 12 12 17 18 10 14 18 13 13 16 10 16 20 9 20 14 8 8 12 13 1 3 6 6 3 1 0
Ch112 11 13 19 14 8 10 16 10 11 16 13 20 13 14 10 14 8 13 17 12 16 16 10 16 11 17 19 12 19 16 18 11 10 1 3 6 6 3 1 0
Ch116 8 15 16 13 11 11 12 11 8 9 15 12 8 9 16 20 18 14 11 17 13 15 9 8 11 16 20 13 11 14 13 16 9 1 3 6 6 3 1 0
Ch120 9 19 12 11 15 17 11 16 8 11 8 14 17 17 14 15 16 11 19 14 20 9 14 15 19 15 19 11 20 18 13 17 11 1 3 6 6 3 1 0
Ch124 11 16 15 17 11 14 18 11 14 10 8 14 18 17 11 17 15 18 15 15 10 11 18 18 16 13 10 10 18 17 20 13 15 1 3 6 6 3 1 0
Ch128 8 13 14 17 10 19 15 9 11 11 17 20 11 20 11 12 18 14 8 16 18 12 18 16 12 8 20 14 17 14 19 14 14 1 3 6 6 3 1 0
Ch132 10 18 8 11 16 17 18 11 10 8 10 14 17 9 13 12 18 20 11 19 17 12 14 13 17 17 13 19 16 8 10 10 11 1 3 6 6 3 1 0
Ch136 13 17 10 11 8 20 11 11 19 20 12 14 11 12 16 10 9 18 16 11 19 14 19 12 11 13 13 17 18 19 14 18 18 1 3 6 6 3 1 0
Ch140 17 11 19 17 14 14 12 15 16 12 20 8 8 18 13 10 18 17 10 19 18 17 12 17 15 12 13 14 8 18 11 12 16 1 3 6 6 3 1 0
Ch144 9 18 13 8 11 14 17 18 16 17 10 17 14 8 13 20 20 14 11 16 9 14 16 19 18 14 9 18 12 19 16 11 16 1 3 6 6 3 1 0
Ch149 17 10 11 8 18 20 16 13 18 19 19 9 16 9 16 13 16 18 14 11 14 20 9 17 18 10 14 10 20 10 11 13 9 1 3 6 6 3 1 0
Ch153 14 13 16 19 9 12 16 15 20 18 14 13 17 11 11 19 9 12 9 8 9 11 11 9 12 14 20 8 16 11 15 16 16 1 3 6 6 3 1 0
Ch157 11 18 19 15 20 8 14 19 17 12 15 16 13 13 19 9 20 12 17 20 12 11 8 14 13 18 14 12 12 13 13 19 20 1 3 6 6 3 1 0
Ch161 10 17 14 17 11 19 20 18 8 17 10 18 17 18 17 8 9 18 16 14 9 20 19 12 15 12 15 11 12 19 10 20 18 1 3 6 6 3 1 0
Ch165 11 10 12 16 13 11 12 16 11 11 15 11 20 20 10 15 8 20 17 9 15 12 16 18 17 8 14 10 19 12 17 17 20 1 3 6 6 3 1 0
Ch169 17 19 12 20 13 17 15 16 18 11 8 17 9 15 12 16 18 12 17 8 15 17 19 8 11 10 18 16 16 20 12 16 13 1 3 6 6 3 1 0
Ch173 19 17 14 14 18 20 13 9 11 18 19 11 15 13 8 20 20 20 15 14 17 12 19 20 15 16 17 17 12 8 12 16 9 1 3 6 6 3 1 0
Ch177 8 17 10 13 12 18 18 18 17 12 10 19 11 8 16 18 13 9 18 13 8 14 11 9 12 14 11 15 13 14 13 19 16 1 3 6 6 3 1 0
Ch181 20 19 19 8 12 14 14 12 20 16 13 10 19 11 8 18 10 9 15 11 12 12 14 19 18 18 20 20 14 14 17 14 14 1 3 6 6 3 1 0

View File

@ -0,0 +1,435 @@
#The word of "Default" must not be removed
Default
AccessControlList0=
AccessControlList1=
AccessControlList10=
AccessControlList11=
AccessControlList12=
AccessControlList13=
AccessControlList14=
AccessControlList15=
AccessControlList2=
AccessControlList3=
AccessControlList4=
AccessControlList5=
AccessControlList6=
AccessControlList7=
AccessControlList8=
AccessControlList9=
AccessPolicy0=0
AccessPolicy1=0
AccessPolicy10=0
AccessPolicy11=0
AccessPolicy12=0
AccessPolicy13=0
AccessPolicy14=0
AccessPolicy15=0
AccessPolicy2=0
AccessPolicy3=0
AccessPolicy4=0
AccessPolicy5=0
AccessPolicy6=0
AccessPolicy7=0
AccessPolicy8=0
AccessPolicy9=0
AckPolicy=0;0;0;0
APACM=0;0;0;0
APAifsn=3;7;1;1
ApCliAuthMode=
ApCliBssid=
ApCliDefaultKeyID=
ApCliEnable=0
ApCliEncrypType=
ApCliKey1Str=
ApCliKey1Str1=
ApCliKey1Type=
ApCliKey2Str=
ApCliKey2Str1=
ApCliKey2Type=
ApCliKey3Str=
ApCliKey3Str1=
ApCliKey3Type=
ApCliKey4Str=
ApCliKey4Str1=
ApCliKey4Type=
ApCliSsid=
ApCliWirelessMode=
ApCliWPAPSK=
ApCliWPAPSK1=
ApCliMuOfdmaDlEnable=0
ApCliMuOfdmaUlEnable=0
ApCliMuMimoDlEnable=0
ApCliMuMimoUlEnable=0
APCwmax=6;10;4;3
APCwmin=4;4;3;2
APSDCapable=1
APTxop=0;0;94;47
AuthMode=OPEN
AutoChannelSelect=3
AutoChannelSkipList=14
AutoProvisionEn=0
BandSteering=0
BasicRate=15
BeaconPeriod=100
BFBACKOFFenable=0
BgndScanSkipCh=
BGProtection=0
BndStrgBssIdx=
BSSACM=0;0;0;0
BSSAifsn=3;7;2;2
BSSCwmax=10;10;4;3
BSSCwmin=4;4;3;2
BssidNum=1
BSSTxop=0;0;94;47
BW_Enable=0
BW_Guarantee_Rate=
BW_Maximum_Rate=
BW_Priority=
BW_Root=0
CalCacheApply=0
CarrierDetect=0
Channel=0
ChannelGrp=
CountryCode=CN
CountryRegion=1
CountryRegionABand=7
CP_SUPPORT=2
CSPeriod=6
DBDC_MODE=1
DebugFlags=0
DefaultKeyID=1
DfsCalibration=0
DfsFalseAlarmPrevent=1
DfsZeroWait=0
DfsZeroWaitCacTime=255
DisableOLBC=0
DtimPeriod=1
E2pAccessMode=2
EAPifname=br-lan
EDCCAEnable=1
EncrypType=NONE
EthConvertMode=dongle
EtherTrafficBand=0
Ethifname=
ETxBfEnCond=1
FineAGC=0
FixedTxMode=
ForceRoamSupport=
FragThreshold=2346
FreqDelta=0
FtSupport=0
GreenAP=0
G_BAND_256QAM=1
HideSSID=0
HT_AMSDU=1
AMSDU_NUM=8
HT_AutoBA=1
HT_BADecline=0
HT_BAWinSize=256
HT_BSSCoexistence=1
HT_BW=1
HT_DisallowTKIP=1
HT_EXTCHA=1
HT_GI=1
HT_HTC=1
HT_LDPC=1
HT_LinkAdapt=0
HT_MCS=33
HT_MpduDensity=4
HT_OpMode=0
HT_PROTECT=1
HT_RDG=0
HT_RxStream=2
HT_STBC=1
HT_TxStream=2
IcapMode=0
idle_timeout_interval=0
IEEE80211H=0
IEEE8021X=0
IgmpSnEnable=1
ITxBfEn=0
Key1Str=
Key1Str1=
Key1Str10=
Key1Str11=
Key1Str12=
Key1Str13=
Key1Str14=
Key1Str15=
Key1Str16=
Key1Str2=
Key1Str3=
Key1Str4=
Key1Str5=
Key1Str6=
Key1Str7=
Key1Str8=
Key1Str9=
Key1Type=0
Key2Str=
Key2Str1=
Key2Str10=
Key2Str11=
Key2Str12=
Key2Str13=
Key2Str14=
Key2Str15=
Key2Str16=
Key2Str2=
Key2Str3=
Key2Str4=
Key2Str5=
Key2Str6=
Key2Str7=
Key2Str8=
Key2Str9=
Key2Type=0
Key3Str=
Key3Str1=
Key3Str10=
Key3Str11=
Key3Str12=
Key3Str13=
Key3Str14=
Key3Str15=
Key3Str16=
Key3Str2=
Key3Str3=
Key3Str4=
Key3Str5=
Key3Str6=
Key3Str7=
Key3Str8=
Key3Str9=
Key3Type=0
Key4Str=
Key4Str1=
Key4Str10=
Key4Str11=
Key4Str12=
Key4Str13=
Key4Str14=
Key4Str15=
Key4Str16=
Key4Str2=
Key4Str3=
Key4Str4=
Key4Str5=
Key4Str6=
Key4Str7=
Key4Str8=
Key4Str9=
Key4Type=0
LinkTestSupport=0
MACRepeaterEn=
MACRepeaterOuiMode=2
MeshAuthMode=
MeshAutoLink=0
MeshDefaultkey=0
MeshEncrypType=
MeshId=
MeshWEPKEY=
MeshWPAKEY=
MUTxRxEnable=1
NoForwarding=0
NoForwardingBTNBSSID=0
own_ip_addr=192.168.1.1
PcieAspm=0
PERCENTAGEenable=0
PhyRateLimit=0
PMFMFPC=0
PMFMFPR=0
PMFSHA256=0
PMKCachePeriod=10
PowerUpCckOfdm=0:0:0:0:0:0:0
PowerUpHT20=0:0:0:0:0:0:0
PowerUpHT40=0:0:0:0:0:0:0
PowerUpVHT160=0:0:0:0:0:0:0
PowerUpVHT20=0:0:0:0:0:0:0
PowerUpVHT40=0:0:0:0:0:0:0
PowerUpVHT80=0:0:0:0:0:0:0
PreAntSwitch=
PreAuth=0
PreAuthifname=br-lan
RadioLinkSelection=0
RadioOn=1
RADIUS_Acct_Key=
RADIUS_Acct_Port=1813
RADIUS_Acct_Server=
RADIUS_Key1=
RADIUS_Key10=
RADIUS_Key11=
RADIUS_Key12=
RADIUS_Key13=
RADIUS_Key14=
RADIUS_Key15=
RADIUS_Key16=
RADIUS_Key2=
RADIUS_Key3=
RADIUS_Key4=
RADIUS_Key5=
RADIUS_Key6=
RADIUS_Key7=
RADIUS_Key8=
RADIUS_Key9=
RADIUS_Port=1812
RADIUS_Server=0
RDRegion=
RED_Enable=1
RekeyInterval=3600
RekeyMethod=DISABLE
RRMEnable=1
RTSThreshold=2347
session_timeout_interval=0
ShortSlot=1
SkuTableIdx=0
SKUenable=0
SREnable=1
SRMode=0
SRDPDEnable=0
SRSDEnable=1
PPEnable=0
SSID=
SSID1=MTK_CHEETAH_AP_2.4G
SSID10=
SSID11=
SSID12=
SSID13=
SSID14=
SSID15=
SSID16=
SSID2=
SSID3=
SSID4=
SSID5=
SSID6=
SSID7=
SSID8=
SSID9=
StationKeepAlive=0
StreamMode=0
StreamModeMac0=
StreamModeMac1=
StreamModeMac2=
StreamModeMac3=
TGnWifiTest=0
ThermalRecal=0
CCKTxStream=4
TWTSupport=0
TxBurst=1
TxPower=100
TxPreamble=1
VHT_BW=0
VHT_BW_SIGNAL=0
VHT_LDPC=1
VHT_Sec80_Channel=0
VHT_SGI=1
VHT_STBC=1
Vht1024QamSupport=0
VLANID=0
VLANPriority=0
VLANTag=0
VOW_Airtime_Ctrl_En=
VOW_Airtime_Fairness_En=1
VOW_BW_Ctrl=0
VOW_Group_Backlog=
VOW_Group_DWRR_Max_Wait_Time=
VOW_Group_DWRR_Quantum=
VOW_Group_Max_Airtime_Bucket_Size=
VOW_Group_Max_Rate=
VOW_Group_Max_Rate_Bucket_Size=
VOW_Group_Max_Ratio=
VOW_Group_Max_Wait_Time=
VOW_Group_Min_Airtime_Bucket_Size=
VOW_Group_Min_Rate=
VOW_Group_Min_Rate_Bucket_Size=
VOW_Group_Min_Ratio=
VOW_Rate_Ctrl_En=
VOW_Refill_Period=
VOW_RX_En=1
VOW_Sta_BE_DWRR_Quantum=
VOW_Sta_BK_DWRR_Quantum=
VOW_Sta_DWRR_Max_Wait_Time=
VOW_Sta_VI_DWRR_Quantum=
VOW_Sta_VO_DWRR_Quantum=
VOW_WATF_Enable=
VOW_WATF_MAC_LV0=
VOW_WATF_MAC_LV1=
VOW_WATF_MAC_LV2=
VOW_WATF_MAC_LV3=
VOW_WATF_Q_LV0=
VOW_WATF_Q_LV1=
VOW_WATF_Q_LV2=
VOW_WATF_Q_LV3=
VOW_WMM_Search_Rule_Band0=
VOW_WMM_Search_Rule_Band1=
WapiAsCertPath=
WapiAsIpAddr=
WapiAsPort=
Wapiifname=
WapiPsk1=
WapiPsk10=
WapiPsk11=
WapiPsk12=
WapiPsk13=
WapiPsk14=
WapiPsk15=
WapiPsk16=
WapiPsk2=
WapiPsk3=
WapiPsk4=
WapiPsk5=
WapiPsk6=
WapiPsk7=
WapiPsk8=
WapiPsk9=
WapiPskType=
WapiUserCertPath=
WCNTest=0
Wds0Key=
Wds1Key=
Wds2Key=
Wds3Key=
WdsEnable=0
WdsEncrypType=NONE
WdsList=
WdsPhyMode=0
WHNAT=1
WiFiTest=0
WirelessMode=16
WmmCapable=1
WPAPSK=
WPAPSK1=12345678
WPAPSK10=
WPAPSK11=
WPAPSK12=
WPAPSK13=
WPAPSK14=
WPAPSK15=
WPAPSK16=
WPAPSK2=
WPAPSK3=
WPAPSK4=
WPAPSK5=
WPAPSK6=
WPAPSK7=
WPAPSK8=
WPAPSK9=
WscConfMode=0
WscConfStatus=2
TxCmdMode=1
MuOfdmaDlEnable=1
MuOfdmaUlEnable=1
MuMimoDlEnable=1
MuMimoUlEnable=1
MapMode=0
IsICAPFW=0
KernelRps=1
MboSupport=1
BSSColorValue=255
QoSR1Enable=1
DscpPriMapEnable=1
ScsEnable=0
QoSMgmtCapa=0
BcnProt=0
ApCliBcnProt=0

View File

@ -0,0 +1,437 @@
#The word of "Default" must not be removed
Default
AccessControlList0=
AccessControlList1=
AccessControlList10=
AccessControlList11=
AccessControlList12=
AccessControlList13=
AccessControlList14=
AccessControlList15=
AccessControlList2=
AccessControlList3=
AccessControlList4=
AccessControlList5=
AccessControlList6=
AccessControlList7=
AccessControlList8=
AccessControlList9=
AccessPolicy0=0
AccessPolicy1=0
AccessPolicy10=0
AccessPolicy11=0
AccessPolicy12=0
AccessPolicy13=0
AccessPolicy14=0
AccessPolicy15=0
AccessPolicy2=0
AccessPolicy3=0
AccessPolicy4=0
AccessPolicy5=0
AccessPolicy6=0
AccessPolicy7=0
AccessPolicy8=0
AccessPolicy9=0
AckPolicy=0;0;0;0
APACM=0;0;0;0
APAifsn=3;7;1;1
ApCliAuthMode=
ApCliBssid=
ApCliDefaultKeyID=
ApCliEnable=0
ApCliEncrypType=
ApCliKey1Str=
ApCliKey1Str1=
ApCliKey1Type=
ApCliKey2Str=
ApCliKey2Str1=
ApCliKey2Type=
ApCliKey3Str=
ApCliKey3Str1=
ApCliKey3Type=
ApCliKey4Str=
ApCliKey4Str1=
ApCliKey4Type=
ApCliSsid=
ApCliWirelessMode=
ApCliWPAPSK=
ApCliWPAPSK1=
ApCliMuOfdmaDlEnable=0
ApCliMuOfdmaUlEnable=0
ApCliMuMimoDlEnable=0
ApCliMuMimoUlEnable=0
APCwmax=6;10;4;3
APCwmin=4;4;3;2
APSDCapable=1
APTxop=0;0;94;47
AuthMode=OPEN
AutoChannelSelect=0
AutoChannelSkipList=52;56;60;64;
AutoProvisionEn=0
BandSteering=0
BasicRate=15
BeaconPeriod=100
BFBACKOFFenable=0
BgndScanSkipCh=
BGProtection=0
BndStrgBssIdx=
BSSACM=0;0;0;0
BSSAifsn=3;7;2;2
BSSCwmax=10;10;4;3
BSSCwmin=4;4;3;2
BssidNum=1
BSSTxop=0;0;94;47
BW_Enable=0
BW_Guarantee_Rate=
BW_Maximum_Rate=
BW_Priority=
BW_Root=0
CalCacheApply=0
CarrierDetect=0
Channel=36
ChannelGrp=
CountryCode=CN
CountryRegion=5
CountryRegionABand=9
CP_SUPPORT=2
CSPeriod=6
DBDC_MODE=1
DebugFlags=0
DefaultKeyID=1
DfsCalibration=0
DfsEnable=0
DfsFalseAlarmPrevent=1
DfsZeroWait=0
DfsZeroWaitCacTime=255
DfsDedicatedZeroWait=0
DfsZeroWaitDefault=0
DisableOLBC=0
DtimPeriod=1
E2pAccessMode=2
EAPifname=br-lan
EDCCAEnable=1
EncrypType=NONE
EthConvertMode=dongle
EtherTrafficBand=0
Ethifname=
ETxBfEnCond=1
FineAGC=0
FixedTxMode=
ForceRoamSupport=
FragThreshold=2346
FreqDelta=0
FtSupport=0
GreenAP=0
G_BAND_256QAM=1
HideSSID=0
HT_AMSDU=1
AMSDU_NUM=8
HT_AutoBA=1
HT_BADecline=0
HT_BAWinSize=256
HT_BSSCoexistence=1
HT_BW=1
HT_DisallowTKIP=1
HT_EXTCHA=1
HT_GI=1
HT_HTC=1
HT_LDPC=1
HT_LinkAdapt=0
HT_MCS=33
HT_MpduDensity=4
HT_OpMode=0
HT_PROTECT=1
HT_RDG=0
HT_RxStream=2
HT_STBC=1
HT_TxStream=2
IcapMode=0
idle_timeout_interval=0
IEEE80211H=1
IEEE8021X=0
IgmpSnEnable=1
ITxBfEn=0
Key1Str=
Key1Str1=
Key1Str10=
Key1Str11=
Key1Str12=
Key1Str13=
Key1Str14=
Key1Str15=
Key1Str16=
Key1Str2=
Key1Str3=
Key1Str4=
Key1Str5=
Key1Str6=
Key1Str7=
Key1Str8=
Key1Str9=
Key1Type=0
Key2Str=
Key2Str1=
Key2Str10=
Key2Str11=
Key2Str12=
Key2Str13=
Key2Str14=
Key2Str15=
Key2Str16=
Key2Str2=
Key2Str3=
Key2Str4=
Key2Str5=
Key2Str6=
Key2Str7=
Key2Str8=
Key2Str9=
Key2Type=0
Key3Str=
Key3Str1=
Key3Str10=
Key3Str11=
Key3Str12=
Key3Str13=
Key3Str14=
Key3Str15=
Key3Str16=
Key3Str2=
Key3Str3=
Key3Str4=
Key3Str5=
Key3Str6=
Key3Str7=
Key3Str8=
Key3Str9=
Key3Type=0
Key4Str=
Key4Str1=
Key4Str10=
Key4Str11=
Key4Str12=
Key4Str13=
Key4Str14=
Key4Str15=
Key4Str16=
Key4Str2=
Key4Str3=
Key4Str4=
Key4Str5=
Key4Str6=
Key4Str7=
Key4Str8=
Key4Str9=
Key4Type=0
LinkTestSupport=0
MACRepeaterEn=
MACRepeaterOuiMode=2
MeshAuthMode=
MeshAutoLink=0
MeshDefaultkey=0
MeshEncrypType=
MeshId=
MeshWEPKEY=
MeshWPAKEY=
MUTxRxEnable=1
NoForwarding=0
NoForwardingBTNBSSID=0
own_ip_addr=192.168.1.1
PcieAspm=0
PERCENTAGEenable=0
PhyRateLimit=0
PMFMFPC=0
PMFMFPR=0
PMFSHA256=0
PMKCachePeriod=10
PowerUpCckOfdm=0:0:0:0:0:0:0
PowerUpHT20=0:0:0:0:0:0:0
PowerUpHT40=0:0:0:0:0:0:0
PowerUpVHT160=0:0:0:0:0:0:0
PowerUpVHT20=0:0:0:0:0:0:0
PowerUpVHT40=0:0:0:0:0:0:0
PowerUpVHT80=0:0:0:0:0:0:0
PreAntSwitch=
PreAuth=0
PreAuthifname=br-lan
RadioLinkSelection=0
RadioOn=1
RADIUS_Acct_Key=
RADIUS_Acct_Port=1813
RADIUS_Acct_Server=
RADIUS_Key1=
RADIUS_Key10=
RADIUS_Key11=
RADIUS_Key12=
RADIUS_Key13=
RADIUS_Key14=
RADIUS_Key15=
RADIUS_Key16=
RADIUS_Key2=
RADIUS_Key3=
RADIUS_Key4=
RADIUS_Key5=
RADIUS_Key6=
RADIUS_Key7=
RADIUS_Key8=
RADIUS_Key9=
RADIUS_Port=1812
RADIUS_Server=0
RDRegion=
RED_Enable=1
RekeyInterval=3600
RekeyMethod=DISABLE
RRMEnable=1
RTSThreshold=2347
session_timeout_interval=0
ShortSlot=1
SkuTableIdx=0
SKUenable=0
SREnable=1
SRMode=0
SRDPDEnable=0
SRSDEnable=1
PPEnable=1
SSID=
SSID1=MTK_CHEETAH_AP_5G
SSID10=
SSID11=
SSID12=
SSID13=
SSID14=
SSID15=
SSID16=
SSID2=
SSID3=
SSID4=
SSID5=
SSID6=
SSID7=
SSID8=
SSID9=
StationKeepAlive=0
StreamMode=0
StreamModeMac0=
StreamModeMac1=
StreamModeMac2=
StreamModeMac3=
TGnWifiTest=0
ThermalRecal=0
CCKTxStream=4
TWTSupport=0
TxBurst=1
TxPower=100
TxPreamble=1
VHT_BW=2
VHT_BW_SIGNAL=0
VHT_LDPC=1
VHT_Sec80_Channel=0
VHT_SGI=1
VHT_STBC=1
Vht1024QamSupport=1
VLANID=0
VLANPriority=0
VLANTag=0
VOW_Airtime_Ctrl_En=
VOW_Airtime_Fairness_En=1
VOW_BW_Ctrl=0
VOW_Group_Backlog=
VOW_Group_DWRR_Max_Wait_Time=
VOW_Group_DWRR_Quantum=
VOW_Group_Max_Airtime_Bucket_Size=
VOW_Group_Max_Rate=
VOW_Group_Max_Rate_Bucket_Size=
VOW_Group_Max_Ratio=
VOW_Group_Max_Wait_Time=
VOW_Group_Min_Airtime_Bucket_Size=
VOW_Group_Min_Rate=
VOW_Group_Min_Rate_Bucket_Size=
VOW_Group_Min_Ratio=
VOW_Rate_Ctrl_En=
VOW_Refill_Period=
VOW_RX_En=1
VOW_Sta_BE_DWRR_Quantum=
VOW_Sta_BK_DWRR_Quantum=
VOW_Sta_DWRR_Max_Wait_Time=
VOW_Sta_VI_DWRR_Quantum=
VOW_Sta_VO_DWRR_Quantum=
VOW_WATF_Enable=
VOW_WATF_MAC_LV0=
VOW_WATF_MAC_LV1=
VOW_WATF_MAC_LV2=
VOW_WATF_MAC_LV3=
VOW_WATF_Q_LV0=
VOW_WATF_Q_LV1=
VOW_WATF_Q_LV2=
VOW_WATF_Q_LV3=
VOW_WMM_Search_Rule_Band0=
VOW_WMM_Search_Rule_Band1=
WapiAsCertPath=
WapiAsIpAddr=
WapiAsPort=
Wapiifname=
WapiPsk1=
WapiPsk10=
WapiPsk11=
WapiPsk12=
WapiPsk13=
WapiPsk14=
WapiPsk15=
WapiPsk16=
WapiPsk2=
WapiPsk3=
WapiPsk4=
WapiPsk5=
WapiPsk6=
WapiPsk7=
WapiPsk8=
WapiPsk9=
WapiPskType=
WapiUserCertPath=
WCNTest=0
Wds0Key=
Wds1Key=
Wds2Key=
Wds3Key=
WdsEnable=0
WdsEncrypType=NONE
WdsList=
WdsPhyMode=0
WHNAT=1
WiFiTest=0
WirelessMode=17
WmmCapable=1
WPAPSK=
WPAPSK1=12345678
WPAPSK10=
WPAPSK11=
WPAPSK12=
WPAPSK13=
WPAPSK14=
WPAPSK15=
WPAPSK16=
WPAPSK2=
WPAPSK3=
WPAPSK4=
WPAPSK5=
WPAPSK6=
WPAPSK7=
WPAPSK8=
WPAPSK9=
WscConfMode=0
WscConfStatus=2
TxCmdMode=1
MuOfdmaDlEnable=1
MuOfdmaUlEnable=1
MuMimoDlEnable=1
MuMimoUlEnable=1
MapMode=0
IsICAPFW=0
BSSColorValue=255
MboSupport=1
QoSR1Enable=1
DscpPriMapEnable=1
ScsEnable=0
QoSMgmtCapa=0
BcnProt=0
ApCliBcnProt=0

View File

@ -38,3 +38,21 @@ define KernelPackage/sdhci-mtk
endef
$(eval $(call KernelPackage,sdhci-mtk))
define KernelPackage/mediatek_hnat
SUBMENU:=Network Devices
TITLE:=Mediatek HNAT module
DEPENDS:=@TARGET_mediatek +kmod-nf-conntrack
KCONFIG:= \
CONFIG_BRIDGE_NETFILTER=y \
CONFIG_NETFILTER_FAMILY_BRIDGE=y \
CONFIG_NET_MEDIATEK_HNAT
FILES:= \
$(LINUX_DIR)/drivers/net/ethernet/mediatek/mtk_hnat/mtkhnat.ko
endef
define KernelPackage/mediatek_hnat/description
Kernel modules for MediaTek HW NAT offloading
endef
$(eval $(call KernelPackage,mediatek_hnat))