OSDN Git Service

net: qos: introduce a gate control flow action
authorPo Liu <Po.Liu@nxp.com>
Fri, 1 May 2020 00:53:15 +0000 (08:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2020 23:08:19 +0000 (16:08 -0700)
commita51c328df3106663879645680609eb49b3ff6444
tree92524c7adaa569d9595101eda73938a9bb4c2bd0
parenteb236c2994b031f805be691fa9ea39cba4690166
net: qos: introduce a gate control flow action

Introduce a ingress frame gate control flow action.
Tc gate action does the work like this:
Assume there is a gate allow specified ingress frames can be passed at
specific time slot, and be dropped at specific time slot. Tc filter
chooses the ingress frames, and tc gate action would specify what slot
does these frames can be passed to device and what time slot would be
dropped.
Tc gate action would provide an entry list to tell how much time gate
keep open and how much time gate keep state close. Gate action also
assign a start time to tell when the entry list start. Then driver would
repeat the gate entry list cyclically.
For the software simulation, gate action requires the user assign a time
clock type.

Below is the setting example in user space. Tc filter a stream source ip
address is 192.168.0.20 and gate action own two time slots. One is last
200ms gate open let frame pass another is last 100ms gate close let
frames dropped. When the ingress frames have reach total frames over
8000000 bytes, the excessive frames will be dropped in that 200000000ns
time slot.

> tc qdisc add dev eth0 ingress

> tc filter add dev eth0 parent ffff: protocol ip \
   flower src_ip 192.168.0.20 \
   action gate index 2 clockid CLOCK_TAI \
   sched-entry open 200000000 -1 8000000 \
   sched-entry close 100000000 -1 -1

> tc chain del dev eth0 ingress chain 0

"sched-entry" follow the name taprio style. Gate state is
"open"/"close". Follow with period nanosecond. Then next item is internal
priority value means which ingress queue should put. "-1" means
wildcard. The last value optional specifies the maximum number of
MSDU octets that are permitted to pass the gate during the specified
time interval.
Base-time is not set will be 0 as default, as result start time would
be ((N + 1) * cycletime) which is the minimal of future time.

Below example shows filtering a stream with destination mac address is
10:00:80:00:00:00 and ip type is ICMP, follow the action gate. The gate
action would run with one close time slot which means always keep close.
The time cycle is total 200000000ns. The base-time would calculate by:

 1357000000000 + (N + 1) * cycletime

When the total value is the future time, it will be the start time.
The cycletime here would be 200000000ns for this case.

> tc filter add dev eth0 parent ffff:  protocol ip \
   flower skip_hw ip_proto icmp dst_mac 10:00:80:00:00:00 \
   action gate index 12 base-time 1357000000000 \
   sched-entry close 200000000 -1 -1 \
   clockid CLOCK_TAI

Signed-off-by: Po Liu <Po.Liu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tc_act/tc_gate.h [new file with mode: 0644]
include/uapi/linux/pkt_cls.h
include/uapi/linux/tc_act/tc_gate.h [new file with mode: 0644]
net/sched/Kconfig
net/sched/Makefile
net/sched/act_gate.c [new file with mode: 0644]