[Tutorial/Call for Testing] Enabling Receive Side Scaling on OPNsense

Started by tuto2, August 16, 2021, 02:13:24 PM

Previous topic - Next topic
Hi,

I am using HP T740 (AMD Ryzen Embedded V1756B with Radeon Vega Gfx (4 cores, 8 threads)) with Intel X710 NIC.  I enabled rss.   In the netstat -Q ouput, the QDrops for IP6 are increasing slowly.   I already tried to increase net.isr.defaultqlimit from 2048 to 8192.  That still did not increase the QLimits for IP6.   

Find the tunables to adjust them,

net.inet.ip.intr_queue_maxlen
net.inet6.ip6.intr_queue_maxlen



root@opnsense:/home/root # netstat -Q
Configuration:
Setting                        Current        Limit
Thread count                         8            8
Default queue limit               8192        10240
Dispatch policy                 direct          n/a
Threads bound to CPUs          enabled          n/a

Protocols:
Name   Proto QLimit Policy Dispatch Flags
ip         1   3000    cpu   hybrid   C--
igmp       2   8192 source  default   ---
rtsock     3   8192 source  default   ---
arp        4   8192 source  default   ---
ether      5   8192    cpu   direct   C--
ip6        6   1000    cpu   hybrid   C--
ip_direct     9   8192    cpu   hybrid   C--
ip6_direct    10   8192    cpu   hybrid   C--

Workstreams:
WSID CPU   Name     Len WMark   Disp'd  HDisp'd   QDrops   Queued  Handled
   0   0   ip         0    12        0      499        0     3039     3538
   0   0   igmp       0     0        0        0        0        0        0
   0   0   rtsock     0     0        0        0        0        0        0
   0   0   arp        0     0      501        0        0        0      501
   0   0   ether      0     0  2271227        0        0        0  2271227
   0   0   ip6        0  1000        0    93596      202  1083995  1177591
   0   0   ip_direct     0     0        0        0        0        0        0
   0   0   ip6_direct     0     0        0        0        0        0        0
   1   1   ip         0    10        0      375        0     5571     5946
   1   1   igmp       0     0        2        0        0        0        2
   1   1   rtsock     0     0        0        0        0        0        0
   1   1   arp        0     0        0        0        0        0        0
   1   1   ether      0     0   865820        0        0        0   865820
   1   1   ip6        0  1000        0     1071      517  1508206  1509277
   1   1   ip_direct     0     0        0        0        0        0        0
   1   1   ip6_direct     0     0        0        0        0        0        0
   2   2   ip         0     7        0      425        0     1902     2327
   2   2   igmp       0     0        0        0        0        0        0
   2   2   rtsock     0     0        0        0        0        0        0
   2   2   arp        0     0        0        0        0        0        0
   2   2   ether      0     0  3891441        0        0        0  3891441
   2   2   ip6        0  1000        0    89837      154   786449   876286
   2   2   ip_direct     0     0        0        0        0        0        0
   2   2   ip6_direct     0     0        0        0        0        0        0
   3   3   ip         0    49        0      117        0    30043    30160
   3   3   igmp       0     0        1        0        0        0        1
   3   3   rtsock     0     0        0        0        0        0        0
   3   3   arp        0     0        0        0        0        0        0
   3   3   ether      0     0  2731942        0        0        0  2731942
   3   3   ip6        0  1000        0      570      160   355308   355878
   3   3   ip_direct     0     0        0        0        0        0        0
   3   3   ip6_direct     0     0        0        0        0        0        0
   4   4   ip         0    10        0      273        0     1897     2170
   4   4   igmp       0     0        0        0        0        0        0
   4   4   rtsock     0     2        0        0        0      115      115
   4   4   arp        0     0        0        0        0        0        0
   4   4   ether      0     0   597119        0        0        0   597119
   4   4   ip6        0  1000        0    66457     1360   988018  1054475
   4   4   ip_direct     0     0        0        0        0        0        0
   4   4   ip6_direct     0     0        0        0        0        0        0
   5   5   ip         0    33        0      671        0     6113     6784
   5   5   igmp       0     0        3        0        0        0        3
   5   5   rtsock     0     0        0        0        0        0        0
   5   5   arp        0     0        0        0        0        0        0
   5   5   ether      0     0   626430        0        0        0   626430
   5   5   ip6        0  1000        0     1430     1226  1361493  1362923
   5   5   ip_direct     0     0        0        0        0        0        0
   5   5   ip6_direct     0     0        0        0        0        0        0
   6   6   ip         0    59        0      331        0     4234     4565
   6   6   igmp       0     0        0        0        0        0        0
   6   6   rtsock     0     0        0        0        0        0        0
   6   6   arp        0     0        0        0        0        0        0
   6   6   ether      0     0   725274        0        0        0   725274
   6   6   ip6        0  1000        0    94895     3162  1398256  1493151
   6   6   ip_direct     0     0        0        0        0        0        0
   6   6   ip6_direct     0     0        0        0        0        0        0
   7   7   ip         0    25        0      644        0     8798     9442
   7   7   igmp       0     0        0        0        0        0        0
   7   7   rtsock     0     0        0        0        0        0        0
   7   7   arp        0     0        0        0        0        0        0
   7   7   ether      0     0   445253        0        0        0   445253
   7   7   ip6        0   936        0      236        0   909138   909374
   7   7   ip_direct     0     0        0        0        0        0        0
   7   7   ip6_direct     0     0        0        0        0        0        0
root@opnsense:/home/root # sysctl -a | grep isr
net.route.netisr_maxqlen: 8192
net.isr.numthreads: 8
net.isr.maxprot: 16
net.isr.defaultqlimit: 8192
net.isr.maxqlimit: 10240
net.isr.bindthreads: 1
net.isr.maxthreads: 8
net.isr.dispatch: direct




We tested RSS on a slow PC Engines APU2 device in combination with an IPsec Site to Site VPN.
With enabled RSS, there are some issues with unbound receiving DNS packets through the VPN tunnel:
- unbound has a DNS override for a specific domain, the IP of the authorative server for that override is set to an IP inside the IPsec P2 remote network.
- The outgoing network interface in unbound is set to the interface, the IPsec P2 local network resides in.

With a packet capture we can see the DNS answer packets arriving at the IPsec P2 local network, but unbound does not see them.

With disabled RSS this setup is working without any issues.

Anyone with numbers? I haven't seen performance difference. I actually tried every possible tuning value for igc NI:C, incl.RSS and there was no difference. RSS caused more dropped packets. The only setting that was slightly impactful was Interface\Disable * and Firewall\Optimization.

Finally had some time to play with it
Setup:
OPNsense 24.1.2_1-amd64
Intel Xeon D-2733NT
32 Gb Ram
I was testing only my 2 25Gb/s ports so far, NIC are "ICE" and they are based on intel e823-c

Ubuntu VM with PCI-e pass through of mellanox connectx-4 25Gb ->ice0 /Opnsense\ ice1-> Windows 11 with mellanox conenctx-4 25Gb
MTU 1500

Performance numbers based on iperf3

Performance Before:
With Zenaromor: 2.7Gb/s (2 cores loaded to max)
Without Zenarmor: 5Gb/s (1 core loaded to max)
Without Zenarmor few streams (different ports): 7Gb/s (1 core loaded to max)

Performance after:
With Zenaromor: 3.9Gb/s (3 cores loaded to 70-80%)
Without Zenarmor: 5.2Gb/s (1 core loaded to ~80%)
Without Zenarmor few streams (different ports): 8Gb/s (1 core loaded to max)

It definitely helped with zenarmor but I expected better performance without zenarmor

root@opr01:~ # netstat -Q
Configuration:
Setting                        Current        Limit
Thread count                        16           16
Default queue limit                256        10240
Dispatch policy                 hybrid          n/a
Threads bound to CPUs          enabled          n/a

Protocols:
Name   Proto QLimit Policy Dispatch Flags
ip         1   1000    cpu   hybrid   C--
igmp       2    256 source  default   ---
rtsock     3    256 source  default   ---
arp        4    256 source  default   ---
ether      5    256    cpu   direct   C--
ip6        6   1000    cpu   hybrid   C--
ip_direct     9    256    cpu   hybrid   C--
ip6_direct    10    256    cpu   hybrid   C--

Workstreams:
WSID CPU   Name     Len WMark   Disp'd  HDisp'd   QDrops   Queued  Handled
   0   0   ip         0   481        0  4292176        0 25295849 29588025
   0   0   igmp       0     0        0        0        0        0        0
   0   0   rtsock     0     0        0        0        0        0        0
   0   0   arp        0     1        0        0        0       29       29
   0   0   ether      0     0 27531623        0        0        0 27531623
   0   0   ip6        0     3        0        0        0    13344    13344
   0   0   ip_direct     0     0        0        0        0        0        0
   0   0   ip6_direct     0     0        0        0        0        0        0
   1   1   ip         0    36        0        4        0  1070042  1070046
   1   1   igmp       0     0        0        0        0        0        0
   1   1   rtsock     0     0        0        0        0        0        0
   1   1   arp        0     1        0        0        0        8        8
   1   1   ether      0     0       14        0        0        0       14
   1   1   ip6        0     2        0        0        0     1125     1125
   1   1   ip_direct     0     0        0        0        0        0        0
   1   1   ip6_direct     0     0        0        0        0        0        0
   2   2   ip         0   200        0        1        0  9914864  9914865
   2   2   igmp       0     0        0        0        0        0        0
   2   2   rtsock     0     0        0        0        0        0        0
   2   2   arp        0     0        0        0        0        0        0
   2   2   ether      0     0   959020        0        0        0   959020
   2   2   ip6        0     2        0        0        0     1225     1225
   2   2   ip_direct     0     0        0        0        0        0        0
   2   2   ip6_direct     0     0        0        0        0        0        0
   3   3   ip         0     7        0        0        0   428639   428639
   3   3   igmp       0     0        0        0        0        0        0
   3   3   rtsock     0     0        0        0        0        0        0
   3   3   arp        0     1        0        0        0        7        7
   3   3   ether      0     0        0        0        0        0        0
   3   3   ip6        0     3        0        0        0     1117     1117
   3   3   ip_direct     0     0        0        0        0        0        0
   3   3   ip6_direct     0     0        0        0        0        0        0
   4   4   ip         0     8        0     5545        0    45152    50697
   4   4   igmp       0     0        0        0        0        0        0
   4   4   rtsock     0     0        0        0        0        0        0
   4   4   arp        0     0        0        0        0        0        0
   4   4   ether      0     0   389516        0        0        0   389516
   4   4   ip6        0     3        0        0        0     1152     1152
   4   4   ip_direct     0     0        0        0        0        0        0
   4   4   ip6_direct     0     0        0        0        0        0        0
   5   5   ip         0   136        0     2229        0    35988    38217
   5   5   igmp       0     0        0        0        0        0        0
   5   5   rtsock     0     0        0        0        0        0        0
   5   5   arp        0     1        0        0        0       27       27
   5   5   ether      0     0 12837078        0        0        0 12837078
   5   5   ip6        0     3        0        0        0     1155     1155
   5   5   ip_direct     0     0        0        0        0        0        0
   5   5   ip6_direct     0     0        0        0        0        0        0
   6   6   ip         0   165        0   133686        0  1893259  2026945
   6   6   igmp       0     0        0        0        0        0        0
   6   6   rtsock     0     0        0        0        0        0        0
   6   6   arp        0     0        0        0        0        0        0
   6   6   ether      0     0   379341        0        0        0   379341
   6   6   ip6        0     2        0        0        0     1175     1175
   6   6   ip_direct     0     0        0        0        0        0        0
   6   6   ip6_direct     0     0        0        0        0        0        0
   7   7   ip         0   448        0       29        0   224705   224734
   7   7   igmp       0     0        0        0        0        0        0
   7   7   rtsock     0     0        0        0        0        0        0
   7   7   arp        0     1        0        0        0       26       26
   7   7   ether      0     0      295        0        0        0      295
   7   7   ip6        0     2        0        0        0     1168     1168
   7   7   ip_direct     0     0        0        0        0        0        0
   7   7   ip6_direct     0     0        0        0        0        0        0
   8   8   ip         0     0        0        0        0        0        0
   8   8   igmp       0     0        0        0        0        0        0
   8   8   rtsock     0     0        0        0        0        0        0
   8   8   arp        0     1        0        0        0        4        4
   8   8   ether      0     0      469        0        0        0      469
   8   8   ip6        0     0        0        0        0        0        0
   8   8   ip_direct     0     0        0        0        0        0        0
   8   8   ip6_direct     0     0        0        0        0        0        0
   9   9   ip         0     0        0        0        0        0        0
   9   9   igmp       0     0        0        0        0        0        0
   9   9   rtsock     0     2        0        0        0      279      279
   9   9   arp        0     0        0        0        0        0        0
   9   9   ether      0     0      901        0        0        0      901
   9   9   ip6        0     0        0        0        0        0        0
   9   9   ip_direct     0     0        0        0        0        0        0
   9   9   ip6_direct     0     0        0        0        0        0        0
  10  10   ip         0     0        0        0        0        0        0
  10  10   igmp       0     0        0        0        0        0        0
  10  10   rtsock     0     0        0        0        0        0        0
  10  10   arp        0     0        0        0        0        0        0
  10  10   ether      0     0     5235        0        0        0     5235
  10  10   ip6        0     0        0        0        0        0        0
  10  10   ip_direct     0     0        0        0        0        0        0
  10  10   ip6_direct     0     0        0        0        0        0        0
  11  11   ip         0     0        0        0        0        0        0
  11  11   igmp       0     0        0        0        0        0        0
  11  11   rtsock     0     0        0        0        0        0        0
  11  11   arp        0     0        0        0        0        0        0
  11  11   ether      0     0        0        0        0        0        0
  11  11   ip6        0     0        0        0        0        0        0
  11  11   ip_direct     0     0        0        0        0        0        0
  11  11   ip6_direct     0     0        0        0        0        0        0
  12  12   ip         0     0        0        0        0        0        0
  12  12   igmp       0     0        0        0        0        0        0
  12  12   rtsock     0     0        0        0        0        0        0
  12  12   arp        0     0        0        0        0        0        0
  12  12   ether      0     0  1058473        0        0        0  1058473
  12  12   ip6        0     0        0        0        0        0        0
  12  12   ip_direct     0     0        0        0        0        0        0
  12  12   ip6_direct     0     0        0        0        0        0        0
  13  13   ip         0     0        0        0        0        0        0
  13  13   igmp       0     0        0        0        0        0        0
  13  13   rtsock     0     0        0        0        0        0        0
  13  13   arp        0     0        0        0        0        0        0
  13  13   ether      0     0        0        0        0        0        0
  13  13   ip6        0     0        0        0        0        0        0
  13  13   ip_direct     0     0        0        0        0        0        0
  13  13   ip6_direct     0     0        0        0        0        0        0
  14  14   ip         0     0        0        0        0        0        0
  14  14   igmp       0     0        0        0        0        0        0
  14  14   rtsock     0     0        0        0        0        0        0
  14  14   arp        0     1        0        0        0        8        8
  14  14   ether      0     0     5734        0        0        0     5734
  14  14   ip6        0     0        0        0        0        0        0
  14  14   ip_direct     0     0        0        0        0        0        0
  14  14   ip6_direct     0     0        0        0        0        0        0
  15  15   ip         0     0        0        0        0        0        0
  15  15   igmp       0     0        0        0        0        0        0
  15  15   rtsock     0     0        0        0        0        0        0
  15  15   arp        0     0        0        0        0        0        0
  15  15   ether      0     0        0        0        0        0        0
  15  15   ip6        0     0        0        0        0        0        0
  15  15   ip_direct     0     0        0        0        0        0        0
  15  15   ip6_direct     0     0        0        0        0        0        0

I have a somewhat similar setup with a Mellanox Connectx4-lx passed through from a proxmox host to opnsensense on an amd ryzen 7 7745hx system. I have the LAN interface attached to a 25Gb port on my switch but my LAN clients are only 10Gb. I'd be happy to run any iperf tests that may be helpful for you but my WAN link is only 2Gb/1Gb. Inter-vlan routing through the firewall does reach 9-10Gb with iperf3 without the need for jumbo frames.

One quick question for you. You seem to be the only result for someone with a connectx4 running zenarmor/netmap on freebsd/opnsense. This used to be completely impossible if older search results are to be believed due to netmap compatibility issues? I'm guessing netmap is functional on your machine with the connectx4? I have not tried it yet and was unaware of this potential issue.


@routetastic I think you misunderstood my post, I have mellanox cards in my desktop and one server, but the second server that is running opnsense doesn't have mellanox card in it, it has 2x25gb ports served by intel e823-c.
If we are talking performance, whats you cpu usage (and specific cores usage and how many cores are used) when you push 10gb?

Even tough this is an old topic for EoL Version I will post here for completion.

Tested on my current test setup:


N100
i226-V (igc)
ZenArmor with Native netmap driver
LAN 2x1G LAGG


netstat -Q
Configuration:
Setting                        Current        Limit
Thread count                         4            4
Default queue limit               2048        10240
Dispatch policy                 hybrid          n/a
Threads bound to CPUs          enabled          n/a

Protocols:
Name   Proto QLimit Policy Dispatch Flags
ip         1   1000    cpu   hybrid   C--
igmp       2   2048 source  default   ---
rtsock     3   2048 source  default   ---
arp        4   2048 source  default   ---
ether      5   2048    cpu   direct   C--
ip6        6   1000    cpu   hybrid   C--
ip_direct     9   2048    cpu   hybrid   C--
ip6_direct    10   2048    cpu   hybrid   C--



Tried RSS as well together with Zenarmor, and one observation.

In order for Zenarmor to perform better you need to click
Do not pin engine packet processors to dedicated CPU cores option

Regards,
S.
Networking is love. You may hate it, but in the end, you always come back to it.

OPNSense HW
APU2D2 - deceased
N5105 - i226-V | Patriot 2x8G 3200 DDR4 | L 790 512G - VM HA(SOON)
N100   - i226-V | Crucial 16G  4800 DDR5 | S 980 500G - PROD

Quote from: pata on February 10, 2022, 10:20:29 AM
Hi,

I'm shooting in the dark here. I activated RSS yesterday on my system with AMD Ryzen CPU. Since the multi-threading technology used by AMD is not the same as Intels hyper-threading should the net.inet.rss.bits be per core or per number of threads for AMD? If I understand it correctly AMD can write simultaneously to the core from the threads and are not limited like Intels hyper-threading?

Any expert out there who knows? Thanks!

I would also love to know the answer to this..

I just ran into this issue with nginx on 24.1 after enabling rss on a Xeon D-1747NTE. Then I upgraded to Opnsense 24.7 and tried it again. It works so far. Maybe they made some changes in FreeBSD 14.1

Can anybody else confirm this behaviour?

Quote from: jakkuh on June 27, 2023, 08:16:22 PM
Tried out the RSS feature for a few days on our OPNsense instance (23.1.9-amd64) and while the performance is great, we've run into some weird issues with internal system services not being able to resolve DNS requests. Disabling RSS seems to fix the issue. We are using the Intel ice driver with a 25GbE SOC based NIC. Machine in question: https://www.supermicro.com/en/products/system/iot/1u/sys-110d-20c-fran8tp

Specifically, pkg update and the GeoIP feature in the firewall cannot connect, and I tracked this down to a DNS issue. When running pkg update via CLI or the GUI it hangs on the fetching process, and when running it with debug you can see its stuck at the resolving DNS stage. The GeoIP feature has similar issues.

Interestingly, if you use ping from CLI or use the DNS diagnostic tool, the system resolves DNS requests totally fine. I enabled debug on Unbound and it doesn't appear to even receive the requests from pkg update or GeoIP downloads. Would love to get this fixed so we can use RSS since it handles our 10G symmetrical connection a lot better.

user@kappa:/usr/local/etc # pkg -ddddddd update
DBG(1)[34160]> pkg initialized
Updating OPNsense repository catalogue...
DBG(1)[34160]> PkgRepo: verifying update for OPNsense
DBG(1)[34160]> PkgRepo: need forced update of OPNsense
DBG(1)[34160]> Pkgrepo, begin update of '/var/db/pkg/repo-OPNsense.sqlite'
DBG(1)[34160]> Request to fetch pkg+https://pkg.opnsense.org/FreeBSD:13:amd64/23.1/latest/meta.conf
DBG(1)[34160]> opening libfetch fetcher
DBG(1)[34160]> Fetch > libfetch: connecting
DBG(1)[34160]> Fetch: fetching from: https://pkg.opnsense.org/FreeBSD:13:amd64/23.1/latest/meta.conf with opts "iv"
resolving server address: pkg.opnsense.org:443

^ hangs here for a while before retrying and effectively goes no where.