Commit 24a7a455 authored by Dhananjay Phadke's avatar Dhananjay Phadke Committed by Jeff Garzik

netxen: fix link status, link speed

For NX3031, the phy is managed by firmware, so driver should avoid
setting any phy registers.
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 4ad7a018
......@@ -140,18 +140,33 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
if (netif_running(dev)) {
ecmd->speed = adapter->link_speed;
ecmd->duplex = adapter->link_duplex;
} else
return -EIO; /* link absent */
ecmd->autoneg = adapter->link_autoneg;
}
} else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
ecmd->supported = (SUPPORTED_TP |
SUPPORTED_1000baseT_Full |
SUPPORTED_10000baseT_Full);
ecmd->advertising = (ADVERTISED_TP |
ADVERTISED_1000baseT_Full |
ADVERTISED_10000baseT_Full);
u32 val;
adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR, &val, 4);
if (val == NETXEN_PORT_MODE_802_3_AP) {
ecmd->supported = SUPPORTED_1000baseT_Full;
ecmd->advertising = ADVERTISED_1000baseT_Full;
} else {
ecmd->supported = SUPPORTED_10000baseT_Full;
ecmd->advertising = ADVERTISED_10000baseT_Full;
}
ecmd->port = PORT_TP;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
u16 pcifn = adapter->ahw.pci_func;
adapter->hw_read_wx(adapter,
P3_LINK_SPEED_REG(pcifn), &val, 4);
ecmd->speed = P3_LINK_SPEED_MHZ *
P3_LINK_SPEED_VAL(pcifn, val);
} else
ecmd->speed = SPEED_10000;
ecmd->duplex = DUPLEX_FULL;
ecmd->autoneg = AUTONEG_DISABLE;
} else
......
......@@ -724,6 +724,13 @@ enum {
#define XG_LINK_STATE_P3(pcifn,val) \
(((val) >> ((pcifn) * 4)) & XG_LINK_STATE_P3_MASK)
#define P3_LINK_SPEED_MHZ 100
#define P3_LINK_SPEED_MASK 0xff
#define P3_LINK_SPEED_REG(pcifn) \
(CRB_PF_LINK_SPEED_1 + (((pcifn) / 4) * 4))
#define P3_LINK_SPEED_VAL(pcifn, reg) \
(((reg) >> (8 * ((pcifn) & 0x3))) & P3_LINK_SPEED_MASK)
#define NETXEN_CAM_RAM_BASE (NETXEN_CRB_CAM + 0x02000)
#define NETXEN_CAM_RAM(reg) (NETXEN_CAM_RAM_BASE + (reg))
#define NETXEN_FW_VERSION_MAJOR (NETXEN_CAM_RAM(0x150))
......
......@@ -2074,12 +2074,22 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
__u32 status;
__u32 autoneg;
__u32 mode;
__u32 port_mode;
netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */
adapter->hw_read_wx(adapter,
NETXEN_PORT_MODE_ADDR, &port_mode, 4);
if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
adapter->link_speed = SPEED_1000;
adapter->link_duplex = DUPLEX_FULL;
adapter->link_autoneg = AUTONEG_DISABLE;
return;
}
if (adapter->phy_read
&& adapter->
phy_read(adapter,
&& adapter->phy_read(adapter,
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
&status) == 0) {
if (netxen_get_phy_link(status)) {
......@@ -2109,8 +2119,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
break;
}
if (adapter->phy_read
&& adapter->
phy_read(adapter,
&& adapter->phy_read(adapter,
NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
&autoneg) != 0)
adapter->link_autoneg = autoneg;
......
......@@ -1410,20 +1410,17 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
port = adapter->physical_port;
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
val = adapter->pci_read_normalize(adapter, CRB_XG_STATE_P3);
val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
linkup = (val == XG_LINK_UP_P3);
} else {
val = adapter->pci_read_normalize(adapter, CRB_XG_STATE);
if (adapter->ahw.board_type == NETXEN_NIC_GBE)
linkup = (val >> port) & 1;
} else {
if (adapter->fw_major < 4) {
val = adapter->pci_read_normalize(adapter,
CRB_XG_STATE);
else {
val = (val >> port*8) & 0xff;
linkup = (val == XG_LINK_UP);
} else {
val = adapter->pci_read_normalize(adapter,
CRB_XG_STATE_P3);
val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
linkup = (val == XG_LINK_UP_P3);
}
}
......
......@@ -610,6 +610,9 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
int i;
DECLARE_MAC_BUF(mac);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
return 0;
for (i = 0; i < 10; i++) {
temp[0] = temp[1] = 0;
memcpy(temp + 2, addr, 2);
......@@ -727,6 +730,9 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
__u32 mac_cfg0;
u32 port = adapter->physical_port;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
return 0;
if (port > NETXEN_NIU_MAX_GBE_PORTS)
return -EINVAL;
mac_cfg0 = 0;
......@@ -743,6 +749,9 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
__u32 mac_cfg;
u32 port = adapter->physical_port;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
return 0;
if (port > NETXEN_NIU_MAX_XG_PORTS)
return -EINVAL;
......@@ -819,6 +828,9 @@ int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
u8 temp[4];
u32 val;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
return 0;
if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS))
return -EIO;
......
......@@ -95,8 +95,8 @@
#define CRB_HOST_STS_PROD NETXEN_NIC_REG(0xdc)
#define CRB_HOST_STS_CONS NETXEN_NIC_REG(0xe0)
#define CRB_PEG_CMD_PROD NETXEN_NIC_REG(0xe4)
#define CRB_PEG_CMD_CONS NETXEN_NIC_REG(0xe8)
#define CRB_HOST_BUFFER_PROD NETXEN_NIC_REG(0xec)
#define CRB_PF_LINK_SPEED_1 NETXEN_NIC_REG(0xe8)
#define CRB_PF_LINK_SPEED_2 NETXEN_NIC_REG(0xec)
#define CRB_HOST_BUFFER_CONS NETXEN_NIC_REG(0xf0)
#define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4)
#define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment