From patchwork Thu Mar 3 09:23:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Vadai X-Patchwork-Id: 591357 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AFB351400CB for ; Thu, 3 Mar 2016 20:20:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757233AbcCCJTq (ORCPT ); Thu, 3 Mar 2016 04:19:46 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33232 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757099AbcCCJTm (ORCPT ); Thu, 3 Mar 2016 04:19:42 -0500 Received: by mail-wm0-f66.google.com with SMTP id n186so3047575wmn.0 for ; Thu, 03 Mar 2016 01:19:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9lQ6spMjgfzePcX+Nf4FNeMBPCSf0VoRDSsbrt8uk+Y=; b=JwNUJ0+LrYmACHBfRSoXd3mroYX6IUrEFvnJ8B6SCYu00HOl6a5uzZHDzw+scAlMTX jm8To1IXquAG8qF2YY9eOsUBq+WPsDeqrZX/4tMPKrN9N+PAoxOqb6rroWIsvEjEstGF V2bU6o3iE9Orl2GbrEFqD36MFBX5zIs3ejJ+/+D9zgAsfTCXSkBF4Hbx7N00i80t0pFz UFz1uxJz502WyciOKcD3YyPOz7Ds4VOBBLmaq0ipf96qO2sngzw+CfTT3iXvKDeHGyaM 4RYM/luuX0wALLllufW3CD+iZTNg+Uo1M7Jar0WUigZg9WBFzlAJ2Ebs/PYjsXeBcK7o UVXg== X-Gm-Message-State: AD7BkJJlKwH31C3OnzNNsqttlHboKfrBxCcb9Rpdh0X6qauojtMQPkYjqnji0CremrtaZA== X-Received: by 10.28.59.212 with SMTP id i203mr2107132wma.69.1456996781009; Thu, 03 Mar 2016 01:19:41 -0800 (PST) Received: from localhost.localdomain (212.116.172.4.static.012.net.il. [212.116.172.4]) by smtp.gmail.com with ESMTPSA id b203sm7947991wmh.8.2016.03.03.01.19.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 01:19:40 -0800 (PST) From: Amir Vadai To: "David S. Miller" Cc: netdev@vger.kernel.org, John Fastabend , Jiri Pirko , Or Gerlitz , Saeed Mahameed , Hadar Har-Zion , Rony Efraim , Amir Vadai Subject: [PATCH net-next V1 03/10] net/sched: Macro instead of CONFIG_NET_CLS_ACT ifdef Date: Thu, 3 Mar 2016 11:23:19 +0200 Message-Id: <1456997006-18538-4-git-send-email-amir@vadai.me> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456997006-18538-1-git-send-email-amir@vadai.me> References: <1456997006-18538-1-git-send-email-amir@vadai.me> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce the macros tc_no_actions and tc_for_each_action to make code clearer. CC: John Fastabend Suggested-by: Jiri Pirko Signed-off-by: Amir Vadai --- John hi, I wanted to change ixgbe code to use this, but it is not a trivial change there, so would prefer you do it. include/net/act_api.h | 21 ++++++++++++++++----- include/net/tc_act/tc_gact.h | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 342be6c..e30856f 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -78,11 +78,6 @@ static inline void tcf_lastuse_update(struct tcf_t *tm) tm->lastuse = now; } -#ifdef CONFIG_NET_CLS_ACT - -#define ACT_P_CREATED 1 -#define ACT_P_DELETED 1 - struct tc_action { void *priv; const struct tc_action_ops *ops; @@ -92,6 +87,11 @@ struct tc_action { struct tcf_hashinfo *hinfo; }; +#ifdef CONFIG_NET_CLS_ACT + +#define ACT_P_CREATED 1 +#define ACT_P_DELETED 1 + struct tc_action_ops { struct list_head head; char kind[IFNAMSIZ]; @@ -171,5 +171,16 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int); int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); + +#define tc_no_actions(_exts) \ + (list_empty(&(_exts)->actions)) + +#define tc_for_each_action(_a, _exts) \ + list_for_each_entry(a, &(_exts)->actions, list) +#else /* CONFIG_NET_CLS_ACT */ + +#define tc_no_actions(_exts) false +#define tc_for_each_action(_a, _exts) while (0) + #endif /* CONFIG_NET_CLS_ACT */ #endif diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h index 04a3183..93c520b 100644 --- a/include/net/tc_act/tc_gact.h +++ b/include/net/tc_act/tc_gact.h @@ -16,9 +16,9 @@ struct tcf_gact { #define to_gact(a) \ container_of(a->priv, struct tcf_gact, common) -#ifdef CONFIG_NET_CLS_ACT static inline bool is_tcf_gact_shot(const struct tc_action *a) { +#ifdef CONFIG_NET_CLS_ACT struct tcf_gact *gact; if (a->ops && a->ops->type != TCA_ACT_GACT) @@ -28,7 +28,7 @@ static inline bool is_tcf_gact_shot(const struct tc_action *a) if (gact->tcf_action == TC_ACT_SHOT) return true; +#endif return false; } -#endif #endif /* __NET_TC_GACT_H */