From patchwork Sun Mar 28 13:48:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 89967 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0A317A034F; Sun, 28 Mar 2021 15:48:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F22D2140DCF; Sun, 28 Mar 2021 15:48:56 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 7D870140DC9 for ; Sun, 28 Mar 2021 15:48:55 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 28 Mar 2021 16:48:55 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 12SDmlHj018703; Sun, 28 Mar 2021 16:48:54 +0300 From: Xueming Li To: Viacheslav Ovsiienko Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso , Matan Azrad , Shahaf Shuler Date: Sun, 28 Mar 2021 13:48:07 +0000 Message-Id: <1616939297-15627-2-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616939297-15627-1-git-send-email-xuemingl@nvidia.com> References: <1616939297-15627-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 1/9] common/mlx5: sub-function representor port name parsing 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" This patch supports representor name parsing for SF. In sysfs, representor name stored under "phys_port_name" sysfs key, similar to VF representor, switch port name of SF representor is "pfsf". For netlink message, net SF type is supported. Examples: pf0sf1 pf0sf[0-3] Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko --- drivers/common/mlx5/linux/mlx5_common_os.c | 32 +++++++++++++++------- drivers/common/mlx5/linux/mlx5_nl.c | 3 ++ drivers/common/mlx5/mlx5_common.h | 2 ++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 3 ++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 0edd78ea6d..5cf9576921 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -97,22 +97,34 @@ void mlx5_translate_port_name(const char *port_name_in, struct mlx5_switch_info *port_info_out) { - char pf_c1, pf_c2, vf_c1, vf_c2, eol; + char ctrl = 0, pf_c1, pf_c2, vf_c1, vf_c2, eol; char *end; int sc_items; - /* - * Check for port-name as a string of the form pf0vf0 - * (support kernel ver >= 5.0 or OFED ver >= 4.6). - */ + sc_items = sscanf(port_name_in, "%c%d", + &ctrl, &port_info_out->ctrl_num); + if (sc_items == 2 && ctrl == 'c') { + port_name_in++; /* 'c' */ + port_name_in += snprintf(NULL, 0, "%d", + port_info_out->ctrl_num); + } + /* Check for port-name as a string of the form pf0vf0 or pf0sf0 */ sc_items = sscanf(port_name_in, "%c%c%d%c%c%d%c", &pf_c1, &pf_c2, &port_info_out->pf_num, &vf_c1, &vf_c2, &port_info_out->port_name, &eol); - if (sc_items == 6 && - pf_c1 == 'p' && pf_c2 == 'f' && - vf_c1 == 'v' && vf_c2 == 'f') { - port_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_PFVF; - return; + if (sc_items == 6 && pf_c1 == 'p' && pf_c2 == 'f') { + if (vf_c1 == 'v' && vf_c2 == 'f') { + /* Kernel ver >= 5.0 or OFED ver >= 4.6 */ + port_info_out->name_type = + MLX5_PHYS_PORT_NAME_TYPE_PFVF; + return; + } + if (vf_c1 == 's' && vf_c2 == 'f') { + /* Kernel ver >= 5.11 or OFED ver >= 5.1 */ + port_info_out->name_type = + MLX5_PHYS_PORT_NAME_TYPE_PFSF; + return; + } } /* * Check for port-name as a string of the form p0 diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index ef7a521379..752c57b33d 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -746,6 +746,7 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, int i; int ret; + memset(macs, 0, n * sizeof(macs[0])); ret = mlx5_nl_mac_addr_list(nlsk_fd, iface_idx, &macs, &macs_n); if (ret) return; @@ -1158,6 +1159,8 @@ mlx5_nl_check_switch_info(bool num_vf_set, case MLX5_PHYS_PORT_NAME_TYPE_PFHPF: /* Fallthrough */ case MLX5_PHYS_PORT_NAME_TYPE_PFVF: + /* Fallthrough */ + case MLX5_PHYS_PORT_NAME_TYPE_PFSF: /* New representors naming schema. */ switch_info->representor = 1; break; diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 5028a05b49..8eda6749b4 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -151,6 +151,7 @@ enum mlx5_nl_phys_port_name_type { MLX5_PHYS_PORT_NAME_TYPE_UPLINK, /* p0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_PFVF, /* pf0vf0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_PFHPF, /* pf0, kernel ver >= 5.7, HPF rep */ + MLX5_PHYS_PORT_NAME_TYPE_PFSF, /* pf0sf0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN, /* Unrecognized. */ }; @@ -159,6 +160,7 @@ struct mlx5_switch_info { uint32_t master:1; /**< Master device. */ uint32_t representor:1; /**< Representor device. */ enum mlx5_nl_phys_port_name_type name_type; /** < Port name type. */ + int32_t ctrl_num; /**< Controller number (valid for c#pf#vf# format). */ int32_t pf_num; /**< PF number (valid for pfxvfx format only). */ int32_t port_name; /**< Representor port name. */ uint64_t switch_id; /**< Switch identifier. */ diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 0e8de9439e..cb692b22f2 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1013,6 +1013,9 @@ mlx5_sysfs_check_switch_info(bool device_dir, /* New representors naming schema. */ switch_info->representor = 1; break; + default: + switch_info->master = device_dir; + break; } }