From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id F0E512B98 for ; Sun, 3 Mar 2019 08:44:20 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 3 Mar 2019 09:44:19 +0200 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.128.130.87]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x237iJhp021977; Sun, 3 Mar 2019 09:44:19 +0200 From: Dekel Peled To: yskoh@mellanox.com, shahafs@mellanox.com Cc: dev@dpdk.org, orika@mellanox.com, dekelp@mellanox.com Date: Sun, 3 Mar 2019 09:43:48 +0200 Message-Id: <1551599028-14591-1-git-send-email-dekelp@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551367513-38224-1-git-send-email-dekelp@mellanox.com> References: <1551367513-38224-1-git-send-email-dekelp@mellanox.com> Subject: [dpdk-dev] [PATCH v2] net/mlx5: support new representors' naming format X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Mar 2019 07:44:21 -0000 Kernel update [1] introduce new format of representors names. This patch implements RFC [2], updating MLX5 PMD to support the new format, while maintaining support of the existing format. [1] https://github.com/torvalds/linux/commit/c12ecc2 [2] http://mails.dpdk.org/archives/dev/2019-March/125676.html --- v2: Use public link to kernel patch, add link to RFC. --- Signed-off-by: Dekel Peled --- drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++- drivers/net/mlx5/mlx5_nl.c | 20 +++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 795c9c7..664f485 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size) bool port_name_set = false; bool port_switch_id_set = false; bool device_dir = false; - char c; + char c, pf_c1, pf_c2, vf_c1, vf_c2; + int32_t pf_num; if (!if_indextoname(ifindex, ifname)) { rte_errno = errno; @@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size) file = fopen(phys_port_name, "rb"); if (file != NULL) { + /* Check for port-name as a number (support kernel ver < 5.0 */ port_name_set = fscanf(file, "%d%c", &data.port_name, &c) == 2 && c == '\n'; + if (!port_name_set) { + /* + * Check for port-name as a string of the form pf0vf0 + * (support kernel ver >= 5.0) + */ + port_name_set = (fscanf(file, "%c%c%d%c%c%d%c", &pf_c1, + &pf_c2, &pf_num, &vf_c1, &vf_c2, + &data.port_name, &c) == 7) && + c == '\n'; + } fclose(file); } file = fopen(phys_switch_id, "rb"); diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c index 0bf6845..cc7b4b8 100644 --- a/drivers/net/mlx5/mlx5_nl.c +++ b/drivers/net/mlx5/mlx5_nl.c @@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data { while (off < nh->nlmsg_len) { struct rtattr *ra = (void *)((uintptr_t)nh + off); void *payload = RTA_DATA(ra); - char *end; + char *end, *vf_str; unsigned int i; if (ra->rta_len > nh->nlmsg_len - off) @@ -861,10 +861,20 @@ struct mlx5_nl_ifindex_data { case IFLA_PHYS_PORT_NAME: errno = 0; info.port_name = strtol(payload, &end, 0); - if (errno || - (size_t)(end - (char *)payload) != strlen(payload)) - goto error; - port_name_set = true; + if (errno || ((size_t)(end - (char *)payload) != + strlen(payload))) { + vf_str = strstr(payload, "vf"); + if (vf_str) { + errno = 0; + info.port_name = strtol(vf_str + 2, + &end, 0); + port_name_set = true; + } + if (errno) + goto error; + } else { + port_name_set = true; + } break; case IFLA_PHYS_SWITCH_ID: info.switch_id = 0; -- 1.8.3.1