Enable SW only or HW only offloads with u32 classifier
Subsystems (3)
PATCH v2 2/2 net: cls_u32: Add support for skip-sw flag to tc u32 classifier.
In reply to Sridhar SamudralaOn 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--- include/net/pkt_cls.h | 17 +++++++++++++++++ include/uapi/linux/pkt_cls.h | 1 + net/sched/cls_u32.c | 45 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 54 insertions(+), 9 deletions(-)
include/net/pkt_cls.h +17 -0
@@ -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 ,
include/uapi/linux/pkt_cls.h +1 -0
@@ -153,6 +153,7 @@ enum {/* tca flags definitions */ #define TCA_CLS_FLAGS_SKIP_HW (1 << 0) +#define TCA_CLS_FLAGS_SKIP_SW (1 << 1)/* U32 filters */
net/sched/cls_u32.c +36 -9
121 lines not on this page · raw message
Signature · 1 line
2.1.0
v2 cover Enable SW only or HW only offloads with u32 classifier
This set of patches export TCA_CLS_FLAGS_SKIP_HW to userspace and also introduces another flag TCA_CLS_FLAGS_SKIP_SW. These flags enable offloading u32 filters to either SW or HW only.
The default semantics with no flags is to add the filter to HW if possible and also into SW.
With SKIP_HW flag, the filter is only added to SW.
With SKIP_SW flag, the filter is added to HW and an error is returned to user on failure.
These flags are mutually exclusive.
There was an earlier discussion on these semantics in the following email thread.
http://thread.gmane.org/gmane.linux.network/401733
Sridhar Samudrala (2):
Move TCA_CLS_FLAGS_SKIP_HW to uapi header file. Add support for skip-sw flag to tc u32 classifier.
include/net/pkt_cls.h | 20 +++++++++++++++++--- include/uapi/linux/pkt_cls.h | 4 ++++ net/sched/cls_u32.c | 45 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 57 insertions(+), 12 deletions(-)
Signature · 1 line
2.1.0
PATCH v2 1/2 net: sched: Move TCA_CLS_FLAGS_SKIP_HW to uapi header file.
--- include/net/pkt_cls.h | 3 --- include/uapi/linux/pkt_cls.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/pkt_cls.h +0 -3
@@ -392,9 +392,6 @@ struct tc_cls_u32_offload { }; }; -/* tca flags definitions */ -#define TCA_CLS_FLAGS_SKIP_HW 1 -static inline bool tc_should_offload (struct net_device *dev,u32 flags) {if (!(dev->features &NETIF_F_HW_TC ))
include/uapi/linux/pkt_cls.h +3 -0
@@ -151,6 +151,9 @@ enum {#define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1) +/* tca flags definitions */ +#define TCA_CLS_FLAGS_SKIP_HW (1 << 0) +/* U32 filters */ #define TC_U32_HTID (h) ((h)&0xFFF00000)
Signature · 1 line
2.1.0
Re: [PATCH v2 net-next 1/2] net: sched: Move TCA_CLS_FLAGS_SKIP_HW to uapi header file.
Quoted 2 lines · Sridhar Samudrala
Signed-off-by Sridhar Samudrala <[email protected]>---
Re: [PATCH v2 net-next 2/2] net: cls_u32: Add support for skip-sw flag to tc u32 classifier.
In reply to Sridhar SamudralaQuoted 29 lines · Sridhar Samudrala
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
Quoted 2 lines
Signed-off-by Sridhar Samudrala <[email protected]>---
Looks good to me thanks for doing this.
David Miller
maintainerFrom: Sridhar Samudrala <[email protected]>
Date: Thu, 12 May 2016 17:08:21 -0700
Quoted 12 lines
This set of patches export
TCA_CLS_FLAGS_SKIP_HWto userspace and also introduces another flagTCA_CLS_FLAGS_SKIP_SW. These flags enable offloading u32 filters to either SW or HW only.The default semantics with no flags is to add the filter to HW if possible and also into SW.
WithSKIP_HWflag, the filter is only added to SW.
WithSKIP_SWflag, the filter is added to HW and an error is returned to user on failure.
These flags are mutually exclusive.
There was an earlier discussion on these semantics in the following email thread.
Quoted 1 line
http://thread.gmane.org/gmane.linux.network/401733
Series applied, thanks.