Skip to content

Commit 170ce01

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add basic EEE support.
Get EEE capability and the initial EEE settings from firmware. Add "EEE is active | not active" to link up dmesg. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c9ee951 commit 170ce01

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4488,12 +4488,49 @@ static void bnxt_report_link(struct bnxt *bp)
44884488
speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed);
44894489
netdev_info(bp->dev, "NIC Link is Up, %d Mbps %s duplex, Flow control: %s\n",
44904490
speed, duplex, flow_ctrl);
4491+
if (bp->flags & BNXT_FLAG_EEE_CAP)
4492+
netdev_info(bp->dev, "EEE is %s\n",
4493+
bp->eee.eee_active ? "active" :
4494+
"not active");
44914495
} else {
44924496
netif_carrier_off(bp->dev);
44934497
netdev_err(bp->dev, "NIC Link is Down\n");
44944498
}
44954499
}
44964500

4501+
static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
4502+
{
4503+
int rc = 0;
4504+
struct hwrm_port_phy_qcaps_input req = {0};
4505+
struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
4506+
4507+
if (bp->hwrm_spec_code < 0x10201)
4508+
return 0;
4509+
4510+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCAPS, -1, -1);
4511+
4512+
mutex_lock(&bp->hwrm_cmd_lock);
4513+
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
4514+
if (rc)
4515+
goto hwrm_phy_qcaps_exit;
4516+
4517+
if (resp->eee_supported & PORT_PHY_QCAPS_RESP_EEE_SUPPORTED) {
4518+
struct ethtool_eee *eee = &bp->eee;
4519+
u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode);
4520+
4521+
bp->flags |= BNXT_FLAG_EEE_CAP;
4522+
eee->supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0);
4523+
bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) &
4524+
PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_LOW_MASK;
4525+
bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) &
4526+
PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK;
4527+
}
4528+
4529+
hwrm_phy_qcaps_exit:
4530+
mutex_unlock(&bp->hwrm_cmd_lock);
4531+
return rc;
4532+
}
4533+
44974534
static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
44984535
{
44994536
int rc = 0;
@@ -4535,8 +4572,44 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
45354572
link_info->phy_ver[2] = resp->phy_bld;
45364573
link_info->media_type = resp->media_type;
45374574
link_info->transceiver = resp->xcvr_pkg_type;
4538-
link_info->phy_addr = resp->eee_config_phy_addr;
4575+
link_info->phy_addr = resp->eee_config_phy_addr &
4576+
PORT_PHY_QCFG_RESP_PHY_ADDR_MASK;
4577+
4578+
if (bp->flags & BNXT_FLAG_EEE_CAP) {
4579+
struct ethtool_eee *eee = &bp->eee;
4580+
u16 fw_speeds;
4581+
4582+
eee->eee_active = 0;
4583+
if (resp->eee_config_phy_addr &
4584+
PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ACTIVE) {
4585+
eee->eee_active = 1;
4586+
fw_speeds = le16_to_cpu(
4587+
resp->link_partner_adv_eee_link_speed_mask);
4588+
eee->lp_advertised =
4589+
_bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0);
4590+
}
4591+
4592+
/* Pull initial EEE config */
4593+
if (!chng_link_state) {
4594+
if (resp->eee_config_phy_addr &
4595+
PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ENABLED)
4596+
eee->eee_enabled = 1;
45394597

4598+
fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask);
4599+
eee->advertised =
4600+
_bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0);
4601+
4602+
if (resp->eee_config_phy_addr &
4603+
PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_TX_LPI) {
4604+
__le32 tmr;
4605+
4606+
eee->tx_lpi_enabled = 1;
4607+
tmr = resp->xcvr_identifier_type_tx_lpi_timer;
4608+
eee->tx_lpi_timer = le32_to_cpu(tmr) &
4609+
PORT_PHY_QCFG_RESP_TX_LPI_TIMER_MASK;
4610+
}
4611+
}
4612+
}
45404613
/* TODO: need to add more logic to report VF link */
45414614
if (chng_link_state) {
45424615
if (link_info->phy_link_status == BNXT_LINK_LINK)
@@ -5825,6 +5898,13 @@ static int bnxt_probe_phy(struct bnxt *bp)
58255898
int rc = 0;
58265899
struct bnxt_link_info *link_info = &bp->link_info;
58275900

5901+
rc = bnxt_hwrm_phy_qcaps(bp);
5902+
if (rc) {
5903+
netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n",
5904+
rc);
5905+
return rc;
5906+
}
5907+
58285908
rc = bnxt_update_link(bp, false);
58295909
if (rc) {
58305910
netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n",

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ struct bnxt {
874874
#define BNXT_FLAG_RFS 0x100
875875
#define BNXT_FLAG_SHARED_RINGS 0x200
876876
#define BNXT_FLAG_PORT_STATS 0x400
877+
#define BNXT_FLAG_EEE_CAP 0x1000
877878

878879
#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
879880
BNXT_FLAG_RFS | \
@@ -1011,6 +1012,9 @@ struct bnxt {
10111012
int ntp_fltr_count;
10121013

10131014
struct bnxt_link_info link_info;
1015+
struct ethtool_eee eee;
1016+
u32 lpi_tmr_lo;
1017+
u32 lpi_tmr_hi;
10141018
};
10151019

10161020
#ifdef CONFIG_NET_RX_BUSY_POLL

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static void bnxt_get_drvinfo(struct net_device *dev,
597597
kfree(pkglog);
598598
}
599599

600-
static u32 _bnxt_fw_to_ethtool_adv_spds(u16 fw_speeds, u8 fw_pause)
600+
u32 _bnxt_fw_to_ethtool_adv_spds(u16 fw_speeds, u8 fw_pause)
601601
{
602602
u32 speed_mask = 0;
603603

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
extern const struct ethtool_ops bnxt_ethtool_ops;
1414

15+
u32 _bnxt_fw_to_ethtool_adv_spds(u16, u8);
1516
u32 bnxt_fw_to_ethtool_speed(u16);
1617

1718
#endif

0 commit comments

Comments
 (0)