summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-01-25 21:23:09 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-25 21:23:09 -0500
commitb89d06ce58f1ebd43d4c491da4a9a9f0f29787d6 (patch)
tree4ebce6a79ade544f6568d78491065a785cc8f63d /include/net
parentfdd6d771c7de9d351c6dbdbab5bdc83805c06955 (diff)
parentbaf6a07e040d8308165654c7f49ee9ee18cd89be (diff)
downloadlinux-b89d06ce58f1ebd43d4c491da4a9a9f0f29787d6.tar.bz2
Merge branch 'use-tc_cls_can_offload_and_chain0-throughout-the-drivers'
Jakub Kicinski says: ==================== use tc_cls_can_offload_and_chain0() throughout the drivers This set makes all drivers use a new tc_cls_can_offload_and_chain0() helper which will set extack in case TC hw offload flag is disabled. I chose to keep the new helper which also looks at the chain but renamed it more appropriately. The rationale being that most drivers don't accept chains other than 0 and since we have to pass extack to the helper we can as well pass the entire struct tc_cls_common_offload and perform the most common checks. This code makes the assumption that type_data in the callback can be interpreted as struct tc_cls_common_offload, i.e. the real offload structure has common part as the first member. This allows us to make the check once for all classifier types if driver supports more than one. v1: - drop the type validation in nfp and netdevsim. v2: - reorder checks in patch 1; - split other changes from patch 1; - add the i40e patch in; - add one more test case - for chain 0 extack. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/pkt_cls.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index fa2f6fb14093..87406252f0a3 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -656,6 +656,20 @@ static inline bool tc_can_offload_extack(const struct net_device *dev,
return can;
}
+static inline bool
+tc_cls_can_offload_and_chain0(const struct net_device *dev,
+ struct tc_cls_common_offload *common)
+{
+ if (!tc_can_offload_extack(dev, common->extack))
+ return false;
+ if (common->chain_index) {
+ NL_SET_ERR_MSG(common->extack,
+ "Driver supports only offload of chain 0");
+ return false;
+ }
+ return true;
+}
+
static inline bool tc_skip_hw(u32 flags)
{
return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false;