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 711F8A0546; Wed, 7 Apr 2021 08:09:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA929140FF7; Wed, 7 Apr 2021 08:09:37 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 337C6140FF5 for ; Wed, 7 Apr 2021 08:09:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from haifeil@nvidia.com) with SMTP; 7 Apr 2021 09:09:31 +0300 Received: from nvidia.com (gen-l-vrt-173.mtl.labs.mlnx [10.234.173.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 13769O3R027398; Wed, 7 Apr 2021 09:09:31 +0300 From: Haifei Luo To: dev@dpdk.org Cc: orika@nvidia.com, viacheslavo@nvidia.com, rasland@nvidia.com, xuemingl@nvidia.com, haifeil@nvidia.com, Matan Azrad , Shahaf Shuler Date: Wed, 7 Apr 2021 09:09:20 +0300 Message-Id: <1617775762-171898-5-git-send-email-haifeil@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1617775762-171898-1-git-send-email-haifeil@nvidia.com> References: <1615277716-64404-1-git-send-email-haifeil@nvidia.com> <1617775762-171898-1-git-send-email-haifeil@nvidia.com> Subject: [dpdk-dev] [PATCH v2 4/5] net/mlx5: add mlx5 APIs for single flow dump feature 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 Sender: "dev" Modify API mlx5_flow_dev_dump to support the feature. Modify mlx5_socket since one extra arg flow_ptr is added. Signed-off-by: Haifei Luo --- drivers/net/mlx5/linux/mlx5_socket.c | 30 ++++++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c index 6e354f4..2ef837c 100644 --- a/drivers/net/mlx5/linux/mlx5_socket.c +++ b/drivers/net/mlx5/linux/mlx5_socket.c @@ -2,6 +2,10 @@ * Copyright 2019 Mellanox Technologies, Ltd */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include #include #include @@ -29,11 +33,15 @@ { int conn_sock; int ret; + int j; struct cmsghdr *cmsg = NULL; - int data; + #define LENGTH 9 + /* The first byte for port_id and the rest for flowptr. */ + int data[LENGTH]; + uint64_t flow_ptr = 0; char buf[CMSG_SPACE(sizeof(int))] = { 0 }; struct iovec io = { - .iov_base = &data, + .iov_base = &data[0], .iov_len = sizeof(data), }; struct msghdr msg = { @@ -46,7 +54,9 @@ int fd; FILE *file = NULL; struct rte_eth_dev *dev; + struct rte_flow_error err; + memset(data, 0, sizeof(data)); /* Accept the connection from the client. */ conn_sock = accept(server_socket, NULL, NULL); if (conn_sock < 0) { @@ -84,15 +94,23 @@ } /* Dump flow. */ dev = &rte_eth_devices[port_id]; - ret = mlx5_flow_dev_dump(dev, NULL, file, NULL); + /* The first byte in data for port_id and the following 8 for flowptr */ + for (j = 1; j < LENGTH; j++) + flow_ptr = (flow_ptr << 8) + data[j]; + if (flow_ptr == 0) + ret = mlx5_flow_dev_dump(dev, NULL, file, NULL); + else + ret = mlx5_flow_dev_dump(dev, + (struct rte_flow *)((uintptr_t)flow_ptr), file, &err); + /* Set-up the ancillary data and reply. */ msg.msg_controllen = 0; msg.msg_control = NULL; msg.msg_iovlen = 1; msg.msg_iov = &io; - data = -ret; - io.iov_len = sizeof(data); - io.iov_base = &data; + data[0] = -ret; + io.iov_len = sizeof(data[0]); + io.iov_base = &data[0]; do { ret = sendmsg(conn_sock, &msg, 0); } while (ret < 0 && errno == EINTR); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bce6ab2..b68909f 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7183,10 +7183,35 @@ struct mlx5_meter_domains_infos * return -ENOTSUP; } + /*dump all*/ if (!flow_idx) return mlx5_devx_cmd_flow_dump(sh->fdb_domain, - sh->rx_domain, sh->tx_domain, file); - return -ENOTSUP; + sh->rx_domain, + sh->tx_domain, file); + /*dump one*/ + uint32_t handle_idx; + int ret; + struct mlx5_flow_handle *dh; + struct rte_flow *flow = mlx5_ipool_get(priv->sh->ipool + [MLX5_IPOOL_RTE_FLOW], (uintptr_t)(void *)flow_idx); + + if (!flow) + return -ENOENT; + handle_idx = flow->dev_handles; + while (handle_idx) { + dh = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW], + handle_idx); + if (!dh) + return -ENOENT; + if (dh->drv_flow) { + ret = mlx5_devx_cmd_flow_single_dump(dh->drv_flow, + file); + if (ret) + return -ENOENT; + } + handle_idx = dh->next.next; + } + return 0; } /** -- 1.8.3.1