Skip to content

Commit 878db9f

Browse files
Jakub Kicinskidavem330
authored andcommitted
pkt_cls: add new tc cls helper to check offload flag and chain index
Very few (mlxsw) upstream drivers seem to allow offload of chains other than 0. Save driver developers typing and add a helper for checking both if ethtool's TC offload flag is on and if chain is 0. This helper will set the extack appropriately in both error cases. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fdd6d77 commit 878db9f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/net/pkt_cls.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,20 @@ static inline bool tc_can_offload_extack(const struct net_device *dev,
656656
return can;
657657
}
658658

659+
static inline bool
660+
tc_cls_can_offload_and_chain0(const struct net_device *dev,
661+
struct tc_cls_common_offload *common)
662+
{
663+
if (!tc_can_offload_extack(dev, common->extack))
664+
return false;
665+
if (common->chain_index) {
666+
NL_SET_ERR_MSG(common->extack,
667+
"Driver supports only offload of chain 0");
668+
return false;
669+
}
670+
return true;
671+
}
672+
659673
static inline bool tc_skip_hw(u32 flags)
660674
{
661675
return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false;

0 commit comments

Comments
 (0)