Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6823090ybf; Fri, 6 Mar 2020 05:17:19 -0800 (PST) X-Google-Smtp-Source: ADFU+vv2XRGY5eOZp3Lq2ipZoI6f6svmDXPM/GqXbPRrgcit7xEIfVvfbCoyn0SxwRBbtMOFmwNY X-Received: by 2002:aca:c0c5:: with SMTP id q188mr2402494oif.169.1583500639106; Fri, 06 Mar 2020 05:17:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1583500639; cv=pass; d=google.com; s=arc-20160816; b=v4zweljm+luAqBvnbbHxnCgNTMf2P9lKaaRUkUP74dcILLHBJO7313bwO231IQS2ap kNSbDeB/A98KUzB69kgTtHPszQx0XMmxkJDdTz99hi7oAD8W16RRROFuMySVQRrFMbW2 Jw1iCjjGZak/3MbSnoW0vB8bB/ccoA8h5VzQIqBAxnVFAC4xsvDrCVFsFdz9SzjidNyl HB5H+D2+8kcvGrlpxjpBIZ6TvfVvKr7f+HsYm6qCJGm3uyU7VBe8buxOmwx4CfG5L3GI Q8QjWjfnwVFxAs0e8RgR7QRFUnZ7wGs54j38lXqZkYxyYk3mNMJPF3vi56lnL2V44yaU qPkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VizipyaTKnU2P4ywJ3FLLpRHu2RS9jn8aGVC+cU3ZTE=; b=rEU9oqWu/so+JrlbBM9D4+W2JcPg9GWu4gI3lgCJe13qrDajDNO8CbizimdSAIOmyE xYhCVlrxg4xvRXXFJLo2XLtzfCtAx0GJfUTJ6FQsSIpPupdoPxGDDnUsTk/QUL19yqyA 21srnchNKpbgbsxGq5B4F8CiOTwdw6DJr1KI01+NqZolN+N1Fdp5BV8zXrspG/0Qlunj Yu9hi4Mwyn5J5H5Qx5gjHA6ZQqvgzzpugCNQnwfBUDOw4WDXhQF5jK3zWSHqYglVI/ZD iInK1escclkk4PAfsVl5QeINO5UZvLg+YwIrNF2y7McgqMrZbW75aNmZ8bMUOdl6C3Iq WyJQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=XB4Ps9Da; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si1461911otk.258.2020.03.06.05.17.07; Fri, 06 Mar 2020 05:17:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=XB4Ps9Da; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbgCFNQa (ORCPT + 99 others); Fri, 6 Mar 2020 08:16:30 -0500 Received: from mail-vi1eur05on2043.outbound.protection.outlook.com ([40.107.21.43]:32801 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727023AbgCFNQ3 (ORCPT ); Fri, 6 Mar 2020 08:16:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wy8tNni4htBXW6JxtZu56+2Ta3RWAdBtIVrttjmZiqkpbNOtcsRqpGDW7lWO5zCDQr56rxgkOiwyUljI2Ni9yZucshZXjTZdBQdjmCUMgeH8379etP+KccV+89Ayw/oWhHkvPempgWwoX9jyIs7MFMH/TLxriygdeqRRev6PbTHviNqyFonrSNBlODm0g1lr+lEruELsEH6KMo5aquxVQBH+keGR/XxXp/UfozVKyQwqFWB5uJjV53rMad6ac50afWGDmu+DYQGeJRjhkiPskcIX+tZ6Drfqrhu2FtaefVWR0GX1GEWzlM0D0b2rJHAU23kagNxsX6QDffNq1cZyFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VizipyaTKnU2P4ywJ3FLLpRHu2RS9jn8aGVC+cU3ZTE=; b=VS6PQItVAERMnZb8qDVGn4KfTK6IMTyEeFYw0MVkSkmvW8l0N64jqSU4cAdDFCiAQ2kHmpeA9PRzh0NDJZfjm0nXeHlglfXGKCMiildF5vu7h6KmRuMEKF8LL3A0KiVgNnN1i9N7xJbKlCHzruLH+0elnV82/2ABQpxRQurPue4GKfgYDdDZn12fzG6DZN39WY96JhEvFG08SnNwIw7d87lnWh+zCy5Wcy0j4AuuakM6xA6k/ke5M1svRn+P4asbWPSkXTPiiMvjuhqCTZFyI3idyY6SUV45ClDBltvphyKJQJ52T0CbjHwG2ZwMTsWGFtLnPjuvH1WieD0HWkYKCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VizipyaTKnU2P4ywJ3FLLpRHu2RS9jn8aGVC+cU3ZTE=; b=XB4Ps9DaWnrOR6d04ZGlVbf5bWv6zEnq7mCNnYRS+9kn8heAhzl2xo0VYQD20wDK9W38nXCUtAhrXvt78v0khTvqRvxrtrnWa5BE1jqwBUbSs8YBddaOUTyo98a7lT9tv7HEiGATHS5Nu/tp/5RTeq3AAC/qNI/hQbtgL5dslEY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=po.liu@nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (20.179.232.221) by VE1PR04MB6527.eurprd04.prod.outlook.com (20.179.233.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Fri, 6 Mar 2020 13:16:02 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::8cb8:5c41:d843:b66d]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::8cb8:5c41:d843:b66d%5]) with mapi id 15.20.2772.019; Fri, 6 Mar 2020 13:16:02 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: vinicius.gomes@intel.com, po.liu@nxp.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, alexandru.marginean@nxp.com, xiaoliang.yang_1@nxp.com, roy.zang@nxp.com, mingkai.hu@nxp.com, jerry.huang@nxp.com, leoyang.li@nxp.com, michael.chan@broadcom.com, vishal@chelsio.com, saeedm@mellanox.com, leon@kernel.org, jiri@mellanox.com, idosch@mellanox.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, kuba@kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, john.hurley@netronome.com, simon.horman@netronome.com, pieter.jansenvanvuuren@netronome.com, pablo@netfilter.org, moshe@mellanox.com, ivan.khoronzhuk@linaro.org, m-karicheri2@ti.com, andre.guedes@linux.intel.com, jakub.kicinski@netronome.com, Po Liu Subject: [RFC,net-next 9/9] net: enetc add tc flower offload flow metering policing action Date: Fri, 6 Mar 2020 20:56:07 +0800 Message-Id: <20200306125608.11717-10-Po.Liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200306125608.11717-1-Po.Liu@nxp.com> References: <20200306125608.11717-1-Po.Liu@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR06CA0205.apcprd06.prod.outlook.com (2603:1096:4:68::13) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.73) by SG2PR06CA0205.apcprd06.prod.outlook.com (2603:1096:4:68::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.14 via Frontend Transport; Fri, 6 Mar 2020 13:15:52 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.73] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 640f593a-1267-4403-e319-08d7c1d0846e X-MS-TrafficTypeDiagnostic: VE1PR04MB6527:|VE1PR04MB6527: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-Forefront-PRVS: 0334223192 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(189003)(199004)(16526019)(186003)(26005)(66476007)(6512007)(4326008)(36756003)(66556008)(7416002)(6666004)(86362001)(478600001)(1076003)(81156014)(8936002)(6506007)(316002)(81166006)(956004)(5660300002)(8676002)(66946007)(2906002)(2616005)(6486002)(69590400007)(52116002)(142933001);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR04MB6527;H:VE1PR04MB6496.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M5GfjOwM5MfowSZagdBeDyICZUBIq9QFP92L1XuRH24PaHDLCcNdQRwp3X/UCchDMcJN/cxDOULrSVLf39L5vSvWPmQI7iz60cEI6c8+Ii+mtfQl/g1YOm2x3usSSN0bg37jmdldNY8Do2gO/awC8xlKzXLnraQY+KVrJKyBWuacD5oX3zixR8xVUMjeaiGWAMuwz4Bvcr8vcRIS5ZcgydTxMOnvozmJIdBeAqyKKqA0r1+Vo12+PZhBvEPkcp34hKqGVUy7v/QF04pMmQBuSGOXqW1SPF4dlFfXatOlh+5YGkban7dG+yptzALkxs2JicxGFHDdnthmniVr4lGDiSMabLaAjSRG/ynIhHQvd2v7NTVa8dW6Rc5YSDxqBria6itDB87NrQkGdbXV8P4QH8PUuZaVFO2Faptbm8BqG5FKZmk7AvoEq9/7OVAPX5cKfyJKRx6edsYi85feZ4NaGPSq+8PhOR3Re8zHtriknEjcFyiYfKNhQhXaSrHXgQrRLMLcIG4sCJHDTHzMECP/YA== X-MS-Exchange-AntiSpam-MessageData: 1eCg0Kl/UstswumskmUNb3/MPTR+uU1uL/takuWHCQoY08akXzblzJsHnWrP4PXQfFMWRPhP6gp92FDGOszwrHoeZqDF+hSXwwbb7/w2aGYyBES8AqkQegkFRASsR7KyrVC97ij0lsi38ULpVmKKSA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 640f593a-1267-4403-e319-08d7c1d0846e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2020 13:16:01.9040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mPssARqGALmJdpYf/o6l1zNUf2f1SlH9jAy7BsQpC7dn89i8kBJ3ZjGgI+ZArjWE X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6527 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Flow metering entries in IEEE 802.1Qci is an optional function for a flow filtering module. Flow metering is two rates two buckets and three color marker to policing the frames. This patch only enable one rate one bucket and in color blind mode. Flow metering instance are as specified in the algorithm in MEF 10.3 and in Bandwidth Profile Parameters. They are: a) Flow meter instance identifier. An integer value identifying the flow meter instance. The patch use the police 'index' as thin value. b) Committed Information Rate (CIR), in bits per second. This patch use the 'rate_bytes_ps' represent this value. c) Committed Burst Size (CBS), in octets. This patch use the 'burst' represent this value. d) Excess Information Rate (EIR), in bits per second. e) Excess Burst Size per Bandwidth Profile Flow (EBS), in octets. And plus some other parameters. This patch set EIR/EBS default disable and color blind mode. Signed-off-by: Po Liu --- .../net/ethernet/freescale/enetc/enetc_hw.h | 24 +++ .../net/ethernet/freescale/enetc/enetc_qos.c | 150 ++++++++++++++++-- 2 files changed, 164 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 640099f48a0d..74eac8ea6336 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -573,6 +573,7 @@ enum bdcr_cmd_class { BDCR_CMD_STREAM_IDENTIFY, BDCR_CMD_STREAM_FILTER, BDCR_CMD_STREAM_GCL, + BDCR_CMD_FLOW_METER, __BDCR_CMD_MAX_LEN, BDCR_CMD_MAX_LEN = __BDCR_CMD_MAX_LEN - 1, }; @@ -739,10 +740,33 @@ struct sgcl_data { struct sgce sgcl[0]; }; +#define ENETC_CBDR_FMI_MR BIT(0) +#define ENETC_CBDR_FMI_MREN BIT(1) +#define ENETC_CBDR_FMI_DOY BIT(2) +#define ENETC_CBDR_FMI_CM BIT(3) +#define ENETC_CBDR_FMI_CF BIT(4) +#define ENETC_CBDR_FMI_NDOR BIT(5) +#define ENETC_CBDR_FMI_OALEN BIT(6) +#define ENETC_CBDR_FMI_IRFPP_MASK GENMASK(4, 0) + +/* class 10: command 0/1, Flow Meter Instance Set, short Format */ +struct fmi_conf { + __le32 cir; + __le32 cbs; + __le32 eir; + __le32 ebs; + u8 conf; + u8 res1; + u8 ir_fpp; + u8 res2[4]; + u8 en; +}; + struct enetc_cbd { union{ struct sfi_conf sfi_conf; struct sgi_table sgi_table; + struct fmi_conf fmi_conf; struct { __le32 addr[2]; union { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 278f1603b00a..8670ab395856 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -407,10 +407,26 @@ struct enetc_psfp_gate { struct action_gate_entry entries[0]; }; +/* Only enable the green color frame now + * Will add eir and ebs color blind, couple flag etc when + * policing action add more offloading parameters + */ +struct enetc_psfp_meter { + u32 index; + u32 cir; + u32 cbs; + u32 refcount; + struct hlist_node node; +}; + +#define ENETC_PSFP_FLAGS_FMI BIT(0) + struct enetc_stream_filter { struct enetc_streamid sid; u32 sfi_index; u32 sgi_index; + u32 flags; + u32 fmi_index; struct flow_stats stats; struct hlist_node node; }; @@ -421,6 +437,7 @@ struct enetc_psfp { struct hlist_head stream_list; struct hlist_head psfp_filter_list; struct hlist_head psfp_gate_list; + struct hlist_head psfp_meter_list; spinlock_t psfp_lock; /* spinlock for the struct enetc_psfp r/w */ }; @@ -830,6 +847,47 @@ static int enetc_streamgate_hw_set(struct enetc_ndev_priv *priv, return err; } +static int enetc_flowmeter_hw_set(struct enetc_ndev_priv *priv, + struct enetc_psfp_meter *fmi, + u8 enable) +{ + struct enetc_cbd cbd = { .cmd = 0 }; + struct fmi_conf *fmi_config; + u64 temp = 0; + + cbd.index = cpu_to_le16((u16)fmi->index); + cbd.cls = BDCR_CMD_FLOW_METER; + cbd.status_flags = 0x80; + + if (!enable) + return enetc_send_cmd(priv->si, &cbd); + + fmi_config = &cbd.fmi_conf; + fmi_config->en = 0x80; + + if (fmi->cir) { + temp = (u64)8000 * fmi->cir; + temp = temp / 3725; + } + + fmi_config->cir = cpu_to_le32((u32)temp); + fmi_config->cbs = cpu_to_le32(fmi->cbs); + + /* Default for eir ebs disable */ + fmi_config->eir = 0; + fmi_config->ebs = 0; + + /* Default: + * mark red disable + * drop on yellow disable + * color mode disable + * couple flag disable + */ + fmi_config->conf = 0; + + return enetc_send_cmd(priv->si, &cbd); +} + static struct enetc_stream_filter *enetc_get_stream_by_index(u32 index) { struct enetc_stream_filter *f; @@ -863,6 +921,17 @@ static struct enetc_psfp_filter *enetc_get_filter_by_index(u32 index) return NULL; } +static struct enetc_psfp_meter *enetc_get_meter_by_index(u32 index) +{ + struct enetc_psfp_meter *m; + + hlist_for_each_entry(m, &epsfp.psfp_meter_list, node) + if (m->index == index) + return m; + + return NULL; +} + static struct enetc_psfp_filter *enetc_psfp_check_sfi(struct enetc_psfp_filter *sfi) { @@ -921,9 +990,28 @@ static void reduce_ref_sgi(struct enetc_ndev_priv *priv, u32 index) } } +static void reduce_ref_fmi(struct enetc_ndev_priv *priv, u32 index) +{ + struct enetc_psfp_meter *fmi; + + fmi = enetc_get_meter_by_index(index); + if (fmi) + return; + + fmi->refcount--; + + if (!fmi->refcount) { + enetc_flowmeter_hw_set(priv, fmi, false); + hlist_del(&fmi->node); + kfree(fmi); + } +} + static void remove_one_chain(struct enetc_ndev_priv *priv, struct enetc_stream_filter *filter) { + if (filter->flags & ENETC_PSFP_FLAGS_FMI) + reduce_ref_fmi(priv, filter->fmi_index); reduce_ref_sgi(priv, filter->sgi_index); reduce_ref_sfi(priv, filter->sfi_index); @@ -934,7 +1022,8 @@ static void remove_one_chain(struct enetc_ndev_priv *priv, static int enetc_psfp_hw_set(struct enetc_ndev_priv *priv, struct enetc_streamid *sid, struct enetc_psfp_filter *sfi, - struct enetc_psfp_gate *sgi) + struct enetc_psfp_gate *sgi, + struct enetc_psfp_meter *fmi) { int err; @@ -952,8 +1041,16 @@ static int enetc_psfp_hw_set(struct enetc_ndev_priv *priv, if (err) goto revert_sfi; + if (fmi) { + err = enetc_flowmeter_hw_set(priv, fmi, true); + if (err) + goto revert_sgi; + } + return 0; +revert_sgi: + enetc_streamgate_hw_set(priv, sgi, false); revert_sfi: if (sfi && !sfi->refcount) enetc_streamfilter_hw_set(priv, sfi, false); @@ -981,6 +1078,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, struct flow_rule *rule = flow_cls_offload_flow_rule(f); struct netlink_ext_ack *extack = f->common.extack; struct enetc_stream_filter *filter, *old_filter; + struct enetc_psfp_meter *fmi = NULL, *old_fmi; struct enetc_psfp_filter *sfi, *old_sfi; struct enetc_psfp_gate *sgi, *old_sgi; struct flow_action_entry *entry; @@ -1095,20 +1193,35 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, filter->sgi_index = sgi->index; + /* flow meter */ + if (entryp) { + fmi = kzalloc(sizeof(*fmi), GFP_KERNEL); + if (!fmi) { + err = -ENOMEM; + goto free_gate; + } + fmi->cir = entryp->police.rate_bytes_ps; + fmi->cbs = entryp->police.burst; + fmi->index = entryp->police.index; + filter->flags |= ENETC_PSFP_FLAGS_FMI; + filter->fmi_index = fmi->index; + } + sfi = kzalloc(sizeof(*sfi), GFP_KERNEL); if (!sfi) { err = -ENOMEM; - goto free_gate; + goto free_fmi; } sfi->gate_id = sgi->index; - /* flow meter not support yet */ - sfi->meter_id = ENETC_PSFP_WILDCARD; - /* Max frame size */ - if (entryp) + if (entryp) { sfi->maxsdu = entryp->police.mtu; + sfi->meter_id = fmi->index; + } else { + sfi->meter_id = ENETC_PSFP_WILDCARD; + } /* prio ref the filter prio */ if (f->common.prio && f->common.prio <= BIT(3)) @@ -1140,11 +1253,22 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } err = enetc_psfp_hw_set(priv, &filter->sid, - sfi_overwrite ? NULL : sfi, sgi); + sfi_overwrite ? NULL : sfi, sgi, fmi); if (err) goto free_sfi; spin_lock(&epsfp.psfp_lock); + if (filter->flags & ENETC_PSFP_FLAGS_FMI) { + old_fmi = enetc_get_meter_by_index(filter->fmi_index); + if (old_fmi) { + fmi->refcount = old_fmi->refcount; + hlist_del(&old_fmi->node); + kfree(old_fmi); + } + fmi->refcount++; + hlist_add_head(&fmi->node, &epsfp.psfp_meter_list); + } + old_sgi = enetc_get_gate_by_index(filter->sgi_index); if (old_sgi) { sgi->refcount = old_sgi->refcount; @@ -1177,6 +1301,8 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, free_sfi: kfree(sfi); +free_fmi: + kfree(fmi); free_gate: kfree(sgi); free_filter: @@ -1273,9 +1399,13 @@ static int enetc_psfp_get_stats(struct enetc_ndev_priv *priv, return -EINVAL; spin_lock(&epsfp.psfp_lock); - stats.pkts = counters.matching_frames_count - filter->stats.pkts; - stats.dropped = counters.not_passing_frames_count - - filter->stats.dropped; + stats.pkts = counters.matching_frames_count + + counters.not_passing_sdu_count - + filter->stats.pkts; + stats.dropped = counters.not_passing_frames_count + + counters.not_passing_sdu_count + + counters.red_frames_count - + filter->stats.dropped; stats.lastused = filter->stats.lastused; filter->stats.pkts += stats.pkts; filter->stats.dropped += stats.dropped; -- 2.17.1