bnxt_en: Updates for net-next.
Michael Chan
maintainercover bnxt_en: Updates for net-next.
Update to latest firmware interface, add EEE feature, unsupported SFP+ module warning, GEEPROM support, and ethtool -s improvements.
Michael Chan (9):
bnxt_en: Update to Firmware 1.2.2 spec.
bnxt_en: Improve flow control autoneg with Firmware 1.2.1 interface.
bnxt_en: Add basic EEE support.
bnxt_en: Add EEE setup code.
bnxt_en: Add get_eee() and set_eee() ethtool support.
bnxt_en: Set async event bits when registering with the firmware.
bnxt_en: Add unsupported SFP+ module warnings.
bnxt_en: Check for valid forced speed during ethtool -s.
bnxt_en: Improve ethtool .get_settings().
Rob Swindell (1):
bnxt_en: Provide NVM information via Ethtool GEEPROM
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 259 ++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 17 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 222 +++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_fw_hdr.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 433 +++++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 14 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h | 2 +- 9 files changed, 855 insertions(+), 100 deletions(-)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 1/10 bnxt_en: Update to Firmware 1.2.2 spec.
Use new field names in API structs and stop using deprecated fields auto_link_speed and auto_duplex in phy_cfg/phy_qcfg structs.
Update copyright year to 2016.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_fw_hdr.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 433 +++++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 14 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h | 2 +- 9 files changed, 431 insertions(+), 56 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +9 -11
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -2763,7 +2763,7 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)* only checks if it is non-zero to enable async event forwarding */ req.async_event_fwd[0 ] |=cpu_to_le32 (1 ); - req.os_type =cpu_to_le16 (1 ); + req.os_type =cpu_to_le16 (FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX ); req.ver_maj =DRV_VER_MAJ ; req.ver_min =DRV_VER_MIN ; req.ver_upd =DRV_VER_UPD ;
@@ -3726,7 +3726,7 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) pf->fw_fid =le16_to_cpu (resp->fid); pf->port_id =le16_to_cpu (resp->port_id); -memcpy (pf->mac_addr, resp->perm_mac_address,ETH_ALEN ); +memcpy (pf->mac_addr, resp->mac_address,ETH_ALEN );memcpy (bp->dev->dev_addr, pf->mac_addr,ETH_ALEN ); pf->max_rsscos_ctxs =le16_to_cpu (resp->max_rsscos_ctx); pf->max_cp_rings =le16_to_cpu (resp->max_cmpl_rings);
@@ -3751,7 +3751,7 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)struct bnxt_vf_info *vf = &bp->vf; vf->fw_fid =le16_to_cpu (resp->fid); -memcpy (vf->mac_addr, resp->perm_mac_address,ETH_ALEN ); +memcpy (vf->mac_addr, resp->mac_address,ETH_ALEN );if (is_valid_ether_addr (vf->mac_addr))/* overwrite netdev dev_adr with admin VF MAC */ memcpy (bp->dev->dev_addr, vf->mac_addr,ETH_ALEN );
@@ -3842,6 +3842,8 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)memcpy (&bp->ver_resp, resp,sizeof (struct hwrm_ver_get_output )); + bp->hwrm_spec_code = resp->hwrm_intf_maj <<16 | + resp->hwrm_intf_min <<8 | resp->hwrm_intf_upd;if (resp->hwrm_intf_maj <1 ) { netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", resp->hwrm_intf_maj, resp->hwrm_intf_min,
@@ -4523,7 +4525,6 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)else link_info->link_speed =0 ; link_info->force_link_speed =le16_to_cpu (resp->force_link_speed); - link_info->auto_link_speed =le16_to_cpu (resp->auto_link_speed); link_info->support_speeds =le16_to_cpu (resp->support_speeds); link_info->auto_link_speeds =le16_to_cpu (resp->auto_link_speed_mask); link_info->lp_auto_link_speeds =
@@ -4533,8 +4534,8 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state) link_info->phy_ver[1 ] = resp->phy_min; link_info->phy_ver[2 ] = resp->phy_bld; link_info->media_type = resp->media_type; - link_info->transceiver = resp->transceiver_type; - link_info->phy_addr = resp->phy_addr; + link_info->transceiver = resp->xcvr_pkg_type; + link_info->phy_addr = resp->eee_config_phy_addr;/* TODO: need to add more logic to report VF link */ if (chng_link_state) {
@@ -4581,7 +4582,7 @@ static void bnxt_hwrm_set_link_common(struct bnxt *bp,if (autoneg &BNXT_AUTONEG_SPEED ) { req->auto_mode |= -PORT_PHY_CFG_REQ_AUTO_MODE_MASK ; +PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK ; req->enables |=cpu_to_le32 (PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK );
@@ -4595,9 +4596,6 @@ static void bnxt_hwrm_set_link_common(struct bnxt *bp, req->flags |=cpu_to_le32 (PORT_PHY_CFG_REQ_FLAGS_FORCE ); } -/* currently don't support half duplex */ - req->auto_duplex =PORT_PHY_CFG_REQ_AUTO_DUPLEX_FULL ; - req->enables |=cpu_to_le32 (PORT_PHY_CFG_REQ_ENABLES_AUTO_DUPLEX );/* tell chimp that the setting takes effect immediately */ req->flags |=cpu_to_le32 (PORT_PHY_CFG_REQ_FLAGS_RESET_PHY ); }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +4 -4
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -11,7 +11,7 @@#define BNXT_H #define DRV_MODULE_NAME "bnxt_en" -#define DRV_MODULE_VERSION "1.0.0" +#define DRV_MODULE_VERSION "1.2.0"#define DRV_VER_MAJ 1#define DRV_VER_MIN 0
@@ -788,7 +788,7 @@ struct bnxt_link_info {#define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS#define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED#define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW -#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_MASK +#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK#define PHY_VER_LEN 3u8 phy_ver[PHY_VER_LEN ];u16 link_speed;
@@ -813,7 +813,6 @@ struct bnxt_link_info {#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GBu16 lp_auto_link_speeds; -u16 auto_link_speed;u16 force_link_speed;u32 preemphasis;
@@ -940,6 +939,7 @@ struct bnxt {u32 msg_enable; +u32 hwrm_spec_code;u16 hwrm_cmd_seq;u32 hwrm_intr_seq_id;void *hwrm_cmd_resp_addr;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -2
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -728,7 +728,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ethtool_speed =bnxt_fw_to_ethtool_speed (link_info->link_speed);ethtool_cmd_speed_set (cmd, ethtool_speed);if (link_info->transceiver == -PORT_PHY_QCFG_RESP_TRANSCEIVER_TYPE_XCVR_INTERNAL ) +PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_INTERNAL ) cmd->transceiver =XCVR_INTERNAL ;else cmd->transceiver =XCVR_EXTERNAL ;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +1 -1
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
drivers/net/ethernet/broadcom/bnxt/bnxt_fw_hdr.h +1 -1
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +407 -26
749 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h +1 -1
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +5 -9
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -771,12 +771,8 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf) PORT_PHY_QCFG_RESP_LINK_NO_LINK) { phy_qcfg_resp.link =PORT_PHY_QCFG_RESP_LINK_LINK ; -if (phy_qcfg_resp.auto_link_speed) - phy_qcfg_resp.link_speed = - phy_qcfg_resp.auto_link_speed; -else - phy_qcfg_resp.link_speed = - phy_qcfg_resp.force_link_speed; + phy_qcfg_resp.link_speed =cpu_to_le16 ( +PORT_PHY_QCFG_RESP_LINK_SPEED_10GB ); phy_qcfg_resp.duplex =PORT_PHY_QCFG_RESP_DUPLEX_FULL ; phy_qcfg_resp.pause =
@@ -859,8 +855,8 @@ void bnxt_update_vf_mac(struct bnxt *bp)* default but the stored zero MAC will allow the VF user to change * the random MAC address using ndo_set_mac_address() if he wants. */ -if (!ether_addr_equal (resp->perm_mac_address, bp->vf.mac_addr)) -memcpy (bp->vf.mac_addr, resp->perm_mac_address,ETH_ALEN ); +if (!ether_addr_equal (resp->mac_address, bp->vf.mac_addr)) +memcpy (bp->vf.mac_addr, resp->mac_address,ETH_ALEN );/* overwrite netdev dev_addr with admin VF MAC */ if (is_valid_ether_addr (bp->vf.mac_addr))
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h +1 -1
@@ -1,6 +1,6 @@/* Broadcom NetXtreme-C/E network driver. * -* Copyright (c) 2014-2015 Broadcom Corporation +* Copyright (c) 2014-2016 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 3/10 bnxt_en: Add basic EEE support.
In reply to Michael ChanGet EEE capability and the initial EEE settings from firmware. Add "EEE is active | not active" to link up dmesg.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 82 ++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 1 + 4 files changed, 87 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +81 -1
@@ -4488,12 +4488,49 @@ static void bnxt_report_link(struct bnxt *bp) speed =bnxt_fw_to_ethtool_speed (bp->link_info.link_speed);netdev_info (bp->dev,"NIC Link is Up, %d Mbps %s duplex, Flow control: %s\n" , speed, duplex, flow_ctrl); +if (bp->flags &BNXT_FLAG_EEE_CAP ) +netdev_info (bp->dev,"EEE is %s\n" , + bp->eee.eee_active ?"active" : +"not active" ); }else {netif_carrier_off (bp->dev);netdev_err (bp->dev,"NIC Link is Down\n" ); } } +static int bnxt_hwrm_phy_qcaps (struct bnxt *bp) +{ +int rc =0 ; +struct hwrm_port_phy_qcaps_input req = {0 }; +struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr; + +if (bp->hwrm_spec_code <0x10201 ) +return 0 ; + +bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_PORT_PHY_QCAPS ,-1 ,-1 ); + +mutex_lock (&bp->hwrm_cmd_lock); + rc =_hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); +if (rc) + goto hwrm_phy_qcaps_exit; + +if (resp->eee_supported &PORT_PHY_QCAPS_RESP_EEE_SUPPORTED ) { +struct ethtool_eee *eee = &bp->eee; +u16 fw_speeds =le16_to_cpu (resp->supported_speeds_eee_mode); + + bp->flags |=BNXT_FLAG_EEE_CAP ; + eee->supported =_bnxt_fw_to_ethtool_adv_spds (fw_speeds,0 ); + bp->lpi_tmr_lo =le32_to_cpu (resp->tx_lpi_timer_low) & +PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_LOW_MASK ; + bp->lpi_tmr_hi =le32_to_cpu (resp->valid_tx_lpi_timer_high) & +PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK ; + } + +hwrm_phy_qcaps_exit: +mutex_unlock (&bp->hwrm_cmd_lock); +return rc; +} +static int bnxt_update_link (struct bnxt *bp,bool chng_link_state) {int rc =0 ;
@@ -4535,8 +4572,44 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state) link_info->phy_ver[2 ] = resp->phy_bld; link_info->media_type = resp->media_type; link_info->transceiver = resp->xcvr_pkg_type; - link_info->phy_addr = resp->eee_config_phy_addr; + link_info->phy_addr = resp->eee_config_phy_addr & +PORT_PHY_QCFG_RESP_PHY_ADDR_MASK ; + +if (bp->flags &BNXT_FLAG_EEE_CAP ) { +struct ethtool_eee *eee = &bp->eee; +u16 fw_speeds; + + eee->eee_active =0 ; +if (resp->eee_config_phy_addr & +PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ACTIVE ) { + eee->eee_active =1 ; + fw_speeds =le16_to_cpu ( + resp->link_partner_adv_eee_link_speed_mask); + eee->lp_advertised = +_bnxt_fw_to_ethtool_adv_spds (fw_speeds,0 ); + } + +/* Pull initial EEE config */ +if (!chng_link_state) { +if (resp->eee_config_phy_addr & +PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ENABLED ) + eee->eee_enabled =1 ; + fw_speeds =le16_to_cpu (resp->adv_eee_link_speed_mask); + eee->advertised = +_bnxt_fw_to_ethtool_adv_spds (fw_speeds,0 ); + +if (resp->eee_config_phy_addr & +PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_TX_LPI ) { +__le32 tmr; + + eee->tx_lpi_enabled =1 ; + tmr = resp->xcvr_identifier_type_tx_lpi_timer; + eee->tx_lpi_timer =le32_to_cpu (tmr) & +PORT_PHY_QCFG_RESP_TX_LPI_TIMER_MASK ; + } + } + }/* TODO: need to add more logic to report VF link */ if (chng_link_state) {if (link_info->phy_link_status ==BNXT_LINK_LINK )
@@ -5825,6 +5898,13 @@ static int bnxt_probe_phy(struct bnxt *bp)int rc =0 ;struct bnxt_link_info *link_info = &bp->link_info; + rc =bnxt_hwrm_phy_qcaps (bp); +if (rc) { +netdev_err (bp->dev,"Probe phy can't get phy capabilities (rc: %x)\n" , + rc); +return rc; + } + rc =bnxt_update_link (bp, false);if (rc) { netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n",
drivers/net/ethernet/broadcom/bnxt/bnxt.h +4 -0
@@ -874,6 +874,7 @@ struct bnxt {#define BNXT_FLAG_RFS 0x100#define BNXT_FLAG_SHARED_RINGS 0x200#define BNXT_FLAG_PORT_STATS 0x400 +#define BNXT_FLAG_EEE_CAP 0x1000#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ BNXT_FLAG_RFS | \
@@ -1011,6 +1012,9 @@ struct bnxt {int ntp_fltr_count;struct bnxt_link_info link_info; +struct ethtool_eee eee; +u32 lpi_tmr_lo; +u32 lpi_tmr_hi; };#ifdef CONFIG_NET_RX_BUSY_POLL
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -1
@@ -597,7 +597,7 @@ static void bnxt_get_drvinfo(struct net_device *dev,kfree (pkglog); } -static u32 _bnxt_fw_to_ethtool_adv_spds (u16 fw_speeds,u8 fw_pause) +u32 _bnxt_fw_to_ethtool_adv_spds (u16 fw_speeds,u8 fw_pause) {u32 speed_mask =0 ;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +1 -0
@@ -12,6 +12,7 @@extern const struct ethtool_ops bnxt_ethtool_ops; +u32 _bnxt_fw_to_ethtool_adv_spds (u16 ,u8 );u32 bnxt_fw_to_ethtool_speed (u16 );#endif
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 2/10 bnxt_en: Improve flow control autoneg with Firmware 1.2.1 interface.
In reply to Michael ChanMake use of the new AUTONEG_PAUSE bit in the new interface to better control autoneg flow control settings, independent of RX and TX advertisement settings.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++++++++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 10 ++++---- 2 files changed, 27 insertions(+), 11 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +23 -5
@@ -4557,6 +4557,9 @@ static void bnxt_hwrm_set_pause_common(struct bnxt *bp, struct hwrm_port_phy_cfg_input *req) {if (bp->link_info.autoneg &BNXT_AUTONEG_FLOW_CTRL ) { +if (bp->hwrm_spec_code >=0x10201 ) + req->auto_pause = +PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE ;if (bp->link_info.req_flow_ctrl &BNXT_LINK_PAUSE_RX ) req->auto_pause |=PORT_PHY_CFG_REQ_AUTO_PAUSE_RX ;if (bp->link_info.req_flow_ctrl &BNXT_LINK_PAUSE_TX )
@@ -4570,6 +4573,11 @@ bnxt_hwrm_set_pause_common(struct bnxt *bp, struct hwrm_port_phy_cfg_input *req) req->force_pause |=PORT_PHY_CFG_REQ_FORCE_PAUSE_TX ; req->enables |=cpu_to_le32 (PORT_PHY_CFG_REQ_ENABLES_FORCE_PAUSE ); +if (bp->hwrm_spec_code >=0x10201 ) { + req->auto_pause = req->force_pause; + req->enables |=cpu_to_le32 ( +PORT_PHY_CFG_REQ_ENABLES_AUTO_PAUSE ); + } } }
@@ -4656,7 +4664,8 @@ static int bnxt_update_phy_setting(struct bnxt *bp)return rc; }if ((link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) && - link_info->auto_pause_setting != link_info->req_flow_ctrl) + (link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) != + link_info->req_flow_ctrl) update_pause = true;if (!(link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) && link_info->force_pause_setting != link_info->req_flow_ctrl)
@@ -5825,15 +5834,24 @@ static int bnxt_probe_phy(struct bnxt *bp)/*initialize the ethool setting copy with NVM settings */ if (BNXT_AUTO_MODE (link_info->auto_mode)) { - link_info->autoneg =BNXT_AUTONEG_SPEED | -BNXT_AUTONEG_FLOW_CTRL ; + link_info->autoneg =BNXT_AUTONEG_SPEED ; +if (bp->hwrm_spec_code >=0x10201 ) { +if (link_info->auto_pause_setting & +PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE ) + link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; + }else { + link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; + } link_info->advertising = link_info->auto_link_speeds; - link_info->req_flow_ctrl = link_info->auto_pause_setting; }else { link_info->req_link_speed = link_info->force_link_speed; link_info->req_duplex = link_info->duplex_setting; - link_info->req_flow_ctrl = link_info->force_pause_setting; } +if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) + link_info->req_flow_ctrl = + link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ; +else + link_info->req_flow_ctrl = link_info->force_pause_setting;return rc; }
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +4 -6
@@ -874,7 +874,9 @@ static int bnxt_set_pauseparam(struct net_device *dev,return -EINVAL ; link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; - link_info->req_flow_ctrl |=BNXT_LINK_PAUSE_BOTH ; +if (bp->hwrm_spec_code >=0x10201 ) + link_info->req_flow_ctrl = +PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE ; }else {/* when transition from auto pause to force pause, * force a link change
@@ -882,17 +884,13 @@ static int bnxt_set_pauseparam(struct net_device *dev,if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) link_info->force_link_chng = true; link_info->autoneg &= ~BNXT_AUTONEG_FLOW_CTRL ; - link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_BOTH ; + link_info->req_flow_ctrl =0 ; }if (epause->rx_pause) link_info->req_flow_ctrl |=BNXT_LINK_PAUSE_RX ; -else - link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_RX ;if (epause->tx_pause) link_info->req_flow_ctrl |=BNXT_LINK_PAUSE_TX ; -else - link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_TX ;if (netif_running (dev)) rc =bnxt_hwrm_set_pause (bp);
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 5/10 bnxt_en: Add get_eee() and set_eee() ethtool support.
In reply to Michael ChanAllow users to get|set EEE parameters.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +73 -0
@@ -1379,6 +1379,77 @@ static int bnxt_set_eeprom(struct net_device *dev, eeprom->len); } +static int bnxt_set_eee (struct net_device *dev,struct ethtool_eee *edata) +{ +struct bnxt *bp =netdev_priv (dev); +struct ethtool_eee *eee = &bp->eee; +struct bnxt_link_info *link_info = &bp->link_info; +u32 advertising = +_bnxt_fw_to_ethtool_adv_spds (link_info->advertising,0 ); +int rc =0 ; + +if (BNXT_VF (bp)) +return 0 ; + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return -EOPNOTSUPP ; + +if (!edata->eee_enabled) + goto eee_ok; + +if (!(link_info->autoneg &BNXT_AUTONEG_SPEED )) { +netdev_warn (dev,"EEE requires autoneg\n" ); +return -EINVAL ; + } +if (edata->tx_lpi_enabled) { +if (bp->lpi_tmr_hi && (edata->tx_lpi_timer > bp->lpi_tmr_hi || + edata->tx_lpi_timer < bp->lpi_tmr_lo)) { +netdev_warn (dev,"Valid LPI timer range is %d and %d microsecs\n" , + bp->lpi_tmr_lo, bp->lpi_tmr_hi); +return -EINVAL ; + }else if (!bp->lpi_tmr_hi) { + edata->tx_lpi_timer = eee->tx_lpi_timer; + } + } +if (!edata->advertised) { + edata->advertised = advertising & eee->supported; + }else if (edata->advertised & ~advertising) { +netdev_warn (dev,"EEE advertised %x must be a subset of autoneg advertised speeds %x\n" , + edata->advertised, advertising); +return -EINVAL ; + } + + eee->advertised = edata->advertised; + eee->tx_lpi_enabled = edata->tx_lpi_enabled; + eee->tx_lpi_timer = edata->tx_lpi_timer; +eee_ok: + eee->eee_enabled = edata->eee_enabled; + +if (netif_running (dev)) + rc =bnxt_hwrm_set_link_setting (bp, false, true); + +return rc; +} + +static int bnxt_get_eee (struct net_device *dev,struct ethtool_eee *edata) +{ +struct bnxt *bp =netdev_priv (dev); + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return -EOPNOTSUPP ; + + *edata = bp->eee; +if (!bp->eee.eee_enabled) { + edata->advertised =0 ; + edata->tx_lpi_enabled =0 ; + } + +if (!bp->eee.eee_active) + edata->lp_advertised =0 ; + +return 0 ; +} +const struct ethtool_ops bnxt_ethtool_ops = { .get_settings = bnxt_get_settings, .set_settings = bnxt_set_settings,
@@ -1407,4 +1478,6 @@ const struct ethtool_ops bnxt_ethtool_ops = { .get_eeprom = bnxt_get_eeprom, .set_eeprom = bnxt_set_eeprom, .get_link = bnxt_get_link, + .get_eee = bnxt_get_eee, + .set_eee = bnxt_set_eee, };
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 4/10 bnxt_en: Add EEE setup code.
In reply to Michael Chan1. Add bnxt_hwrm_set_eee() function to setup EEE firmware parameters based on the bp->eee settings.
2. The new function bnxt_eee_config_ok() will check if EEE parameters need to be modified due to autoneg changes.
3. bnxt_hwrm_set_link() has added a new parameter to update EEE. If the parameter is set, it will call bnxt_hwrm_set_eee().
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 ++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 1 + 4 files changed, 60 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +56 -2
@@ -4711,7 +4711,30 @@ int bnxt_hwrm_set_pause(struct bnxt *bp)return rc; } -int bnxt_hwrm_set_link_setting (struct bnxt *bp,bool set_pause) +static void bnxt_hwrm_set_eee (struct bnxt *bp, +struct hwrm_port_phy_cfg_input *req) +{ +struct ethtool_eee *eee = &bp->eee; + +if (eee->eee_enabled) { +u16 eee_speeds; +u32 flags =PORT_PHY_CFG_REQ_FLAGS_EEE_ENABLE ; + +if (eee->tx_lpi_enabled) + flags |=PORT_PHY_CFG_REQ_FLAGS_EEE_TX_LPI_ENABLE ; +else + flags |=PORT_PHY_CFG_REQ_FLAGS_EEE_TX_LPI_DISABLE ; + + req->flags |=cpu_to_le32 (flags); + eee_speeds =bnxt_get_fw_auto_link_speeds (eee->advertised); + req->eee_link_speed_mask =cpu_to_le16 (eee_speeds); + req->tx_lpi_timer =cpu_to_le32 (eee->tx_lpi_timer); + }else { + req->flags |=cpu_to_le32 (PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE ); + } +} + +int bnxt_hwrm_set_link_setting (struct bnxt *bp,bool set_pause,bool set_eee) {struct hwrm_port_phy_cfg_input req = {0 };
@@ -4720,14 +4743,42 @@ int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause)bnxt_hwrm_set_pause_common (bp, &req);bnxt_hwrm_set_link_common (bp, &req); + +if (set_eee) +bnxt_hwrm_set_eee (bp, &req);return hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); } +static bool bnxt_eee_config_ok (struct bnxt *bp) +{ +struct ethtool_eee *eee = &bp->eee; +struct bnxt_link_info *link_info = &bp->link_info; + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return true; + +if (eee->eee_enabled) { +u32 advertising = +_bnxt_fw_to_ethtool_adv_spds (link_info->advertising,0 ); + +if (!(link_info->autoneg &BNXT_AUTONEG_SPEED )) { + eee->eee_enabled =0 ; +return false; + } +if (eee->advertised & ~advertising) { + eee->advertised = advertising & eee->supported; +return false; + } + } +return true; +} +static int bnxt_update_phy_setting (struct bnxt *bp) {int rc;bool update_link = false;bool update_pause = false; +bool update_eee = false;struct bnxt_link_info *link_info = &bp->link_info; rc =bnxt_update_link (bp, true);
@@ -4757,8 +4808,11 @@ static int bnxt_update_phy_setting(struct bnxt *bp) update_link = true; } +if (!bnxt_eee_config_ok (bp)) + update_eee = true; +if (update_link) - rc =bnxt_hwrm_set_link_setting (bp, update_pause); + rc =bnxt_hwrm_set_link_setting (bp, update_pause, update_eee);else if (update_pause) rc =bnxt_hwrm_set_pause (bp);if (rc) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -1
@@ -1112,7 +1112,7 @@ int hwrm_send_message_silent(struct bnxt *, void *, u32, int);int bnxt_hwrm_set_coal (struct bnxt *);int bnxt_hwrm_func_qcaps (struct bnxt *);int bnxt_hwrm_set_pause (struct bnxt *); -int bnxt_hwrm_set_link_setting (struct bnxt *,bool ); +int bnxt_hwrm_set_link_setting (struct bnxt *,bool ,bool );int bnxt_open_nic (struct bnxt *,bool ,bool );int bnxt_close_nic (struct bnxt *,bool ,bool );int bnxt_get_max_rings (struct bnxt *,int *,int *,bool );
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -2
@@ -763,7 +763,7 @@ static u32 bnxt_get_fw_speed(struct net_device *dev, u16 ethtool_speed)return 0 ; } -static u16 bnxt_get_fw_auto_link_speeds (u32 advertising) +u16 bnxt_get_fw_auto_link_speeds (u32 advertising) {u16 fw_speed_mask =0 ;
@@ -840,7 +840,7 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) }if (netif_running (dev)) - rc =bnxt_hwrm_set_link_setting (bp, set_pause); + rc =bnxt_hwrm_set_link_setting (bp, set_pause, false); set_setting_exit:return rc;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +1 -0
@@ -14,5 +14,6 @@ extern const struct ethtool_ops bnxt_ethtool_ops;u32 _bnxt_fw_to_ethtool_adv_spds (u16 ,u8 );u32 bnxt_fw_to_ethtool_speed (u16 ); +u16 bnxt_get_fw_auto_link_speeds (u32 );#endif
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 6/10 bnxt_en: Set async event bits when registering with the firmware.
In reply to Michael ChanCurrently, the driver only sets bit 0 of the async_event_fwd fields. To be compatible with the latest spec, we need to set the appropriate event bits handled by the driver. We should be handling link change and PF driver unload events, so these 2 bits should be set.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +14 -4
@@ -118,6 +118,11 @@ static const u16 bnxt_vf_req_snif[] = { HWRM_CFA_L2_FILTER_ALLOC, }; +static const u16 bnxt_async_events_arr[] = { +HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE , +HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD , +}; +static bool bnxt_vf_pciid (enum board_idx idx) {return (idx ==BCM57304_VF || idx ==BCM57404_VF );
@@ -2751,6 +2756,8 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp) {struct hwrm_func_drv_rgtr_input req = {0 };int i; +DECLARE_BITMAP (async_events_bmap,256 ); +u32 *events = (u32 *)async_events_bmap;bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_FUNC_DRV_RGTR ,-1 ,-1 );
@@ -2759,10 +2766,13 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)FUNC_DRV_RGTR_REQ_ENABLES_VER | FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD); -/* TODO: current async event fwd bits are not defined and the firmware -* only checks if it is non-zero to enable async event forwarding -*/ - req.async_event_fwd[0 ] |=cpu_to_le32 (1 ); +memset (async_events_bmap,0 ,sizeof (async_events_bmap)); +for (i =0 ; i <ARRAY_SIZE (bnxt_async_events_arr); i++) +__set_bit (bnxt_async_events_arr[i], async_events_bmap); + +for (i =0 ; i <8 ; i++) + req.async_event_fwd[i] |=cpu_to_le32 (events[i]); + req.os_type =cpu_to_le16 (FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX ); req.ver_maj =DRV_VER_MAJ ; req.ver_min =DRV_VER_MIN ;
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 7/10 bnxt_en: Add unsupported SFP+ module warnings.
In reply to Michael ChanAdd the PORT_CONN_NOT_ALLOWED async event handling logic. The driver will print an appropriate warning to reflect the SFP+ module enforcement policy done in the firmware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 55 +++++++++++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++ 2 files changed, 58 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +55 -0
@@ -121,6 +121,7 @@ static const u16 bnxt_vf_req_snif[] = {static const u16 bnxt_async_events_arr[] = {HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE ,HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD , +HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED , };static bool bnxt_vf_pciid (enum board_idx idx)
@@ -1236,6 +1237,19 @@ next_rx_no_prod:return rc; } +#define BNXT_GET_EVENT_PORT (data) \ + ((data) & \ + HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_PORT_ID_MASK) + +#define BNXT_EVENT_POLICY_MASK \ + HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_MASK + +#define BNXT_EVENT_POLICY_SFT \ + HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_SFT + +#define BNXT_GET_EVENT_POLICY (data) \ + (((data) & BNXT_EVENT_POLICY_MASK) >> BNXT_EVENT_POLICY_SFT) +static int bnxt_async_event_process (struct bnxt *bp,struct hwrm_async_event_cmpl *cmpl) {
@@ -1249,6 +1263,22 @@ static int bnxt_async_event_process(struct bnxt *bp,case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD :set_bit (BNXT_HWRM_PF_UNLOAD_SP_EVENT , &bp->sp_event);break ; +case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED : { +u32 data1 =le32_to_cpu (cmpl->event_data1); +u16 port_id =BNXT_GET_EVENT_PORT (data1); + +if (BNXT_VF (bp)) +break ; + +if (bp->pf.port_id != port_id) +break ; + + bp->link_info.last_port_module_event = +BNXT_GET_EVENT_POLICY (data1); + +set_bit (BNXT_HWRM_PORT_MODULE_SP_EVENT , &bp->sp_event); +break ; + }default :netdev_err (bp->dev,"unhandled ASYNC event (id 0x%x)\n" , event_id);
@@ -5447,6 +5477,28 @@ bnxt_restart_timer:mod_timer (&bp->timer, jiffies + bp->current_interval); } +static void bnxt_port_module_event (struct bnxt *bp) +{ +struct bnxt_link_info *link_info = &bp->link_info; +struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; + +if (bnxt_update_link (bp, true)) +return ; + +if (link_info->last_port_module_event !=0 ) { +netdev_warn (bp->dev,"Unqualified SFP+ module detected on port %d\n" , + bp->pf.port_id); +if (bp->hwrm_spec_code >=0x10201 ) { +netdev_warn (bp->dev,"Module part number %s\n" , + resp->phy_vendor_partnumber); + } + } +if (link_info->last_port_module_event ==1 ) +netdev_warn (bp->dev,"TX is disabled\n" ); +if (link_info->last_port_module_event ==3 ) +netdev_warn (bp->dev,"Shutdown SFP+ module\n" ); +} +static void bnxt_cfg_ntp_filters (struct bnxt *);static void bnxt_sp_task (struct work_struct *work)
@@ -5494,6 +5546,9 @@ static void bnxt_sp_task(struct work_struct *work)rtnl_unlock (); } +if (test_and_clear_bit (BNXT_HWRM_PORT_MODULE_SP_EVENT , &bp->sp_event)) +bnxt_port_module_event (bp); +if (test_and_clear_bit (BNXT_PERIODIC_STATS_SP_EVENT , &bp->sp_event))bnxt_hwrm_port_qstats (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +3 -0
@@ -825,6 +825,8 @@ struct bnxt_link_info {u16 req_link_speed;u32 advertising;bool force_link_chng; + +u8 last_port_module_event;/* a copy of phy_qcfg output used to report link * info to VF */
@@ -992,6 +994,7 @@ struct bnxt {#define BNXT_RST_RING_SP_EVENT 7#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8#define BNXT_PERIODIC_STATS_SP_EVENT 9 +#define BNXT_HWRM_PORT_MODULE_SP_EVENT 10struct bnxt_pf_info pf;#ifdef CONFIG_BNXT_SRIOV
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 8/10 bnxt_en: Provide NVM information via Ethtool GEEPROM
In reply to Michael ChanFrom: Rob Swindell <[email protected]>
Provide details about the NVM device and the firmware version, etc, via the Ethtool GEEPROM command.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 60 +++++++++++++++++++++-- 1 file changed, 55 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +55 -5
@@ -1311,8 +1311,18 @@ static int bnxt_get_eeprom(struct net_device *dev,struct ethtool_eeprom *eeprom, u8 *data) { + int i; +int rc;u32 index;u32 offset; +u32 size; +struct bnxt *bp =netdev_priv (dev); +struct hwrm_fw_qstatus_input fw_status_req = {0 }; +struct hwrm_fw_qstatus_output *fw_status_resp = bp->hwrm_cmd_resp_addr; +struct hwrm_nvm_get_dev_info_input dev_info_req = {0 }; + +if (eeprom->len <1 ) +return -EINVAL ;if (eeprom->offset ==0 )/* special offset value to get directory */ return bnxt_get_nvram_directory (dev, eeprom->len, data);
@@ -1320,12 +1330,52 @@ static int bnxt_get_eeprom(struct net_device *dev, index = eeprom->offset >>24 ; offset = eeprom->offset &0xffffff ; -if (index ==0 ) { -netdev_err (dev,"unsupported index value: %d\n" , index); -return -EINVAL ; - } +if (index !=0 ) +return bnxt_get_nvram_item (dev, index -1 , offset, eeprom->len, + data); -return bnxt_get_nvram_item (dev, index -1 , offset, eeprom->len, data); +switch (offset) { +case 1 :/* Query firmware reset status */ +if (eeprom->len <5 ) +return -EINVAL ; + size =4 ;/* procs: BOOT, MGMT, NETCTRL, and ROCE */ + *(data++) = size; +mutex_lock (&bp->hwrm_cmd_lock); +for (i =0 ; i < size; i++) { +bnxt_hwrm_cmd_hdr_init (bp, &fw_status_req, +HWRM_FW_QSTATUS ,-1 ,-1 ); + fw_status_req.embedded_proc_type = i; + rc =_hwrm_send_message (bp, &fw_status_req, +sizeof (fw_status_req), +HWRM_CMD_TIMEOUT ); +if (rc ==0 ) + *(data++) = fw_status_resp->selfrst_status; +else +break ; + } +mutex_unlock (&bp->hwrm_cmd_lock); +return rc; +case 2 :/* Query firmware version information */ + size =sizeof (bp->ver_resp); + *(data++) = size; +memcpy (data, &bp->ver_resp,min (size, eeprom->len -1 )); +return 0 ; +case 3 :/* Query NVM device information */ +bnxt_hwrm_cmd_hdr_init (bp, &dev_info_req, +HWRM_NVM_GET_DEV_INFO ,-1 ,-1 ); +mutex_lock (&bp->hwrm_cmd_lock); + rc =_hwrm_send_message (bp, &dev_info_req,sizeof (dev_info_req), +HWRM_CMD_TIMEOUT ); +if (rc ==0 ) { + size =sizeof (struct hwrm_nvm_get_dev_info_output ); + *(data++) = size; +memcpy (data, bp->hwrm_cmd_resp_addr, +min (size, eeprom->len -1 )); + } +mutex_unlock (&bp->hwrm_cmd_lock); +return rc; + } +return -EINVAL ; }static int bnxt_erase_nvram_directory (struct net_device *dev,u8 index)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 10/10 bnxt_en: Improve ethtool .get_settings().
In reply to Michael ChanIf autoneg is off, we should always report the speed and duplex settings even if it is link down so the user knows the current settings. The unknown speed and duplex should only be used for autoneg when link is down.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +13 -8
@@ -698,10 +698,23 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)if (link_info->phy_link_status ==BNXT_LINK_LINK ) cmd->lp_advertising =bnxt_fw_to_ethtool_lp_adv (link_info); + ethtool_speed =bnxt_fw_to_ethtool_speed (link_info->link_speed); +if (!netif_carrier_ok (dev)) + cmd->duplex =DUPLEX_UNKNOWN ; +else if (link_info->duplex &BNXT_LINK_DUPLEX_FULL ) + cmd->duplex =DUPLEX_FULL ; +else + cmd->duplex =DUPLEX_HALF ; }else { cmd->autoneg =AUTONEG_DISABLE ; cmd->advertising =0 ; + ethtool_speed = +bnxt_fw_to_ethtool_speed (link_info->req_link_speed); + cmd->duplex =DUPLEX_HALF ; +if (link_info->req_duplex ==BNXT_LINK_DUPLEX_FULL ) + cmd->duplex =DUPLEX_FULL ; } +ethtool_cmd_speed_set (cmd, ethtool_speed); cmd->port =PORT_NONE ;if (link_info->media_type ==PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP ) {
@@ -719,14 +732,6 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) cmd->port =PORT_FIBRE ; } -if (link_info->phy_link_status ==BNXT_LINK_LINK ) { -if (link_info->duplex &BNXT_LINK_DUPLEX_FULL ) - cmd->duplex =DUPLEX_FULL ; - }else { - cmd->duplex =DUPLEX_UNKNOWN ; - } - ethtool_speed =bnxt_fw_to_ethtool_speed (link_info->link_speed); -ethtool_cmd_speed_set (cmd, ethtool_speed);if (link_info->transceiver ==PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_INTERNAL ) cmd->transceiver =XCVR_INTERNAL ;
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 9/10 bnxt_en: Check for valid forced speed during ethtool -s.
In reply to Michael ChanCheck that the forced speed is a valid speed supported by firmware. If not supported, return -EINVAL.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 48 ++++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +38 -10
@@ -739,28 +739,49 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)static u32 bnxt_get_fw_speed (struct net_device *dev,u16 ethtool_speed) { +struct bnxt *bp =netdev_priv (dev); +struct bnxt_link_info *link_info = &bp->link_info; +u16 support_spds = link_info->support_speeds; +u32 fw_speed =0 ; +switch (ethtool_speed) {case SPEED_100 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100MB ; +if (support_spds &BNXT_LINK_SPEED_MSK_100MB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100MB ; +break ;case SPEED_1000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_1GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_1GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_1GB ; +break ;case SPEED_2500 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_2_5GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_2_5GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_2_5GB ; +break ;case SPEED_10000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_10GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_10GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_10GB ; +break ;case SPEED_20000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_20GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_20GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_20GB ; +break ;case SPEED_25000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_25GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_25GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_25GB ; +break ;case SPEED_40000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_40GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_40GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_40GB ; +break ;case SPEED_50000 : -return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_50GB ; +if (support_spds &BNXT_LINK_SPEED_MSK_50GB ) + fw_speed =PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_50GB ; +break ;default :netdev_err (dev,"unsupported speed!\n" );break ; } -return 0 ; +return fw_speed; }u16 bnxt_get_fw_auto_link_speeds (u32 advertising)
@@ -823,6 +844,8 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)*/ set_pause = true; }else { +u16 fw_speed; +/* TODO: currently don't support half duplex */ if (cmd->duplex ==DUPLEX_HALF ) {netdev_err (dev,"HALF DUPLEX is not supported!\n" );
@@ -833,7 +856,12 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)if (cmd->duplex ==DUPLEX_UNKNOWN ) cmd->duplex =DUPLEX_FULL ; speed =ethtool_cmd_speed (cmd); - link_info->req_link_speed =bnxt_get_fw_speed (dev, speed); + fw_speed =bnxt_get_fw_speed (dev, speed); +if (!fw_speed) { + rc = -EINVAL ; + goto set_setting_exit; + } + link_info->req_link_speed = fw_speed; link_info->req_duplex =BNXT_LINK_DUPLEX_FULL ; link_info->autoneg =0 ; link_info->advertising =0 ;
Signature · 1 line
1.8.3.1
Re: [PATCH net-next 05/10] bnxt_en: Add get_eee() and set_eee() ethtool support.
In reply to Michael ChanQuoted 32 lines · Michael Chan
Allow users to get|set EEE parameters.
Signed-off-by Michael Chan <[email protected]>---
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 73 +++++++++++++++++++++++1 file changed, 73 insertions(+)drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +0
-0@@ -1379,6 +1379,77 @@ static int bnxt_set_eeprom(struct net_device *dev, eeprom->len); }drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +17
-0+static int bnxt_set_eee (struct net_device *dev,struct ethtool_eee *edata) +{ +struct bnxt *bp =netdev_priv (dev); +struct ethtool_eee *eee = &bp->eee; +struct bnxt_link_info *link_info = &bp->link_info; +u32 advertising = + _bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0); +int rc =0 ; + +if (BNXT_VF (bp)) +return 0 ; + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return -EOPNOTSUPP ; + +if (!edata->eee_enabled) + goto eee_ok;
[...]
Quoted 13 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +13
-0+ eee->advertised = edata->advertised; + eee->tx_lpi_enabled = edata->tx_lpi_enabled; + eee->tx_lpi_timer = edata->tx_lpi_timer; +eee_ok: + eee->eee_enabled = edata->eee_enabled; + +if (netif_running (dev)) + rc =bnxt_hwrm_set_link_setting (bp, false, true); + +return rc; +} + +static int bnxt_get_eee (struct net_device *dev,struct ethtool_eee *edata)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c static int bnxt_set_eeprom(struct net_device *dev, · line 1444
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +10
-0+{ +struct bnxt *bp =netdev_priv (dev); + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return -EOPNOTSUPP ; + + *edata = bp->eee; +if (!bp->eee.eee_enabled) { + edata->advertised =0 ; + edata->tx_lpi_enabled =0 ;
What about tx_lpi_timer?
And, wouldn't it make more sense to do these fixups to the internal state in bnxt_set_eee()?
Ben.
Quoted 7 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +7
-0+ } + +if (!bp->eee.eee_active) + edata->lp_advertised =0 ; + +return 0 ; +}
[...]
Signature · 2 lines
Ben Hutchings No political challenge can be met by shopping. - George Monbiot
Michael Chan
maintainerRe: [PATCH net-next 05/10] bnxt_en: Add get_eee() and set_eee() ethtool support.
Quoted 52 lines · Ben Hutchings
Quoted 32 lines · Michael Chan
Allow users to get|set EEE parameters.
Signed-off-by Michael Chan <[email protected]>--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+)drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +17
-0@@ -1379,6 +1379,77 @@ static int bnxt_set_eeprom(struct net_device *dev, eeprom->len); } +static int bnxt_set_eee (struct net_device *dev,struct ethtool_eee *edata) +{ +struct bnxt *bp =netdev_priv (dev); +struct ethtool_eee *eee = &bp->eee; +struct bnxt_link_info *link_info = &bp->link_info; +u32 advertising = +_bnxt_fw_to_ethtool_adv_spds (link_info->advertising,0 ); +int rc =0 ; + +if (BNXT_VF (bp)) +return 0 ; + +if (!(bp->flags &BNXT_FLAG_EEE_CAP )) +return -EOPNOTSUPP ; + +if (!edata->eee_enabled) + goto eee_ok;[...]
Quoted 17 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +17
-0+ eee->advertised = edata->advertised; + eee->tx_lpi_enabled = edata->tx_lpi_enabled; + eee->tx_lpi_timer = edata->tx_lpi_timer; +eee_ok: + eee->eee_enabled = edata->eee_enabled; + +if (netif_running (dev)) + rc =bnxt_hwrm_set_link_setting (bp, false, true); + +return rc; +} + +static int bnxt_get_eee (struct net_device *dev,struct ethtool_eee *edata) +{ +struct bnxt *bp =netdev_priv (dev); + +if (!(bp->flags &BNXT_FLAG_EEE_CAP ))
Quoted 8 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c static int bnxt_set_eeprom(struct net_device *dev, · line 1444
Quoted 6 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +6
-0+return -EOPNOTSUPP ; + + *edata = bp->eee; +if (!bp->eee.eee_enabled) { + edata->advertised =0 ; + edata->tx_lpi_enabled =0 ;What about
tx_lpi_timer?
We want to keep the tx_lpi_timer value so that it can be used again when it is turned on again.
The user doesn't have to figure out what value to use if he just wants to use the default or the last value.
Quoted 3 lines
And, wouldn't it make more sense to do these fixups to the internal state in
bnxt_set_eee()?
I don't understand. If the user is enabling EEE, we take all the parameters. If he is disabling, we don't take any of the parameters.
Quoted 15 lines
Ben.
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c static int bnxt_set_eeprom(struct net_device *dev, · line 1451
Quoted 7 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +7
-0+ } + +if (!bp->eee.eee_active) + edata->lp_advertised =0 ; + +return 0 ; +}[...]
--
Ben Hutchings
No political challenge can be met by shopping. - George Monbiot
Re: [PATCH net-next 05/10] bnxt_en: Add get_eee() and set_eee() ethtool support.
Quoted 1 line · Michael Chan
On Tue, Apr 5, 2016 at 3:07 AM, Ben Hutchings <[email protected]> wrote:
[...]
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +4
-0+static int bnxt_get_eee (struct net_device *dev,struct ethtool_eee *edata) +{ + struct bnxt *bp = netdev_priv(dev); +Quoted 8 lines
Quoted 7 lines
+ if (!(bp->flags &
BNXT_FLAG_EEE_CAP))
+ return-EOPNOTSUPP;
+
+ *edata =bp->eee;
+ if (!bp->eee.eee_enabled) {
+ edata->advertised = 0;
+ edata->tx_lpi_enabled = 0;What about
tx_lpi_timer?
Quoted 5 lines
We want to keep the
tx_lpi_timervalue so that it can be used again when it is turned on again.The user doesn't have to figure out what value to use if he just wants to use the default or the last value.
OK, that seems like a good reason.
Quoted 6 lines
Quoted 4 lines
And, wouldn't it make more sense to do these fixups to the internal state in
bnxt_set_eee()?I don't understand. If the user is enabling EEE, we take all the parameters. If he is disabling, we don't take any of the parameters.
Right - it's just a bit weird that you keep the internal state in a struct ethtool_eee but get_eee() returns a slightly different version of the state.
Ben.
Signature · 2 lines
Ben Hutchings No political challenge can be met by shopping. - George Monbiot