Commit f31a45d2 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

sfc: Remove MII extension cruft

Replace efx_nic::link_options bitfield with link_speed (speed in
Mbit/s) and link_fd (full duplex flag).

Remove broken auto-negotiation functions.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 50050877
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/topology.h> #include <linux/topology.h>
#include "net_driver.h" #include "net_driver.h"
#include "gmii.h"
#include "ethtool.h" #include "ethtool.h"
#include "tx.h" #include "tx.h"
#include "rx.h" #include "rx.h"
...@@ -551,26 +550,8 @@ static void efx_link_status_changed(struct efx_nic *efx) ...@@ -551,26 +550,8 @@ static void efx_link_status_changed(struct efx_nic *efx)
/* Status message for kernel log */ /* Status message for kernel log */
if (efx->link_up) { if (efx->link_up) {
struct mii_if_info *gmii = &efx->mii; EFX_INFO(efx, "link up at %uMbps %s-duplex (MTU %d)%s\n",
unsigned adv, lpa; efx->link_speed, efx->link_fd ? "full" : "half",
/* NONE here means direct XAUI from the controller, with no
* MDIO-attached device we can query. */
if (efx->phy_type != PHY_TYPE_NONE) {
adv = gmii_advertised(gmii);
lpa = gmii_lpa(gmii);
} else {
lpa = GM_LPA_10000 | LPA_DUPLEX;
adv = lpa;
}
EFX_INFO(efx, "link up at %dMbps %s-duplex "
"(adv %04x lpa %04x) (MTU %d)%s\n",
(efx->link_options & GM_LPA_10000 ? 10000 :
(efx->link_options & GM_LPA_1000 ? 1000 :
(efx->link_options & GM_LPA_100 ? 100 :
10))),
(efx->link_options & GM_LPA_DUPLEX ?
"full" : "half"),
adv, lpa,
efx->net_dev->mtu, efx->net_dev->mtu,
(efx->promiscuous ? " [PROMISC]" : "")); (efx->promiscuous ? " [PROMISC]" : ""));
} else { } else {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "efx.h" #include "efx.h"
#include "ethtool.h" #include "ethtool.h"
#include "falcon.h" #include "falcon.h"
#include "gmii.h"
#include "spi.h" #include "spi.h"
#include "mac.h" #include "mac.h"
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include <linux/mii.h>
#include "net_driver.h" #include "net_driver.h"
#include "bitfield.h" #include "bitfield.h"
#include "efx.h" #include "efx.h"
#include "mac.h" #include "mac.h"
#include "gmii.h"
#include "spi.h" #include "spi.h"
#include "falcon.h" #include "falcon.h"
#include "falcon_hwdefs.h" #include "falcon_hwdefs.h"
...@@ -1915,14 +1915,12 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx) ...@@ -1915,14 +1915,12 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
int link_speed; int link_speed;
bool tx_fc; bool tx_fc;
if (efx->link_options & GM_LPA_10000) switch (efx->link_speed) {
link_speed = 0x3; case 10000: link_speed = 3; break;
else if (efx->link_options & GM_LPA_1000) case 1000: link_speed = 2; break;
link_speed = 0x2; case 100: link_speed = 1; break;
else if (efx->link_options & GM_LPA_100) default: link_speed = 0; break;
link_speed = 0x1; }
else
link_speed = 0x0;
/* MAC_LINK_STATUS controls MAC backpressure but doesn't work /* MAC_LINK_STATUS controls MAC backpressure but doesn't work
* as advertised. Disable to ensure packets are not * as advertised. Disable to ensure packets are not
* indefinitely held and TX queue can be flushed at any point * indefinitely held and TX queue can be flushed at any point
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "falcon_hwdefs.h" #include "falcon_hwdefs.h"
#include "falcon_io.h" #include "falcon_io.h"
#include "mac.h" #include "mac.h"
#include "gmii.h"
#include "mdio_10g.h" #include "mdio_10g.h"
#include "phy.h" #include "phy.h"
#include "boards.h" #include "boards.h"
......
/**************************************************************************** /****************************************************************************
* Driver for Solarflare Solarstorm network controllers and boards * Driver for Solarflare Solarstorm network controllers and boards
* Copyright 2005-2006 Fen Systems Ltd. * Copyright 2005-2006 Fen Systems Ltd.
* Copyright 2006 Solarflare Communications Inc. * Copyright 2006-2008 Solarflare Communications Inc.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published * under the terms of the GNU General Public License version 2 as published
...@@ -57,139 +57,4 @@ ...@@ -57,139 +57,4 @@
#define ISR_POLARITY_CHG 0x0002 /* Bit 1 - polarity changed */ #define ISR_POLARITY_CHG 0x0002 /* Bit 1 - polarity changed */
#define ISR_JABBER 0x0001 /* Bit 0 - jabber */ #define ISR_JABBER 0x0001 /* Bit 0 - jabber */
/* Logically extended advertisement register */
#define GM_ADVERTISE_SLCT ADVERTISE_SLCT
#define GM_ADVERTISE_CSMA ADVERTISE_CSMA
#define GM_ADVERTISE_10HALF ADVERTISE_10HALF
#define GM_ADVERTISE_1000XFULL ADVERTISE_1000XFULL
#define GM_ADVERTISE_10FULL ADVERTISE_10FULL
#define GM_ADVERTISE_1000XHALF ADVERTISE_1000XHALF
#define GM_ADVERTISE_100HALF ADVERTISE_100HALF
#define GM_ADVERTISE_1000XPAUSE ADVERTISE_1000XPAUSE
#define GM_ADVERTISE_100FULL ADVERTISE_100FULL
#define GM_ADVERTISE_1000XPSE_ASYM ADVERTISE_1000XPSE_ASYM
#define GM_ADVERTISE_100BASE4 ADVERTISE_100BASE4
#define GM_ADVERTISE_PAUSE_CAP ADVERTISE_PAUSE_CAP
#define GM_ADVERTISE_PAUSE_ASYM ADVERTISE_PAUSE_ASYM
#define GM_ADVERTISE_RESV ADVERTISE_RESV
#define GM_ADVERTISE_RFAULT ADVERTISE_RFAULT
#define GM_ADVERTISE_LPACK ADVERTISE_LPACK
#define GM_ADVERTISE_NPAGE ADVERTISE_NPAGE
#define GM_ADVERTISE_1000FULL (ADVERTISE_1000FULL << 8)
#define GM_ADVERTISE_1000HALF (ADVERTISE_1000HALF << 8)
#define GM_ADVERTISE_1000 (GM_ADVERTISE_1000FULL | \
GM_ADVERTISE_1000HALF)
#define GM_ADVERTISE_FULL (GM_ADVERTISE_1000FULL | \
ADVERTISE_FULL)
#define GM_ADVERTISE_ALL (GM_ADVERTISE_1000FULL | \
GM_ADVERTISE_1000HALF | \
ADVERTISE_ALL)
/* Logically extended link partner ability register */
#define GM_LPA_SLCT LPA_SLCT
#define GM_LPA_10HALF LPA_10HALF
#define GM_LPA_1000XFULL LPA_1000XFULL
#define GM_LPA_10FULL LPA_10FULL
#define GM_LPA_1000XHALF LPA_1000XHALF
#define GM_LPA_100HALF LPA_100HALF
#define GM_LPA_1000XPAUSE LPA_1000XPAUSE
#define GM_LPA_100FULL LPA_100FULL
#define GM_LPA_1000XPAUSE_ASYM LPA_1000XPAUSE_ASYM
#define GM_LPA_100BASE4 LPA_100BASE4
#define GM_LPA_PAUSE_CAP LPA_PAUSE_CAP
#define GM_LPA_PAUSE_ASYM LPA_PAUSE_ASYM
#define GM_LPA_RESV LPA_RESV
#define GM_LPA_RFAULT LPA_RFAULT
#define GM_LPA_LPACK LPA_LPACK
#define GM_LPA_NPAGE LPA_NPAGE
#define GM_LPA_1000FULL (LPA_1000FULL << 6)
#define GM_LPA_1000HALF (LPA_1000HALF << 6)
#define GM_LPA_10000FULL 0x00040000
#define GM_LPA_10000HALF 0x00080000
#define GM_LPA_DUPLEX (GM_LPA_1000FULL | GM_LPA_10000FULL \
| LPA_DUPLEX)
#define GM_LPA_10 (LPA_10FULL | LPA_10HALF)
#define GM_LPA_100 LPA_100
#define GM_LPA_1000 (GM_LPA_1000FULL | GM_LPA_1000HALF)
#define GM_LPA_10000 (GM_LPA_10000FULL | GM_LPA_10000HALF)
/* Retrieve GMII autonegotiation advertised abilities
*
* The MII advertisment register (MII_ADVERTISE) is logically extended
* to include advertisement bits ADVERTISE_1000FULL and
* ADVERTISE_1000HALF from MII_CTRL1000. The result can be tested
* against the GM_ADVERTISE_xxx constants.
*/
static inline unsigned int gmii_advertised(struct mii_if_info *gmii)
{
unsigned int advertise;
unsigned int ctrl1000;
advertise = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_ADVERTISE);
ctrl1000 = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_CTRL1000);
return (((ctrl1000 << 8) & GM_ADVERTISE_1000) | advertise);
}
/* Retrieve GMII autonegotiation link partner abilities
*
* The MII link partner ability register (MII_LPA) is logically
* extended by adding bits LPA_1000HALF and LPA_1000FULL from
* MII_STAT1000. The result can be tested against the GM_LPA_xxx
* constants.
*/
static inline unsigned int gmii_lpa(struct mii_if_info *gmii)
{
unsigned int lpa;
unsigned int stat1000;
lpa = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_LPA);
stat1000 = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_STAT1000);
return (((stat1000 << 6) & GM_LPA_1000) | lpa);
}
/* Calculate GMII autonegotiated link technology
*
* "negotiated" should be the result of gmii_advertised() logically
* ANDed with the result of gmii_lpa().
*
* "tech" will be negotiated with the unused bits masked out. For
* example, if both ends of the link are capable of both
* GM_LPA_1000FULL and GM_LPA_100FULL, GM_LPA_100FULL will be masked
* out.
*/
static inline unsigned int gmii_nway_result(unsigned int negotiated)
{
unsigned int other_bits;
/* Mask out the speed and duplexity bits */
other_bits = negotiated & ~(GM_LPA_10 | GM_LPA_100 | GM_LPA_1000);
if (negotiated & GM_LPA_1000FULL)
return (other_bits | GM_LPA_1000FULL);
else if (negotiated & GM_LPA_1000HALF)
return (other_bits | GM_LPA_1000HALF);
else
return (other_bits | mii_nway_result(negotiated));
}
/* Calculate GMII non-autonegotiated link technology
*
* This provides an equivalent to gmii_nway_result for the case when
* autonegotiation is disabled.
*/
static inline unsigned int gmii_forced_result(unsigned int bmcr)
{
unsigned int result;
int full_duplex;
full_duplex = bmcr & BMCR_FULLDPLX;
if (bmcr & BMCR_SPEED1000)
result = full_duplex ? GM_LPA_1000FULL : GM_LPA_1000HALF;
else if (bmcr & BMCR_SPEED100)
result = full_duplex ? GM_LPA_100FULL : GM_LPA_100HALF;
else
result = full_duplex ? GM_LPA_10FULL : GM_LPA_10HALF;
return result;
}
#endif /* EFX_GMII_H */ #endif /* EFX_GMII_H */
...@@ -694,7 +694,8 @@ union efx_multicast_hash { ...@@ -694,7 +694,8 @@ union efx_multicast_hash {
* @mii: PHY interface * @mii: PHY interface
* @phy_mode: PHY operating mode. Serialised by @mac_lock. * @phy_mode: PHY operating mode. Serialised by @mac_lock.
* @link_up: Link status * @link_up: Link status
* @link_options: Link options (MII/GMII format) * @link_fd: Link is full duplex
* @link_speed: Link speed (Mbps)
* @n_link_state_changes: Number of times the link has changed state * @n_link_state_changes: Number of times the link has changed state
* @promiscuous: Promiscuous flag. Protected by netif_tx_lock. * @promiscuous: Promiscuous flag. Protected by netif_tx_lock.
* @multicast_hash: Multicast hash table * @multicast_hash: Multicast hash table
...@@ -772,7 +773,8 @@ struct efx_nic { ...@@ -772,7 +773,8 @@ struct efx_nic {
enum efx_phy_mode phy_mode; enum efx_phy_mode phy_mode;
bool link_up; bool link_up;
unsigned int link_options; bool link_fd;
unsigned int link_speed;
unsigned int n_link_state_changes; unsigned int n_link_state_changes;
bool promiscuous; bool promiscuous;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include "efx.h" #include "efx.h"
#include "gmii.h"
#include "mdio_10g.h" #include "mdio_10g.h"
#include "falcon.h" #include "falcon.h"
#include "phy.h" #include "phy.h"
...@@ -362,7 +361,8 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx) ...@@ -362,7 +361,8 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx)
phy_data->loopback_mode = efx->loopback_mode; phy_data->loopback_mode = efx->loopback_mode;
phy_data->phy_mode = efx->phy_mode; phy_data->phy_mode = efx->phy_mode;
efx->link_up = tenxpress_link_ok(efx, false); efx->link_up = tenxpress_link_ok(efx, false);
efx->link_options = GM_LPA_10000FULL; efx->link_speed = 10000;
efx->link_fd = true;
} }
static void tenxpress_phy_clear_interrupt(struct efx_nic *efx) static void tenxpress_phy_clear_interrupt(struct efx_nic *efx)
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "efx.h" #include "efx.h"
#include "gmii.h"
#include "mdio_10g.h" #include "mdio_10g.h"
#include "xenpack.h" #include "xenpack.h"
#include "phy.h" #include "phy.h"
...@@ -154,7 +153,8 @@ static void xfp_phy_reconfigure(struct efx_nic *efx) ...@@ -154,7 +153,8 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
phy_data->phy_mode = efx->phy_mode; phy_data->phy_mode = efx->phy_mode;
efx->link_up = xfp_link_ok(efx); efx->link_up = xfp_link_ok(efx);
efx->link_options = GM_LPA_10000FULL; efx->link_speed = 10000;
efx->link_fd = true;
} }
......
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