Skip to content

Commit

Permalink
gen_setup.py: Add eth flowtype proto rx filter processing to json
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Noor Azura Ahmad Tarmizi authored and ws-intel committed Sep 7, 2023
1 parent 92accd8 commit c37d274
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
50 changes: 48 additions & 2 deletions json/gen_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def delete_qdiscs(iface):
proc = sh_run(cmd)
sh_run('sleep 5')

def delete_flowtype_filter(iface):
#print('Deleting existing flow type filters. Assuming we add max 4 (63-60) rules only')
for rule_ID in range (60,64):
del_flowtype_filt_cmd = "ethtool -N {} ".format(iface)
del_flowtype_filt_cmd += "delete {} ".format(rule_ID)
del_flowtype_filt_cmd += "2> /dev/null"
proc = sh_run(del_flowtype_filt_cmd)
sh_run('sleep 1')

def init_ingress(iface, show_qdisc_cmd):
clear_rx_cmd = "tc qdisc del dev {} parent ffff:".format(iface)
add_ingress_cmd = "tc qdisc add dev {} ingress".format(iface)
Expand All @@ -71,6 +80,40 @@ def set_vlanrx(iface, config, show_qdisc_cmd):

output = sh_run(set_vlanrx_cmd)

def set_flowtype_ether_proto(iface, config):

if not 'proto' in config:
err_exit('Proto not defined in flow type filter config')
if not 'rx_queue' in config:
err_exit('Queue not defined in flow type filter config')

proto = str(config['proto'])
rx_queue = str(config['rx_queue'])

set_flowtype_filter_rx_cmd = "ethtool -N {} ".format(iface)
set_flowtype_filter_rx_cmd += "flow-type ether proto {} ".format(proto)
set_flowtype_filter_rx_cmd += "queue {} ".format(rx_queue)

output = sh_run(set_flowtype_filter_rx_cmd)
sh_run('sleep 1')

def process_eth_flowtype_ether_proto(data):

# If file is empty then we do nothing
if len(data) == 0:
return

if not 'interface' in data:
err_exit('Interface not found in eth flowtype ether proto config')

interface = data.get('interface')

delete_flowtype_filter(interface)

if 'ether_proto' in data:
#print('Setup flowtype ether proto RX steering')
for each_config in data["ether_proto"]:
set_flowtype_ether_proto(interface, each_config)

def set_taprio(iface, maps, config, basetime, clkid):
schedules = ""
Expand Down Expand Up @@ -345,8 +388,7 @@ def process_phc2sys(obj):
' leap61 0 leap59 0 currentUtcOffsetValid 0 ptpTimescale 1 timeTraceable'
' 1 frequencyTraceable 0 timeSource 0xa0', '"']
run_with_out(arglist, '/var/log/pmc.log')

sh_run('sleep 2')
sh_run('sleep 30')

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

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

if 'eth_flowtype_ether_proto' in data:
for each_eth_flow_type in data["eth_flowtype_ether_proto"]:
process_eth_flowtype_ether_proto(each_eth_flow_type)

if 'custom_sync_a' in data: process_custom_a(data['custom_sync_a'])
if 'custom_sync_b' in data: process_custom_b(data['custom_sync_b'])

Expand Down
11 changes: 11 additions & 0 deletions json/i225/opcua-pkt1a-tsn.json.i
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,16 @@
}
]
}
],
"eth_flowtype_ether_proto": [
{
"interface": "_PREPROCESS_STR_interface",
"ether_proto": [
{
"proto": "0x88f7",
"rx_queue": 0
}
]
}
]
}
11 changes: 11 additions & 0 deletions json/i225/opcua-pkt1b-tsn.json.i
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,16 @@
}
]
}
],
"eth_flowtype_ether_proto": [
{
"interface": "_PREPROCESS_STR_interface",
"ether_proto": [
{
"proto": "0x88f7",
"rx_queue": 0
}
]
}
]
}

0 comments on commit c37d274

Please sign in to comment.