diff options
author | Samudrala, Sridhar <sridhar.samudrala@intel.com> | 2016-05-12 17:08:23 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-16 13:30:57 -0400 |
commit | d34e3e181395192d6d1f50dd97bd7854e04e33a4 (patch) | |
tree | 79482667c26a1d1dcc54fc8147a27ddb92be5cea /include/net | |
parent | 760edee8b59ebf05bb268d0a6b568f76bb1bb599 (diff) | |
download | linux-d34e3e181395192d6d1f50dd97bd7854e04e33a4.tar.gz linux-d34e3e181395192d6d1f50dd97bd7854e04e33a4.tar.bz2 linux-d34e3e181395192d6d1f50dd97bd7854e04e33a4.zip |
net: cls_u32: Add support for skip-sw flag to tc u32 classifier.
On devices that support TC U32 offloads, this flag enables a filter to be
added only to HW. skip-sw and skip-hw are mutually exclusive flags. By
default without any flags, the filter is added to both HW and SW, but no
error checks are done in case of failure to add to HW. With skip-sw,
failure to add to HW is treated as an error.
Here is a sample script that adds 2 filters, one with skip-sw and the other
with skip-hw flag.
# add ingress qdisc
tc qdisc add dev p4p1 ingress
# enable hw tc offload.
ethtool -K p4p1 hw-tc-offload on
# add u32 filter with skip-sw flag.
tc filter add dev p4p1 parent ffff: protocol ip prio 99 \
handle 800:0:1 u32 ht 800: flowid 800:1 \
skip-sw \
match ip src 192.168.1.0/24 \
action drop
# add u32 filter with skip-hw flag.
tc filter add dev p4p1 parent ffff: protocol ip prio 99 \
handle 800:0:2 u32 ht 800: flowid 800:2 \
skip-hw \
match ip src 192.168.2.0/24 \
action drop
Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/pkt_cls.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 339ef08e35ae..8b4893878cf4 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -406,6 +406,23 @@ static inline bool tc_should_offload(struct net_device *dev, u32 flags) return true; } +static inline bool tc_skip_sw(u32 flags) +{ + return (flags & TCA_CLS_FLAGS_SKIP_SW) ? true : false; +} + +/* SKIP_HW and SKIP_SW are mutually exclusive flags. */ +static inline bool tc_flags_valid(u32 flags) +{ + if (flags & ~(TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW)) + return false; + + if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW))) + return false; + + return true; +} + enum tc_fl_command { TC_CLSFLOWER_REPLACE, TC_CLSFLOWER_DESTROY, |