Skip to content

Commit f1cc809

Browse files
committed
Merge branch 'bnxt_en-next'
Michael Chan says: ==================== bnxt_en: Updates for net-next. Update to latest firmware interface, add EEE feature, unsupported SFP+ module warning, and ethtool -s improvements. v2: Removed the GEEPROM patch and added more comments to the get_eee patch. ====================
2 parents 04c85bf + 29c262f commit f1cc809

File tree

9 files changed

+803
-95
lines changed

9 files changed

+803
-95
lines changed

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

Lines changed: 237 additions & 22 deletions
Large diffs are not rendered by default.

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2014-2015 Broadcom Corporation
3+
* Copyright (c) 2014-2016 Broadcom Corporation
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -11,7 +11,7 @@
1111
#define BNXT_H
1212

1313
#define DRV_MODULE_NAME "bnxt_en"
14-
#define DRV_MODULE_VERSION "1.0.0"
14+
#define DRV_MODULE_VERSION "1.2.0"
1515

1616
#define DRV_VER_MAJ 1
1717
#define DRV_VER_MIN 0
@@ -788,7 +788,7 @@ struct bnxt_link_info {
788788
#define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
789789
#define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
790790
#define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
791-
#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_MASK
791+
#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
792792
#define PHY_VER_LEN 3
793793
u8 phy_ver[PHY_VER_LEN];
794794
u16 link_speed;
@@ -813,7 +813,6 @@ struct bnxt_link_info {
813813
#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
814814
#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
815815
u16 lp_auto_link_speeds;
816-
u16 auto_link_speed;
817816
u16 force_link_speed;
818817
u32 preemphasis;
819818

@@ -826,6 +825,8 @@ struct bnxt_link_info {
826825
u16 req_link_speed;
827826
u32 advertising;
828827
bool force_link_chng;
828+
829+
u8 last_port_module_event;
829830
/* a copy of phy_qcfg output used to report link
830831
* info to VF
831832
*/
@@ -875,6 +876,7 @@ struct bnxt {
875876
#define BNXT_FLAG_RFS 0x100
876877
#define BNXT_FLAG_SHARED_RINGS 0x200
877878
#define BNXT_FLAG_PORT_STATS 0x400
879+
#define BNXT_FLAG_EEE_CAP 0x1000
878880

879881
#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
880882
BNXT_FLAG_RFS | \
@@ -940,6 +942,7 @@ struct bnxt {
940942

941943
u32 msg_enable;
942944

945+
u32 hwrm_spec_code;
943946
u16 hwrm_cmd_seq;
944947
u32 hwrm_intr_seq_id;
945948
void *hwrm_cmd_resp_addr;
@@ -991,6 +994,7 @@ struct bnxt {
991994
#define BNXT_RST_RING_SP_EVENT 7
992995
#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
993996
#define BNXT_PERIODIC_STATS_SP_EVENT 9
997+
#define BNXT_HWRM_PORT_MODULE_SP_EVENT 10
994998

995999
struct bnxt_pf_info pf;
9961000
#ifdef CONFIG_BNXT_SRIOV
@@ -1011,6 +1015,9 @@ struct bnxt {
10111015
int ntp_fltr_count;
10121016

10131017
struct bnxt_link_info link_info;
1018+
struct ethtool_eee eee;
1019+
u32 lpi_tmr_lo;
1020+
u32 lpi_tmr_hi;
10141021
};
10151022

10161023
#ifdef CONFIG_NET_RX_BUSY_POLL
@@ -1108,7 +1115,7 @@ int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
11081115
int bnxt_hwrm_set_coal(struct bnxt *);
11091116
int bnxt_hwrm_func_qcaps(struct bnxt *);
11101117
int bnxt_hwrm_set_pause(struct bnxt *);
1111-
int bnxt_hwrm_set_link_setting(struct bnxt *, bool);
1118+
int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
11121119
int bnxt_open_nic(struct bnxt *, bool, bool);
11131120
int bnxt_close_nic(struct bnxt *, bool, bool);
11141121
int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);

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

Lines changed: 136 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2014-2015 Broadcom Corporation
3+
* Copyright (c) 2014-2016 Broadcom Corporation
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -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

@@ -698,10 +698,23 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
698698
if (link_info->phy_link_status == BNXT_LINK_LINK)
699699
cmd->lp_advertising =
700700
bnxt_fw_to_ethtool_lp_adv(link_info);
701+
ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
702+
if (!netif_carrier_ok(dev))
703+
cmd->duplex = DUPLEX_UNKNOWN;
704+
else if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
705+
cmd->duplex = DUPLEX_FULL;
706+
else
707+
cmd->duplex = DUPLEX_HALF;
701708
} else {
702709
cmd->autoneg = AUTONEG_DISABLE;
703710
cmd->advertising = 0;
711+
ethtool_speed =
712+
bnxt_fw_to_ethtool_speed(link_info->req_link_speed);
713+
cmd->duplex = DUPLEX_HALF;
714+
if (link_info->req_duplex == BNXT_LINK_DUPLEX_FULL)
715+
cmd->duplex = DUPLEX_FULL;
704716
}
717+
ethtool_cmd_speed_set(cmd, ethtool_speed);
705718

706719
cmd->port = PORT_NONE;
707720
if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) {
@@ -719,16 +732,8 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
719732
cmd->port = PORT_FIBRE;
720733
}
721734

722-
if (link_info->phy_link_status == BNXT_LINK_LINK) {
723-
if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
724-
cmd->duplex = DUPLEX_FULL;
725-
} else {
726-
cmd->duplex = DUPLEX_UNKNOWN;
727-
}
728-
ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
729-
ethtool_cmd_speed_set(cmd, ethtool_speed);
730735
if (link_info->transceiver ==
731-
PORT_PHY_QCFG_RESP_TRANSCEIVER_TYPE_XCVR_INTERNAL)
736+
PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_INTERNAL)
732737
cmd->transceiver = XCVR_INTERNAL;
733738
else
734739
cmd->transceiver = XCVR_EXTERNAL;
@@ -739,31 +744,52 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
739744

740745
static u32 bnxt_get_fw_speed(struct net_device *dev, u16 ethtool_speed)
741746
{
747+
struct bnxt *bp = netdev_priv(dev);
748+
struct bnxt_link_info *link_info = &bp->link_info;
749+
u16 support_spds = link_info->support_speeds;
750+
u32 fw_speed = 0;
751+
742752
switch (ethtool_speed) {
743753
case SPEED_100:
744-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100MB;
754+
if (support_spds & BNXT_LINK_SPEED_MSK_100MB)
755+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100MB;
756+
break;
745757
case SPEED_1000:
746-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_1GB;
758+
if (support_spds & BNXT_LINK_SPEED_MSK_1GB)
759+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_1GB;
760+
break;
747761
case SPEED_2500:
748-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_2_5GB;
762+
if (support_spds & BNXT_LINK_SPEED_MSK_2_5GB)
763+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_2_5GB;
764+
break;
749765
case SPEED_10000:
750-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_10GB;
766+
if (support_spds & BNXT_LINK_SPEED_MSK_10GB)
767+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_10GB;
768+
break;
751769
case SPEED_20000:
752-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_20GB;
770+
if (support_spds & BNXT_LINK_SPEED_MSK_20GB)
771+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_20GB;
772+
break;
753773
case SPEED_25000:
754-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_25GB;
774+
if (support_spds & BNXT_LINK_SPEED_MSK_25GB)
775+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_25GB;
776+
break;
755777
case SPEED_40000:
756-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_40GB;
778+
if (support_spds & BNXT_LINK_SPEED_MSK_40GB)
779+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_40GB;
780+
break;
757781
case SPEED_50000:
758-
return PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_50GB;
782+
if (support_spds & BNXT_LINK_SPEED_MSK_50GB)
783+
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_50GB;
784+
break;
759785
default:
760786
netdev_err(dev, "unsupported speed!\n");
761787
break;
762788
}
763-
return 0;
789+
return fw_speed;
764790
}
765791

766-
static u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
792+
u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
767793
{
768794
u16 fw_speed_mask = 0;
769795

@@ -823,6 +849,8 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
823849
*/
824850
set_pause = true;
825851
} else {
852+
u16 fw_speed;
853+
826854
/* TODO: currently don't support half duplex */
827855
if (cmd->duplex == DUPLEX_HALF) {
828856
netdev_err(dev, "HALF DUPLEX is not supported!\n");
@@ -833,14 +861,19 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
833861
if (cmd->duplex == DUPLEX_UNKNOWN)
834862
cmd->duplex = DUPLEX_FULL;
835863
speed = ethtool_cmd_speed(cmd);
836-
link_info->req_link_speed = bnxt_get_fw_speed(dev, speed);
864+
fw_speed = bnxt_get_fw_speed(dev, speed);
865+
if (!fw_speed) {
866+
rc = -EINVAL;
867+
goto set_setting_exit;
868+
}
869+
link_info->req_link_speed = fw_speed;
837870
link_info->req_duplex = BNXT_LINK_DUPLEX_FULL;
838871
link_info->autoneg = 0;
839872
link_info->advertising = 0;
840873
}
841874

842875
if (netif_running(dev))
843-
rc = bnxt_hwrm_set_link_setting(bp, set_pause);
876+
rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);
844877

845878
set_setting_exit:
846879
return rc;
@@ -874,25 +907,23 @@ static int bnxt_set_pauseparam(struct net_device *dev,
874907
return -EINVAL;
875908

876909
link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL;
877-
link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_BOTH;
910+
if (bp->hwrm_spec_code >= 0x10201)
911+
link_info->req_flow_ctrl =
912+
PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE;
878913
} else {
879914
/* when transition from auto pause to force pause,
880915
* force a link change
881916
*/
882917
if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL)
883918
link_info->force_link_chng = true;
884919
link_info->autoneg &= ~BNXT_AUTONEG_FLOW_CTRL;
885-
link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_BOTH;
920+
link_info->req_flow_ctrl = 0;
886921
}
887922
if (epause->rx_pause)
888923
link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_RX;
889-
else
890-
link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_RX;
891924

892925
if (epause->tx_pause)
893926
link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_TX;
894-
else
895-
link_info->req_flow_ctrl &= ~BNXT_LINK_PAUSE_TX;
896927

897928
if (netif_running(dev))
898929
rc = bnxt_hwrm_set_pause(bp);
@@ -1381,6 +1412,80 @@ static int bnxt_set_eeprom(struct net_device *dev,
13811412
eeprom->len);
13821413
}
13831414

1415+
static int bnxt_set_eee(struct net_device *dev, struct ethtool_eee *edata)
1416+
{
1417+
struct bnxt *bp = netdev_priv(dev);
1418+
struct ethtool_eee *eee = &bp->eee;
1419+
struct bnxt_link_info *link_info = &bp->link_info;
1420+
u32 advertising =
1421+
_bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0);
1422+
int rc = 0;
1423+
1424+
if (BNXT_VF(bp))
1425+
return 0;
1426+
1427+
if (!(bp->flags & BNXT_FLAG_EEE_CAP))
1428+
return -EOPNOTSUPP;
1429+
1430+
if (!edata->eee_enabled)
1431+
goto eee_ok;
1432+
1433+
if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) {
1434+
netdev_warn(dev, "EEE requires autoneg\n");
1435+
return -EINVAL;
1436+
}
1437+
if (edata->tx_lpi_enabled) {
1438+
if (bp->lpi_tmr_hi && (edata->tx_lpi_timer > bp->lpi_tmr_hi ||
1439+
edata->tx_lpi_timer < bp->lpi_tmr_lo)) {
1440+
netdev_warn(dev, "Valid LPI timer range is %d and %d microsecs\n",
1441+
bp->lpi_tmr_lo, bp->lpi_tmr_hi);
1442+
return -EINVAL;
1443+
} else if (!bp->lpi_tmr_hi) {
1444+
edata->tx_lpi_timer = eee->tx_lpi_timer;
1445+
}
1446+
}
1447+
if (!edata->advertised) {
1448+
edata->advertised = advertising & eee->supported;
1449+
} else if (edata->advertised & ~advertising) {
1450+
netdev_warn(dev, "EEE advertised %x must be a subset of autoneg advertised speeds %x\n",
1451+
edata->advertised, advertising);
1452+
return -EINVAL;
1453+
}
1454+
1455+
eee->advertised = edata->advertised;
1456+
eee->tx_lpi_enabled = edata->tx_lpi_enabled;
1457+
eee->tx_lpi_timer = edata->tx_lpi_timer;
1458+
eee_ok:
1459+
eee->eee_enabled = edata->eee_enabled;
1460+
1461+
if (netif_running(dev))
1462+
rc = bnxt_hwrm_set_link_setting(bp, false, true);
1463+
1464+
return rc;
1465+
}
1466+
1467+
static int bnxt_get_eee(struct net_device *dev, struct ethtool_eee *edata)
1468+
{
1469+
struct bnxt *bp = netdev_priv(dev);
1470+
1471+
if (!(bp->flags & BNXT_FLAG_EEE_CAP))
1472+
return -EOPNOTSUPP;
1473+
1474+
*edata = bp->eee;
1475+
if (!bp->eee.eee_enabled) {
1476+
/* Preserve tx_lpi_timer so that the last value will be used
1477+
* by default when it is re-enabled.
1478+
*/
1479+
edata->advertised = 0;
1480+
edata->tx_lpi_enabled = 0;
1481+
}
1482+
1483+
if (!bp->eee.eee_active)
1484+
edata->lp_advertised = 0;
1485+
1486+
return 0;
1487+
}
1488+
13841489
const struct ethtool_ops bnxt_ethtool_ops = {
13851490
.get_settings = bnxt_get_settings,
13861491
.set_settings = bnxt_set_settings,
@@ -1409,4 +1514,6 @@ const struct ethtool_ops bnxt_ethtool_ops = {
14091514
.get_eeprom = bnxt_get_eeprom,
14101515
.set_eeprom = bnxt_set_eeprom,
14111516
.get_link = bnxt_get_link,
1517+
.get_eee = bnxt_get_eee,
1518+
.set_eee = bnxt_set_eee,
14121519
};

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2014-2015 Broadcom Corporation
3+
* Copyright (c) 2014-2016 Broadcom Corporation
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -12,6 +12,8 @@
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);
17+
u16 bnxt_get_fw_auto_link_speeds(u32);
1618

1719
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2014-2015 Broadcom Corporation
3+
* Copyright (c) 2014-2016 Broadcom Corporation
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by

0 commit comments

Comments
 (0)