From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: [PATCH bpf-next v3 07/11] net: sched: create tc_can_offload_extack() wrapper Date: Tue, 16 Jan 2018 13:38:35 -0800 Message-ID: <20180116213839.24537-8-jakub.kicinski@netronome.com> References: <20180116213839.24537-1-jakub.kicinski@netronome.com> Cc: dsahern@gmail.com, oss-drivers@netronome.com, jiri@resnulli.us, john.fastabend@gmail.com, jhs@mojatatu.com, gerlitz.or@gmail.com, aring@mojatatu.com, xiyou.wangcong@gmail.com, Quentin Monnet To: davem@davemloft.net, daniel@iogearbox.net, alexei.starovoitov@gmail.com, netdev@vger.kernel.org Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:39148 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbeAPVjF (ORCPT ); Tue, 16 Jan 2018 16:39:05 -0500 Received: by mail-pf0-f196.google.com with SMTP id e11so10378540pff.6 for ; Tue, 16 Jan 2018 13:39:05 -0800 (PST) In-Reply-To: <20180116213839.24537-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Quentin Monnet Create a wrapper around tc_can_offload() that takes an additional extack pointer argument in order to output an error message if TC offload is disabled on the device. In this way, the error message is handled by the core and can be the same for all drivers. Signed-off-by: Quentin Monnet Reviewed-by: Jakub Kicinski --- include/net/pkt_cls.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index c88c61234cb3..a3ad6a5a2d12 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -644,6 +644,17 @@ static inline bool tc_can_offload(const struct net_device *dev) return dev->features & NETIF_F_HW_TC; } +static inline bool tc_can_offload_extack(const struct net_device *dev, + struct netlink_ext_ack *extack) +{ + bool can = tc_can_offload(dev); + + if (!can) + NL_SET_ERR_MSG(extack, "TC offload is disabled on net device"); + + return can; +} + static inline bool tc_skip_hw(u32 flags) { return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false; -- 2.15.1