From patchwork Tue Jan 6 02:54:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: david decotigny X-Patchwork-Id: 425484 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8A6B814009B for ; Tue, 6 Jan 2015 13:56:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932358AbbAFCzx (ORCPT ); Mon, 5 Jan 2015 21:55:53 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:52640 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932248AbbAFCzF (ORCPT ); Mon, 5 Jan 2015 21:55:05 -0500 Received: by mail-ig0-f169.google.com with SMTP id z20so4213610igj.0; Mon, 05 Jan 2015 18:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sb8r4aniH3LqNSBPVgt5vuclP9Sp4izeF36OMo3kTKU=; b=vrESEfQNxJrduaUm1ATQSufBh1wMZ2Z8ooZ5NOhrqTkNV7PsiO9XZ43kY9XTDwX4C+ QSXWOdGArA+yvAwg9QSWVXfmZi1Dv9XVR1JjERf5ryn3oD7JlCGRoHwiEBdE9dxaTpl8 YBXwl4rdnUwmXAp/5mlFMmhTVnPIsW0MdW9FVwXfS22MpTa6ti+YcfUHgeEiH37pwosw v3BEWRHQnEaxQT1INWqC3mGWNE7EejLed4v1nMBEMEMfBCkWVADyIImrErg/qU1o7dhJ QtK/1ou1K2SVTg/uIIB9l5ILM5v/vHQEBL0LKPzBkXMj5gci6rMx6DB+A5uLfk28DvBA +KiA== X-Received: by 10.107.135.34 with SMTP id j34mr81313514iod.84.1420512904329; Mon, 05 Jan 2015 18:55:04 -0800 (PST) Received: from decotigny.mtv.corp.google.com ([172.18.64.159]) by mx.google.com with ESMTPSA id m11sm4450891igt.7.2015.01.05.18.55.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jan 2015 18:55:03 -0800 (PST) From: David Decotigny To: Amir Vadai , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: David Decotigny , "David S. Miller" , Jason Wang , "Michael S. Tsirkin" , Herbert Xu , Al Viro , Ben Hutchings , Masatake YAMATO , Xi Wang , Neil Horman , WANG Cong , Flavio Leitner , Tom Gundersen , Jiri Pirko , Vlad Yasevich , "Eric W. Biederman" , Saeed Mahameed , Venkata Duvvuru , Govindarajulu Varadarajan <_govind@gmx.com> Subject: [PATCH net-next v2 8/8] net: mlx4_en: extend link mode support to 48 bits Date: Mon, 5 Jan 2015 18:54:10 -0800 Message-Id: <1420512850-24699-9-git-send-email-ddecotig@gmail.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com> References: <1420512850-24699-1-git-send-email-ddecotig@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Decotigny Signed-off-by: David Decotigny --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 73 ++++++++++++++++--------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 90e0f04..8ccbe3f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -46,6 +46,11 @@ #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff) #define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff) +static u32 mlx4_en_get_compat_flags(struct net_device *unused_netdev) +{ + return ETH_COMPAT_SUPPORT_LINK_MODE_48b; +} + static int mlx4_en_moderation_update(struct mlx4_en_priv *priv) { int i; @@ -388,7 +393,8 @@ static u32 mlx4_en_autoneg_get(struct net_device *dev) return autoneg; } -static u32 ptys_get_supported_port(struct mlx4_ptys_reg *ptys_reg) +static ethtool_link_mode_mask_t +ptys_get_supported_port(struct mlx4_ptys_reg *ptys_reg) { u32 eth_proto = be32_to_cpu(ptys_reg->eth_proto_cap); @@ -465,7 +471,7 @@ enum ethtool_report { }; /* Translates mlx4 link mode to equivalent ethtool Link modes/speed */ -static u32 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = { +static u64 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = { [MLX4_100BASE_TX] = { SUPPORTED_100baseT_Full, ADVERTISED_100baseT_Full, @@ -558,10 +564,11 @@ static u32 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = { }, }; -static u32 ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report) +static ethtool_link_mode_mask_t +ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report) { int i; - u32 link_modes = 0; + ethtool_link_mode_mask_t link_modes = 0; for (i = 0; i < MLX4_LINK_MODES_SZ; i++) { if (eth_proto & MLX4_PROT_MASK(i)) @@ -570,7 +577,8 @@ static u32 ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report) return link_modes; } -static u32 ethtool2ptys_link_modes(u32 link_modes, enum ethtool_report report) +static u32 ethtool2ptys_link_modes(ethtool_link_mode_mask_t link_modes, + enum ethtool_report report) { int i; u32 ptys_modes = 0; @@ -601,6 +609,9 @@ static int ethtool_get_ptys_settings(struct net_device *dev, struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_ptys_reg ptys_reg; u32 eth_proto; + ethtool_link_mode_mask_t eth_supported; + ethtool_link_mode_mask_t eth_advertising; + ethtool_link_mode_mask_t eth_lp_advertising; int ret; memset(&ptys_reg, 0, sizeof(ptys_reg)); @@ -624,41 +635,44 @@ static int ethtool_get_ptys_settings(struct net_device *dev, en_dbg(DRV, priv, "ptys_reg.eth_proto_lp_adv %x\n", be32_to_cpu(ptys_reg.eth_proto_lp_adv)); - cmd->supported = 0; - cmd->advertising = 0; + eth_supported = 0; + eth_advertising = 0; - cmd->supported |= ptys_get_supported_port(&ptys_reg); + eth_supported |= ptys_get_supported_port(&ptys_reg); eth_proto = be32_to_cpu(ptys_reg.eth_proto_cap); - cmd->supported |= ptys2ethtool_link_modes(eth_proto, SUPPORTED); + eth_supported |= ptys2ethtool_link_modes(eth_proto, SUPPORTED); eth_proto = be32_to_cpu(ptys_reg.eth_proto_admin); - cmd->advertising |= ptys2ethtool_link_modes(eth_proto, ADVERTISED); + eth_advertising |= ptys2ethtool_link_modes(eth_proto, ADVERTISED); - cmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; - cmd->advertising |= (priv->prof->tx_pause) ? ADVERTISED_Pause : 0; + eth_supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; + eth_advertising |= (priv->prof->tx_pause) ? ADVERTISED_Pause : 0; - cmd->advertising |= (priv->prof->tx_pause ^ priv->prof->rx_pause) ? + eth_advertising |= (priv->prof->tx_pause ^ priv->prof->rx_pause) ? ADVERTISED_Asym_Pause : 0; cmd->port = ptys_get_active_port(&ptys_reg); - cmd->transceiver = (SUPPORTED_TP & cmd->supported) ? + cmd->transceiver = (SUPPORTED_TP & eth_supported) ? XCVR_EXTERNAL : XCVR_INTERNAL; if (mlx4_en_autoneg_get(dev)) { - cmd->supported |= SUPPORTED_Autoneg; - cmd->advertising |= ADVERTISED_Autoneg; + eth_supported |= SUPPORTED_Autoneg; + eth_advertising |= ADVERTISED_Autoneg; } cmd->autoneg = (priv->port_state.flags & MLX4_EN_PORT_ANC) ? AUTONEG_ENABLE : AUTONEG_DISABLE; eth_proto = be32_to_cpu(ptys_reg.eth_proto_lp_adv); - cmd->lp_advertising = ptys2ethtool_link_modes(eth_proto, ADVERTISED); + eth_lp_advertising = ptys2ethtool_link_modes(eth_proto, ADVERTISED); - cmd->lp_advertising |= (priv->port_state.flags & MLX4_EN_PORT_ANC) ? + eth_lp_advertising |= (priv->port_state.flags & MLX4_EN_PORT_ANC) ? ADVERTISED_Autoneg : 0; + ethtool_cmd_supported_set(cmd, eth_supported); + ethtool_cmd_advertising_set(cmd, eth_advertising); + ethtool_cmd_lp_advertising_set(cmd, eth_lp_advertising); cmd->phy_address = 0; cmd->mdio_support = 0; cmd->maxtxpkt = 0; @@ -673,27 +687,30 @@ static void ethtool_get_default_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct mlx4_en_priv *priv = netdev_priv(dev); + ethtool_link_mode_mask_t eth_supported, eth_advertising; int trans_type; cmd->autoneg = AUTONEG_DISABLE; - cmd->supported = SUPPORTED_10000baseT_Full; - cmd->advertising = ADVERTISED_10000baseT_Full; + eth_supported = SUPPORTED_10000baseT_Full; + eth_advertising = ADVERTISED_10000baseT_Full; trans_type = priv->port_state.transceiver; if (trans_type > 0 && trans_type <= 0xC) { cmd->port = PORT_FIBRE; cmd->transceiver = XCVR_EXTERNAL; - cmd->supported |= SUPPORTED_FIBRE; - cmd->advertising |= ADVERTISED_FIBRE; + eth_supported |= SUPPORTED_FIBRE; + eth_advertising |= ADVERTISED_FIBRE; } else if (trans_type == 0x80 || trans_type == 0) { cmd->port = PORT_TP; cmd->transceiver = XCVR_INTERNAL; - cmd->supported |= SUPPORTED_TP; - cmd->advertising |= ADVERTISED_TP; + eth_supported |= SUPPORTED_TP; + eth_advertising |= ADVERTISED_TP; } else { cmd->port = -1; cmd->transceiver = -1; } + ethtool_cmd_supported_set(cmd, eth_supported); + ethtool_cmd_advertising_set(cmd, eth_advertising); } static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) @@ -747,13 +764,14 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_ptys_reg ptys_reg; __be32 proto_admin; + const ethtool_link_mode_mask_t eth_adv = ethtool_cmd_advertising(cmd); int ret; - u32 ptys_adv = ethtool2ptys_link_modes(cmd->advertising, ADVERTISED); + u32 ptys_adv = ethtool2ptys_link_modes(eth_adv, ADVERTISED); int speed = ethtool_cmd_speed(cmd); - en_dbg(DRV, priv, "Set Speed=%d adv=0x%x autoneg=%d duplex=%d\n", - speed, cmd->advertising, cmd->autoneg, cmd->duplex); + en_dbg(DRV, priv, "Set Speed=%d adv=0x%llx autoneg=%d duplex=%d\n", + speed, eth_adv, cmd->autoneg, cmd->duplex); if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL) || (cmd->duplex == DUPLEX_HALF)) @@ -1821,6 +1839,7 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev, } const struct ethtool_ops mlx4_en_ethtool_ops = { + .get_compat_flags = mlx4_en_get_compat_flags, .get_drvinfo = mlx4_en_get_drvinfo, .get_settings = mlx4_en_get_settings, .set_settings = mlx4_en_set_settings,