aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/ethtool.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-09-01 07:47:16 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-03 09:53:45 -0400
commit4a5b504d0c582db80813b70359b616ea30e91743 (patch)
treec3b10e411914a42c21d2a525e26eb440e37c6651 /drivers/net/sfc/ethtool.c
parent4d566063a799231b99d9a21128634ea78b89ab72 (diff)
sfc: Export boot configuration in EEPROM through ethtool
Extend the SPI device setup code to support this. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/sfc/ethtool.c')
-rw-r--r--drivers/net/sfc/ethtool.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 6142c3a394bf..72a2eb2e3a19 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -17,6 +17,7 @@
17#include "ethtool.h" 17#include "ethtool.h"
18#include "falcon.h" 18#include "falcon.h"
19#include "gmii.h" 19#include "gmii.h"
20#include "spi.h"
20#include "mac.h" 21#include "mac.h"
21 22
22const char *efx_loopback_mode_names[] = { 23const char *efx_loopback_mode_names[] = {
@@ -171,6 +172,11 @@ static struct efx_ethtool_stat efx_ethtool_stats[] = {
171/* Number of ethtool statistics */ 172/* Number of ethtool statistics */
172#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats) 173#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
173 174
175/* EEPROM range with gPXE configuration */
176#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
177#define EFX_ETHTOOL_EEPROM_MIN 0x100U
178#define EFX_ETHTOOL_EEPROM_MAX 0x400U
179
174/************************************************************************** 180/**************************************************************************
175 * 181 *
176 * Ethtool operations 182 * Ethtool operations
@@ -532,6 +538,49 @@ static u32 efx_ethtool_get_link(struct net_device *net_dev)
532 return efx->link_up; 538 return efx->link_up;
533} 539}
534 540
541static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
542{
543 struct efx_nic *efx = netdev_priv(net_dev);
544 struct efx_spi_device *spi = efx->spi_eeprom;
545
546 if (!spi)
547 return 0;
548 return min(spi->size, EFX_ETHTOOL_EEPROM_MAX) -
549 min(spi->size, EFX_ETHTOOL_EEPROM_MIN);
550}
551
552static int efx_ethtool_get_eeprom(struct net_device *net_dev,
553 struct ethtool_eeprom *eeprom, u8 *buf)
554{
555 struct efx_nic *efx = netdev_priv(net_dev);
556 struct efx_spi_device *spi = efx->spi_eeprom;
557 size_t len;
558 int rc;
559
560 rc = falcon_spi_read(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN,
561 eeprom->len, &len, buf);
562 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
563 eeprom->len = len;
564 return rc;
565}
566
567static int efx_ethtool_set_eeprom(struct net_device *net_dev,
568 struct ethtool_eeprom *eeprom, u8 *buf)
569{
570 struct efx_nic *efx = netdev_priv(net_dev);
571 struct efx_spi_device *spi = efx->spi_eeprom;
572 size_t len;
573 int rc;
574
575 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
576 return -EINVAL;
577
578 rc = falcon_spi_write(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN,
579 eeprom->len, &len, buf);
580 eeprom->len = len;
581 return rc;
582}
583
535static int efx_ethtool_get_coalesce(struct net_device *net_dev, 584static int efx_ethtool_get_coalesce(struct net_device *net_dev,
536 struct ethtool_coalesce *coalesce) 585 struct ethtool_coalesce *coalesce)
537{ 586{
@@ -653,6 +702,9 @@ struct ethtool_ops efx_ethtool_ops = {
653 .get_drvinfo = efx_ethtool_get_drvinfo, 702 .get_drvinfo = efx_ethtool_get_drvinfo,
654 .nway_reset = efx_ethtool_nway_reset, 703 .nway_reset = efx_ethtool_nway_reset,
655 .get_link = efx_ethtool_get_link, 704 .get_link = efx_ethtool_get_link,
705 .get_eeprom_len = efx_ethtool_get_eeprom_len,
706 .get_eeprom = efx_ethtool_get_eeprom,
707 .set_eeprom = efx_ethtool_set_eeprom,
656 .get_coalesce = efx_ethtool_get_coalesce, 708 .get_coalesce = efx_ethtool_get_coalesce,
657 .set_coalesce = efx_ethtool_set_coalesce, 709 .set_coalesce = efx_ethtool_set_coalesce,
658 .get_pauseparam = efx_ethtool_get_pauseparam, 710 .get_pauseparam = efx_ethtool_get_pauseparam,