From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B553A034E; Mon, 21 Feb 2022 09:28:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8621E40DF6; Mon, 21 Feb 2022 09:28:24 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by mails.dpdk.org (Postfix) with ESMTP id 182FC4068C for ; Mon, 21 Feb 2022 09:28:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pp47zKaSldeUSXeByaQ2u+hEBL4B1xukbK5UlkA4wnOtFMZUwChyiZpNcbPagGa1RLpOxH3bdiJD2cO5ZZr97nW+IZeHH+FBRzEqc5Kd+OITvSvVPGJxEf4arxqQExX1GjaWTDgwcXT97p9GM6z5fTib6Zhd2Sa/lkQLeATLeDv1pMW4LEnKSGpyTxMXmIkjNxWnE1Jtiqptg7Ug/jSifb7Bp7DLp+/HMSWNbDni3QRFrScOvdlsOy4OgqvEYzE7AzY0zd0nXFd2vCN55SCEcDOeZ2bii0weQ32wfJlGJVu4qs2nAbNS871p8jlKqcAKFyFSmGfrkYy/k14x8Of4Pw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tvsEOBIm7jrHDraoYr7xjcS56aRur4W4EqzGZYcTMWY=; b=QEtysUEPA5w1dtXPnrzPVyTh84b6H2F//0deKnkMARR55c9uiijypEyFcMfFdZtqLxopUezlhd3V18j8WHiogvDH/srkPoGsBdmyfZJXtpaE5S+l6rUl64R3ieYmQTlSDqYx+Vu1dcBRh3iezQGKGHe0/yuZ9sP3r2Mhw+VTqRqphkJCaJHsKPeba65uDxzsrNU7Eth53Xg7glQMHCGYQwzt8KH5vt0a2uPRTVe+wWDaQzjfDNFY2MZGAnzF8SD94aTKiYu7RY6ImxpbrAn+g2FZZiD3Z8Ry3ZoOWR5NllxyWqokkT78sAUlPwAMoHtXbPIq00VDaB015jInna3x3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tvsEOBIm7jrHDraoYr7xjcS56aRur4W4EqzGZYcTMWY=; b=pd/cYbIkO9wqW1gxOmj7J5JCh0X3/No+XxR5QDbu26K82enWMe5AnZquj85PqrzXWeyOEjQl/jUl0Gql/vDkhXLrMahxWlrSuoiPj5037iJqjhSUYi166bkRr8QEwNPXPQVOUN47QA/IfyaH+fIHk1eYQtK/O5ItYj8pE5ZtwxAo+67j1Hho6vpFszPmFFgTIjbs7zvzAbsWZUSRQhklFQ1nh6GWd3ALP/RrkfLnWhLfXyxNLt2RLB2xhW5jv9d9LNti4uFCEpUwYqRWk5YT2qd7uAt/XwcTwwUuSYAlkomj1ytNIy6qpchmGNy2RZgObS4v3qAbbNUHzYaO5Wj7iQ== Received: from MW4P223CA0029.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::34) by BN6PR12MB1730.namprd12.prod.outlook.com (2603:10b6:404:ff::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Mon, 21 Feb 2022 08:28:19 +0000 Received: from CO1NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::45) by MW4P223CA0029.outlook.office365.com (2603:10b6:303:80::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.19 via Frontend Transport; Mon, 21 Feb 2022 08:28:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT032.mail.protection.outlook.com (10.13.174.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4995.15 via Frontend Transport; Mon, 21 Feb 2022 08:28:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 21 Feb 2022 08:28:07 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 21 Feb 2022 00:28:03 -0800 From: Haifei Luo To: , , , "Shahaf Shuler" CC: , , Subject: [PATCH] net/mlx5: functions refactor for getting counter's action Date: Mon, 21 Feb 2022 10:27:21 +0200 Message-ID: <20220221082721.49462-1-haifeil@nvidia.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fdd3d38-f2bb-4252-81f7-08d9f5141d2f X-MS-TrafficTypeDiagnostic: BN6PR12MB1730:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qyt0Ds128yt20ZyMARJhViDinIvQGh2C31k0pSGlktfgSKvQr3XpNH9/y4yv+2iH4hQ396viBTErKtF98J3eoPWD2xGVnYno7GxnEEEaAKMMWx6nH0UUlz4QOi/jZFN+aCrq5RfeWEatImUeJiZkqWWiu/D5+blOmgXXBFze4aQ9+RUcbQI8Zid1dDNMa+s/NfcHVhJ6x6PlZBzNWmCPXi2Brlc2WjM+hE5qfUlD2CoER1t20i1yqMcnrSDtXY9WlbgJaoRySTd9O0Qsm6qz3Sl4sNdqJE0tfsETuUbKDu5ha+0A3fzLXZjop0dRjqy/P97Esam5n14Bn2lPHj7Fr+1/hn5bYwnKUw0sOECwKO5beIRpKFPc921JIMlEU3aTFI6/ZTUoncdqvITY13NUnunnmb9O5JX+n8Y/S9NdJNYMuRHAAwK2pdYU+YL0FRQkwWSpTZEjFg1jIcCTq7G7fSdpCstLyiRw6cy9YCDBWqfQ4Xmbuo91WWAJNNs6Xk6HaWtO+7ifI4FZTcpzo8AtOmrcyfDaeQIH3RjG04TDqgzPnUPLyey52I7joteeHrue3VjPWTGf272JY5cr5u8VbNipUvo8HA9YTw+yO5sr9RIfaFU/MFR9zvY6ZKtqHQN4hnqUAP9Cj9YCH7ifbGKIBLviEZNSkq7pdnST48S9uBIxHZvNpIlPFajS0vJ/4QX8Zel7TlMUD4urZLCrLyWk/A== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(1076003)(110136005)(6666004)(70586007)(7696005)(5660300002)(4326008)(186003)(336012)(426003)(26005)(316002)(107886003)(6286002)(508600001)(2616005)(16526019)(70206006)(83380400001)(6636002)(36756003)(47076005)(8676002)(8936002)(356005)(55016003)(36860700001)(2906002)(40460700003)(81166007)(54906003)(82310400004)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2022 08:28:18.6189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fdd3d38-f2bb-4252-81f7-08d9f5141d2f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1730 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Previously API flow_dv_query_count_ptr is defined to get counter's action pointer. This dv function is directly called and the better way is by the callback. Add one arg in API mlx5_counter_query and the related callback counter_query. The added arg is for counter's action pointer. Signed-off-by: Haifei Luo Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 41 ++++++++++++++++--------------- drivers/net/mlx5/mlx5_flow.h | 7 +----- drivers/net/mlx5/mlx5_flow_dv.c | 49 ++++---------------------------------- drivers/net/mlx5/mlx5_flow_meter.c | 2 +- 5 files changed, 28 insertions(+), 73 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 737ad68..c217a7d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1734,7 +1734,7 @@ void mlx5_flow_async_pool_query_handle(struct mlx5_dev_ctx_shared *sh, uint32_t mlx5_counter_alloc(struct rte_eth_dev *dev); void mlx5_counter_free(struct rte_eth_dev *dev, uint32_t cnt); int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt, - bool clear, uint64_t *pkts, uint64_t *bytes); + bool clear, uint64_t *pkts, uint64_t *bytes, void **action); int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow, FILE *file, struct rte_flow_error *error); int save_dump_file(const unsigned char *data, uint32_t size, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 179cc3b..f12ec58 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7797,14 +7797,15 @@ struct mlx5_flow_workspace* */ int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt, - bool clear, uint64_t *pkts, uint64_t *bytes) + bool clear, uint64_t *pkts, uint64_t *bytes, void **action) { const struct mlx5_flow_driver_ops *fops; struct rte_flow_attr attr = { .transfer = 0 }; if (flow_get_drv_type(dev, &attr) == MLX5_FLOW_TYPE_DV) { fops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV); - return fops->counter_query(dev, cnt, clear, pkts, bytes); + return fops->counter_query(dev, cnt, clear, pkts, + bytes, action); } DRV_LOG(ERR, "port %u counter query is not supported.", @@ -8376,6 +8377,16 @@ struct mlx5_flow_workspace* "invalid flow handle"); } handle_idx = flow->dev_handles; + /* query counter */ + if (flow->counter && + (!mlx5_counter_query(dev, flow->counter, false, + &count.hits, &count.bytes, &action)) && action) { + id = (uint64_t)(uintptr_t)action; + type = DR_DUMP_REC_TYPE_PMD_COUNTER; + save_dump_file(NULL, 0, type, + id, (void *)&count, file); + } + while (handle_idx) { dh = mlx5_ipool_get(priv->sh->ipool [MLX5_IPOOL_MLX5_FLOW], handle_idx); @@ -8383,16 +8394,6 @@ struct mlx5_flow_workspace* continue; handle_idx = dh->next.next; - /* query counter */ - type = DR_DUMP_REC_TYPE_PMD_COUNTER; - flow_dv_query_count_ptr(dev, flow->counter, - &action, error); - if (action) { - id = (uint64_t)(uintptr_t)action; - if (!mlx5_flow_query_counter(dev, flow, &count, error)) - save_dump_file(NULL, 0, type, - id, (void *)&count, file); - } /* Get modify_hdr and encap_decap buf from ipools. */ encap_decap = NULL; modify_hdr = dh->dvh.modify_hdr; @@ -8438,7 +8439,7 @@ struct mlx5_flow_workspace* */ static int mlx5_flow_dev_dump_sh_all(struct rte_eth_dev *dev, - FILE *file, struct rte_flow_error *error) + FILE *file, struct rte_flow_error *error __rte_unused) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_ctx_shared *sh = priv->sh; @@ -8523,14 +8524,12 @@ struct mlx5_flow_workspace* max = MLX5_COUNTERS_PER_POOL * cmng->n_valid; for (j = 1; j <= max; j++) { action = NULL; - flow_dv_query_count_ptr(dev, j, &action, error); - if (action) { - if (!flow_dv_query_count(dev, j, &count, error)) { - type = DR_DUMP_REC_TYPE_PMD_COUNTER; - id = (uint64_t)(uintptr_t)action; - save_dump_file(NULL, 0, type, - id, (void *)&count, file); - } + if ((!mlx5_counter_query(dev, j, false, &count.hits, + &count.bytes, &action)) && action) { + id = (uint64_t)(uintptr_t)action; + type = DR_DUMP_REC_TYPE_PMD_COUNTER; + save_dump_file(NULL, 0, type, + id, (void *)&count, file); } } return 0; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 7fec79a..2b53961 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1180,7 +1180,7 @@ typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev, typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev, uint32_t cnt, bool clear, uint64_t *pkts, - uint64_t *bytes); + uint64_t *bytes, void **action); typedef int (*mlx5_flow_get_aged_flows_t) (struct rte_eth_dev *dev, void **context, @@ -1723,11 +1723,6 @@ struct mlx5_list_entry *flow_dv_dest_array_clone_cb(void *tool_ctx, struct mlx5_list_entry *entry, void *cb_ctx); void flow_dv_dest_array_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry); -int flow_dv_query_count_ptr(struct rte_eth_dev *dev, uint32_t cnt_idx, - void **action, struct rte_flow_error *error); -int -flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data, - struct rte_flow_error *error); struct mlx5_aso_age_action *flow_aso_age_get_by_idx(struct rte_eth_dev *dev, uint32_t age_idx); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index ef9c66e..204b045 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15826,7 +15826,7 @@ struct mlx5_list_entry * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -int +static int flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data, struct rte_flow_error *error) { @@ -15864,48 +15864,6 @@ struct mlx5_list_entry * "counters are not available"); } - -/** - * Query counter's action pointer for a DV flow rule via DevX. - * - * @param[in] dev - * Pointer to Ethernet device. - * @param[in] cnt_idx - * Index to the flow counter. - * @param[out] action_ptr - * Action pointer for counter. - * @param[out] error - * Perform verbose error reporting if not NULL. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -int -flow_dv_query_count_ptr(struct rte_eth_dev *dev, uint32_t cnt_idx, - void **action_ptr, struct rte_flow_error *error) -{ - struct mlx5_priv *priv = dev->data->dev_private; - - if (!priv->sh->devx || !action_ptr) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "counters are not supported"); - - if (cnt_idx) { - struct mlx5_flow_counter *cnt = NULL; - cnt = flow_dv_counter_get_by_idx(dev, cnt_idx, NULL); - if (cnt) { - *action_ptr = cnt->action; - return 0; - } - } - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "counters are not available"); -} - static int flow_dv_action_query(struct rte_eth_dev *dev, const struct rte_flow_action_handle *handle, void *data, @@ -17483,7 +17441,7 @@ struct mlx5_list_entry * */ static int flow_dv_counter_query(struct rte_eth_dev *dev, uint32_t counter, bool clear, - uint64_t *pkts, uint64_t *bytes) + uint64_t *pkts, uint64_t *bytes, void **action) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_counter *cnt; @@ -17497,6 +17455,9 @@ struct mlx5_list_entry * if (ret) return -1; cnt = flow_dv_counter_get_by_idx(dev, counter, NULL); + if (cnt && action) + *action = cnt->action; + *pkts = inn_pkts - cnt->hits; *bytes = inn_bytes - cnt->bytes; if (clear) { diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 4f5de5e..b2725db 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -1726,7 +1726,7 @@ struct mlx5_flow_meter_policy * memset(stats, 0, sizeof(*stats)); if (fm->drop_cnt) { ret = mlx5_counter_query(dev, fm->drop_cnt, clear, &pkts, - &bytes); + &bytes, NULL); if (ret) goto error; /* If need to read the packets, set it. */ -- 1.8.3.1