InnoRoute / RealtimeHAT

Documentation and source for InnoRoutes Raspberry TSN addon HAT
GNU General Public License v3.0
44 stars 5 forks source link

hardware offload capabilities #6

Open GaelRaphal opened 1 year ago

GaelRaphal commented 1 year ago

Hi,

I'm working on a project to demonstrate capabilities of real-time networking and we need a hightly deterministic method to send packets. We choose to use ETF functionnality over MQPRIO qdisc and we want to use hardware offload to realise a precise time launch.

Did Realtime Hat support hardware offload for ETF policy ?

Thanks for your help !

Salah3beed commented 11 months ago

Hello Gael,

Have you tried any of the following methods? 1- Using tc qdisc commands on linux 2- Using the RT Hat python module: https://github.com/InnoRoute/RT_HAT_python It would be great if either of them address your issue.

Sincerely, Salaheldin

GaelRaphal commented 9 months ago

Hello Salaheldin,

To configure queue discipline we use tc qdisc with the following commands Here we configure interface RT0 to a multiqueue priority Qdisc

sudo tc qdisc add dev RT0 parent root handle 100 mqprio  num_tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 0

Then we add ETF functionnality with hardware offload capability to first queue

sudo tc qdisc add dev RT0 parent 100:1 etf offload clockid CLOCK_TAI delta 60000

Here is the result configuration

pi@tsnpi2:~/TSN $ sudo tc qdisc show dev RT0
qdisc mqprio 100: root tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 
             queues:(0:0) (1:1) (2:3) 
qdisc pfifo_fast 0: parent 100:8 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:7 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:6 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:5 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:4 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:3 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent 100:2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc etf 8006: parent 100:1 clockid TAI delta 60000 offload on deadline_mode off skip_sock_check off

Then we cyclically send an udp packet with launch time in the message Here's the command to compile the source file to reproduce the measurements

gcc -o udp_tai -lpthread udp_tai.c

And the argument passed to the command

sudo ./udp_tai -i RT0 -P 1000000 -p 90 -d 600000

And we capture the real launch time with the following command

sudo tcpdump -c 60000 -i RT0 -w tmp.pcap -j adapter_unsynced -tt --time-stamp-precision=nano udp port 7788

We expect the udp packets to be sent few nano seconds after the launch time configured, but we actually measure that udp packets are sent few microseconds before the launch time.

We do believe that is caused by the absence of hardware offload for ETF policy. Can you confirm our analysis or point out our misinterpretation ?

Thanks in advance

udp_tai.zip