From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [PATCH net-next v4 6/8] net: sched: create tc_can_offload_extack() wrapper Date: Sat, 20 Jan 2018 09:59:29 +0100 Message-ID: <20180120085929.GB2147@nanopsycho.orion> References: <20180120014450.29666-1-jakub.kicinski@netronome.com> <20180120014450.29666-7-jakub.kicinski@netronome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: davem@davemloft.net, dsahern@gmail.com, aring@mojatatu.com, daniel@iogearbox.net, alexei.starovoitov@gmail.com, netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet To: Jakub Kicinski Return-path: Received: from mail-wr0-f194.google.com ([209.85.128.194]:46238 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbeATI7b (ORCPT ); Sat, 20 Jan 2018 03:59:31 -0500 Received: by mail-wr0-f194.google.com with SMTP id g21so3615863wrb.13 for ; Sat, 20 Jan 2018 00:59:30 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180120014450.29666-7-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: Sat, Jan 20, 2018 at 02:44:48AM CET, jakub.kicinski@netronome.com wrote: >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 f497f622580b..2f8f16a4d88e 100644 >--- a/include/net/pkt_cls.h >+++ b/include/net/pkt_cls.h >@@ -656,6 +656,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) I don't like to add tc_can_offload variant for this. It makes sense the original tc_can_offload to be extended and set the extack message always. It would require some more work in drivers (5), sure, but we endup with nicer and consistent code. >+{ >+ 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 >