@quarky I find something interesting....

static struct nss_platform_data nss0_pdata = {
	.num_irq		= 2,
	.irq[0]			= NSS_UBI32_CORE0_IRQ_0,
	.irq[1]			= NSS_UBI32_CORE0_IRQ_1,
	.nmap			= (uint32_t)MSM_UBI32_0_CSM_BASE,
	.vmap			= (uint32_t)MSM_NSS_TCM_BASE,
	.nphys			= IPQ806X_UBI32_0_CSM_PHYS,
	.vphys			= IPQ806X_NSS_TCM_PHYS,
	.rst_addr		= 0x40000000,
	.load_addr		= NSS_CORE0_LOAD_ADDR,
	.turbo_frequency	= NSS_FEATURE_NOT_ENABLED,
	.ipv4_enabled		= NSS_FEATURE_ENABLED,
	.ipv4_reasm_enabled	= NSS_FEATURE_ENABLED,
	.ipv6_enabled		= NSS_FEATURE_ENABLED,
	.ipv6_reasm_enabled	= NSS_FEATURE_ENABLED,
	.l2switch_enabled	= NSS_FEATURE_ENABLED,
	.crypto_enabled		= NSS_FEATURE_NOT_ENABLED,
	.ipsec_enabled		= NSS_FEATURE_NOT_ENABLED,
	.wlanredirect_enabled	= NSS_FEATURE_ENABLED,
	.tun6rd_enabled		= NSS_FEATURE_ENABLED,
	.l2tpv2_enabled		= NSS_FEATURE_ENABLED,
	.tunipip6_enabled	= NSS_FEATURE_ENABLED,
	.gre_redir_enabled	= NSS_FEATURE_ENABLED,
	.shaping_enabled	= NSS_FEATURE_ENABLED,
	.gmac_enabled[0]	= NSS_FEATURE_ENABLED,
	.gmac_enabled[1]	= NSS_FEATURE_ENABLED,
	.gmac_enabled[2]	= NSS_FEATURE_ENABLED,
	.gmac_enabled[3]	= NSS_FEATURE_ENABLED,
	.wifioffload_enabled	= NSS_FEATURE_ENABLED,
};

struct platform_device ipq806x_device_nss0 = {
	.name	= "qca-nss",
	.id	= 0,
	.dev	= {
		.platform_data = &nss0_pdata,
	},
};

static int __init parse_qca_nss_load0(char *p)
{
	nss0_pdata.load_addr = memparse(p, NULL);
	return 0;
}
early_param("qca-nss-drv.load0", parse_qca_nss_load0);

static struct nss_platform_data nss1_pdata = {
	.num_irq		= 2,
	.irq[0]			= NSS_UBI32_CORE1_IRQ_0,
	.irq[1]			= NSS_UBI32_CORE1_IRQ_1,
	.nmap			= (uint32_t)MSM_UBI32_1_CSM_BASE,
	.vmap			= (uint32_t)(MSM_NSS_TCM_BASE + SZ_64K),
	.vphys			= IPQ806X_NSS_TCM_PHYS + SZ_64K,
	.nphys			= IPQ806X_UBI32_1_CSM_PHYS,
	.rst_addr		= 0x40800000,
	.load_addr		= NSS_CORE1_LOAD_ADDR,
	.turbo_frequency	= NSS_FEATURE_NOT_ENABLED,
	.ipv4_enabled		= NSS_FEATURE_NOT_ENABLED,
	.ipv4_reasm_enabled	= NSS_FEATURE_NOT_ENABLED,
	.ipv6_enabled		= NSS_FEATURE_NOT_ENABLED,
	.ipv6_reasm_enabled	= NSS_FEATURE_NOT_ENABLED,
	.l2switch_enabled	= NSS_FEATURE_NOT_ENABLED,
	.crypto_enabled		= NSS_FEATURE_ENABLED,
	.ipsec_enabled		= NSS_FEATURE_ENABLED,
	.wlanredirect_enabled	= NSS_FEATURE_NOT_ENABLED,
	.tun6rd_enabled		= NSS_FEATURE_NOT_ENABLED,
	.l2tpv2_enabled		= NSS_FEATURE_NOT_ENABLED,
	.tunipip6_enabled	= NSS_FEATURE_NOT_ENABLED,
	.gre_redir_enabled	= NSS_FEATURE_NOT_ENABLED,
	.shaping_enabled	= NSS_FEATURE_NOT_ENABLED,
	.gmac_enabled[0]	= NSS_FEATURE_NOT_ENABLED,
	.gmac_enabled[1]	= NSS_FEATURE_NOT_ENABLED,
	.gmac_enabled[2]	= NSS_FEATURE_NOT_ENABLED,
	.gmac_enabled[3]	= NSS_FEATURE_NOT_ENABLED,
	.wifioffload_enabled	= NSS_FEATURE_NOT_ENABLED,
};

This is from the r7800 gpl source... As we can see turbo frequency is disabled for both core and also only the second core is used for crypto operation...
Wonder if our platform doesn't support turbo at all (or they found that it does cause stability problem)

Also there is a low mid freq that is not used at all... (275000000)

static struct clk_freq_tbl clk_tbl_nss[] = {
	F_NSS_CORE(110000000, pll18, 0x0100fa, 0xfb0141, &pll18_rate[0]),	/* 110Mhz */
	F_NSS_CORE(275000000, pll18, 0x0100fd, 0xfe0141, &pll18_rate[0]),	/* 275Mhz */
	F_NSS_CORE(550000000, pll18, 0xff00ff, 0xff0001, &pll18_rate[0]),	/* 550Mhz */
	F_NSS_CORE(733000000, pll18, 0xff00ff, 0xff0001, &pll18_rate[1]),	/* 733Mhz */
	F_END
};

static struct clk_freq_tbl clk_tbl_nss_fast[] = {
	F_NSS_CORE(110000000, pll18, 0x0100fa, 0xfb0141, &pll18_rate[0]),	/* 110Mhz */
	F_NSS_CORE(275000000, pll18, 0x0100fd, 0xfe0141, &pll18_rate[0]),	/* 275Mhz */
	F_NSS_CORE(600000000, pll18, 0xff00ff, 0xff0001, &pll18_rate[3]),	/* 600Mhz */
	F_NSS_CORE(800000000, pll18, 0xff00ff, 0xff0001, &pll18_rate[2]),	/* 800Mhz */
	F_END
};
1 Like

R7800 GPL source is based on an ancient QSDK version, I mean its so old that it does not even use DTS for IPQ806x.

If QCA enabled the turbo frequency in their relevant reference board DTS then its supported, and second core was always for crypto only.

You can clearly see which functions certain core does in the DTS as well FW binary size.
NSS1 FW is much smaller than NSS0

still i can't find a reason why they would disable turbo support. Would be interesting to check if other gpl source also disables it.

Ok nope... my bad in another c file they enable it based on the SoC

if (cpu_is_ipq8062() || cpu_is_ipq8066()) {
		pdata->turbo_frequency = NSS_FEATURE_NOT_ENABLED;
	} else {
		pdata->turbo_frequency = NSS_FEATURE_ENABLED;
	}

Most likely because the version of the driver and FW was a really early version that did not support it properly.
I doubt that tens of revisions later it would still be enabled by default without actually working.
I mean, its easy to test simply turn turbo to 0 in DTS

Summary of the 600Mhz NSS test and my UDP removal patch.
The router works great. I was unable to suspend it or cause a crash (I tried very hard). I generated a lot of connections, load the network and the main CPU. Works perfectly :slight_smile:
Below are the statistics from my banner.


BusyBox v1.31.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r20-a406a9f2
 -----------------------------------------------------
 ----------------------------------------------------------------
 | Machine: Netgear Nighthawk X4S R7800, Name: OpenWrt          |
 | System uptime: 3d 03:07:39, Now: 2020-06-24 23:20:06         |
 | System load: 0.14, 0.25, 0.26                                |
 | RootFS: total: 59.7MB, used: 4.2MB, 7.0%, free: 55.5MB       |
 | Memory: total: 465.2MB, used: 167.4MB, 36.0%, free: 297.8MB  |
 | Swap: total: 64.0MB, used: 0B, 0.0%, free: 64.0MB            |
 | WAN: 192.168.178.10/24(eth0.2), gateway: 192.168.178.1       |
 | proto: dhcp, uptime: 3d 03:06:59, rx/tx: 861.7GB/182.8GB      |
 | dns: 192.168.178.1                                           |
 | LAN: 192.168.1.1/24(br-lan), dhcp: n/a, dhcp.leases: 6       |
 | WLAN: !DoM-5Ghz!(ap), ch: 100, conn: 2                       |
 | WLAN: !DoM!(ap), ch: 11, conn: 1                             |
 ----------------------------------------------------------------
root@OpenWrt:~# 

I am starting the test on 800Mhz NSS frequency.
I'll let you know.

1 Like

800 MHz should be stable. My R7800 seems stable so far, other that a self inflicted KP. Now testing it with one LAN and two WiFi clients, doing my normal daily Internet stuffs.

I think it depends on how you use the router. If I use the CPU for cryptography and for other tasks, the cache could be clogged and I had a crash. That's why the system was hanging from your sources. At the moment I'm testing for 800Mhz NSS - if I have failure I will write here.

@quarky
Hi
I found compile your "master-ipq806x-nss-qsdk11" is ok, but if you choise dnsmasq-full instead of dnsmasq ,it will shows following erros:

  CC [M]  net/netfilter/nf_conntrack_seqadj.o
  CC [M]  net/netfilter/nf_conntrack_proto_icmpv6.o
  CC [M]  net/netfilter/nf_conntrack_timeout.o
  CC [M]  net/netfilter/nf_conntrack_ecache.o
  LD [M]  net/netfilter/nf_conntrack.o
  CC [M]  net/netfilter/nf_conntrack_rtcache.o
  CC [M]  net/netfilter/nf_conntrack_netlink.o
net/netfilter/nf_conntrack_netlink.c:3505:15: error: variable 'ctnl_notifier' has initializer but incomplete type
 static struct nf_ct_event_notifier ctnl_notifier = {
               ^~~~~~~~~~~~~~~~~~~~
net/netfilter/nf_conntrack_netlink.c:3506:3: error: 'struct nf_ct_event_notifier' has no member named 'fcn'
  .fcn = ctnetlink_conntrack_event,
   ^~~
net/netfilter/nf_conntrack_netlink.c:3506:9: warning: excess elements in struct initializer
  .fcn = ctnetlink_conntrack_event,
         ^~~~~~~~~~~~~~~~~~~~~~~~~
net/netfilter/nf_conntrack_netlink.c:3506:9: note: (near initialization for 'ctnl_notifier')
net/netfilter/nf_conntrack_netlink.c: In function 'ctnetlink_net_init':
net/netfilter/nf_conntrack_netlink.c:3569:44: error: passing argument 2 of 'nf_conntrack_register_notifier' from incompatible pointer type [-Werror=incompatible-pointer-types]
  ret = nf_conntrack_register_notifier(net, &ctnl_notifier);
                                            ^~~~~~~~~~~~~~
In file included from ./include/net/netfilter/nf_conntrack_core.h:18,
                 from net/netfilter/nf_conntrack_netlink.c:38:
./include/net/netfilter/nf_conntrack_ecache.h:76:83: note: expected 'struct notifier_block *' but argument is of type 'struct nf_ct_event_notifier *'
 extern int nf_conntrack_register_notifier(struct net *net, struct notifier_block *nb);
                                                            ~~~~~~~~~~~~~~~~~~~~~~~^~
net/netfilter/nf_conntrack_netlink.c:3585:40: error: passing argument 2 of 'nf_conntrack_unregister_notifier' from incompatible pointer type [-Werror=incompatible-pointer-types]
  nf_conntrack_unregister_notifier(net, &ctnl_notifier);
                                        ^~~~~~~~~~~~~~
In file included from ./include/net/netfilter/nf_conntrack_core.h:18,
                 from net/netfilter/nf_conntrack_netlink.c:38:
./include/net/netfilter/nf_conntrack_ecache.h:77:85: note: expected 'struct notifier_block *' but argument is of type 'struct nf_ct_event_notifier *'
 extern int nf_conntrack_unregister_notifier(struct net *net, struct notifier_block *nb);
                                                              ~~~~~~~~~~~~~~~~~~~~~~~^~
net/netfilter/nf_conntrack_netlink.c: In function 'ctnetlink_net_exit':
net/netfilter/nf_conntrack_netlink.c:3595:40: error: passing argument 2 of 'nf_conntrack_unregister_notifier' from incompatible pointer type [-Werror=incompatible-pointer-types]
  nf_conntrack_unregister_notifier(net, &ctnl_notifier);
                                        ^~~~~~~~~~~~~~
In file included from ./include/net/netfilter/nf_conntrack_core.h:18,
                 from net/netfilter/nf_conntrack_netlink.c:38:
./include/net/netfilter/nf_conntrack_ecache.h:77:85: note: expected 'struct notifier_block *' but argument is of type 'struct nf_ct_event_notifier *'
 extern int nf_conntrack_unregister_notifier(struct net *net, struct notifier_block *nb);
                                                              ~~~~~~~~~~~~~~~~~~~~~~~^~
net/netfilter/nf_conntrack_netlink.c: At top level:
net/netfilter/nf_conntrack_netlink.c:3505:36: error: storage size of 'ctnl_notifier' isn't known
 static struct nf_ct_event_notifier ctnl_notifier = {
                                    ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:265: recipe for target 'net/netfilter/nf_conntrack_netlink.o' failed
make[6]: *** [net/netfilter/nf_conntrack_netlink.o] Error 1
scripts/Makefile.build:500: recipe for target 'net/netfilter' failed
make[5]: *** [net/netfilter] Error 2
Makefile:1707: recipe for target 'net' failed
make[4]: *** [net] Error 2
make[4]: Leaving directory '/media/jack/128G/sam2/mastershortcut/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/linux-ipq806x_generic/linux-5.4.48'
Makefile:26: recipe for target '/media/jack/128G/sam2/mastershortcut/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/linux-ipq806x_generic/linux-5.4.48/.modules' failed
make[3]: *** [/media/jack/128G/sam2/mastershortcut/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/linux-ipq806x_generic/linux-5.4.48/.modules] Error 2
make[3]: Leaving directory '/media/jack/128G/sam2/mastershortcut/target/linux/ipq806x'
Makefile:13: recipe for target 'compile' failed
make[2]: *** [compile] Error 2
make[2]: Leaving directory '/media/jack/128G/sam2/mastershortcut/target/linux'
time: target/linux/compile#268.70#34.69#296.46
target/Makefile:23: recipe for target 'target/linux/compile' failed
make[1]: *** [target/linux/compile] Error 2
make[1]: Leaving directory '/media/jack/128G/sam2/mastershortcut'
/media/jack/128G/sam2/mastershortcut/include/toplevel.mk:222: recipe for target 'target/linux/compile' failed
make: *** [target/linux/compile] Error 2

I need ipset function so I selected dnsmasq-full ,it will automatically select kmod-nf-conntrack**
then it will not be compiled


Please help
thanks

@jack338c another forum member reported the same problem to me earlier. I'd just pushed a fix. Please pull latest source and see if that solves your problem.

I got it
Thank you

If you compile qca-nss-ecm and qca-rfs, you'll hit error as well. I've just pushed fixes for both.

ok,thanks for your mention :handshake:

@quarky
Did I select the right packages for master-ipq806x-nss-qsdk11?
Please help me correct it if I made wrong selection

CONFIG_PACKAGE_kmod-qca-nss-cfi-cryptoapi=y
CONFIG_PACKAGE_kmod-qca-nss-crypto=y
CONFIG_PACKAGE_kmod-qca-nss-drv=y
CONFIG_PACKAGE_kmod-qca-nss-drv-capwapmgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-clmapmgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-dtlsmgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-eogremgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-gre=y
CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2=y
CONFIG_PACKAGE_kmod-qca-nss-drv-lag-mgr=y
CONFIG_PACKAGE_kmod-qca-nss-drv-map-t=y
CONFIG_PACKAGE_kmod-qca-nss-drv-match=y
CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe=y
CONFIG_PACKAGE_kmod-qca-nss-drv-pptp=y
CONFIG_PACKAGE_kmod-qca-nss-drv-profile=y
CONFIG_PACKAGE_kmod-qca-nss-drv-pvxlanmgr=y
# CONFIG_PACKAGE_kmod-qca-nss-drv-qdisc is not set
CONFIG_PACKAGE_kmod-qca-nss-drv-tun6rd=y
CONFIG_PACKAGE_kmod-qca-nss-drv-tunipip6=y
CONFIG_PACKAGE_kmod-qca-nss-drv-vxlanmgr=y
# CONFIG_PACKAGE_kmod-qca-nss-ecm-noload is not set
CONFIG_PACKAGE_kmod-qca-nss-ecm-premium=y
# CONFIG_PACKAGE_kmod-qca-nss-ecm-premium-noload is not set
CONFIG_PACKAGE_kmod-qca-nss-ecm-standard=y
CONFIG_PACKAGE_kmod-qca-nss-gmac=y
CONFIG_PACKAGE_kmod-qca-rfs=y
CONFIG_PACKAGE_kmod-qca-ssdk-hnat=y
CONFIG_PACKAGE_kmod-qca-ssdk-nohnat=y

@quarky wow you split a lot of the nss-drv good work

1 Like

You all put in tremendous effort, I don't know about anyone else, but I know I'm very grateful for the time and energy you put into the cause.

@quarky, @ansuel, @robimarko: thank you all for the fabulous work. I've been tracking this thread for a while and today decided to join the bandwagon and test your work in my R7800. I'm using @ansuel qsdk10 repo as a base and these are my first remarks so far:

  • Right off the bat, router rebooted twice after some 30 minutes testing with essentially some downloads and web browsing. Could not identify any cause-effect event for such reboots.

  • After that, I locked nss frequency at 600 MHz, in line with @sqter approach. Router has been stable for 8 hours now.

  • Internet browsing is now more responsive and speed test hit 400 mbps whereas before I was hitting 340 mpbs tops (on a 300/150 mbps link - yeah, my ISP is a bit complacent...).

  • Oddly enough, I can't access any other devices in my internal lan if connection is via wifi. I have a few wifi security cameras that cannot be accessed for example. By the way, I tested for this problem by including and excluding the mac80211 nss support patch, and in both cases the problem remains. I was able to connect to other local wired devices when I connected my laptop to the router via ethernet cable though. There seems to be some firewall forward rule in place that is preventing wifi connections in the local lan, but I did not dig deeper into it.

  • I'll check now for stability until tomorrow and report back. Unfortunately, with the wifi problem above, I won't be able to test for too long as I'll need my local network fully operational before long.

If you guys want me to run other tests, please let me know.

Cheers for the good work.

try to disable ap_isolation, i have the same problem when devices connected to the same wifi dev

I did not change any settings when I upgraded to the nss version so there should be no impact as a result of that. Anyway, I'll try that option and will let you know. Thanks for the tip.

This has been an issue since lede-17.01 apparently. Even though there's no configuration to turn on AP isolation, when hostapd runs, somehow the ap_isolate setting is turned on. So this cause all WiFi clients associated on the same AP WiFi interface to be blocked from each other. You can access WiFi clients on the other interfaces tho, e.g. 2G clients and communicate with 5G clients.

You would have to change the netifd scripts to force the ap_isolate settings to '0' if you need WiFi clients to talk to each other on the same AP WiFi interface.

1 Like

I hope this change will make the NSS drivers more compatible with other components that requires conntrack notifications. I guess the QCA folks noticed the limitation of current implementation where there's only one notifier allowed for conntrack events, so they switched to a chained event model. Unfortunately doing so broke other modules that also requires conntrack events notification.

My changes should play nice with existing implementation but will still allow all the QCA NSS stuffs to work.

Hopefully this will make it easier for this to be accepted into OpenWrt, if ever.

1 Like