diff options
author | jack9603301 <jack9603301@163.com> | 2022-09-13 16:03:49 +0800 |
---|---|---|
committer | jack9603301 <jack9603301@163.com> | 2022-09-15 16:09:11 +0800 |
commit | ac4e07f96ae329bab51c3da8596a2b975a0f3f17 (patch) | |
tree | 579ccb9a943306df74bd06ae3f7fc7c38029aab0 /python/vyos/ifconfig/ethernet.py | |
parent | d283048d3858e95b37df96f0a8acb5fc4223aa43 (diff) | |
download | vyos-1x-ac4e07f96ae329bab51c3da8596a2b975a0f3f17.tar.gz vyos-1x-ac4e07f96ae329bab51c3da8596a2b975a0f3f17.zip |
rfs: T4689: Support RFS(Receive Flow Steering)
Diffstat (limited to 'python/vyos/ifconfig/ethernet.py')
-rw-r--r-- | python/vyos/ifconfig/ethernet.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index b8deb3311..eac72ab8c 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -16,6 +16,7 @@ import os import re +from glob import glob from vyos.ethtool import Ethtool from vyos.ifconfig.interface import Interface from vyos.util import run @@ -74,6 +75,10 @@ class EthernetIf(Interface): 'convert': lambda cpus: cpus if cpus else '0', 'location': '/sys/class/net/{ifname}/queues/rx-0/rps_cpus', }, + 'rfs': { + 'convert': lambda num: num if num else '0', + 'location': '/proc/sys/net/core/rps_sock_flow_entries', + }, }} def __init__(self, ifname, **kargs): @@ -258,6 +263,22 @@ class EthernetIf(Interface): # send bitmask representation as hex string without leading '0x' return self.set_interface('rps', rps_cpus) + def set_rfs(self, state): + rfs_flow = 0 + global_rfs_flow = 0 + ifname = self.config['ifname'] + queues = glob(f'/sys/class/net/{ifname}/queues/rx-*') + if state: + global_rfs_flow = 32768 + rfs_flow = global_rfs_flow/len(queues) + + self.set_interface('rfs', str(int(global_rfs_flow))) + + for i in range(0,len(queues)): + self._write_sysfs(f'/sys/class/net/{ifname}/queues/rx-{i}/rps_flow_cnt',str(int(rfs_flow))) + + return state + def set_sg(self, state): """ Enable Scatter-Gather support. State can be either True or False. @@ -342,6 +363,9 @@ class EthernetIf(Interface): # RPS - Receive Packet Steering self.set_rps(dict_search('offload.rps', config) != None) + # RFS - Receive Flow Steering + self.set_rfs(dict_search('offload.rfs', config) != None) + # scatter-gather option self.set_sg(dict_search('offload.sg', config) != None) |