Merge ~liaou3/checkbox-iiotg/+git/checkbox-provider-intliotg:fix_typo_tsn into ~checkbox-dev/checkbox-iiotg/+git/checkbox-provider-intliotg:master

Proposed by Vincent Liao
Status: Merged
Approved by: Vincent Liao
Approved revision: 3d2cc712b959d23334b6c308a5bc6bc400ebac67
Merged at revision: 2116266db92a2813ddaac5bfb6a4966103f216cd
Proposed branch: ~liaou3/checkbox-iiotg/+git/checkbox-provider-intliotg:fix_typo_tsn
Merge into: ~checkbox-dev/checkbox-iiotg/+git/checkbox-provider-intliotg:master
Diff against target: 106 lines (+50/-38)
2 files modified
bin/tsn_credit_based_shaper.sh (+49/-0)
units/tsn/jobs.pxu (+1/-38)
Reviewer Review Type Date Requested Status
Rick Wu Approve
StanleyHuang Approve
Patrick Liu (community) Approve
PeiYao Chang Pending
Vic Liu Pending
Review via email: mp+453894@code.launchpad.net

Commit message

Fix the job `tsn/ieee802.1qav/check-credit-based-shaper-{{ interface }}`
 - Fix typo from `1000000` to `100000`
 - Make the command field into shell script
 - Replace `tc` command from the snap `iproute2-rt`

To post a comment you must log in.
Revision history for this message
Patrick Liu (patliu) wrote :

+1

review: Approve
Revision history for this message
Vincent Liao (liaou3) wrote :
Revision history for this message
Rick Wu (rickwu4444) wrote :

@Vincent, Please see my inline comment.

review: Needs Information
Revision history for this message
StanleyHuang (stanley31) wrote :

LGTM

review: Approve
Revision history for this message
Vincent Liao (liaou3) wrote :

@Rick
This is an unused variable. Thank you for the reminder. I have removed it.

Revision history for this message
Rick Wu (rickwu4444) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/tsn_credit_based_shaper.sh b/bin/tsn_credit_based_shaper.sh
2new file mode 100755
3index 0000000..f023b3b
4--- /dev/null
5+++ b/bin/tsn_credit_based_shaper.sh
6@@ -0,0 +1,49 @@
7+#!/bin/bash
8+
9+set -e
10+
11+eth_interface=$1
12+server_user=$2
13+server_ip=$3
14+server_pwd=$4
15+server_eth_interface=$5
16+
17+echo "## Clearing previous queue discipline configuration..."
18+echo "## You will get errors if there's no previous configuration, but you could ignore it."
19+sshpass -p "$server_pwd" ssh -o StrictHostKeyChecking=no "$server_user"@"$server_ip" "echo ${server_pwd} | sudo -S iproute2-rt.tc qdisc del dev $server_eth_interface root" || true
20+iproute2-rt.tc qdisc del dev "$eth_interface" root || true
21+echo ""
22+
23+echo "## Setting 4 traffic classes mapping..."
24+iproute2-rt.tc qdisc replace dev "$eth_interface" handle 100: parent root mqprio num_tc 4 map 0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 queues 1@0 1@1 1@2 1@3 hw 0
25+iproute2-rt.tc -g class show dev "$eth_interface"
26+echo ""
27+
28+echo "## Setting Traffic Class 1 (Queue 1) to 10% bandwidth of 1 Gbps..."
29+iproute2-rt.tc qdisc replace dev "$eth_interface" parent 100:1 cbs locredit -1350 hicredit 150 sendslope -900000 idleslope 100000 offload 1
30+iproute2-rt.tc qdisc show dev "$eth_interface"
31+echo ""
32+
33+echo "## Start sending UDP packets of 1500 bytes using socket priority 1 with tsn-talker..."
34+stdbuf -oL timeout 60 tsn-talker -d 01:AA:AA:AA:AA:AA -i "$eth_interface" -p 0 -s 1500 &
35+sleep 5
36+echo ""
37+
38+echo "## Start listening on TSN server..."
39+output=$(mktemp)
40+(sshpass -p "$server_pwd" ssh -o StrictHostKeyChecking=no "$server_user"@"$server_ip" "echo $server_pwd | sudo -S stdbuf -oL timeout 55 ./tsn-listener -d 01:AA:AA:AA:AA:AA -i $server_eth_interface -s 1500") | tee "$output"
41+lines=$(tail -n 50 "$output")
42+while read -r line
43+do
44+ speed=$(echo "$line" | awk 'match($0, /: [0-9]* kbps/) {print substr($0, RSTART+2, RLENGTH-7)}')
45+ if [ "$speed" -gt 100000 ]; then
46+ echo "FAIL: Data rate over 100000 kbps!"
47+ exit 1
48+ fi
49+ if [ "$speed" -lt 90000 ]; then
50+ echo "FAIL: Data rate cannot reach 90% of 100000 kbps!"
51+ exit 1
52+ fi
53+done <<< "$lines"
54+echo ""
55+echo "Pass: Data rate within -10% of 100000 kbps"
56diff --git a/units/tsn/jobs.pxu b/units/tsn/jobs.pxu
57index e975c30..b422172 100644
58--- a/units/tsn/jobs.pxu
59+++ b/units/tsn/jobs.pxu
60@@ -276,45 +276,8 @@ environ:
61 TSN_SERVER_USER
62 TSN_SERVER_PWD
63 TSN_SERVER_INTERFACE
64- GPTP_CONFIG_PATH
65 command:
66- echo "## Clearing previous queue discipline configuration..."
67- echo "## You will get error if there's no previous configuration, but you could ignore it."
68- echo ""
69- sshpass -p "$TSN_SERVER_PWD" ssh -o StrictHostKeyChecking=no "$TSN_SERVER_USER"@"$TSN_SERVER_IP" "echo $TSN_SERVER_PWD | sudo -S tc qdisc del dev $TSN_SERVER_INTERFACE root"
70- tc qdisc del dev {{ interface }} root
71- echo ""
72- echo "## Setting 4 traffic classes mapping..."
73- tc qdisc replace dev {{ interface }} handle 100: parent root mqprio num_tc 4 map 0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 queues 1@0 1@1 1@2 1@3 hw 0
74- tc -g class show dev {{ interface }}
75- echo ""
76- echo "## Setting Traffic Class 1 (Queue 1) to 10% bandwidth of 1 Gbps..."
77- tc qdisc replace dev {{ interface }} parent 100:1 cbs locredit -1350 hicredit 150 sendslope -900000 idleslope 100000 offload 1
78- tc qdisc show dev {{ interface }}
79- echo ""
80- echo "## Start sending UDP packets of 1500 bytes using socket priority 1 with tsn-talker..."
81- stdbuf -oL timeout 60 tsn-talker -d 01:AA:AA:AA:AA:AA -i {{ interface }} -p 0 -s 1500 &
82- sleep 5
83- echo ""
84- echo "## Start listening on TSN server..."
85- output=$(mktemp)
86- (sshpass -p "$TSN_SERVER_PWD" ssh -o StrictHostKeyChecking=no "$TSN_SERVER_USER"@"$TSN_SERVER_IP" "echo $TSN_SERVER_PWD | sudo -S stdbuf -oL timeout 55 ./tsn-listener -d 01:AA:AA:AA:AA:AA -i $TSN_SERVER_INTERFACE -s 1500") | tee $output
87- lines=$(cat $output | tail -n 50)
88- while read -r line
89- do
90- speed=$(echo "$line" | awk 'match($0, /: [0-9]* kbps/) {print substr($0, RSTART+2, RLENGTH-7)}')
91- if [ $speed -gt 100000 ]; then
92- echo "FAIL: Data rate over 1000000 kbps!"
93- exit 1
94- fi
95- if [ $speed -lt 90000 ]; then
96- echo "FAIL: Data rate cannot reach 90% of 1000000 kbps!"
97- exit 1
98- fi
99- done <<< $lines
100- echo ""
101- echo "Pass: Data rate within -10% of 1000000kbps"
102- exit 0
103+ tsn_credit_based_shaper.sh {{ interface }} "$TSN_SERVER_USER" "$TSN_SERVER_IP" "$TSN_SERVER_PWD" "$TSN_SERVER_INTERFACE"
104
105 unit: template
106 template-resource: tsn/tsn-devices

Subscribers

People subscribed via source and target branches