From patchwork Thu Sep 12 06:38:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= X-Patchwork-Id: 13801480 Received: from smtp.emenem.pl (cmyk.emenem.pl [217.79.154.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49C513307B; Thu, 12 Sep 2024 06:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.79.154.63 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123177; cv=none; b=GQYar3Rmu6Jj6jIPrdfZYsJvsaOSFhp+ardTs5Jpd/kX/+H1nJu2uL7uUX0RSRwVlIVFJ2B61ri3U0PW8hXuQpIl5urMgpgx9ruQSAv+zE8wMWC9Mg4V5XY4ZBRqAE7RfnLCDD1RF/31IpCJjVlrfAoO0AQx2Qny+pq7HTAFM1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123177; c=relaxed/simple; bh=qMti8TOkF49at/JjjM+2xZd1VDN8ouRs1Xy7zFMILuU=; h=Message-ID:Date:MIME-Version:From:To:Cc:Subject:Content-Type; b=XssP4y+9NQPLgOWUsBoDPJr9Kn5MrEar2ikG4oN7pGlME8FOOCxre1AhbfQR6IvvA0soSqkLw4TRPfmDNx3T2L9LwC560eRxm9ShLjLE9RAlF2J+fXWdaIwPNa1WRK+MbCynSRTPnGGx5UFnLqoA2ovEp83PIOzVhq0LvDvbluk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl; spf=none smtp.mailfrom=ans.pl; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b=ZDlSgDhc; arc=none smtp.client-ip=217.79.154.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ans.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b="ZDlSgDhc" X-Virus-Scanned: amavisd-new at emenem.pl Received: from [192.168.1.10] (c-98-45-176-131.hsd1.ca.comcast.net [98.45.176.131]) (authenticated bits=0) by cmyk.emenem.pl (8.17.1.9/8.17.1.9) with ESMTPSA id 48C6clPq019590 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 12 Sep 2024 08:38:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ans.pl; s=20190507; t=1726123133; bh=EZB+B2jWXk2HnC/1CNaI0I+2FNtEtAYvByasMjqWJb0=; h=Date:From:To:Cc:Subject; b=ZDlSgDhcvucG32W5brufng+MytqdyyQ+LRs2SH4IAmX17BJ5/7OWl7iC3ILRKbvY9 9sAZxQXgIgGrxPh48HrO9GtcvH8mclf5tgvY1KtlRuU2pcKCT55iFYsYqUpst5QAVl +viO25z2spBYFKjSZWp4mvUdofj00YnTHkE8BL/g= Message-ID: <14a24f93-f8d6-4bc7-8b87-86489bcedb28@ans.pl> Date: Wed, 11 Sep 2024 23:38:45 -0700 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= To: Ido Schimmel , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saeed Mahameed , Leon Romanovsky , Yishai Hadas Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org Subject: [PATCH net-next 1/4] mlx4/mlx5: {mlx4,mlx5e}_en_get_module_info cleanup Use SFF8024 constants defined in linux/sfp.h instead of private ones. Make mlx4_en_get_module_info() and mlx5e_get_module_info() to look as close as possible to each other. Simplify the logic for selecting SFF_8436 vs SFF_8636. Signed-off-by: Krzysztof Piotr Oledzki --- .../net/ethernet/mellanox/mlx4/en_ethtool.c | 33 ++++++++++--------- drivers/net/ethernet/mellanox/mlx4/port.c | 9 ++--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 28 +++++++++------- .../net/ethernet/mellanox/mlx5/core/port.c | 9 ++--- include/linux/mlx4/device.h | 7 ---- include/linux/mlx5/port.h | 8 ----- 6 files changed, 44 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index cd17a3f4faf8..4c985d62af12 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "mlx4_en.h" #include "en_port.h" @@ -2029,33 +2030,35 @@ static int mlx4_en_get_module_info(struct net_device *dev, /* Read first 2 bytes to get Module & REV ID */ ret = mlx4_get_module_info(mdev->dev, priv->port, - 0/*offset*/, 2/*size*/, data); + 0 /*offset*/, 2 /*size*/, data); if (ret < 2) return -EIO; - switch (data[0] /* identifier */) { - case MLX4_MODULE_ID_QSFP: - modinfo->type = ETH_MODULE_SFF_8436; + /* data[0] = identifier byte */ + switch (data[0]) { + case SFF8024_ID_QSFP_8438: + modinfo->type = ETH_MODULE_SFF_8436; modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; break; - case MLX4_MODULE_ID_QSFP_PLUS: - if (data[1] >= 0x3) { /* revision id */ - modinfo->type = ETH_MODULE_SFF_8636; - modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; - } else { - modinfo->type = ETH_MODULE_SFF_8436; + case SFF8024_ID_QSFP_8436_8636: + /* data[1] = revision id */ + if (data[1] < 0x3) { + modinfo->type = ETH_MODULE_SFF_8436; modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; + break; } - break; - case MLX4_MODULE_ID_QSFP28: - modinfo->type = ETH_MODULE_SFF_8636; + fallthrough; + case SFF8024_ID_QSFP28_8636: + modinfo->type = ETH_MODULE_SFF_8636; modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; break; - case MLX4_MODULE_ID_SFP: - modinfo->type = ETH_MODULE_SFF_8472; + case SFF8024_ID_SFP: + modinfo->type = ETH_MODULE_SFF_8472; modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; break; default: + netdev_err(dev, "%s: cable type not recognized: 0x%x\n", + __func__, data[0]); return -EINVAL; } diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 4e43f4a7d246..6dbd505e7f30 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -2139,12 +2140,12 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port, return ret; switch (module_id) { - case MLX4_MODULE_ID_SFP: + case SFF8024_ID_SFP: mlx4_sfp_eeprom_params_set(&i2c_addr, &page_num, &offset); break; - case MLX4_MODULE_ID_QSFP: - case MLX4_MODULE_ID_QSFP_PLUS: - case MLX4_MODULE_ID_QSFP28: + case SFF8024_ID_QSFP_8438: + case SFF8024_ID_QSFP_8436_8636: + case SFF8024_ID_QSFP28_8636: mlx4_qsfp_eeprom_params_set(&i2c_addr, &page_num, &offset); break; default: diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 4d123dae912c..12a22e5c60ae 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -32,6 +32,7 @@ #include #include +#include #include "en.h" #include "en/channels.h" @@ -1899,36 +1900,39 @@ static int mlx5e_get_module_info(struct net_device *netdev, { struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5_core_dev *dev = priv->mdev; - int size_read = 0; + int ret; u8 data[4] = {0}; - size_read = mlx5_query_module_eeprom(dev, 0, 2, data); - if (size_read < 2) + /* Read first 2 bytes to get Module & REV ID */ + ret = mlx5_query_module_eeprom(dev, + 0 /*offset*/, 2 /*size*/, data); + if (ret < 2) return -EIO; /* data[0] = identifier byte */ switch (data[0]) { - case MLX5_MODULE_ID_QSFP: + case SFF8024_ID_QSFP_8438: modinfo->type = ETH_MODULE_SFF_8436; modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; break; - case MLX5_MODULE_ID_QSFP_PLUS: - case MLX5_MODULE_ID_QSFP28: + case SFF8024_ID_QSFP_8436_8636: /* data[1] = revision id */ - if (data[0] == MLX5_MODULE_ID_QSFP28 || data[1] >= 0x3) { - modinfo->type = ETH_MODULE_SFF_8636; - modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; - } else { + if (data[1] < 0x3) { modinfo->type = ETH_MODULE_SFF_8436; modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; + break; } + fallthrough; + case SFF8024_ID_QSFP28_8636: + modinfo->type = ETH_MODULE_SFF_8636; + modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; break; - case MLX5_MODULE_ID_SFP: + case SFF8024_ID_SFP: modinfo->type = ETH_MODULE_SFF_8472; modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; break; default: - netdev_err(priv->netdev, "%s: cable type not recognized:0x%x\n", + netdev_err(priv->netdev, "%s: cable type not recognized: 0x%x\n", __func__, data[0]); return -EINVAL; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c index 50931584132b..4258489a5782 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/port.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c @@ -30,6 +30,7 @@ * SOFTWARE. */ +#include #include #include "mlx5_core.h" @@ -425,12 +426,12 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev, return err; switch (module_id) { - case MLX5_MODULE_ID_SFP: + case SFF8024_ID_SFP: mlx5_sfp_eeprom_params_set(&query.i2c_address, &query.page, &offset); break; - case MLX5_MODULE_ID_QSFP: - case MLX5_MODULE_ID_QSFP_PLUS: - case MLX5_MODULE_ID_QSFP28: + case SFF8024_ID_QSFP_8438: + case SFF8024_ID_QSFP_8436_8636: + case SFF8024_ID_QSFP28_8636: mlx5_qsfp_eeprom_params_set(&query.i2c_address, &query.page, &offset); break; default: diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 27f42f713c89..a75bfb2a4438 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -487,13 +487,6 @@ enum { #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK) -enum mlx4_module_id { - MLX4_MODULE_ID_SFP = 0x3, - MLX4_MODULE_ID_QSFP = 0xC, - MLX4_MODULE_ID_QSFP_PLUS = 0xD, - MLX4_MODULE_ID_QSFP28 = 0x11, -}; - enum { /* rl */ MLX4_QP_RATE_LIMIT_NONE = 0, MLX4_QP_RATE_LIMIT_KBS = 1, diff --git a/include/linux/mlx5/port.h b/include/linux/mlx5/port.h index e68d42b8ce65..e9495271160f 100644 --- a/include/linux/mlx5/port.h +++ b/include/linux/mlx5/port.h @@ -40,14 +40,6 @@ enum mlx5_beacon_duration { MLX5_BEACON_DURATION_INF = 0xffff, }; -enum mlx5_module_id { - MLX5_MODULE_ID_SFP = 0x3, - MLX5_MODULE_ID_QSFP = 0xC, - MLX5_MODULE_ID_QSFP_PLUS = 0xD, - MLX5_MODULE_ID_QSFP28 = 0x11, - MLX5_MODULE_ID_DSFP = 0x1B, -}; - enum mlx5_an_status { MLX5_AN_UNAVAILABLE = 0, MLX5_AN_COMPLETE = 1, From patchwork Thu Sep 12 06:40:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= X-Patchwork-Id: 13801481 Received: from smtp.emenem.pl (cmyk.emenem.pl [217.79.154.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B14418BC0F; Thu, 12 Sep 2024 06:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.79.154.63 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123250; cv=none; b=hishDz0cWbTsFgcXPFQEyQFQU56rV+VZDeMsAGYtZM2FLhSGylcJkU2Gm8Bjj/yh9NvlLihw7P8/dwXzFGPcYd1m5OxpxTMo2baIeIldMpmSVsI+F/mVlbdULx22W2fH7H7Rnxn9SyfN82bQOmIOsHwlakG3Qx5ZQiwW8D6oOrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123250; c=relaxed/simple; bh=XMBlrxlCPx0VfV796VkgKFGj4bPWZhKG3tKFHyzrVG4=; h=Message-ID:Date:MIME-Version:From:To:Cc:Subject:Content-Type; b=kVvTY/ztQHwkxR4jSb9+ma+43tp9K2cfFERPH9dBQdU2UdgCoZ2dtruEYHu62o98hEWZ+rPuXmtPgAdlXeA+csn6J+bwGYx45VyaVaTmPgqP9MJXAG8PhuZt4Wh5Or4/J7bqlMFwdcXjiLbo+FYzpHeLxsUc2ilCJhOU6Kito44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl; spf=none smtp.mailfrom=ans.pl; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b=SzrOVy7K; arc=none smtp.client-ip=217.79.154.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ans.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b="SzrOVy7K" X-Virus-Scanned: amavisd-new at emenem.pl Received: from [192.168.1.10] (c-98-45-176-131.hsd1.ca.comcast.net [98.45.176.131]) (authenticated bits=0) by cmyk.emenem.pl (8.17.1.9/8.17.1.9) with ESMTPSA id 48C6eM94019664 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 12 Sep 2024 08:40:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ans.pl; s=20190507; t=1726123226; bh=lJRYyaXMq7ZdxEsduECClyk7Cf2kY7DFi8yM/c0tHXQ=; h=Date:From:To:Cc:Subject; b=SzrOVy7KqkHQkubWe60ZWDZO+gmV/4WBvg/PErmAW+ZQkkYwziLGXocbuJXsvvMEr YOrvQa43Prxbjn8EHyRPXaCNuhQHeEc+sBDEW8Z5Rl2/pwJJgt5Vidt8nNV3m5fuEG ztKfspFRUgMROw8NdNMYFdHgsS45AjbCro5SeeSA= Message-ID: <12a1d143-35d6-43f3-b8b3-ab0198f5540a@ans.pl> Date: Wed, 11 Sep 2024 23:40:21 -0700 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= To: Ido Schimmel , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yishai Hadas Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org Subject: [PATCH net-next 2/4] mlx4: Use MLX4_ATTR_CABLE_INFO instead of 0xFF60 magic value Use MLX4_ATTR_CABLE_INFO instead of 0xFF60 magic value. Also, remove MLX4_ATTR_EXTENDED_PORT_INFO which should have been done in commit 8154c07fe14e ("mlx4_core: Get rid of redundant ext_port_cap flags"). Signed-off-by: Krzysztof Piotr Oledzki --- drivers/net/ethernet/mellanox/mlx4/port.c | 8 ++++---- include/linux/mlx4/device.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 6dbd505e7f30..1ebd459d1d21 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -2052,7 +2052,7 @@ static int mlx4_get_module_id(struct mlx4_dev *dev, u8 port, u8 *module_id) inmad->class_version = 0x1; inmad->mgmt_class = 0x1; inmad->base_version = 0x1; - inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */ + inmad->attr_id = cpu_to_be16(MLX4_ATTR_CABLE_INFO); cable_info = (struct mlx4_cable_info *)inmad->data; cable_info->dev_mem_address = 0; @@ -2071,7 +2071,7 @@ static int mlx4_get_module_id(struct mlx4_dev *dev, u8 port, u8 *module_id) ret = be16_to_cpu(outmad->status); mlx4_warn(dev, "MLX4_CMD_MAD_IFC Get Module ID attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n", - 0xFF60, port, I2C_ADDR_LOW, 0, 1, ret, + MLX4_ATTR_CABLE_INFO, port, I2C_ADDR_LOW, 0, 1, ret, cable_info_mad_err_str(ret)); ret = -ret; goto out; @@ -2170,7 +2170,7 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port, inmad->class_version = 0x1; inmad->mgmt_class = 0x1; inmad->base_version = 0x1; - inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */ + inmad->attr_id = cpu_to_be16(MLX4_ATTR_CABLE_INFO); if (offset < I2C_PAGE_SIZE && offset + size > I2C_PAGE_SIZE) /* Cross pages reads are not allowed @@ -2195,7 +2195,7 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port, ret = be16_to_cpu(outmad->status); mlx4_warn(dev, "MLX4_CMD_MAD_IFC Get Module info attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n", - 0xFF60, port, i2c_addr, offset, size, + MLX4_ATTR_CABLE_INFO, port, i2c_addr, offset, size, ret, cable_info_mad_err_str(ret)); if (i2c_addr == I2C_ADDR_HIGH && diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index a75bfb2a4438..4f2ff466b459 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -265,7 +265,7 @@ enum { }; -#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) +#define MLX4_ATTR_CABLE_INFO 0xff60 enum { MLX4_BMME_FLAG_WIN_TYPE_2B = 1 << 1, From patchwork Thu Sep 12 06:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= X-Patchwork-Id: 13801489 Received: from smtp.emenem.pl (cmyk.emenem.pl [217.79.154.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C72D118952C; Thu, 12 Sep 2024 06:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.79.154.63 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123299; cv=none; b=Y8wzXbE2af6Q4yB3Ako2Dw7OlafJETOyu4W/BRJ4kTXBWZVM+NURr0m1/qO2tSnlQRLhsLqtM1B92m+8DGBiEH8GQkedY6+zKONpX3rV8m7hQD/dfEU8NLn8bWsMurdQc+/s2kfuu3fGDZlP6eKolfeTE+Jv9SCbp7ejD4rym58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123299; c=relaxed/simple; bh=zIrVbo2KbiQUEuSx07s3yuqK2iwfLP6ZlnpOTlHmQh4=; h=Message-ID:Date:MIME-Version:From:To:Cc:Subject:Content-Type; b=q9jkzASvVuvAeU9EghQyzNmP96s6YrSyhU/epYvtfR11i4UckacLW/IrLxHROzgFoUG0XF2zgrf176YzCyUQ3F7ZumhrfENdZE45d3TJsTR6AH1rJ0S8Q9fSgdyK/IiXQ0VhsUJxOJXHlmSSlZedzm9oral4yGyWrqN0j11hn/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl; spf=none smtp.mailfrom=ans.pl; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b=j0l+p40m; arc=none smtp.client-ip=217.79.154.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ans.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b="j0l+p40m" X-Virus-Scanned: amavisd-new at emenem.pl Received: from [192.168.1.10] (c-98-45-176-131.hsd1.ca.comcast.net [98.45.176.131]) (authenticated bits=0) by cmyk.emenem.pl (8.17.1.9/8.17.1.9) with ESMTPSA id 48C6fC48019711 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 12 Sep 2024 08:41:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ans.pl; s=20190507; t=1726123276; bh=J+6fkP0ad5n7/Hr0nrC4Rko89CYV+gxUyBVkcGsfPE8=; h=Date:From:To:Cc:Subject; b=j0l+p40mowfmQdO4uw/+siNe9SeOcm5tiT2Zk78OpI/BzRr571pENBIGtDWN6el/J 3W24m6ZZaUemL8m+mfMwbrGZ+xYjbAwnLkLqsBnXgvCPBnNr60fsc/aOb8rdyeDU11 DsjML8Y1rP0wI84xXzSnKIQNHP/UAUygtB9EvMeQ= Message-ID: <2aa0787e-a148-456e-b1b5-8f1e9785ed04@ans.pl> Date: Wed, 11 Sep 2024 23:41:11 -0700 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= To: Ido Schimmel , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Gal Pressman , Amir Vadai , Saeed Mahameed Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org Subject: [PATCH net-next 3/4] mlx4: Do not mask failure accessing page A2h (0x51) Due to HW/FW limitation, page A2h (I2C 0x51) may not be available. Do not mask the problem so the userspace can properly handle it. When returning the error to the userspace, use -EIO instead of "err" because it holds MAD_STATUS. Fixes: f5826c8c9d57 ("net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure") Fixes: 32a173c7f9e9 ("net/mlx4_core: Introduce mlx4_get_module_info for cable module info reading") Signed-off-by: Krzysztof Piotr Oledzki --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 2 +- drivers/net/ethernet/mellanox/mlx4/port.c | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 4c985d62af12..677917168bd5 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -2094,7 +2094,7 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev, en_err(priv, "mlx4_get_module_info i(%d) offset(%d) bytes_to_read(%d) - FAILED (0x%x)\n", i, offset, ee->len - i, ret); - return ret; + return -EIO; } i += ret; diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 1ebd459d1d21..8c2a384404f9 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -2198,14 +2198,7 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port, MLX4_ATTR_CABLE_INFO, port, i2c_addr, offset, size, ret, cable_info_mad_err_str(ret)); - if (i2c_addr == I2C_ADDR_HIGH && - MAD_STATUS_2_CABLE_ERR(ret) == CABLE_INF_I2C_ADDR) - /* Some SFP cables do not support i2c slave - * address 0x51 (high page), abort silently. - */ - ret = 0; - else - ret = -ret; + ret = -ret; goto out; } cable_info = (struct mlx4_cable_info *)outmad->data; From patchwork Thu Sep 12 06:42:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= X-Patchwork-Id: 13801490 Received: from smtp.emenem.pl (cmyk.emenem.pl [217.79.154.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD168189BB0; Thu, 12 Sep 2024 06:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.79.154.63 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123354; cv=none; b=IxdyMeYoCaA2FEVx8iXpOflxWfHFnL8nYBDpPvDXjceSZkFhQu9hTuBlJRuaGVH/uZk+rkO7/IISFQVTLnWTWxgODcoeM+qtt2DtHdLt2z7VZy/wTWUNyyLbaL+yk/RQHlonOCVMrf1hPUiPI/msDTkeYA+fdXuAEglctLi2d7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726123354; c=relaxed/simple; bh=D5Pn4h1284j4OUOqpZme8DG3ltDWWwpkQMEEd3WMpgI=; h=Message-ID:Date:MIME-Version:From:To:Cc:Subject:Content-Type; b=l6r9wMPnk2a0KASyodxY9aOOc+8OeszgpFzLyOOZvPR0oCyOf3Sris8iKhNfw9I9KbtXCYbmWxR44DQHwUoa7BWWmt+XfGHDUCehlnS8vWR2J+zQ0cpvkw+p++op8xy/VqJoPUlW6dEYOu0RlDHWm0JhHAhiPiF4kpuJeDNZq6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl; spf=none smtp.mailfrom=ans.pl; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b=D8MtRxoK; arc=none smtp.client-ip=217.79.154.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ans.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ans.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ans.pl header.i=@ans.pl header.b="D8MtRxoK" X-Virus-Scanned: amavisd-new at emenem.pl Received: from [192.168.1.10] (c-98-45-176-131.hsd1.ca.comcast.net [98.45.176.131]) (authenticated bits=0) by cmyk.emenem.pl (8.17.1.9/8.17.1.9) with ESMTPSA id 48C6gBPw019738 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 12 Sep 2024 08:42:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ans.pl; s=20190507; t=1726123335; bh=OQCdqXcgMg0VpcDr+sngwSohrYLV13e2sD1Rt2GwKuc=; h=Date:From:To:Cc:Subject; b=D8MtRxoKVDXnXt0bG7GbM4aDlSymXdaKtUepfxG9kS2bIXr60Oj0vkMjA0BcybjRA zKj2ZUfxgAj98uufwJl9oQkZn0uQkFRchWDHEx7UbbYw4N3nZ9A2jq7wrb8FtGw5Jp bDbmRqguon5fCbjHvOUUb9N950gvt4RjitZS+uVw= Message-ID: Date: Wed, 11 Sep 2024 23:42:10 -0700 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: =?utf-8?q?Krzysztof_Ol=C4=99dzki?= To: Ido Schimmel , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yishai Hadas Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org Subject: [PATCH net-next 4/4] mlx4: mlx4_get_port_ib_caps() cleanup Remove magic values and casts from mlx4_get_port_ib_caps() and use proper structures instead. Replace 0x0015 with MLX4_ATTR_PORT_INFO that is named after a similar const from ib_smi.h and because "GetPortInfo MAD" name is also mentioned in the Firmware Release Notes. Use cap_mask name after "struct ib_port_info" given the offset (64 + 20) matches. Signed-off-by: Krzysztof Piotr Oledzki --- drivers/net/ethernet/mellanox/mlx4/port.c | 26 ++++++++++++++--------- include/linux/mlx4/device.h | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 8c2a384404f9..d5109e38cbd5 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -1054,10 +1054,15 @@ int mlx4_unbond_vlan_table(struct mlx4_dev *dev) return ret; } +struct mlx4_mad_port_info { + u8 reserved[20]; + __be32 cap_mask; +}; + int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps) { struct mlx4_cmd_mailbox *inmailbox, *outmailbox; - u8 *inbuf, *outbuf; + struct mlx4_mad_ifc *inmad, *outmad; int err; inmailbox = mlx4_alloc_cmd_mailbox(dev); @@ -1070,20 +1075,21 @@ int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps) return PTR_ERR(outmailbox); } - inbuf = inmailbox->buf; - outbuf = outmailbox->buf; - inbuf[0] = 1; - inbuf[1] = 1; - inbuf[2] = 1; - inbuf[3] = 1; - *(__be16 *) (&inbuf[16]) = cpu_to_be16(0x0015); - *(__be32 *) (&inbuf[20]) = cpu_to_be32(port); + inmad = (struct mlx4_mad_ifc *)(inmailbox->buf); + outmad = (struct mlx4_mad_ifc *)(outmailbox->buf); + + inmad->method = 0x1; /* Get */ + inmad->class_version = 0x1; + inmad->mgmt_class = 0x1; + inmad->base_version = 0x1; + inmad->attr_id = cpu_to_be16(MLX4_ATTR_PORT_INFO); + inmad->attr_mod = cpu_to_be32(port); err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3, MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C, MLX4_CMD_NATIVE); if (!err) - *caps = *(__be32 *) (outbuf + 84); + *caps = ((struct mlx4_mad_port_info *)outmad->data)->cap_mask; mlx4_free_cmd_mailbox(dev, inmailbox); mlx4_free_cmd_mailbox(dev, outmailbox); return err; diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 4f2ff466b459..e64fc35c80b6 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -264,7 +264,7 @@ enum { MLX4_FUNC_CAP_DMFS_A0_STATIC = 1L << 2 }; - +#define MLX4_ATTR_PORT_INFO 0x0015 #define MLX4_ATTR_CABLE_INFO 0xff60 enum {