iPXE
Data Structures | Macros | Enumerations | Functions | Variables
sundance.c File Reference
#include "etherboot.h"
#include "nic.h"
#include <ipxe/pci.h>
#include "mii.h"

Go to the source code of this file.

Data Structures

struct  netdev_desc
 
struct  sundance_private
 

Macros

#define drv_version   "v1.12"
 
#define drv_date   "2004-03-21"
 
#define HZ   100
 
#define virt_to_le32desc(addr)   cpu_to_le32(virt_to_bus(addr))
 
#define le32desc_to_virt(addr)   bus_to_virt(le32_to_cpu(addr))
 
#define TX_RING_SIZE   2
 
#define TX_QUEUE_LEN   10 /* Limit ring entries actually used. */
 
#define RX_RING_SIZE   4
 
#define TX_TIME_OUT   (4*HZ)
 
#define PKT_BUF_SZ   1536
 
#define rxb   rx_tx_buf.rxb
 
#define txb   rx_tx_buf.txb
 
#define EEPROM_SIZE   128
 
#define PCI_IOTYPE   (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)
 
#define MII_CNT   4
 
#define EEPROM_SA_OFFSET   0x10
 
#define DEFAULT_INTR
 
#define mdio_in(mdio_addr)   inb(mdio_addr)
 
#define mdio_out(value, mdio_addr)   outb(value, mdio_addr)
 
#define mdio_delay(mdio_addr)   inb(mdio_addr)
 
#define MDIO_EnbIn   (0)
 
#define MDIO_WRITE0   (MDIO_EnbOutput)
 
#define MDIO_WRITE1   (MDIO_Data | MDIO_EnbOutput)
 

Enumerations

enum  alta_offsets {
  DMACtrl = 0x00, TxListPtr = 0x04, TxDMABurstThresh = 0x08, TxDMAUrgentThresh = 0x09,
  TxDMAPollPeriod = 0x0a, RxDMAStatus = 0x0c, RxListPtr = 0x10, DebugCtrl0 = 0x1a,
  DebugCtrl1 = 0x1c, RxDMABurstThresh = 0x14, RxDMAUrgentThresh = 0x15, RxDMAPollPeriod = 0x16,
  LEDCtrl = 0x1a, ASICCtrl = 0x30, EEData = 0x34, EECtrl = 0x36,
  TxStartThresh = 0x3c, RxEarlyThresh = 0x3e, FlashAddr = 0x40, FlashData = 0x44,
  TxStatus = 0x46, TxFrameId = 0x47, DownCounter = 0x18, IntrClear = 0x4a,
  IntrEnable = 0x4c, IntrStatus = 0x4e, MACCtrl0 = 0x50, MACCtrl1 = 0x52,
  StationAddr = 0x54, MaxFrameSize = 0x5A, RxMode = 0x5c, MIICtrl = 0x5e,
  MulticastFilter0 = 0x60, MulticastFilter1 = 0x64, RxOctetsLow = 0x68, RxOctetsHigh = 0x6a,
  TxOctetsLow = 0x6c, TxOctetsHigh = 0x6e, TxFramesOK = 0x70, RxFramesOK = 0x72,
  StatsCarrierError = 0x74, StatsLateColl = 0x75, StatsMultiColl = 0x76, StatsOneColl = 0x77,
  StatsTxDefer = 0x78, RxMissed = 0x79, StatsTxXSDefer = 0x7a, StatsTxAbort = 0x7b,
  StatsBcastTx = 0x7c, StatsBcastRx = 0x7d, StatsMcastTx = 0x7e, StatsMcastRx = 0x7f,
  RxStatus = 0x0c
}
 
enum  ASICCtrl_HiWord_bit {
  GlobalReset = 0x0001, RxReset = 0x0002, TxReset = 0x0004, DMAReset = 0x0008,
  FIFOReset = 0x0010, NetworkReset = 0x0020, HostReset = 0x0040, ResetBusy = 0x0400
}
 
enum  intr_status_bits {
  IntrSummary = 0x0001, IntrPCIErr = 0x0002, IntrMACCtrl = 0x0008, IntrTxDone = 0x0004,
  IntrRxDone = 0x0010, IntrRxStart = 0x0020, IntrDrvRqst = 0x0040, StatsMax = 0x0080,
  LinkChange = 0x0100, IntrTxDMADone = 0x0200, IntrRxDMADone = 0x0400, NormalIntr =0x10000,
  AbnormalIntr =0x8000, IntrPCIErr =0x2000, TimerInt =0x800, IntrRxDied =0x100,
  RxNoBuf =0x80, IntrRxDone =0x40, TxFIFOUnderflow =0x20, RxErrIntr =0x10,
  TxIdle =0x04, IntrTxStopped =0x02, IntrTxDone =0x01
}
 
enum  rx_mode_bits {
  AcceptAllIPMulti = 0x20, AcceptMultiHash = 0x10, AcceptAll = 0x08, AcceptBroadcast = 0x04,
  AcceptMulticast = 0x02, AcceptMyPhys, AcceptErr =0x80, AcceptRunt =0x40,
  AcceptBroadcast =0x20, AcceptMulticast =0x10, AcceptAllPhys =0x08, AcceptMyPhys =0x02
}
 
enum  mac_ctrl0_bits { EnbFullDuplex = 0x20, EnbRcvLargeFrame = 0x40, EnbFlowCtrl = 0x100, EnbPassRxCRC = 0x200 }
 
enum  mac_ctrl1_bits {
  StatsEnable = 0x0020, StatsDisable = 0x0040, StatsEnabled = 0x0080, TxEnable = 0x0100,
  TxDisable = 0x0200, TxEnabled = 0x0400, RxEnable = 0x0800, RxDisable = 0x1000,
  RxEnabled = 0x2000
}
 
enum  desc_status_bits {
  DescOwn = 0x8000, DescEndPacket = 0x4000, DescEndRing = 0x2000, LastFrag = 0x80000000,
  DescIntrOnTx = 0x8000, DescIntrOnDMADone = 0x80000000, DisableAlign = 0x00000001, DescOwnded =0x80000000,
  RxDescFatalErr =0x8000, RxWholePkt =0x0300, DescOwn =0x80000000, DescEndRing =0x02000000,
  DescUseLink =0x01000000, DescWholePkt =0x60000000, DescStartPkt =0x20000000, DescEndPkt =0x40000000,
  DescIntr =0x80000000
}
 
enum  pci_id_flags_bits {
  PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4, PCI_ADDR0 = 0 << 4,
  PCI_ADDR1 = 1 << 4, PCI_ADDR2, PCI_ADDR3 = 3 << 4, PCI_USES_IO =1,
  PCI_USES_MEM =2, PCI_USES_MASTER =4, PCI_ADDR0 =0<<4, PCI_ADDR1 =1<<4,
  PCI_ADDR2 =2<<4, PCI_ADDR3 =3<<4, PCI_ADDR_64BITS =0x100, PCI_NO_ACPI_WAKE =0x200,
  PCI_NO_MIN_LATENCY =0x400, PCI_UNUSED_IRQ =0x800
}
 
enum  chip_capability_flags { CanHaveMII = 1, KendinPktDropBug = 2, CanHaveMII =1, HasBrokenTx =2 }
 
enum  mii_reg_bits {
  MDIO_ShiftClk = 0x0001, MDIO_Data = 0x0002, MDIO_EnbOutput, MDIO_ShiftClk =0x10000,
  MDIO_DataIn =0x80000, MDIO_DataOut =0x20000, MDIO_EnbOutput =0x40000, MDIO_EnbIn = 0x00000
}
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static int eeprom_read (long ioaddr, int location)
 
static int mdio_read (struct nic *nic, int phy_id, unsigned int location)
 
static void mdio_write (struct nic *nic, int phy_id, unsigned int location, int value)
 
static void set_rx_mode (struct nic *nic)
 
static void check_duplex (struct nic *nic)
 
static void init_ring (struct nic *nic __unused)
 
static void sundance_reset (struct nic *nic)
 
static void sundance_irq (struct nic *nic, irq_action_t action)
 
static int sundance_poll (struct nic *nic, int retrieve)
 
static void sundance_transmit (struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
 
static void sundance_disable (struct nic *nic __unused)
 
static int sundance_probe (struct nic *nic, struct pci_device *pci)
 
static void mdio_sync (long mdio_addr)
 
static int mdio_read (struct nic *nic __unused, int phy_id, unsigned int location)
 
static void mdio_write (struct nic *nic __unused, int phy_id, unsigned int location, int value)
 
static void set_rx_mode (struct nic *nic __unused)
 
 PCI_DRIVER (sundance_driver, sundance_nics, PCI_NO_CLASS)
 
 DRIVER ("SUNDANCE/PCI", nic_driver, pci_driver, sundance_driver, sundance_probe, sundance_disable)
 

Variables

static int mtu = 1514
 
static int rx_copybreak = 0
 
static int flowctrl = 1
 
static char media [] = "autosense"
 
static struct netdev_desc tx_ring [TX_RING_SIZE]
 
static struct netdev_desc rx_ring [RX_RING_SIZE]
 
struct {
   unsigned char   txb [PKT_BUF_SZ *TX_RING_SIZE]
 
   unsigned char   rxb [RX_RING_SIZE *PKT_BUF_SZ]
 
__shared
 
static u32 BASE
 
static struct sundance_private sdx
 
static struct sundance_privatesdc
 
static struct nic_operations sundance_operations
 
static struct pci_device_id sundance_nics []
 

Macro Definition Documentation

◆ drv_version

#define drv_version   "v1.12"

Definition at line 54 of file sundance.c.

◆ drv_date

#define drv_date   "2004-03-21"

Definition at line 55 of file sundance.c.

◆ HZ

#define HZ   100

Definition at line 57 of file sundance.c.

◆ virt_to_le32desc

#define virt_to_le32desc (   addr)    cpu_to_le32(virt_to_bus(addr))

Definition at line 60 of file sundance.c.

◆ le32desc_to_virt

#define le32desc_to_virt (   addr)    bus_to_virt(le32_to_cpu(addr))

Definition at line 61 of file sundance.c.

◆ TX_RING_SIZE

#define TX_RING_SIZE   2

Definition at line 92 of file sundance.c.

◆ TX_QUEUE_LEN

#define TX_QUEUE_LEN   10 /* Limit ring entries actually used. */

Definition at line 93 of file sundance.c.

◆ RX_RING_SIZE

#define RX_RING_SIZE   4

Definition at line 94 of file sundance.c.

◆ TX_TIME_OUT

#define TX_TIME_OUT   (4*HZ)

Definition at line 99 of file sundance.c.

◆ PKT_BUF_SZ

#define PKT_BUF_SZ   1536

Definition at line 100 of file sundance.c.

◆ rxb

#define rxb   rx_tx_buf.rxb

Definition at line 240 of file sundance.c.

◆ txb

#define txb   rx_tx_buf.txb

Definition at line 241 of file sundance.c.

◆ EEPROM_SIZE

#define EEPROM_SIZE   128

Definition at line 245 of file sundance.c.

◆ PCI_IOTYPE

#define PCI_IOTYPE   (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)

Definition at line 254 of file sundance.c.

◆ MII_CNT

#define MII_CNT   4

Definition at line 256 of file sundance.c.

◆ EEPROM_SA_OFFSET

#define EEPROM_SA_OFFSET   0x10

Definition at line 280 of file sundance.c.

◆ DEFAULT_INTR

#define DEFAULT_INTR
Value:
IntrDrvRqst | IntrTxDone | StatsMax | \
LinkChange)

Definition at line 281 of file sundance.c.

◆ mdio_in

#define mdio_in (   mdio_addr)    inb(mdio_addr)

Definition at line 775 of file sundance.c.

◆ mdio_out

#define mdio_out (   value,
  mdio_addr 
)    outb(value, mdio_addr)

Definition at line 776 of file sundance.c.

◆ mdio_delay

#define mdio_delay (   mdio_addr)    inb(mdio_addr)

Definition at line 777 of file sundance.c.

◆ MDIO_EnbIn

#define MDIO_EnbIn   (0)

Definition at line 783 of file sundance.c.

◆ MDIO_WRITE0

#define MDIO_WRITE0   (MDIO_EnbOutput)

Definition at line 784 of file sundance.c.

◆ MDIO_WRITE1

#define MDIO_WRITE1   (MDIO_Data | MDIO_EnbOutput)

Definition at line 785 of file sundance.c.

Enumeration Type Documentation

◆ alta_offsets

Enumerator
DMACtrl 
TxListPtr 
TxDMABurstThresh 
TxDMAUrgentThresh 
TxDMAPollPeriod 
RxDMAStatus 
RxListPtr 
DebugCtrl0 
DebugCtrl1 
RxDMABurstThresh 
RxDMAUrgentThresh 
RxDMAPollPeriod 
LEDCtrl 
ASICCtrl 
EEData 
EECtrl 
TxStartThresh 
RxEarlyThresh 
FlashAddr 
FlashData 
TxStatus 
TxFrameId 
DownCounter 
IntrClear 
IntrEnable 
IntrStatus 
MACCtrl0 
MACCtrl1 
StationAddr 
MaxFrameSize 
RxMode 
MIICtrl 
MulticastFilter0 
MulticastFilter1 
RxOctetsLow 
RxOctetsHigh 
TxOctetsLow 
TxOctetsHigh 
TxFramesOK 
RxFramesOK 
StatsCarrierError 
StatsLateColl 
StatsMultiColl 
StatsOneColl 
StatsTxDefer 
RxMissed 
StatsTxXSDefer 
StatsTxAbort 
StatsBcastTx 
StatsBcastRx 
StatsMcastTx 
StatsMcastRx 
RxStatus 

Definition at line 110 of file sundance.c.

110  {
111  DMACtrl = 0x00,
112  TxListPtr = 0x04,
113  TxDMABurstThresh = 0x08,
114  TxDMAUrgentThresh = 0x09,
115  TxDMAPollPeriod = 0x0a,
116  RxDMAStatus = 0x0c,
117  RxListPtr = 0x10,
118  DebugCtrl0 = 0x1a,
119  DebugCtrl1 = 0x1c,
120  RxDMABurstThresh = 0x14,
121  RxDMAUrgentThresh = 0x15,
122  RxDMAPollPeriod = 0x16,
123  LEDCtrl = 0x1a,
124  ASICCtrl = 0x30,
125  EEData = 0x34,
126  EECtrl = 0x36,
127  TxStartThresh = 0x3c,
128  RxEarlyThresh = 0x3e,
129  FlashAddr = 0x40,
130  FlashData = 0x44,
131  TxStatus = 0x46,
132  TxFrameId = 0x47,
133  DownCounter = 0x18,
134  IntrClear = 0x4a,
135  IntrEnable = 0x4c,
136  IntrStatus = 0x4e,
137  MACCtrl0 = 0x50,
138  MACCtrl1 = 0x52,
139  StationAddr = 0x54,
140  MaxFrameSize = 0x5A,
141  RxMode = 0x5c,
142  MIICtrl = 0x5e,
143  MulticastFilter0 = 0x60,
144  MulticastFilter1 = 0x64,
145  RxOctetsLow = 0x68,
146  RxOctetsHigh = 0x6a,
147  TxOctetsLow = 0x6c,
148  TxOctetsHigh = 0x6e,
149  TxFramesOK = 0x70,
150  RxFramesOK = 0x72,
151  StatsCarrierError = 0x74,
152  StatsLateColl = 0x75,
153  StatsMultiColl = 0x76,
154  StatsOneColl = 0x77,
155  StatsTxDefer = 0x78,
156  RxMissed = 0x79,
157  StatsTxXSDefer = 0x7a,
158  StatsTxAbort = 0x7b,
159  StatsBcastTx = 0x7c,
160  StatsBcastRx = 0x7d,
161  StatsMcastTx = 0x7e,
162  StatsMcastRx = 0x7f,
163  /* Aliased and bogus values! */
164  RxStatus = 0x0c,
165 };

◆ ASICCtrl_HiWord_bit

Enumerator
GlobalReset 
RxReset 
TxReset 
DMAReset 
FIFOReset 
NetworkReset 
HostReset 
ResetBusy 

Definition at line 166 of file sundance.c.

166  {
167  GlobalReset = 0x0001,
168  RxReset = 0x0002,
169  TxReset = 0x0004,
170  DMAReset = 0x0008,
171  FIFOReset = 0x0010,
172  NetworkReset = 0x0020,
173  HostReset = 0x0040,
174  ResetBusy = 0x0400,
175 };

◆ intr_status_bits

Enumerator
IntrSummary 
IntrPCIErr 
IntrMACCtrl 
IntrTxDone 
IntrRxDone 
IntrRxStart 
IntrDrvRqst 
StatsMax 
LinkChange 
IntrTxDMADone 
IntrRxDMADone 
NormalIntr 
AbnormalIntr 
IntrPCIErr 
TimerInt 
IntrRxDied 
RxNoBuf 
IntrRxDone 
TxFIFOUnderflow 
RxErrIntr 
TxIdle 
IntrTxStopped 
IntrTxDone 

Definition at line 178 of file sundance.c.

178  {
179  IntrSummary = 0x0001, IntrPCIErr = 0x0002, IntrMACCtrl = 0x0008,
180  IntrTxDone = 0x0004, IntrRxDone = 0x0010, IntrRxStart = 0x0020,
181  IntrDrvRqst = 0x0040,
182  StatsMax = 0x0080, LinkChange = 0x0100,
183  IntrTxDMADone = 0x0200, IntrRxDMADone = 0x0400,
184 };

◆ rx_mode_bits

Enumerator
AcceptAllIPMulti 
AcceptMultiHash 
AcceptAll 
AcceptBroadcast 
AcceptMulticast 
AcceptMyPhys 
AcceptErr 
AcceptRunt 
AcceptBroadcast 
AcceptMulticast 
AcceptAllPhys 
AcceptMyPhys 

Definition at line 187 of file sundance.c.

187  {
188  AcceptAllIPMulti = 0x20, AcceptMultiHash = 0x10, AcceptAll = 0x08,
190  0x01,
191 };

◆ mac_ctrl0_bits

Enumerator
EnbFullDuplex 
EnbRcvLargeFrame 
EnbFlowCtrl 
EnbPassRxCRC 

Definition at line 193 of file sundance.c.

193  {
194  EnbFullDuplex = 0x20, EnbRcvLargeFrame = 0x40,
195  EnbFlowCtrl = 0x100, EnbPassRxCRC = 0x200,
196 };

◆ mac_ctrl1_bits

Enumerator
StatsEnable 
StatsDisable 
StatsEnabled 
TxEnable 
TxDisable 
TxEnabled 
RxEnable 
RxDisable 
RxEnabled 

Definition at line 197 of file sundance.c.

197  {
198  StatsEnable = 0x0020, StatsDisable = 0x0040, StatsEnabled = 0x0080,
199  TxEnable = 0x0100, TxDisable = 0x0200, TxEnabled = 0x0400,
200  RxEnable = 0x0800, RxDisable = 0x1000, RxEnabled = 0x2000,
201 };

◆ desc_status_bits

Enumerator
DescOwn 
DescEndPacket 
DescEndRing 
LastFrag 
DescIntrOnTx 
DescIntrOnDMADone 
DisableAlign 
DescOwnded 
RxDescFatalErr 
RxWholePkt 
DescOwn 
DescEndRing 
DescUseLink 
DescWholePkt 
DescStartPkt 
DescEndPkt 
DescIntr 

Definition at line 215 of file sundance.c.

215  {
216  DescOwn = 0x8000,
217  DescEndPacket = 0x4000,
218  DescEndRing = 0x2000,
219  LastFrag = 0x80000000,
220  DescIntrOnTx = 0x8000,
221  DescIntrOnDMADone = 0x80000000,
222  DisableAlign = 0x00000001,
223 };

◆ pci_id_flags_bits

Enumerator
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 
PCI_ADDR_64BITS 
PCI_NO_ACPI_WAKE 
PCI_NO_MIN_LATENCY 
PCI_UNUSED_IRQ 

Definition at line 247 of file sundance.c.

247  {
249  PCI_ADDR0 = 0 << 4, PCI_ADDR1 = 1 << 4, PCI_ADDR2 =
250  2 << 4, PCI_ADDR3 = 3 << 4,
251 };

◆ chip_capability_flags

Enumerator
CanHaveMII 
KendinPktDropBug 
CanHaveMII 
HasBrokenTx 

Definition at line 253 of file sundance.c.

◆ mii_reg_bits

Enumerator
MDIO_ShiftClk 
MDIO_Data 
MDIO_EnbOutput 
MDIO_ShiftClk 
MDIO_DataIn 
MDIO_DataOut 
MDIO_EnbOutput 
MDIO_EnbIn 

Definition at line 779 of file sundance.c.

779  {
780  MDIO_ShiftClk = 0x0001, MDIO_Data = 0x0002, MDIO_EnbOutput =
781  0x0004,
782 };

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ eeprom_read()

static int eeprom_read ( long  ioaddr,
int  location 
)
static

Definition at line 752 of file sundance.c.

753 {
754  int boguscnt = 10000; /* Typical 1900 ticks */
755  outw(0x0200 | (location & 0xff), ioaddr + EECtrl);
756  do {
757  if (!(inw(ioaddr + EECtrl) & 0x8000)) {
758  return inw(ioaddr + EEData);
759  }
760  }
761  while (--boguscnt > 0);
762  return 0;
763 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
static unsigned long ioaddr
Definition: davicom.c:129

References EECtrl, EEData, inw(), ioaddr, and outw.

Referenced by sundance_probe().

◆ mdio_read() [1/2]

static int mdio_read ( struct nic nic,
int  phy_id,
unsigned int  location 
)
static

Referenced by check_duplex(), and sundance_probe().

◆ mdio_write() [1/2]

static void mdio_write ( struct nic nic,
int  phy_id,
unsigned int  location,
int  value 
)
static

Referenced by sundance_probe().

◆ set_rx_mode() [1/2]

static void set_rx_mode ( struct nic nic)
static

Referenced by sundance_reset().

◆ check_duplex()

static void check_duplex ( struct nic nic)
static

Definition at line 291 of file sundance.c.

292 {
293  int mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA);
294  int negotiated = mii_lpa & sdc->mii_if.advertising;
295  int duplex;
296 
297  /* Force media */
298  if (!sdc->an_enable || mii_lpa == 0xffff) {
299  if (sdc->mii_if.full_duplex)
301  BASE + MACCtrl0);
302  return;
303  }
304 
305  /* Autonegotiation */
306  duplex = (negotiated & 0x0100) || (negotiated & 0x01C0) == 0x0040;
307  if (sdc->mii_if.full_duplex != duplex) {
309  DBG ("%s: Setting %s-duplex based on MII #%d "
310  "negotiated capability %4.4x.\n", sdc->nic_name,
311  duplex ? "full" : "half", sdc->phys[0],
312  negotiated );
313  outw(inw(BASE + MACCtrl0) | duplex ? 0x20 : 0,
314  BASE + MACCtrl0);
315  }
316 }
#define MII_LPA
Definition: atl1e.h:876
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
unsigned int full_duplex
Definition: mii.h:148
#define outw(data, io_addr)
Definition: io.h:319
const char * nic_name
Definition: sundance.c:258
static u32 BASE
Definition: sundance.c:244
static struct sundance_private * sdc
Definition: sundance.c:277
unsigned int an_enable
Definition: sundance.c:266
Definition: nic.h:49
duplex
Definition: nic.h:40
int advertising
Definition: mii.h:144
struct mii_if_info mii_if
Definition: sundance.c:271
static int mdio_read(struct nic *nic, int phy_id, unsigned int location)
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
unsigned char phys[MII_CNT]
Definition: sundance.c:273

References mii_if_info::advertising, sundance_private::an_enable, BASE, DBG, EnbFullDuplex, mii_if_info::full_duplex, inw(), MACCtrl0, mdio_read(), sundance_private::mii_if, MII_LPA, sundance_private::nic_name, outw, sundance_private::phys, and sdc.

Referenced by sundance_probe().

◆ init_ring()

static void init_ring ( struct nic *nic  __unused)
static

Definition at line 322 of file sundance.c.

323 {
324  int i;
325 
326  sdc->cur_rx = 0;
327 
328  /* Initialize all the Rx descriptors */
329  for (i = 0; i < RX_RING_SIZE; i++) {
331  rx_ring[i].status = 0;
332  rx_ring[i].length = 0;
333  rx_ring[i].addr = 0;
334  }
335 
336  /* Mark the last entry as wrapping the ring */
338 
339  for (i = 0; i < RX_RING_SIZE; i++) {
342  }
343 
344  /* We only use one transmit buffer, but two
345  * descriptors so transmit engines have somewhere
346  * to point should they feel the need */
347  tx_ring[0].status = 0x00000000;
348  tx_ring[0].addr = virt_to_bus(&txb[0]);
349  tx_ring[0].next_desc = 0; /* virt_to_bus(&tx_ring[1]); */
350 
351  /* This descriptor is never used */
352  tx_ring[1].status = 0x00000000;
353  tx_ring[1].addr = 0; /*virt_to_bus(&txb[0]); */
354  tx_ring[1].next_desc = 0;
355 
356  /* Mark the last entry as wrapping the ring,
357  * though this should never happen */
359 }
u32 next_desc
Definition: sundance.c:208
#define rxb
Definition: sundance.c:240
static struct netdev_desc tx_ring[TX_RING_SIZE]
Definition: sundance.c:229
static struct netdev_desc rx_ring[RX_RING_SIZE]
Definition: sundance.c:232
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define RX_RING_SIZE
Definition: sundance.c:94
static struct sundance_private * sdc
Definition: sundance.c:277
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define PKT_BUF_SZ
Definition: sundance.c:100
#define txb
Definition: sundance.c:241
u32 length
Definition: sundance.c:211
#define virt_to_le32desc(addr)
Definition: sundance.c:60
unsigned int cur_rx
Definition: sundance.c:261
u32 status
Definition: sundance.c:209

References netdev_desc::addr, cpu_to_le32, sundance_private::cur_rx, LastFrag, netdev_desc::length, netdev_desc::next_desc, PKT_BUF_SZ, rx_ring, RX_RING_SIZE, rxb, sdc, netdev_desc::status, tx_ring, txb, virt_to_bus(), and virt_to_le32desc.

Referenced by sundance_reset().

◆ sundance_reset()

static void sundance_reset ( struct nic nic)
static

Definition at line 364 of file sundance.c.

365 {
366  int i;
367 
368  init_ring(nic);
369 
371  /* The Tx List Pointer is written as packets are queued */
372 
373  /* Initialize other registers. */
374  /* __set_mac_addr(dev); */
375  {
376  u16 addr16;
377 
378  addr16 = (nic->node_addr[0] | (nic->node_addr[1] << 8));
379  outw(addr16, BASE + StationAddr);
380  addr16 = (nic->node_addr[2] | (nic->node_addr[3] << 8));
381  outw(addr16, BASE + StationAddr + 2);
382  addr16 = (nic->node_addr[4] | (nic->node_addr[5] << 8));
383  outw(addr16, BASE + StationAddr + 4);
384  }
385 
386  outw(sdc->mtu + 14, BASE + MaxFrameSize);
387  if (sdc->mtu > 2047) /* this will never happen with default options */
388  outl(inl(BASE + ASICCtrl) | 0x0c, BASE + ASICCtrl);
389 
390  set_rx_mode(nic);
391 
392  outw(0, BASE + DownCounter);
393  /* Set the chip to poll every N*30nsec */
394  outb(100, BASE + RxDMAPollPeriod);
395 
396  /* Fix DFE-580TX packet drop issue */
397  if (sdc->pci_rev_id >= 0x14)
398  writeb(0x01, BASE + DebugCtrl1);
399 
401 
402  /* Construct a perfect filter frame with the mac address as first match
403  * and broadcast for all others */
404  for (i = 0; i < 192; i++)
405  txb[i] = 0xFF;
406 
407  txb[0] = nic->node_addr[0];
408  txb[1] = nic->node_addr[1];
409  txb[2] = nic->node_addr[2];
410  txb[3] = nic->node_addr[3];
411  txb[4] = nic->node_addr[4];
412  txb[5] = nic->node_addr[5];
413 
414  DBG ( "%s: Done sundance_reset, status: Rx %hX Tx %hX "
415  "MAC Control %hX, %hX %hX\n",
416  sdc->nic_name, (int) inl(BASE + RxStatus),
417  (int) inw(BASE + TxStatus), (int) inl(BASE + MACCtrl0),
418  (int) inw(BASE + MACCtrl1), (int) inw(BASE + MACCtrl0) );
419 }
uint16_t u16
Definition: stdint.h:21
static void init_ring(struct nic *nic __unused)
Definition: sundance.c:322
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
const char * nic_name
Definition: sundance.c:258
unsigned char pci_rev_id
Definition: sundance.c:274
static struct netdev_desc rx_ring[RX_RING_SIZE]
Definition: sundance.c:232
void writeb(uint8_t data, volatile uint8_t *io_addr)
Write byte to memory-mapped device.
static void set_rx_mode(struct nic *nic)
static u32 BASE
Definition: sundance.c:244
unsigned int mtu
Definition: sundance.c:262
static struct sundance_private * sdc
Definition: sundance.c:277
#define outl(data, io_addr)
Definition: io.h:329
Definition: nic.h:49
#define txb
Definition: sundance.c:241
unsigned char * node_addr
Definition: nic.h:52
#define outb(data, io_addr)
Definition: io.h:309
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
#define virt_to_le32desc(addr)
Definition: sundance.c:60
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ASICCtrl, BASE, DBG, DebugCtrl1, DownCounter, init_ring(), inl(), inw(), MACCtrl0, MACCtrl1, MaxFrameSize, sundance_private::mtu, sundance_private::nic_name, nic::node_addr, outb, outl, outw, sundance_private::pci_rev_id, rx_ring, RxDMAPollPeriod, RxEnable, RxListPtr, RxStatus, sdc, set_rx_mode(), StationAddr, txb, TxEnable, TxStatus, virt_to_le32desc, and writeb().

Referenced by sundance_probe().

◆ sundance_irq()

static void sundance_irq ( struct nic nic,
irq_action_t  action 
)
static

Definition at line 424 of file sundance.c.

424  {
425  unsigned int intr_status;
426 
427  switch ( action ) {
428  case DISABLE :
429  case ENABLE :
430  intr_status = inw(nic->ioaddr + IntrStatus);
431  intr_status = intr_status & ~DEFAULT_INTR;
432  if ( action == ENABLE )
433  intr_status = intr_status | DEFAULT_INTR;
434  outw(intr_status, nic->ioaddr + IntrEnable);
435  break;
436  case FORCE :
437  outw(0x0200, BASE + ASICCtrl);
438  break;
439  }
440 }
Definition: nic.h:35
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
static u32 BASE
Definition: sundance.c:244
unsigned int ioaddr
Definition: nic.h:55
Definition: nic.h:37
Definition: nic.h:49
Definition: nic.h:36
#define DEFAULT_INTR
Definition: sundance.c:281

References ASICCtrl, BASE, DEFAULT_INTR, DISABLE, ENABLE, FORCE, IntrEnable, IntrStatus, inw(), nic::ioaddr, and outw.

◆ sundance_poll()

static int sundance_poll ( struct nic nic,
int  retrieve 
)
static

Definition at line 444 of file sundance.c.

445 {
446  /* return true if there's an ethernet packet ready to read */
447  /* nic->packet should contain data on return */
448  /* nic->packetlen should contain length of data */
449  int entry = sdc->cur_rx % RX_RING_SIZE;
450  u32 frame_status = le32_to_cpu(rx_ring[entry].status);
451  int intr_status;
452  int pkt_len = 0;
453 
454  if (!(frame_status & DescOwn))
455  return 0;
456 
457  /* There is a packet ready */
458  if(!retrieve)
459  return 1;
460 
461  intr_status = inw(nic->ioaddr + IntrStatus);
462  outw(intr_status, nic->ioaddr + IntrStatus);
463 
464  pkt_len = frame_status & 0x1fff;
465 
466  if (frame_status & 0x001f4000) {
467  DBG ( "Polling frame_status error\n" ); /* Do we really care about this */
468  } else {
469  if (pkt_len < rx_copybreak) {
470  /* FIXME: What should happen Will this ever occur */
471  printf("Poll Error: pkt_len < rx_copybreak");
472  } else {
473  nic->packetlen = pkt_len;
474  memcpy(nic->packet, rxb +
476 
477  }
478  }
480  rx_ring[entry].status = 0;
481  entry++;
484  nic->ioaddr + IntrStatus);
485  return 1;
486 }
#define rxb
Definition: sundance.c:240
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define outw(data, io_addr)
Definition: io.h:319
static struct netdev_desc rx_ring[RX_RING_SIZE]
Definition: sundance.c:232
uint8_t status
Status.
Definition: ena.h:16
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int ioaddr
Definition: nic.h:55
#define RX_RING_SIZE
Definition: sundance.c:94
static struct sundance_private * sdc
Definition: sundance.c:277
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int packetlen
Definition: nic.h:54
static int rx_copybreak
Definition: sundance.c:74
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
#define PKT_BUF_SZ
Definition: sundance.c:100
Definition: nic.h:49
u32 length
Definition: sundance.c:211
unsigned char * packet
Definition: nic.h:53
#define DEFAULT_INTR
Definition: sundance.c:281
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
unsigned int cur_rx
Definition: sundance.c:261
u32 status
Definition: sundance.c:209
uint32_t u32
Definition: stdint.h:23

References cpu_to_le32, sundance_private::cur_rx, DBG, DEFAULT_INTR, DescOwn, entry, IntrRxDMADone, IntrRxDone, IntrStatus, inw(), nic::ioaddr, LastFrag, le32_to_cpu, netdev_desc::length, memcpy(), outw, nic::packet, nic::packetlen, PKT_BUF_SZ, printf(), rx_copybreak, rx_ring, RX_RING_SIZE, rxb, sdc, status, and netdev_desc::status.

◆ sundance_transmit()

static void sundance_transmit ( struct nic nic,
const char *  d,
unsigned int  t,
unsigned int  s,
const char *  p 
)
static

Definition at line 491 of file sundance.c.

495 { /* Packet */
496  u16 nstype;
497  u32 to;
498 
499  /* Disable the Tx */
501 
502  memcpy(txb, d, ETH_ALEN);
504  nstype = htons((u16) t);
505  memcpy(txb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
506  memcpy(txb + ETH_HLEN, p, s);
507 
508  s += ETH_HLEN;
509  s &= 0x0FFF;
510  while (s < ETH_ZLEN)
511  txb[s++] = '\0';
512 
513  /* Setup the transmit descriptor */
515  tx_ring[0].status = cpu_to_le32(0x00000001);
516 
517  /* Point to transmit descriptor */
519 
520  /* Enable Tx */
522  /* Trigger an immediate send */
523  outw(0, BASE + TxStatus);
524 
525  to = currticks() + TX_TIME_OUT;
526  while (!(tx_ring[0].status & 0x00010000) && (currticks() < to)); /* wait */
527 
528  if (currticks() >= to) {
529  printf("TX Time Out");
530  }
531  /* Disable Tx */
533 
534 }
uint16_t u16
Definition: stdint.h:21
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define outw(data, io_addr)
Definition: io.h:319
static struct netdev_desc tx_ring[TX_RING_SIZE]
Definition: sundance.c:229
#define TX_TIME_OUT
Definition: sundance.c:99
uint8_t status
Status.
Definition: ena.h:16
static u32 BASE
Definition: sundance.c:244
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define ETH_HLEN
Definition: if_ether.h:9
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define outl(data, io_addr)
Definition: io.h:329
#define ETH_ALEN
Definition: if_ether.h:8
#define ETH_ZLEN
Definition: if_ether.h:10
Definition: nic.h:49
#define txb
Definition: sundance.c:241
u32 length
Definition: sundance.c:211
unsigned char * node_addr
Definition: nic.h:52
uint32_t d
Definition: md4.c:31
#define virt_to_le32desc(addr)
Definition: sundance.c:60
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
u32 status
Definition: sundance.c:209
#define htons(value)
Definition: byteswap.h:135
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References BASE, cpu_to_le32, currticks(), d, ETH_ALEN, ETH_HLEN, ETH_ZLEN, htons, LastFrag, netdev_desc::length, MACCtrl1, memcpy(), nic::node_addr, outl, outw, printf(), status, netdev_desc::status, tx_ring, TX_TIME_OUT, txb, TxDisable, TxEnable, TxListPtr, TxStatus, and virt_to_le32desc.

◆ sundance_disable()

static void sundance_disable ( struct nic *nic  __unused)
static

Definition at line 539 of file sundance.c.

539  {
540  /* put the card in its initial state */
541  /* This function serves 3 purposes.
542  * This disables DMA and interrupts so we don't receive
543  * unexpected packets or interrupts from the card after
544  * etherboot has finished.
545  * This frees resources so etherboot may use
546  * this driver on another interface
547  * This allows etherboot to reinitialize the interface
548  * if something is something goes wrong.
549  */
550  outw(0x0000, BASE + IntrEnable);
551  /* Stop the Chipchips Tx and Rx Status */
553 }
#define outw(data, io_addr)
Definition: io.h:319
static u32 BASE
Definition: sundance.c:244

References BASE, IntrEnable, MACCtrl1, outw, RxDisable, StatsDisable, and TxDisable.

◆ sundance_probe()

static int sundance_probe ( struct nic nic,
struct pci_device pci 
)
static

Definition at line 566 of file sundance.c.

566  {
567 
569  u16 mii_ctl;
570  int i;
571  int speed;
572 
573  if (pci->ioaddr == 0)
574  return 0;
575 
576  /* BASE is used throughout to address the card */
577  BASE = pci->ioaddr;
578  printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
579  pci->id->name, pci->vendor, pci->device);
580 
581  /* Get the MAC Address by reading the EEPROM */
582  for (i = 0; i < 3; i++) {
583  ((u16 *) ee_data)[i] =
585  }
586  /* Update the nic structure with the MAC Address */
587  for (i = 0; i < ETH_ALEN; i++) {
588  nic->node_addr[i] = ee_data[i];
589  }
590 
591  /* Set the card as PCI Bus Master */
592  adjust_pci_device(pci);
593 
594 // sdc->mii_if.dev = pci;
595 // sdc->mii_if.phy_id_mask = 0x1f;
596 // sdc->mii_if.reg_num_mask = 0x1f;
597 
598  /* point to private storage */
599  sdc = &sdx;
600 
601  sdc->nic_name = pci->id->name;
602  sdc->mtu = mtu;
603 
605 
606  DBG ( "Device revision id: %hx\n", sdc->pci_rev_id );
607 
608  /* Print out some hardware info */
609  DBG ( "%s: %s at ioaddr %hX, ",
610  pci->id->name, nic->node_addr, (unsigned int) BASE);
611 
613  if (1) {
614  int phy, phy_idx = 0;
615  sdc->phys[0] = 1; /* Default Setting */
617  for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
618  int mii_status = mdio_read(nic, phy, MII_BMSR);
619  if (mii_status != 0xffff && mii_status != 0x0000) {
620  sdc->phys[phy_idx++] = phy;
622  mdio_read(nic, phy, MII_ADVERTISE);
623  if ((mii_status & 0x0040) == 0)
625  DBG
626  ( "%s: MII PHY found at address %d, status " "%hX advertising %hX\n", sdc->nic_name, phy, mii_status, sdc->mii_if.advertising );
627  }
628  }
630  if (phy_idx == 0)
631  printf("%s: No MII transceiver found!\n",
632  sdc->nic_name);
633  sdc->mii_if.phy_id = sdc->phys[0];
634  }
635 
636  /* Parse override configuration */
637  sdc->an_enable = 1;
638  if (strcasecmp(media, "autosense") != 0) {
639  sdc->an_enable = 0;
640  if (strcasecmp(media, "100mbps_fd") == 0 ||
641  strcasecmp(media, "4") == 0) {
642  sdc->speed = 100;
643  sdc->mii_if.full_duplex = 1;
644  } else if (strcasecmp(media, "100mbps_hd") == 0
645  || strcasecmp(media, "3") == 0) {
646  sdc->speed = 100;
647  sdc->mii_if.full_duplex = 0;
648  } else if (strcasecmp(media, "10mbps_fd") == 0 ||
649  strcasecmp(media, "2") == 0) {
650  sdc->speed = 10;
651  sdc->mii_if.full_duplex = 1;
652  } else if (strcasecmp(media, "10mbps_hd") == 0 ||
653  strcasecmp(media, "1") == 0) {
654  sdc->speed = 10;
655  sdc->mii_if.full_duplex = 0;
656  } else {
657  sdc->an_enable = 1;
658  }
659  }
660  if (flowctrl == 1)
661  sdc->flowctrl = 1;
662 
663  /* Fibre PHY? */
664  if (inl(BASE + ASICCtrl) & 0x80) {
665  /* Default 100Mbps Full */
666  if (sdc->an_enable) {
667  sdc->speed = 100;
668  sdc->mii_if.full_duplex = 1;
669  sdc->an_enable = 0;
670  }
671  }
672 
673  /* The Linux driver uses flow control and resets the link here. This means the
674  mii section from above would need to be re done I believe. Since it serves
675  no real purpose leave it out. */
676 
677  /* Force media type */
678  if (!sdc->an_enable) {
679  mii_ctl = 0;
680  mii_ctl |= (sdc->speed == 100) ? BMCR_SPEED100 : 0;
681  mii_ctl |= (sdc->mii_if.full_duplex) ? BMCR_FULLDPLX : 0;
682  mdio_write(nic, sdc->phys[0], MII_BMCR, mii_ctl);
683  printf("Override speed=%d, %s duplex\n",
684  sdc->speed,
685  sdc->mii_if.full_duplex ? "Full" : "Half");
686  }
687 
688  /* Reset the chip to erase previous misconfiguration */
689  DBG ( "ASIC Control is %#x\n", inl(BASE + ASICCtrl) );
690  outw(0x007f, BASE + ASICCtrl + 2);
691 
692  /*
693  * wait for reset to complete
694  * this is heavily inspired by the linux sundance driver
695  * according to the linux driver it can take up to 1ms for the reset
696  * to complete
697  */
698  i = 0;
699  while(inl(BASE + ASICCtrl) & (ResetBusy << 16)) {
700  if(i++ >= 10) {
701  DBG("sundance: NIC reset did not complete.\n");
702  break;
703  }
704  udelay(100);
705  }
706 
707  DBG ( "ASIC Control is now %#x.\n", inl(BASE + ASICCtrl) );
708 
710  if (sdc->an_enable) {
711  u16 mii_advertise, mii_lpa;
712  mii_advertise =
714  mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA);
715  mii_advertise &= mii_lpa;
716  if (mii_advertise & ADVERTISE_100FULL)
717  sdc->speed = 100;
718  else if (mii_advertise & ADVERTISE_100HALF)
719  sdc->speed = 100;
720  else if (mii_advertise & ADVERTISE_10FULL)
721  sdc->speed = 10;
722  else if (mii_advertise & ADVERTISE_10HALF)
723  sdc->speed = 10;
724  } else {
725  mii_ctl = mdio_read(nic, sdc->phys[0], MII_BMCR);
726  speed = (mii_ctl & BMCR_SPEED100) ? 100 : 10;
727  sdc->speed = speed;
728  printf("%s: Link changed: %dMbps ,", sdc->nic_name, speed);
729  printf("%s duplex.\n", (mii_ctl & BMCR_FULLDPLX) ?
730  "full" : "half");
731  }
732  check_duplex(nic);
733  if (sdc->flowctrl && sdc->mii_if.full_duplex) {
734  outw(inw(BASE + MulticastFilter1 + 2) | 0x0200,
735  BASE + MulticastFilter1 + 2);
737  }
738  printf("%dMbps, %s-Duplex\n", sdc->speed,
739  sdc->mii_if.full_duplex ? "Full" : "Half");
740 
741  /* point to NIC specific routines */
743 
744  nic->irqno = pci->irq;
745  nic->ioaddr = BASE;
746 
747  return 1;
748 }
unsigned char irqno
Definition: nic.h:56
#define MII_ADVERTISE
Definition: atl1e.h:875
uint16_t u16
Definition: stdint.h:21
int phy_id
Definition: mii.h:143
#define MII_LPA
Definition: atl1e.h:876
uint8_t irq
Interrupt number.
Definition: pci.h:211
static void sundance_reset(struct nic *nic)
Definition: sundance.c:364
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define EEPROM_SIZE
Definition: sundance.c:245
unsigned int full_duplex
Definition: mii.h:148
int mii_preamble_required
Definition: sundance.c:272
#define EEPROM_SA_OFFSET
Definition: sundance.c:280
#define ADVERTISE_10FULL
Definition: mii.h:74
#define outw(data, io_addr)
Definition: io.h:319
unsigned long ioaddr
I/O address.
Definition: pci.h:203
const char * nic_name
Definition: sundance.c:258
unsigned char pci_rev_id
Definition: sundance.c:274
static unsigned char ee_data[EEPROM_SIZE]
Definition: davicom.c:67
#define ADVERTISE_100FULL
Definition: mii.h:78
unsigned int flowctrl
Definition: sundance.c:265
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition: string.c:207
static int flowctrl
Definition: sundance.c:75
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
static u32 BASE
Definition: sundance.c:244
#define MII_CNT
Definition: sundance.c:256
unsigned int ioaddr
Definition: nic.h:55
uint16_t device
Device ID.
Definition: pci.h:207
static struct sundance_private sdx
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static int mtu
Definition: sundance.c:64
unsigned int mtu
Definition: sundance.c:262
static struct sundance_private * sdc
Definition: sundance.c:277
unsigned int an_enable
Definition: sundance.c:266
#define MII_BMCR
Definition: atl1e.h:871
#define ETH_ALEN
Definition: if_ether.h:8
#define le16_to_cpu(value)
Definition: byteswap.h:112
Definition: nic.h:49
const char * name
Name.
Definition: pci.h:154
static void mdio_write(struct nic *nic, int phy_id, unsigned int location, int value)
uint16_t vendor
Vendor ID.
Definition: pci.h:205
static struct nic_operations sundance_operations
Definition: sundance.c:555
unsigned char * node_addr
Definition: nic.h:52
static void check_duplex(struct nic *nic)
Definition: sundance.c:291
int advertising
Definition: mii.h:144
#define ADVERTISE_10HALF
Definition: mii.h:72
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
struct pci_device_id * id
Driver device ID.
Definition: pci.h:223
struct mii_if_info mii_if
Definition: sundance.c:271
static char media[]
Definition: sundance.c:85
#define PCI_REVISION
PCI revision.
Definition: pci.h:44
static int eeprom_read(long ioaddr, int location)
Definition: sundance.c:752
#define ADVERTISE_100HALF
Definition: mii.h:76
static int mdio_read(struct nic *nic, int phy_id, unsigned int location)
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct nic_operations * nic_op
Definition: nic.h:50
#define MII_BMSR
Definition: atl1e.h:872
unsigned int speed
Definition: sundance.c:268
#define BMCR_SPEED100
Definition: mii.h:48
unsigned char phys[MII_CNT]
Definition: sundance.c:273
uint8_t u8
Definition: stdint.h:19
#define BMCR_FULLDPLX
Definition: mii.h:43
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.

References adjust_pci_device(), ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, mii_if_info::advertising, sundance_private::an_enable, ASICCtrl, BASE, BMCR_FULLDPLX, BMCR_SPEED100, check_duplex(), DBG, pci_device::device, ee_data, eeprom_read(), EEPROM_SA_OFFSET, EEPROM_SIZE, EnbFlowCtrl, ETH_ALEN, flowctrl, sundance_private::flowctrl, mii_if_info::full_duplex, pci_device::id, inl(), inw(), nic::ioaddr, pci_device::ioaddr, pci_device::irq, nic::irqno, le16_to_cpu, MACCtrl0, mdio_read(), mdio_write(), media, MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CNT, sundance_private::mii_if, MII_LPA, sundance_private::mii_preamble_required, mtu, sundance_private::mtu, MulticastFilter1, pci_device_id::name, sundance_private::nic_name, nic::nic_op, nic::node_addr, outw, pci_read_config_byte(), sundance_private::pci_rev_id, PCI_REVISION, mii_if_info::phy_id, sundance_private::phys, printf(), ResetBusy, sdc, sdx, sundance_private::speed, strcasecmp(), sundance_operations, sundance_reset(), udelay(), and pci_device::vendor.

◆ mdio_sync()

static void mdio_sync ( long  mdio_addr)
static

Definition at line 789 of file sundance.c.

790 {
791  int bits = 32;
792 
793  /* Establish sync by sending at least 32 logic ones. */
794  while (--bits >= 0) {
795  mdio_out(MDIO_WRITE1, mdio_addr);
796  mdio_delay(mdio_addr);
797  mdio_out(MDIO_WRITE1 | MDIO_ShiftClk, mdio_addr);
798  mdio_delay(mdio_addr);
799  }
800 }
#define mdio_out(value, mdio_addr)
Definition: sundance.c:776
#define mdio_delay(mdio_addr)
Definition: sundance.c:777
static volatile void * bits
Definition: bitops.h:27
#define MDIO_WRITE1
Definition: sundance.c:785

References bits, mdio_delay, mdio_out, MDIO_ShiftClk, and MDIO_WRITE1.

Referenced by mdio_read(), and mdio_write().

◆ mdio_read() [2/2]

static int mdio_read ( struct nic *nic  __unused,
int  phy_id,
unsigned int  location 
)
static

Definition at line 803 of file sundance.c.

804 {
805  long mdio_addr = BASE + MIICtrl;
806  int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
807  int i, retval = 0;
808 
810  mdio_sync(mdio_addr);
811 
812  /* Shift the read command bits out. */
813  for (i = 15; i >= 0; i--) {
814  int dataval =
815  (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
816 
817  mdio_out(dataval, mdio_addr);
818  mdio_delay(mdio_addr);
819  mdio_out(dataval | MDIO_ShiftClk, mdio_addr);
820  mdio_delay(mdio_addr);
821  }
822  /* Read the two transition, 16 data, and wire-idle bits. */
823  for (i = 19; i > 0; i--) {
824  mdio_out(MDIO_EnbIn, mdio_addr);
825  mdio_delay(mdio_addr);
826  retval = (retval << 1) | ((mdio_in(mdio_addr) & MDIO_Data)
827  ? 1 : 0);
828  mdio_out(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
829  mdio_delay(mdio_addr);
830  }
831  return (retval >> 1) & 0xffff;
832 }
#define MDIO_WRITE0
Definition: sundance.c:784
int mii_preamble_required
Definition: sundance.c:272
#define mdio_out(value, mdio_addr)
Definition: sundance.c:776
static void mdio_sync(long mdio_addr)
Definition: sundance.c:789
static u32 BASE
Definition: sundance.c:244
static struct sundance_private * sdc
Definition: sundance.c:277
#define mdio_delay(mdio_addr)
Definition: sundance.c:777
#define mdio_in(mdio_addr)
Definition: sundance.c:775
unsigned long retval
Definition: xen.h:45
#define MDIO_WRITE1
Definition: sundance.c:785
#define MDIO_EnbIn
Definition: sundance.c:783

References BASE, MDIO_Data, mdio_delay, MDIO_EnbIn, mdio_in, mdio_out, MDIO_ShiftClk, mdio_sync(), MDIO_WRITE0, MDIO_WRITE1, sundance_private::mii_preamble_required, MIICtrl, retval, and sdc.

◆ mdio_write() [2/2]

static void mdio_write ( struct nic *nic  __unused,
int  phy_id,
unsigned int  location,
int  value 
)
static

Definition at line 835 of file sundance.c.

837 {
838  long mdio_addr = BASE + MIICtrl;
839  int mii_cmd =
840  (0x5002 << 16) | (phy_id << 23) | (location << 18) | value;
841  int i;
842 
844  mdio_sync(mdio_addr);
845 
846  /* Shift the command bits out. */
847  for (i = 31; i >= 0; i--) {
848  int dataval =
849  (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
850  mdio_out(dataval, mdio_addr);
851  mdio_delay(mdio_addr);
852  mdio_out(dataval | MDIO_ShiftClk, mdio_addr);
853  mdio_delay(mdio_addr);
854  }
855  /* Clear out extra bits. */
856  for (i = 2; i > 0; i--) {
857  mdio_out(MDIO_EnbIn, mdio_addr);
858  mdio_delay(mdio_addr);
859  mdio_out(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
860  mdio_delay(mdio_addr);
861  }
862  return;
863 }
#define MDIO_WRITE0
Definition: sundance.c:784
int mii_preamble_required
Definition: sundance.c:272
#define mdio_out(value, mdio_addr)
Definition: sundance.c:776
static void mdio_sync(long mdio_addr)
Definition: sundance.c:789
static u32 BASE
Definition: sundance.c:244
static struct sundance_private * sdc
Definition: sundance.c:277
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define mdio_delay(mdio_addr)
Definition: sundance.c:777
#define MDIO_WRITE1
Definition: sundance.c:785
#define MDIO_EnbIn
Definition: sundance.c:783

References BASE, mdio_delay, MDIO_EnbIn, mdio_out, MDIO_ShiftClk, mdio_sync(), MDIO_WRITE0, MDIO_WRITE1, sundance_private::mii_preamble_required, MIICtrl, sdc, and value.

◆ set_rx_mode() [2/2]

static void set_rx_mode ( struct nic *nic  __unused)
static

Definition at line 865 of file sundance.c.

866 {
867  int i;
868  u16 mc_filter[4]; /* Multicast hash filter */
869  u32 rx_mode;
870 
871  memset(mc_filter, 0xff, sizeof(mc_filter));
873 
874  if (sdc->mii_if.full_duplex && sdc->flowctrl)
875  mc_filter[3] |= 0x0200;
876  for (i = 0; i < 4; i++)
877  outw(mc_filter[i], BASE + MulticastFilter0 + i * 2);
878  outb(rx_mode, BASE + RxMode);
879  return;
880 }
uint16_t u16
Definition: stdint.h:21
unsigned int full_duplex
Definition: mii.h:148
#define outw(data, io_addr)
Definition: io.h:319
unsigned int flowctrl
Definition: sundance.c:265
static u32 BASE
Definition: sundance.c:244
static struct sundance_private * sdc
Definition: sundance.c:277
#define outb(data, io_addr)
Definition: io.h:309
struct mii_if_info mii_if
Definition: sundance.c:271
uint32_t u32
Definition: stdint.h:23
void * memset(void *dest, int character, size_t len) __nonnull

References AcceptBroadcast, AcceptMulticast, AcceptMyPhys, BASE, sundance_private::flowctrl, mii_if_info::full_duplex, memset(), sundance_private::mii_if, MulticastFilter0, outb, outw, RxMode, and sdc.

◆ PCI_DRIVER()

PCI_DRIVER ( sundance_driver  ,
sundance_nics  ,
PCI_NO_CLASS   
)

◆ DRIVER()

DRIVER ( "SUNDANCE/PCI"  ,
nic_driver  ,
pci_driver  ,
sundance_driver  ,
sundance_probe  ,
sundance_disable   
)

Variable Documentation

◆ mtu

int mtu = 1514
static

Definition at line 64 of file sundance.c.

Referenced by sundance_probe().

◆ rx_copybreak

int rx_copybreak = 0
static

Definition at line 74 of file sundance.c.

Referenced by sundance_poll().

◆ flowctrl

int flowctrl = 1
static

◆ media

char media[] = "autosense"
static

Definition at line 85 of file sundance.c.

Referenced by parse_eeprom(), pcnet32_chip_detect(), smc9000_probe(), and sundance_probe().

◆ tx_ring

struct netdev_desc tx_ring[TX_RING_SIZE]
static

Definition at line 229 of file sundance.c.

Referenced by init_ring(), and sundance_transmit().

◆ rx_ring

struct netdev_desc rx_ring[RX_RING_SIZE]
static

Definition at line 232 of file sundance.c.

Referenced by init_ring(), sundance_poll(), and sundance_reset().

◆ txb

unsigned char txb[PKT_BUF_SZ *TX_RING_SIZE]

Definition at line 237 of file sundance.c.

◆ rxb

unsigned char rxb[RX_RING_SIZE *PKT_BUF_SZ]

Definition at line 238 of file sundance.c.

◆ __shared

struct { ... } __shared

◆ BASE

u32 BASE
static

◆ sdx

struct sundance_private sdx
static

Referenced by sundance_probe().

◆ sdc

struct sundance_private* sdc
static

◆ sundance_operations

struct nic_operations sundance_operations
static
Initial value:
= {
.connect = dummy_connect,
.poll = sundance_poll,
.transmit = sundance_transmit,
.irq = sundance_irq,
}
static void sundance_irq(struct nic *nic, irq_action_t action)
Definition: sundance.c:424
static void sundance_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
Definition: sundance.c:491
int dummy_connect(struct nic *nic __unused)
Definition: legacy.c:151
static int sundance_poll(struct nic *nic, int retrieve)
Definition: sundance.c:444

Definition at line 555 of file sundance.c.

Referenced by sundance_probe().

◆ sundance_nics

struct pci_device_id sundance_nics[]
static
Initial value:
= {
PCI_ROM(0x13f0, 0x0201, "sundance", "ST201 Sundance 'Alta' based Adaptor", 0),
PCI_ROM(0x1186, 0x1002, "dfe530txs", "D-Link DFE530TXS (Sundance ST201 Alta)", 0),
PCI_ROM(0x13f0, 0x0200, "ip100a", "IC+ IP100A", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:286

Definition at line 882 of file sundance.c.