From patchwork Sat Mar 7 11:40:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 222883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D30C10F00 for ; Sat, 7 Mar 2020 11:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0B712073D for ; Sat, 7 Mar 2020 11:40:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="nqMV0Z4o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726174AbgCGLk3 (ORCPT ); Sat, 7 Mar 2020 06:40:29 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36949 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgCGLk1 (ORCPT ); Sat, 7 Mar 2020 06:40:27 -0500 Received: by mail-wr1-f65.google.com with SMTP id 6so5375422wre.4 for ; Sat, 07 Mar 2020 03:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tYDmebcFXDgyaGfDwBTZgKExPTtiUpULiECPHwTYhI0=; b=nqMV0Z4ofG9NMpcvu5mcfyMcW+P/xUn6LMTEr6lLXAjBVslLCJw8IrWmtgMLq9Ef4N MKapLeEPCyqBKhjHY7GrvMpUHFJLB4y5wriDCczKePVKjB9AZPAZmSWzkglUtyBK6IVl 4GqABLqU0yuaWjq0/QqD1SfRgQGkmZKtrAB7Eb7y8gyhJ4MFUjtJm4wxSxneB0xiBZxS DiR0/kLf5DQbYKil8f1koCaKKKg6YhGWcA7Ulqoc+pHOL9StfaCDwrY7tT8bgAD2Pz6a urjLPtYNfvmVt6WjCrL+gtWxVI3KB0JAK2Y9cuKhmQVn8EfquNwa9Wm3sd5QelLJSXFb IXWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tYDmebcFXDgyaGfDwBTZgKExPTtiUpULiECPHwTYhI0=; b=hkTtW6bY26WUrCGIluClRDhHcFSFz5yUE30TJihv7D1Nf3tIzbP7gJual/iiORU5Vi 2I5/d3UxzObsNttwVNL0TV6eFopk11aFpTQIj3IrzrnJ1IZyh5XChypuBMtV+TEkITci 71Uj90YRN7C1gTu6ml+PDDLEMKu4ddW3zyg3u7l/ItuczRQxcpjSVmlNO1N23ct/z4Ta YquVuI4iFtkoWmfRRAsTmfzwGmmNEu+rquqJR2FLaaJ+NN8GDZ4hx0y8GC+gqkAIwLiT 1IXun7mCX/gESFRuh2Gj0jVau3LqVpeY9AlBUjd4qfciZ1H3iarBf0PG4UEayfn48ysT p1qA== X-Gm-Message-State: ANhLgQ2s+tRQi8Jv8n+YWoJlHf1lxVZ+uDmYhWO7RrD+KvLwrd9loM+r quwE4+07kVmuiIvMMdpi6LvREx+lNJk= X-Google-Smtp-Source: ADFU+vsKXjXyOO8+MGSACrvflA3GFFdj7cs7tpi0HnBS3jinxnK8gYLYBW4xqmJi+uXYP7NcZcYaoA== X-Received: by 2002:adf:b3d6:: with SMTP id x22mr9194174wrd.242.1583581225542; Sat, 07 Mar 2020 03:40:25 -0800 (PST) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id s14sm40461777wrv.44.2020.03.07.03.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 03:40:25 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, saeedm@mellanox.com, leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com, jeffrey.t.kirsher@intel.com, idosch@mellanox.com, aelior@marvell.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, ecree@solarflare.com, mlxsw@mellanox.com Subject: [patch net-next v4 01/10] flow_offload: Introduce offload of HW stats type Date: Sat, 7 Mar 2020 12:40:11 +0100 Message-Id: <20200307114020.8664-2-jiri@resnulli.us> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200307114020.8664-1-jiri@resnulli.us> References: <20200307114020.8664-1-jiri@resnulli.us> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Initially, pass "ANY" (struct is zeroed) to the drivers as that is the current implicit value coming down to flow_offload. Add a bool indicating that entries have mixed HW stats type. Signed-off-by: Jiri Pirko --- v3->v4: - fixed member alignment v2->v3: - moved to bitfield - removed "mixed" bool v1->v2: - moved to actions - add mixed bool --- include/net/flow_offload.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index cd3510ac66b0..93d17f37e980 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -154,6 +154,8 @@ enum flow_action_mangle_base { FLOW_ACT_MANGLE_HDR_TYPE_UDP, }; +#define FLOW_ACTION_HW_STATS_TYPE_ANY 0 + typedef void (*action_destr)(void *priv); struct flow_action_cookie { @@ -168,6 +170,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie); struct flow_action_entry { enum flow_action_id id; + u8 hw_stats_type; action_destr destructor; void *destructor_priv; union { From patchwork Sat Mar 7 11:40:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 222882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C295C10F26 for ; Sat, 7 Mar 2020 11:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F130F2073C for ; Sat, 7 Mar 2020 11:40:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="A4WeIwtG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbgCGLkc (ORCPT ); Sat, 7 Mar 2020 06:40:32 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33848 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbgCGLkb (ORCPT ); Sat, 7 Mar 2020 06:40:31 -0500 Received: by mail-wr1-f65.google.com with SMTP id z15so5384440wrl.1 for ; Sat, 07 Mar 2020 03:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mrpHG9UkjI9atoomHrpT7FnfXqD/Qo8ylYotp+n0sGY=; b=A4WeIwtGHyIzmtZcVV/iHVmzKb/5TMnmbEBj/k2tsWrEz1bFVo0R7/DpUvA9kG6zjj ArrUV707A5eIYK+GO6fV0vyO+MnREJqAd0PcAPN//9DyGr/n9J+SZczEDqSseVJXWMp8 qgvUbIMmRvHwy9P/UeQt4/gbYLduBFo3alM66PTcPkX0YZvjFa9+LmflLCRWG+4Fr/Fc TcyxTLtedrREFSjhqmM5wNdWiHq7BcI+lwDmSTbIF/tw+9FEZFeBtiwxOdPc0z/iN//t JY8s4tkK1KLzsOmAPMwbtmGndXsvc1a5aOyeSMAyTRMpwvMf/00M+s/mcjGCRab5QyV0 u7cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mrpHG9UkjI9atoomHrpT7FnfXqD/Qo8ylYotp+n0sGY=; b=U0AmfBtj5r2NoLX7/6+1O0gts0hRdt5ukuw9a+70i6ztPel8aE1bJ1eeyAb65rRwc3 lrSakv3s+/TLVHUN1KVogJPkP5QKlDB/r9o/cfkf5s2Vnf4u4yMaIK/hWqVKp3dEmQdF jokbSo02Y7vODqVpVZnWtE/bgnyr9mDk5TDR5wnxE199V8hSaVLKOhsAi1sh+WHc9+E0 ORn4MJDr6kXRx1upstfRpye+pZLdvIKERgvFCW3K8YMHHBFj5hNCAWafDOtvIlj+G76A OphDwUG7X2Bn0wKoGEkcqCdAPIcxcntCWzvRlGZRs6xh8c9CHabtAeyBPlrkwctE29Ek KSTA== X-Gm-Message-State: ANhLgQ1MXjtcH6CZgPdCizImTsSodkduNjdTJdn6GeNstBnGzXaCipUo qPb7FA7S+vwcB76it9o9uU0QM0aYDQc= X-Google-Smtp-Source: ADFU+vsyPpoWf9+rYciByqh1zAQYpVfQ+GfwsvLUkNoBAF4sz9YTzw7R6SIsRGJDrgGkoIqFI7Fg4A== X-Received: by 2002:adf:f14a:: with SMTP id y10mr9259721wro.325.1583581227744; Sat, 07 Mar 2020 03:40:27 -0800 (PST) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id b16sm49500180wrq.14.2020.03.07.03.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 03:40:27 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, saeedm@mellanox.com, leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com, jeffrey.t.kirsher@intel.com, idosch@mellanox.com, aelior@marvell.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, ecree@solarflare.com, mlxsw@mellanox.com Subject: [patch net-next v4 03/10] flow_offload: check for basic action hw stats type Date: Sat, 7 Mar 2020 12:40:13 +0100 Message-Id: <20200307114020.8664-4-jiri@resnulli.us> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200307114020.8664-1-jiri@resnulli.us> References: <20200307114020.8664-1-jiri@resnulli.us> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Introduce flow_action_basic_hw_stats_types_check() helper and use it in drivers. That sanitizes the drivers which do not have support for action HW stats types. Signed-off-by: Jiri Pirko --- v3->v4: - fixed entries iteration in check (s/0/i/) - compare allowed type explicitly to 0 to avoid confusion v2->v3: - added flow_action_hw_stats_types_check() to pass allowed types - "mixed" bool got remove, iterate entries in check - added mlx5 checking instead of separate patches (will be changed by later patch to flow_action_hw_stats_types_check() v1->v2: - new patch --- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 9 ++- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 8 ++- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 3 +- .../chelsio/cxgb4/cxgb4_tc_matchall.c | 3 +- .../net/ethernet/marvell/mvpp2/mvpp2_cls.c | 6 ++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 9 +++ drivers/net/ethernet/mscc/ocelot_flower.c | 4 ++ .../ethernet/netronome/nfp/flower/action.c | 4 ++ .../net/ethernet/qlogic/qede/qede_filter.c | 10 ++- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 9 ++- include/net/flow_offload.h | 61 +++++++++++++++++++ net/dsa/slave.c | 4 ++ 12 files changed, 119 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index 9bec256b0934..523bf4be43cc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -279,7 +279,8 @@ bnxt_tc_parse_pedit(struct bnxt *bp, struct bnxt_tc_actions *actions, static int bnxt_tc_parse_actions(struct bnxt *bp, struct bnxt_tc_actions *actions, - struct flow_action *flow_action) + struct flow_action *flow_action, + struct netlink_ext_ack *extack) { /* Used to store the L2 rewrite mask for dmac (6 bytes) followed by * smac (6 bytes) if rewrite of both is specified, otherwise either @@ -299,6 +300,9 @@ static int bnxt_tc_parse_actions(struct bnxt *bp, return -EINVAL; } + if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, flow_action) { switch (act->id) { case FLOW_ACTION_DROP: @@ -491,7 +495,8 @@ static int bnxt_tc_parse_flow(struct bnxt *bp, flow->tun_mask.tp_src = match.mask->src; } - return bnxt_tc_parse_actions(bp, &flow->actions, &rule->action); + return bnxt_tc_parse_actions(bp, &flow->actions, &rule->action, + tc_flow_cmd->common.extack); } static int bnxt_hwrm_cfa_flow_free(struct bnxt *bp, diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c index bb5513bdd293..cc46277e98de 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c @@ -544,7 +544,8 @@ static bool valid_pedit_action(struct net_device *dev, } int cxgb4_validate_flow_actions(struct net_device *dev, - struct flow_action *actions) + struct flow_action *actions, + struct netlink_ext_ack *extack) { struct flow_action_entry *act; bool act_redir = false; @@ -552,6 +553,9 @@ int cxgb4_validate_flow_actions(struct net_device *dev, bool act_vlan = false; int i; + if (!flow_action_basic_hw_stats_types_check(actions, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, actions) { switch (act->id) { case FLOW_ACTION_ACCEPT: @@ -642,7 +646,7 @@ int cxgb4_tc_flower_replace(struct net_device *dev, struct filter_ctx ctx; int fidx, ret; - if (cxgb4_validate_flow_actions(dev, &rule->action)) + if (cxgb4_validate_flow_actions(dev, &rule->action, extack)) return -EOPNOTSUPP; if (cxgb4_validate_flow_match(dev, cls)) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h index e132516e9868..0a30c96b81ff 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h @@ -112,7 +112,8 @@ void cxgb4_process_flow_actions(struct net_device *in, struct flow_action *actions, struct ch_filter_specification *fs); int cxgb4_validate_flow_actions(struct net_device *dev, - struct flow_action *actions); + struct flow_action *actions, + struct netlink_ext_ack *extack); int cxgb4_tc_flower_replace(struct net_device *dev, struct flow_cls_offload *cls); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c index 1b7681a4eb32..d80dee4d316d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c @@ -286,7 +286,8 @@ int cxgb4_tc_matchall_replace(struct net_device *dev, } ret = cxgb4_validate_flow_actions(dev, - &cls_matchall->rule->action); + &cls_matchall->rule->action, + extack); if (ret) return ret; diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c index 35478cba2aa5..0a0c6ec2336c 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c @@ -1082,6 +1082,9 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port, u8 qh, ql, pmap; int index, ctx; + if (!flow_action_basic_hw_stats_types_check(&rule->flow->action, NULL)) + return -EOPNOTSUPP; + memset(&c2, 0, sizeof(c2)); index = mvpp2_cls_c2_port_flow_index(port, rule->loc); @@ -1305,6 +1308,9 @@ static int mvpp2_cls_rfs_parse_rule(struct mvpp2_rfs_rule *rule) struct flow_rule *flow = rule->flow; struct flow_action_entry *act; + if (!flow_action_basic_hw_stats_types_check(&rule->flow->action, NULL)) + return -EOPNOTSUPP; + act = &flow->action.entries[0]; if (act->id != FLOW_ACTION_QUEUE && act->id != FLOW_ACTION_DROP) return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 4eb2f2392d2d..cfe393cb4026 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2878,6 +2878,9 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, if (!flow_action_has_entries(flow_action)) return -EINVAL; + if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + return -EOPNOTSUPP; + attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; flow_action_for_each(i, act, flow_action) { @@ -3330,6 +3333,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, if (!flow_action_has_entries(flow_action)) return -EINVAL; + if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, flow_action) { switch (act->id) { case FLOW_ACTION_DROP: @@ -4148,6 +4154,9 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv, return -EOPNOTSUPP; } + if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, flow_action) { switch (act->id) { case FLOW_ACTION_POLICE: diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 8986f209e981..6d84173373c7 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -17,6 +17,10 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f, if (!flow_offload_has_one_action(&f->rule->action)) return -EOPNOTSUPP; + if (!flow_action_basic_hw_stats_types_check(&f->rule->action, + f->common.extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, a, &f->rule->action) { switch (a->id) { case FLOW_ACTION_DROP: diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index c06600fb47ff..4aa7346cb040 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -1207,6 +1207,10 @@ int nfp_flower_compile_action(struct nfp_app *app, bool pkt_host = false; u32 csum_updated = 0; + if (!flow_action_basic_hw_stats_types_check(&flow->rule->action, + extack)) + return -EOPNOTSUPP; + memset(nfp_flow->action_data, 0, NFP_FL_MAX_A_SIZ); nfp_flow->meta.act_len = 0; tun_type = NFP_FL_TUNNEL_NONE; diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index d1ce4531d01a..6505f7e2d1db 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -1746,7 +1746,8 @@ int qede_get_arfs_filter_count(struct qede_dev *edev) } static int qede_parse_actions(struct qede_dev *edev, - struct flow_action *flow_action) + struct flow_action *flow_action, + struct netlink_ext_ack *extack) { const struct flow_action_entry *act; int i; @@ -1756,6 +1757,9 @@ static int qede_parse_actions(struct qede_dev *edev, return -EINVAL; } + if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, flow_action) { switch (act->id) { case FLOW_ACTION_DROP: @@ -1970,7 +1974,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto, } /* parse tc actions and get the vf_id */ - if (qede_parse_actions(edev, &f->rule->action)) + if (qede_parse_actions(edev, &f->rule->action, f->common.extack)) goto unlock; if (qede_flow_find_fltr(edev, &t)) { @@ -2038,7 +2042,7 @@ static int qede_flow_spec_validate(struct qede_dev *edev, return -EINVAL; } - if (qede_parse_actions(edev, flow_action)) + if (qede_parse_actions(edev, flow_action, NULL)) return -EINVAL; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 7a01dee2f9a8..a0e6118444b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -367,7 +367,8 @@ static int tc_setup_cbs(struct stmmac_priv *priv, static int tc_parse_flow_actions(struct stmmac_priv *priv, struct flow_action *action, - struct stmmac_flow_entry *entry) + struct stmmac_flow_entry *entry, + struct netlink_ext_ack *extack) { struct flow_action_entry *act; int i; @@ -375,6 +376,9 @@ static int tc_parse_flow_actions(struct stmmac_priv *priv, if (!flow_action_has_entries(action)) return -EINVAL; + if (!flow_action_basic_hw_stats_types_check(action, extack)) + return -EOPNOTSUPP; + flow_action_for_each(i, act, action) { switch (act->id) { case FLOW_ACTION_DROP: @@ -530,7 +534,8 @@ static int tc_add_flow(struct stmmac_priv *priv, return -ENOENT; } - ret = tc_parse_flow_actions(priv, &rule->action, entry); + ret = tc_parse_flow_actions(priv, &rule->action, entry, + cls->common.extack); if (ret) return ret; diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 93d17f37e980..8b40f612a565 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -251,6 +252,66 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action) return action->num_entries == 1; } +static inline bool +flow_action_mixed_hw_stats_types_check(const struct flow_action *action, + struct netlink_ext_ack *extack) +{ + const struct flow_action_entry *action_entry; + u8 uninitialized_var(last_hw_stats_type); + int i; + + if (flow_offload_has_one_action(action)) + return true; + + for (i = 0; i < action->num_entries; i++) { + action_entry = &action->entries[i]; + if (i && action_entry->hw_stats_type != last_hw_stats_type) { + NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported"); + return false; + } + last_hw_stats_type = action_entry->hw_stats_type; + } + return true; +} + +static inline const struct flow_action_entry * +flow_action_first_entry_get(const struct flow_action *action) +{ + WARN_ON(!flow_action_has_entries(action)); + return &action->entries[0]; +} + +static inline bool +flow_action_hw_stats_types_check(const struct flow_action *action, + struct netlink_ext_ack *extack, + u8 allowed_hw_stats_type) +{ + const struct flow_action_entry *action_entry; + + if (!flow_action_has_entries(action)) + return true; + if (!flow_action_mixed_hw_stats_types_check(action, extack)) + return false; + action_entry = flow_action_first_entry_get(action); + if (allowed_hw_stats_type == 0 && + action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) { + NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\""); + return false; + } else if (allowed_hw_stats_type != 0 && + action_entry->hw_stats_type != allowed_hw_stats_type) { + NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type"); + return false; + } + return true; +} + +static inline bool +flow_action_basic_hw_stats_types_check(const struct flow_action *action, + struct netlink_ext_ack *extack) +{ + return flow_action_hw_stats_types_check(action, extack, 0); +} + #define flow_action_for_each(__i, __act, __actions) \ for (__i = 0, __act = &(__actions)->entries[0]; __i < (__actions)->num_entries; __act = &(__actions)->entries[++__i]) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 79d9b4384d7b..fca9bfa8437e 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -865,6 +865,10 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev, if (!flow_offload_has_one_action(&cls->rule->action)) return err; + if (!flow_action_basic_hw_stats_types_check(&cls->rule->action, + cls->common.extack)) + return err; + act = &cls->rule->action.entries[0]; if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) { From patchwork Sat Mar 7 11:40:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 222879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72ECCC10F00 for ; Sat, 7 Mar 2020 11:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48CAB2073C for ; Sat, 7 Mar 2020 11:40:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="d5N2ZSOn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgCGLkr (ORCPT ); Sat, 7 Mar 2020 06:40:47 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39690 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbgCGLke (ORCPT ); Sat, 7 Mar 2020 06:40:34 -0500 Received: by mail-wm1-f68.google.com with SMTP id f7so655878wml.4 for ; Sat, 07 Mar 2020 03:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZV1OAjtFuFntGAAt75OOGrGInSNGoLqWj92PEA7sZXE=; b=d5N2ZSOnrP0LnZVuTGwASi0mIFi5CxAr2oBobRn0srV9ET4zbSPi2K9H0Qc2sZMily dkBiU32uHCIvGGrTuIMSr678Q0V4H1HWF0sToz1OiplHDe2iu/+s+VpHo+QTJNrFVrWm 3olY1XTKwehGu0K8na0+fckWTLe1/l9WLMsvxwv54kmgCXQnyoV5nWNHfygnab2QsRCp /bLr+E74yTOW7S0xfKmsLIVl5cpD4guy/6LZ9h7+iJibxAZx5rLdhltMpU2f4fJYxJr2 /Tz+pnsaXbAbVsLNuhirI+QgZYDccx9ojewL/GG5uD/mmXJYbhODp9hPZSx1UCqO9M65 oLqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZV1OAjtFuFntGAAt75OOGrGInSNGoLqWj92PEA7sZXE=; b=NUfC8TW3dISy6IwfSwZDcIhqKS4vD6P+IkRItHCFepmbAhSBvVM5lFFabvV51XT1TD L6KQUZyZXlyhgKwBJY6Z+nvH9XNFZCKGjGZA/y2CD65w91DRiVMLgNP0L0WLrxGRoipl MlByuSlyNvVtJTQCYKYnW9mCYI6ogVZYkWjwUo2tUh9FIpkkpcnEYMpnwPPsiDnsxSL5 9aFekkJiOeVSsRY7vB4ggglxyAYHDLfPu/ozkWIk6YmfLVOKeh+WMmrfMHQer6Rm2600 d1w1Ul5UOcjn6HXmDLv0mLywPGYdTFZy9TkCstUKGHAw/4rizSlkU94kqsMhLjsPlOXQ JRvg== X-Gm-Message-State: ANhLgQ3Lf3U+0B1YtbJPQuJHL/FDFlQhevTaK/OvxvtovHgKfG0yu5uJ IeLr+tfR8DqyqlvYBPa3oPwU1exS2ZA= X-Google-Smtp-Source: ADFU+vsMihhcjHbyf79C3QEjJ3tsHSS97pf7jhi2QqbrZX/IjrT/hZC+aWScIQj/6LRC4yAmb/vPig== X-Received: by 2002:a1c:e0d6:: with SMTP id x205mr8969620wmg.29.1583581232549; Sat, 07 Mar 2020 03:40:32 -0800 (PST) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id q16sm37784516wrj.73.2020.03.07.03.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 03:40:32 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, saeedm@mellanox.com, leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com, jeffrey.t.kirsher@intel.com, idosch@mellanox.com, aelior@marvell.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, ecree@solarflare.com, mlxsw@mellanox.com Subject: [patch net-next v4 07/10] flow_offload: introduce "delayed" HW stats type and allow it in mlx5 Date: Sat, 7 Mar 2020 12:40:17 +0100 Message-Id: <20200307114020.8664-8-jiri@resnulli.us> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200307114020.8664-1-jiri@resnulli.us> References: <20200307114020.8664-1-jiri@resnulli.us> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Introduce new type for delayed HW stats and allow the value in mlx5 offload. Signed-off-by: Jiri Pirko --- v2->v3: - converted to newly introduced flow_action_hw_stats_types_check() - moved to bitfield v1->v2: - moved to action - fixed c&p error in patch description --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++-- include/net/flow_offload.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index cfe393cb4026..cdc63dd59867 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2878,7 +2878,8 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, if (!flow_action_has_entries(flow_action)) return -EINVAL; - if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + if (!flow_action_hw_stats_types_check(flow_action, extack, + FLOW_ACTION_HW_STATS_TYPE_DELAYED)) return -EOPNOTSUPP; attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; @@ -3333,7 +3334,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, if (!flow_action_has_entries(flow_action)) return -EINVAL; - if (!flow_action_basic_hw_stats_types_check(flow_action, extack)) + if (!flow_action_hw_stats_types_check(flow_action, extack, + FLOW_ACTION_HW_STATS_TYPE_DELAYED)) return -EOPNOTSUPP; flow_action_for_each(i, act, flow_action) { diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 6580c58b368f..1b6500f0fbca 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -156,7 +156,9 @@ enum flow_action_mangle_base { }; #define FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE BIT(0) -#define FLOW_ACTION_HW_STATS_TYPE_ANY FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE +#define FLOW_ACTION_HW_STATS_TYPE_DELAYED BIT(1) +#define FLOW_ACTION_HW_STATS_TYPE_ANY (FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE | \ + FLOW_ACTION_HW_STATS_TYPE_DELAYED) typedef void (*action_destr)(void *priv); From patchwork Sat Mar 7 11:40:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 222881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6575AC10F00 for ; Sat, 7 Mar 2020 11:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39CE52073C for ; Sat, 7 Mar 2020 11:40:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="vzcCkD9y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726319AbgCGLkk (ORCPT ); Sat, 7 Mar 2020 06:40:40 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43520 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbgCGLkg (ORCPT ); Sat, 7 Mar 2020 06:40:36 -0500 Received: by mail-wr1-f66.google.com with SMTP id v9so5346211wrf.10 for ; Sat, 07 Mar 2020 03:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hRRmxLuEk05sgVp2at+yzser7wFMFga5gusCRSow7xo=; b=vzcCkD9yJjkbxtuu29+WVliQFxZVKF/W3mBsd7id7nQyurtBwQyiBjd/6rM+xkt9oU 1o0LRe1Ut5jwqJKI9GYaHYafucV2zvAV+nFA+JiL5qCHdQlQXupHiYxjaTmZjVGvnqaP AynMVgx0WlVyjnat8VzUxZ6WHARF2zvWtLTbzpNP4k5ZR5NFMeeloyk5RYuk/D0PUnSc 1rso+fouMxC8qTs1DF2jcl7qOj/SLlixt2JIR0yTFiEJlDRrC9OOrijtVgF23LUROFfg SbDSrvesxsfUnwHxBjkwXXd/MFqS6N0EGlAR2X8LJye6JSWg4mixHYwW+BKlwtPnSHn7 fArQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hRRmxLuEk05sgVp2at+yzser7wFMFga5gusCRSow7xo=; b=DGLr9lX9boIAFNnSD/SJ2KWHbCGrkY98THJFnKfKhmDVy15Wfp8tyZijn26gpNlvNi rxExICLBao5iK1KIqwND5HM6ofLsMWuktyqHrvoUBemSPGuQJSrNV083zLRDuzMhSTKD FOxP5j5FTWe1o+rvYysAWjb4cZJh4IOlD+xNKNBw0XAWxhKHZMqYhayEsRGMxQlbfO24 P319bxwhlF6a8/i76xOxnUF0rwPsuSfgZKCzp7UjVKngz6UlylHXmWFR1GguD9YznNYm S/BbL66TCU5V0F/svGh/l/M3RE+rQ7DfBZp1L6XL2GwoZBvIYCWsJ50pGZ+weT08N3Iu jlAg== X-Gm-Message-State: ANhLgQ08bTapUnO52XciDxjGtqobMCI+F8u1Zf2+eC4pXwMbwGjXqzW1 YPebTBmdhSxqhMQnYkyXDG6mdOAtRbs= X-Google-Smtp-Source: ADFU+vtFdlKTWvvZH/PHPyFaflaB40UggfuxualxIGXCyl8nT8eUXzOGzF+u9T5paja181Bvy8Lkqw== X-Received: by 2002:a5d:5089:: with SMTP id a9mr9598318wrt.187.1583581234743; Sat, 07 Mar 2020 03:40:34 -0800 (PST) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id u17sm28679525wrq.74.2020.03.07.03.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 03:40:34 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, saeedm@mellanox.com, leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com, jeffrey.t.kirsher@intel.com, idosch@mellanox.com, aelior@marvell.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, ecree@solarflare.com, mlxsw@mellanox.com Subject: [patch net-next v4 09/10] flow_offload: introduce "disabled" HW stats type and allow it in mlxsw Date: Sat, 7 Mar 2020 12:40:19 +0100 Message-Id: <20200307114020.8664-10-jiri@resnulli.us> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200307114020.8664-1-jiri@resnulli.us> References: <20200307114020.8664-1-jiri@resnulli.us> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Introduce new type for disabled HW stats and allow the value in mlxsw offload. Signed-off-by: Jiri Pirko --- v2->v3: - moved to bitfield v1->v2: - moved to action --- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- include/net/flow_offload.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index 4bf3ac1cb20d..88aa554415df 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -36,7 +36,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack); if (err) return err; - } else { + } else if (act->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_DISABLED) { NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type"); return -EOPNOTSUPP; } diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 1b6500f0fbca..64807aa03cee 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -159,6 +159,7 @@ enum flow_action_mangle_base { #define FLOW_ACTION_HW_STATS_TYPE_DELAYED BIT(1) #define FLOW_ACTION_HW_STATS_TYPE_ANY (FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE | \ FLOW_ACTION_HW_STATS_TYPE_DELAYED) +#define FLOW_ACTION_HW_STATS_TYPE_DISABLED 0 typedef void (*action_destr)(void *priv); From patchwork Sat Mar 7 11:40:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 222880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C31AEC10F26 for ; Sat, 7 Mar 2020 11:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 939002073C for ; Sat, 7 Mar 2020 11:40:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="zxLSOppQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgCGLko (ORCPT ); Sat, 7 Mar 2020 06:40:44 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36965 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgCGLki (ORCPT ); Sat, 7 Mar 2020 06:40:38 -0500 Received: by mail-wr1-f65.google.com with SMTP id 6so5375743wre.4 for ; Sat, 07 Mar 2020 03:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Rmi0sC4ZOb9CTz7dqsCHikMLwzkdKpWFb8GwbJ6WJU=; b=zxLSOppQkPveFaJj0bkTAiodNFRgOwrZGNqrn1rExnqVbpxDs9ttokJzyRhO4j8g5l lKHARsYOjr8/dYopuBEoFE2qm/232JfMn9mxpzfFMu44br2+R1AgN+6MTe9BRKpQd6gd xU8oFWDY7hli9VDBam3QlwSPcpktQFUlVlRp5eFYnRUbgor6JnzJr3YTTcIf21w0z5zH iMcLX7rSFMnyEvSvU7PSBTnPMdtsRlW0Z1MsZASqMlA/n+ns4zc89HZjopskALCj4pAU aKP/yuRucPG4HmGuRNWzKu7Uzed6ndjiSmyVAOoLiLsc8nQqh09wKAw0OiQ0tXiCYMIl CUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Rmi0sC4ZOb9CTz7dqsCHikMLwzkdKpWFb8GwbJ6WJU=; b=hc7jvjckbG3IHggtXLV552b5CevageXlzPrCGqZhhZyKb/Pv4xEWtwIDE/ponKmiv7 0uVyVZCWjTeAhd/DrIiCrjjwE0ylOBqKXaTfCxmMG7LY758pSU4271yLtgMhhBK5FgAz YqVmaiboKvr79TwIeZW5+m8L95aYHPTOJFjuKHHa8boLDrilKz1sQkNnTUTj/YJyjpBm gflZyTZ4Vg2EJbjfr2y6RTEnHHNbYdnQo9QxwSwzQ3XrUb6LLzbz8bwadPvPj+BOSiPG qrOPSp/+nVwXRPZFkc2lStY2v0Gxpq1Pmn2faGPnwQsnE120HaEkT5uY9WBLcoFRcqkj Uw2Q== X-Gm-Message-State: ANhLgQ3gIVA+0hoAd6Bmpzb6kWwpqnzir5aMJJOLfgb/Iv9lT0J5OXBR MqnlM/UNsu+5rJKL0YehpXRTxdDUGCo= X-Google-Smtp-Source: ADFU+vvrtXXZB8thO4RSs46E5+eXWlUgSOIzn27OOV9wK7GPDoVJkl9yM1loRDwTwu8JZkU5JwAhlw== X-Received: by 2002:a5d:4104:: with SMTP id l4mr7770344wrp.55.1583581235906; Sat, 07 Mar 2020 03:40:35 -0800 (PST) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id r28sm55453943wra.16.2020.03.07.03.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 03:40:35 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, saeedm@mellanox.com, leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com, jeffrey.t.kirsher@intel.com, idosch@mellanox.com, aelior@marvell.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, ecree@solarflare.com, mlxsw@mellanox.com Subject: [patch net-next v4 10/10] sched: act: allow user to specify type of HW stats for a filter Date: Sat, 7 Mar 2020 12:40:20 +0100 Message-Id: <20200307114020.8664-11-jiri@resnulli.us> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200307114020.8664-1-jiri@resnulli.us> References: <20200307114020.8664-1-jiri@resnulli.us> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Currently, user who is adding an action expects HW to report stats, however it does not have exact expectations about the stats types. That is aligned with TCA_ACT_HW_STATS_TYPE_ANY. Allow user to specify the type of HW stats for an action and require it. Pass the information down to flow_offload layer. Signed-off-by: Jiri Pirko --- v2->v3: - removed "mixed" bool init - moved to bitfield - removed "inline" v1->v2: - moved the stats attr from cls_flower (filter) to any action - rebased on top of cookie offload changes - adjusted the patch description a bit --- include/net/act_api.h | 4 ++++ include/uapi/linux/pkt_cls.h | 22 ++++++++++++++++++++++ net/sched/act_api.c | 36 ++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 7 +++++++ 4 files changed, 69 insertions(+) diff --git a/include/net/act_api.h b/include/net/act_api.h index 71347a90a9d1..41337c7fc728 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -41,6 +41,7 @@ struct tc_action { struct tc_cookie __rcu *act_cookie; struct tcf_chain __rcu *goto_chain; u32 tcfa_flags; + u8 hw_stats_type; }; #define tcf_index common.tcfa_index #define tcf_refcnt common.tcfa_refcnt @@ -52,6 +53,9 @@ struct tc_action { #define tcf_rate_est common.tcfa_rate_est #define tcf_lock common.tcfa_lock +#define TCA_ACT_HW_STATS_TYPE_ANY (TCA_ACT_HW_STATS_TYPE_IMMEDIATE | \ + TCA_ACT_HW_STATS_TYPE_DELAYED) + /* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice. */ diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 449a63971451..81cc1a869588 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -17,6 +17,7 @@ enum { TCA_ACT_PAD, TCA_ACT_COOKIE, TCA_ACT_FLAGS, + TCA_ACT_HW_STATS_TYPE, __TCA_ACT_MAX }; @@ -24,6 +25,27 @@ enum { * actions stats. */ +/* tca HW stats type + * When user does not pass the attribute, he does not care. + * It is the same as if he would pass the attribute with + * all supported bits set. + * In case no bits are set, user is not interested in getting any HW statistics. + */ +#define TCA_ACT_HW_STATS_TYPE_IMMEDIATE (1 << 0) /* Means that in dump, user + * gets the current HW stats + * state from the device + * queried at the dump time. + */ +#define TCA_ACT_HW_STATS_TYPE_DELAYED (1 << 1) /* Means that in dump, user gets + * HW stats that might be out + * of date for some time, maybe + * couple of seconds. This is + * the case when driver polls + * stats updates periodically + * or when it gets async stats update + * from the device. + */ + #define TCA_ACT_MAX __TCA_ACT_MAX #define TCA_OLD_COMPAT (TCA_ACT_MAX+1) #define TCA_ACT_MAX_PRIO 32 diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 8c466a712cda..aa7b737fed2e 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -185,6 +185,7 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act) return nla_total_size(0) /* action number nested */ + nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */ + cookie_len /* TCA_ACT_COOKIE */ + + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_HW_STATS_TYPE */ + nla_total_size(0) /* TCA_ACT_STATS nested */ + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_FLAGS */ /* TCA_STATS_BASIC */ @@ -788,6 +789,17 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) } rcu_read_unlock(); + if (a->hw_stats_type != TCA_ACT_HW_STATS_TYPE_ANY) { + struct nla_bitfield32 hw_stats_type = { + a->hw_stats_type, + TCA_ACT_HW_STATS_TYPE_ANY, + }; + + if (nla_put(skb, TCA_ACT_HW_STATS_TYPE, sizeof(hw_stats_type), + &hw_stats_type)) + goto nla_put_failure; + } + if (a->tcfa_flags) { struct nla_bitfield32 flags = { a->tcfa_flags, a->tcfa_flags, }; @@ -854,7 +866,23 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) return c; } +static u8 tcf_action_hw_stats_type_get(struct nlattr *hw_stats_type_attr) +{ + struct nla_bitfield32 hw_stats_type_bf; + + /* If the user did not pass the attr, that means he does + * not care about the type. Return "any" in that case + * which is setting on all supported types. + */ + if (!hw_stats_type_attr) + return TCA_ACT_HW_STATS_TYPE_ANY; + hw_stats_type_bf = nla_get_bitfield32(hw_stats_type_attr); + return hw_stats_type_bf.value; +} + static const u32 tca_act_flags_allowed = TCA_ACT_FLAGS_NO_PERCPU_STATS; +static const u32 tca_act_hw_stats_type_allowed = TCA_ACT_HW_STATS_TYPE_ANY; + static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { [TCA_ACT_KIND] = { .type = NLA_STRING }, [TCA_ACT_INDEX] = { .type = NLA_U32 }, @@ -863,6 +891,8 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { [TCA_ACT_OPTIONS] = { .type = NLA_NESTED }, [TCA_ACT_FLAGS] = { .type = NLA_BITFIELD32, .validation_data = &tca_act_flags_allowed }, + [TCA_ACT_HW_STATS_TYPE] = { .type = NLA_BITFIELD32, + .validation_data = &tca_act_hw_stats_type_allowed }, }; struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, @@ -871,6 +901,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, bool rtnl_held, struct netlink_ext_ack *extack) { + u8 hw_stats_type = TCA_ACT_HW_STATS_TYPE_ANY; struct nla_bitfield32 flags = { 0, 0 }; struct tc_action *a; struct tc_action_ops *a_o; @@ -903,6 +934,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, goto err_out; } } + hw_stats_type = + tcf_action_hw_stats_type_get(tb[TCA_ACT_HW_STATS_TYPE]); if (tb[TCA_ACT_FLAGS]) flags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]); } else { @@ -953,6 +986,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, if (!name && tb[TCA_ACT_COOKIE]) tcf_set_action_cookie(&a->act_cookie, cookie); + if (!name) + a->hw_stats_type = hw_stats_type; + /* module count goes up only when brand new policy is created * if it exists and is only bound to in a_o->init() then * ACT_P_CREATED is not returned (a zero is). diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 4e766c5ab77a..e91448640a4f 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3464,6 +3464,10 @@ int tc_setup_flow_action(struct flow_action *flow_action, struct tc_action *act; int i, j, k, err = 0; + BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_ANY != FLOW_ACTION_HW_STATS_TYPE_ANY); + BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_IMMEDIATE != FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE); + BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_DELAYED != FLOW_ACTION_HW_STATS_TYPE_DELAYED); + if (!exts) return 0; @@ -3476,6 +3480,9 @@ int tc_setup_flow_action(struct flow_action *flow_action, err = tcf_act_get_cookie(entry, act); if (err) goto err_out_locked; + + entry->hw_stats_type = act->hw_stats_type; + if (is_tcf_gact_ok(act)) { entry->id = FLOW_ACTION_ACCEPT; } else if (is_tcf_gact_shot(act)) {