Skip to content

Commit c37d274

Browse files
Noor Azura Ahmad Tarmiziws-intel
authored andcommitted
gen_setup.py: Add eth flowtype proto rx filter processing to json
i225/i226 is using ethtool flowtype proto filtering to steer receiving packets to the correct queue. We are now adding this functionality to support ethtool flowtype. It will filter packet according to proto type to the specific queue. For example, we are steering ptp packets to queue 0. Signed-off-by: Noor Azura Ahmad Tarmizi <[email protected]> Signed-off-by: Goh, Wei Sheng <[email protected]>
1 parent 92accd8 commit c37d274

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

json/gen_setup.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ def delete_qdiscs(iface):
5050
proc = sh_run(cmd)
5151
sh_run('sleep 5')
5252

53+
def delete_flowtype_filter(iface):
54+
#print('Deleting existing flow type filters. Assuming we add max 4 (63-60) rules only')
55+
for rule_ID in range (60,64):
56+
del_flowtype_filt_cmd = "ethtool -N {} ".format(iface)
57+
del_flowtype_filt_cmd += "delete {} ".format(rule_ID)
58+
del_flowtype_filt_cmd += "2> /dev/null"
59+
proc = sh_run(del_flowtype_filt_cmd)
60+
sh_run('sleep 1')
61+
5362
def init_ingress(iface, show_qdisc_cmd):
5463
clear_rx_cmd = "tc qdisc del dev {} parent ffff:".format(iface)
5564
add_ingress_cmd = "tc qdisc add dev {} ingress".format(iface)
@@ -71,6 +80,40 @@ def set_vlanrx(iface, config, show_qdisc_cmd):
7180

7281
output = sh_run(set_vlanrx_cmd)
7382

83+
def set_flowtype_ether_proto(iface, config):
84+
85+
if not 'proto' in config:
86+
err_exit('Proto not defined in flow type filter config')
87+
if not 'rx_queue' in config:
88+
err_exit('Queue not defined in flow type filter config')
89+
90+
proto = str(config['proto'])
91+
rx_queue = str(config['rx_queue'])
92+
93+
set_flowtype_filter_rx_cmd = "ethtool -N {} ".format(iface)
94+
set_flowtype_filter_rx_cmd += "flow-type ether proto {} ".format(proto)
95+
set_flowtype_filter_rx_cmd += "queue {} ".format(rx_queue)
96+
97+
output = sh_run(set_flowtype_filter_rx_cmd)
98+
sh_run('sleep 1')
99+
100+
def process_eth_flowtype_ether_proto(data):
101+
102+
# If file is empty then we do nothing
103+
if len(data) == 0:
104+
return
105+
106+
if not 'interface' in data:
107+
err_exit('Interface not found in eth flowtype ether proto config')
108+
109+
interface = data.get('interface')
110+
111+
delete_flowtype_filter(interface)
112+
113+
if 'ether_proto' in data:
114+
#print('Setup flowtype ether proto RX steering')
115+
for each_config in data["ether_proto"]:
116+
set_flowtype_ether_proto(interface, each_config)
74117

75118
def set_taprio(iface, maps, config, basetime, clkid):
76119
schedules = ""
@@ -345,8 +388,7 @@ def process_phc2sys(obj):
345388
' leap61 0 leap59 0 currentUtcOffsetValid 0 ptpTimescale 1 timeTraceable'
346389
' 1 frequencyTraceable 0 timeSource 0xa0', '"']
347390
run_with_out(arglist, '/var/log/pmc.log')
348-
349-
sh_run('sleep 2')
391+
sh_run('sleep 30')
350392

351393
# phc2sys -c CLOCK_REALTIME --step_threshold=1 -s eth0 \
352394
# --transportSpecific=1 -O 0 -w -ml 7
@@ -464,6 +506,10 @@ def main():
464506

465507
if 'phc2sys' in data: process_phc2sys(data['phc2sys'])
466508

509+
if 'eth_flowtype_ether_proto' in data:
510+
for each_eth_flow_type in data["eth_flowtype_ether_proto"]:
511+
process_eth_flowtype_ether_proto(each_eth_flow_type)
512+
467513
if 'custom_sync_a' in data: process_custom_a(data['custom_sync_a'])
468514
if 'custom_sync_b' in data: process_custom_b(data['custom_sync_b'])
469515

json/i225/opcua-pkt1a-tsn.json.i

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,16 @@
5353
}
5454
]
5555
}
56+
],
57+
"eth_flowtype_ether_proto": [
58+
{
59+
"interface": "_PREPROCESS_STR_interface",
60+
"ether_proto": [
61+
{
62+
"proto": "0x88f7",
63+
"rx_queue": 0
64+
}
65+
]
66+
}
5667
]
5768
}

json/i225/opcua-pkt1b-tsn.json.i

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,16 @@
3838
}
3939
]
4040
}
41+
],
42+
"eth_flowtype_ether_proto": [
43+
{
44+
"interface": "_PREPROCESS_STR_interface",
45+
"ether_proto": [
46+
{
47+
"proto": "0x88f7",
48+
"rx_queue": 0
49+
}
50+
]
51+
}
4152
]
4253
}

0 commit comments

Comments
 (0)