Skip to content

Commit

Permalink
rc: tQoS fixes from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
RMerl committed Jan 11, 2022
1 parent 74d4ea0 commit 0bc048f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
1 change: 0 additions & 1 deletion release/src/router/rc/Makefile
Expand Up @@ -206,7 +206,6 @@ endif
endif

ifeq ($(RTCONFIG_FBWIFI),y)
CFLAGS += -I$(TOP)/fb_wifi
LDFLAGS += -L$(TOP)/fb_wifi -lfbwifi
endif

Expand Down
47 changes: 20 additions & 27 deletions release/src/router/rc/qos.c
@@ -1,5 +1,5 @@
/*
* Copyright 2020, ASUSTeK Inc.
* Copyright 2022, ASUSTeK Inc.
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND ASUS GRANTS NO WARRANTIES OF ANY
Expand Down Expand Up @@ -27,9 +27,6 @@
#include "rc.h"
#include <arpa/inet.h>
#include <sys/socket.h>
#ifdef RTCONFIG_FBWIFI
#include <fbwifi.h>
#endif
#ifdef RTCONFIG_BWDPI
#include <bwdpi.h>
#endif
Expand Down Expand Up @@ -368,7 +365,7 @@ void del_EbtablesRules(void)

#ifdef CONFIG_BCMWL5 // TODO: it is only for the case, eth0 as wan, vlanx as lan

#ifdef RTCONFIG_FBWIFI
#if defined(RTCONFIG_FBWIFI)
static void set_fbwifi_mark(void)
{
int band, j, max_mssid;
Expand All @@ -381,12 +378,9 @@ static void set_fbwifi_mark(void)

snprintf(mark, sizeof(mark), "0x%x", FBWIFI_MARK_SET(1));
snprintf(inv_mask, sizeof(inv_mask), "0x%x", FBWIFI_MARK_INV_MASK);
for (band = 0; band < ARRAYSIZE(fbwifi_iface); ++band) {
#ifndef RTCONFIG_HAS_5G_2
/* Skip band 2, 5G-2, if DUT not support 2-nd 5G band. */
if (band == 2)
continue;
#endif

for (band = 0; band < min(MAX_NR_WL_IF, (sizeof(fbwifi_iface)/sizeof(fbwifi_iface[0]))); ++band) {
SKIP_ABSENT_BAND(band);

if (nvram_match(fbwifi_iface[band], "off"))
continue;
Expand All @@ -406,6 +400,8 @@ static void set_fbwifi_mark(void)
eval("ebtables", "-A", "INPUT", "-i", wl_if, "-j", "mark", "--mark-or", mark, "--mark-target", "ACCEPT");
}
}
#else
static inline void set_fbwifi_mark(void) { };
#endif

void add_EbtablesRules(void)
Expand All @@ -415,6 +411,7 @@ void add_EbtablesRules(void)
nv = g = strdup(nvram_safe_get("wl_ifnames"));
if(nv){
while ((p = strsep(&g, " ")) != NULL){
SKIP_ABSENT_FAKE_IFACE(p);
QOSLOG("p=%s", p);
eval("ebtables", "-t", "nat", "-A", "PREROUTING", "-i", p, "-j", "mark", "--mark-or", "6", "--mark-target", "ACCEPT");
eval("ebtables", "-t", "nat", "-A", "POSTROUTING", "-o", p, "-j", "mark", "--mark-or", "6", "--mark-target", "ACCEPT");
Expand All @@ -423,8 +420,8 @@ void add_EbtablesRules(void)
}

// for MultiSSID
int UnitNum = 2; // wl0.x, wl1.x
int GuestNum = 3; // wlx.0, wlx.1, wlx.2
int UnitNum = 2; // wl0.x, wl1.x
int GuestNum = MAX_NO_MSSID - 1; // wlx.0, wlx.1, wlx.2
char mssid_if[32];
char mssid_enable[32];
int i, j;
Expand Down Expand Up @@ -802,7 +799,7 @@ static int add_qos_rules(char *pcWANIF)
char *tmp_trans, *q_min, *q_max;
long min = 0, max =0;

snprintf(tmp, sizeof(tmp), "%s", transferred);
strlcpy(tmp, transferred, sizeof (tmp));
tmp_trans = tmp;
q_min = strsep(&tmp_trans, "~");
q_max = tmp_trans;
Expand All @@ -813,14 +810,14 @@ static int add_qos_rules(char *pcWANIF)
else{
min = atol(q_min);

if(strcmp(q_max,"") == 0) // q_max == NULL
if (strcmp(q_max,"") == 0) // q_max == NULL
snprintf(conn, sizeof(conn), "-m connbytes --connbytes %ld:%s --connbytes-dir both --connbytes-mode bytes", min*1024, q_max);
else{// q_max != NULL
max = atol(q_max);
snprintf(conn, sizeof(conn), "-m connbytes --connbytes %ld:%ld --connbytes-dir both --connbytes-mode bytes", min*1024, max*1024-1);
}
}
QOSLOG("[qos] tmp=%s, transferred=%s, min=%ld, max=%ld, q_max=%s, conn=%s", tmp, transferred, min*1024, max*1024-1, q_max, conn);
QOSLOG("[qos] transferred=%s, min=%ld, max=%ld, q_max=%s, conn=%s", transferred, min*1024, max*1024-1, q_max, conn);

/*************************************************/
/* proto */
Expand Down Expand Up @@ -1211,9 +1208,10 @@ static int start_tqos(void)
"# upload 1:60: LAN-to-LAN (vlan@%s)\n"
"\t$TCAUL parent 1:2 classid 1:60 htb rate 1000000kbit ceil 1000000kbit burst 10000 cburst 10000 prio 6\n"
"\t$TQAUL parent 1:60 handle 60: pfifo\n"
"\t$TFAUL parent 1: prio 6 protocol 802.1q u32 match u32 0 0 flowid 1:60\n",
"\t$TFAUL parent 1: prio 6 protocol 802.1q u32 match mark 6 0x%x flowid 1:60\n",

This comment has been minimized.

Copy link
@dave14305

dave14305 Apr 6, 2022

Contributor

Reverting this line restores the full download throughput in tQoS.

This comment has been minimized.

Copy link
@RMerl

RMerl Apr 6, 2022

Author Owner

This came from this specific PR commit:

3575e8d

Looks as if that change got reverted here for some reason.

wan_ifname,
wan_ifname
wan_ifname,
QOS_MASK
);
#endif

Expand All @@ -1238,15 +1236,10 @@ static int start_tqos(void)
else s[0] = 0;
x = (i + 1) * 10;

fprintf(f,
"# upload 1:%d: %u-%u%%\n"
"\t$TCAUL parent 1:1 classid 1:%d htb rate %ukbit %s %s prio %d quantum %u %s\n"
"\t$TQAUL parent 1:%d handle %d: $SCH\n"
"\t$TFAUL parent 1: prio %d u32 match mark %d 7 flowid 1:%d\n",
i, rate, ceil,
x, calc(bw, rate), s, burst_leaf, (i >= 6) ? 7 : (i + 1), mtu, overheadstr,
x, x,
x, i + 1, x);
fprintf(f, "# egress %d: %u-%u%%\n", i, rate, ceil);
fprintf(f, "\t$TCAUL parent 1:1 classid 1:%d htb rate %ukbit %s %s prio %d quantum %u %s\n", x, calc(bw, rate), s, burst_leaf, (i >= 6) ? 7 : (i + 1), mtu, overheadstr);
fprintf(f, "\t$TQAUL parent 1:%d handle %d: $SCH\n", x, x);
fprintf(f, "\t$TFAUL parent 1: prio %d u32 match mark %d 0x%x flowid 1:%d\n", x, i + 1, QOS_MASK, x);
}
free(buf);

Expand Down
39 changes: 23 additions & 16 deletions release/src/router/rc/qos_multiwan.c
@@ -1,31 +1,30 @@
/*
* Copyright 2020, ASUSTeK Inc.
* Copyright 2022, ASUSTeK Inc.
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND ASUS GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. ASUS
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
*
*/

/*
feature implement:
1. traditaional qos
2. bandwdith limiter (also for guest network)
3. facebook wifi (already EOL in the end of 2017)
4. GeForceNow qos
NOTE:
qos mark bit 8~31 : TrendMicro adaptive qos usage, so ASUS only can use bit 0~7 for different applications
ex. Traditional qos / bandwidth limiter / Facebook wifi
ex. Traditional qos / bandwidth limiter / Facebook wifi / GeForceNow QoS
*/

#include "rc.h"
#include <arpa/inet.h>
#include <sys/socket.h>
#ifdef RTCONFIG_FBWIFI
#include <fbwifi.h>
#endif
#include <sys/stat.h>
#ifdef RTCONFIG_BWDPI
#include <bwdpi.h>
#endif
Expand Down Expand Up @@ -344,6 +343,14 @@ static void address_format_checker(int *type, char *old, char *new, int len)
// mac format
g = buf = strdup(old);
if (sscanf(g, "%02X:%02X:%02X:%02X:%02X:%02X",&s[0],&s[1],&s[2],&s[3],&s[4],&s[5]) == 6) {
#ifdef RTCONFIG_AMAS
QOSLOG("address_format_checker");
if (amas_lib_device_ip_query(old, new)) {
*type = TYPE_IP;
QOSLOG("is_ip=%d, is_mac=%d, is_range=%d, type=%d, new=%s", is_ip, is_mac, is_range, *type, new);
return;
} else
#endif
is_mac = 1;
goto end;
}
Expand Down Expand Up @@ -414,7 +421,7 @@ static void set_fbwifi_mark(void)

snprintf(mark, sizeof(mark), "0x%x", FBWIFI_MARK_SET(1));
snprintf(inv_mask, sizeof(inv_mask), "0x%x", FBWIFI_MARK_INV_MASK);
for (band = 0; band < min(MAX_NR_WL_IF, ARRAYSIZE(fbwifi_iface)); ++band) {
for (band = 0; band < min(MAX_NR_WL_IF, (sizeof(fbwifi_iface)/sizeof(fbwifi_iface[0]))); ++band) {
SKIP_ABSENT_BAND(band);

if (nvram_match(fbwifi_iface[band], "off"))
Expand Down Expand Up @@ -455,7 +462,7 @@ void add_EbtablesRules(void)
}

// for MultiSSID
int UnitNum = 2; // wl0.x, wl1.x
int UnitNum = 2; // wl0.x, wl1.x
int GuestNum = MAX_NO_MSSID - 1; // wlx.0, wlx.1, wlx.2
char mssid_if[32];
char mssid_enable[32];
Expand All @@ -472,11 +479,11 @@ void add_EbtablesRules(void)
}
}

#ifdef RTCONFIG_FBWIFI
if(sw_mode() == SW_MODE_AP){
#ifdef RTCONFIG_FBWIFI
if(sw_mode() == SW_MODE_ROUTER){
set_fbwifi_mark();
}
#endif
#endif

etable_flag = 1;
}
Expand Down Expand Up @@ -849,14 +856,14 @@ static int add_qos_rules(char *pcWANIF)
else{
min = atol(q_min);

if(strcmp(q_max,"") == 0) // q_max == NULL
if (strcmp(q_max,"") == 0) // q_max == NULL
sprintf(conn, "-m connbytes --connbytes %ld:%s --connbytes-dir both --connbytes-mode bytes", min*1024, q_max);
else{// q_max != NULL
else {// q_max != NULL
max = atol(q_max);
sprintf(conn, "-m connbytes --connbytes %ld:%ld --connbytes-dir both --connbytes-mode bytes", min*1024, max*1024-1);
}
}
QOSLOG("[qos] tmp=%s, transferred=%s, min=%ld, max=%ld, q_max=%s, conn=%s", tmp, transferred, min*1024, max*1024-1, q_max, conn);
QOSLOG("[qos] transferred=%s, min=%ld, max=%ld, q_max=%s, conn=%s", transferred, min*1024, max*1024-1, q_max, conn);

/*************************************************/
/* proto */
Expand Down Expand Up @@ -2737,4 +2744,4 @@ int start_cake(void)

return 0;
}
#endif
#endif

0 comments on commit 0bc048f

Please sign in to comment.