Skip to content

Commit 939f7f0

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add EEE setup code.
1. 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(). Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 170ce01 commit 939f7f0

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

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

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4711,7 +4711,30 @@ int bnxt_hwrm_set_pause(struct bnxt *bp)
47114711
return rc;
47124712
}
47134713

4714-
int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause)
4714+
static void bnxt_hwrm_set_eee(struct bnxt *bp,
4715+
struct hwrm_port_phy_cfg_input *req)
4716+
{
4717+
struct ethtool_eee *eee = &bp->eee;
4718+
4719+
if (eee->eee_enabled) {
4720+
u16 eee_speeds;
4721+
u32 flags = PORT_PHY_CFG_REQ_FLAGS_EEE_ENABLE;
4722+
4723+
if (eee->tx_lpi_enabled)
4724+
flags |= PORT_PHY_CFG_REQ_FLAGS_EEE_TX_LPI_ENABLE;
4725+
else
4726+
flags |= PORT_PHY_CFG_REQ_FLAGS_EEE_TX_LPI_DISABLE;
4727+
4728+
req->flags |= cpu_to_le32(flags);
4729+
eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised);
4730+
req->eee_link_speed_mask = cpu_to_le16(eee_speeds);
4731+
req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer);
4732+
} else {
4733+
req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE);
4734+
}
4735+
}
4736+
4737+
int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause, bool set_eee)
47154738
{
47164739
struct hwrm_port_phy_cfg_input req = {0};
47174740

@@ -4720,14 +4743,42 @@ int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause)
47204743
bnxt_hwrm_set_pause_common(bp, &req);
47214744

47224745
bnxt_hwrm_set_link_common(bp, &req);
4746+
4747+
if (set_eee)
4748+
bnxt_hwrm_set_eee(bp, &req);
47234749
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
47244750
}
47254751

4752+
static bool bnxt_eee_config_ok(struct bnxt *bp)
4753+
{
4754+
struct ethtool_eee *eee = &bp->eee;
4755+
struct bnxt_link_info *link_info = &bp->link_info;
4756+
4757+
if (!(bp->flags & BNXT_FLAG_EEE_CAP))
4758+
return true;
4759+
4760+
if (eee->eee_enabled) {
4761+
u32 advertising =
4762+
_bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0);
4763+
4764+
if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) {
4765+
eee->eee_enabled = 0;
4766+
return false;
4767+
}
4768+
if (eee->advertised & ~advertising) {
4769+
eee->advertised = advertising & eee->supported;
4770+
return false;
4771+
}
4772+
}
4773+
return true;
4774+
}
4775+
47264776
static int bnxt_update_phy_setting(struct bnxt *bp)
47274777
{
47284778
int rc;
47294779
bool update_link = false;
47304780
bool update_pause = false;
4781+
bool update_eee = false;
47314782
struct bnxt_link_info *link_info = &bp->link_info;
47324783

47334784
rc = bnxt_update_link(bp, true);
@@ -4757,8 +4808,11 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
47574808
update_link = true;
47584809
}
47594810

4811+
if (!bnxt_eee_config_ok(bp))
4812+
update_eee = true;
4813+
47604814
if (update_link)
4761-
rc = bnxt_hwrm_set_link_setting(bp, update_pause);
4815+
rc = bnxt_hwrm_set_link_setting(bp, update_pause, update_eee);
47624816
else if (update_pause)
47634817
rc = bnxt_hwrm_set_pause(bp);
47644818
if (rc) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
11121112
int bnxt_hwrm_set_coal(struct bnxt *);
11131113
int bnxt_hwrm_func_qcaps(struct bnxt *);
11141114
int bnxt_hwrm_set_pause(struct bnxt *);
1115-
int bnxt_hwrm_set_link_setting(struct bnxt *, bool);
1115+
int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
11161116
int bnxt_open_nic(struct bnxt *, bool, bool);
11171117
int bnxt_close_nic(struct bnxt *, bool, bool);
11181118
int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ static u32 bnxt_get_fw_speed(struct net_device *dev, u16 ethtool_speed)
763763
return 0;
764764
}
765765

766-
static u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
766+
u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
767767
{
768768
u16 fw_speed_mask = 0;
769769

@@ -840,7 +840,7 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
840840
}
841841

842842
if (netif_running(dev))
843-
rc = bnxt_hwrm_set_link_setting(bp, set_pause);
843+
rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);
844844

845845
set_setting_exit:
846846
return rc;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ extern const struct ethtool_ops bnxt_ethtool_ops;
1414

1515
u32 _bnxt_fw_to_ethtool_adv_spds(u16, u8);
1616
u32 bnxt_fw_to_ethtool_speed(u16);
17+
u16 bnxt_get_fw_auto_link_speeds(u32);
1718

1819
#endif

0 commit comments

Comments
 (0)