iPXE
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_bss
struct  sundance_private

Macros

#define drv_version   "v1.12"
#define drv_date   "2004-03-21"
#define HZ   100
#define virt_to_le32desc(addr)
#define le32desc_to_virt(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 rx_tx_buf   NIC_FAKE_BSS ( struct sundance_bss )
#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)
#define mdio_out(value, mdio_addr)
#define mdio_delay(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
}
enum  rx_mode_bits {
  AcceptAllIPMulti = 0x20 , AcceptMultiHash = 0x10 , AcceptAll = 0x08 , AcceptBroadcast = 0x04 ,
  AcceptMulticast = 0x02 , AcceptMyPhys
}
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
}
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
}
enum  chip_capability_flags { CanHaveMII = 1 , KendinPktDropBug = 2 }
enum  mii_reg_bits { MDIO_ShiftClk = 0x0001 , MDIO_Data = 0x0002 , MDIO_EnbOutput }

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, void *hwdev __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, rx_tx_buf)

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]
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)
Value:
uint32_t addr
Buffer address.
Definition dwmac.h:9
#define cpu_to_le32(value)
Definition byteswap.h:108
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184

Definition at line 60 of file sundance.c.

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

◆ le32desc_to_virt

#define le32desc_to_virt ( addr)
Value:
#define le32_to_cpu(value)
Definition byteswap.h:114
static __always_inline void * bus_to_virt(unsigned long bus_addr)
Convert bus address to a virtual address.
Definition io.h:196

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.

◆ rx_tx_buf

#define rx_tx_buf   NIC_FAKE_BSS ( struct sundance_bss )

Definition at line 240 of file sundance.c.

Referenced by DRIVER().

◆ rxb

#define rxb   rx_tx_buf.rxb

Definition at line 241 of file sundance.c.

◆ txb

#define txb   rx_tx_buf.txb

Definition at line 242 of file sundance.c.

◆ EEPROM_SIZE

#define EEPROM_SIZE   128

Definition at line 246 of file sundance.c.

◆ PCI_IOTYPE

#define PCI_IOTYPE   (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)

Definition at line 255 of file sundance.c.

◆ MII_CNT

#define MII_CNT   4

Definition at line 257 of file sundance.c.

Referenced by sundance_probe().

◆ EEPROM_SA_OFFSET

#define EEPROM_SA_OFFSET   0x10

Definition at line 281 of file sundance.c.

Referenced by sundance_probe().

◆ DEFAULT_INTR

#define DEFAULT_INTR
Value:
@ LinkChange
Definition sis190.h:110
@ IntrRxDMADone
Definition sundance.c:183
@ IntrTxDone
Definition sundance.c:180
@ IntrDrvRqst
Definition sundance.c:181
@ StatsMax
Definition sundance.c:182
@ IntrPCIErr
Definition sundance.c:179

Definition at line 282 of file sundance.c.

282#define DEFAULT_INTR (IntrRxDMADone | IntrPCIErr | \
283 IntrDrvRqst | IntrTxDone | StatsMax | \
284 LinkChange)

Referenced by sundance_irq(), and sundance_poll().

◆ mdio_in

#define mdio_in ( mdio_addr)
Value:
inb(mdio_addr)
#define inb(io_addr)
Definition io.h:283

Definition at line 776 of file sundance.c.

Referenced by mdio_read().

◆ mdio_out

#define mdio_out ( value,
mdio_addr )
Value:
outb(value, mdio_addr)
pseudo_bit_t value[0x00020]
Definition arbel.h:2
#define outb(data, io_addr)
Definition io.h:310

Definition at line 777 of file sundance.c.

Referenced by mdio_read(), mdio_sync(), and mdio_write().

◆ mdio_delay

#define mdio_delay ( mdio_addr)
Value:
inb(mdio_addr)

Definition at line 778 of file sundance.c.

Referenced by mdio_read(), mdio_sync(), and mdio_write().

◆ MDIO_EnbIn

#define MDIO_EnbIn   (0)

Definition at line 784 of file sundance.c.

Referenced by mdio_read(), mdio_read(), and mdio_write().

◆ MDIO_WRITE0

#define MDIO_WRITE0   (MDIO_EnbOutput)

Definition at line 785 of file sundance.c.

Referenced by mdio_read(), mdio_read(), and mdio_write().

◆ MDIO_WRITE1

#define MDIO_WRITE1   (MDIO_Data | MDIO_EnbOutput)

Definition at line 786 of file sundance.c.

Referenced by mdio_read(), mdio_read(), mdio_sync(), mdio_sync(), and mdio_write().

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};
@ TxStatus
Definition 3c515.c:140
@ RxStatus
Definition 3c515.c:140
@ IntrStatus
Definition sis190.h:77
@ RxDMAUrgentThresh
Definition sundance.c:121
@ StatsOneColl
Definition sundance.c:154
@ IntrEnable
Definition sundance.c:135
@ RxListPtr
Definition sundance.c:117
@ IntrClear
Definition sundance.c:134
@ MIICtrl
Definition sundance.c:142
@ TxDMAPollPeriod
Definition sundance.c:115
@ DownCounter
Definition sundance.c:133
@ StatsCarrierError
Definition sundance.c:151
@ TxDMAUrgentThresh
Definition sundance.c:114
@ RxDMAStatus
Definition sundance.c:116
@ StatsTxXSDefer
Definition sundance.c:157
@ TxFrameId
Definition sundance.c:132
@ StatsTxDefer
Definition sundance.c:155
@ TxOctetsLow
Definition sundance.c:147
@ RxMode
Definition sundance.c:141
@ MulticastFilter0
Definition sundance.c:143
@ RxDMABurstThresh
Definition sundance.c:120
@ StatsBcastRx
Definition sundance.c:160
@ DebugCtrl1
Definition sundance.c:119
@ TxListPtr
Definition sundance.c:112
@ TxFramesOK
Definition sundance.c:149
@ StatsMcastRx
Definition sundance.c:162
@ MACCtrl0
Definition sundance.c:137
@ EEData
Definition sundance.c:125
@ RxOctetsHigh
Definition sundance.c:146
@ RxDMAPollPeriod
Definition sundance.c:122
@ MulticastFilter1
Definition sundance.c:144
@ FlashAddr
Definition sundance.c:129
@ RxOctetsLow
Definition sundance.c:145
@ DMACtrl
Definition sundance.c:111
@ RxFramesOK
Definition sundance.c:150
@ RxEarlyThresh
Definition sundance.c:128
@ StationAddr
Definition sundance.c:139
@ StatsMultiColl
Definition sundance.c:153
@ EECtrl
Definition sundance.c:126
@ LEDCtrl
Definition sundance.c:123
@ DebugCtrl0
Definition sundance.c:118
@ RxMissed
Definition sundance.c:156
@ StatsMcastTx
Definition sundance.c:161
@ StatsBcastTx
Definition sundance.c:159
@ ASICCtrl
Definition sundance.c:124
@ FlashData
Definition sundance.c:130
@ MaxFrameSize
Definition sundance.c:140
@ MACCtrl1
Definition sundance.c:138
@ TxOctetsHigh
Definition sundance.c:148
@ StatsTxAbort
Definition sundance.c:158
@ TxDMABurstThresh
Definition sundance.c:113
@ StatsLateColl
Definition sundance.c:152
@ TxStartThresh
Definition sundance.c:127

◆ 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};
@ RxReset
Definition 3c515.c:107
@ TxReset
Definition 3c515.c:111
@ HostReset
Definition sundance.c:173
@ DMAReset
Definition sundance.c:170
@ GlobalReset
Definition sundance.c:167
@ FIFOReset
Definition sundance.c:171
@ NetworkReset
Definition sundance.c:172
@ ResetBusy
Definition sundance.c:174

◆ intr_status_bits

Enumerator
IntrSummary 
IntrPCIErr 
IntrMACCtrl 
IntrTxDone 
IntrRxDone 
IntrRxStart 
IntrDrvRqst 
StatsMax 
LinkChange 
IntrTxDMADone 
IntrRxDMADone 

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};
@ IntrRxStart
Definition sundance.c:180
@ IntrMACCtrl
Definition sundance.c:179
@ IntrTxDMADone
Definition sundance.c:183
@ IntrRxDone
Definition sundance.c:180
@ IntrSummary
Definition sundance.c:179

◆ rx_mode_bits

Enumerator
AcceptAllIPMulti 
AcceptMultiHash 
AcceptAll 
AcceptBroadcast 
AcceptMulticast 
AcceptMyPhys 

Definition at line 187 of file sundance.c.

187 {
188 AcceptAllIPMulti = 0x20, AcceptMultiHash = 0x10, AcceptAll = 0x08,
190 0x01,
191};
@ AcceptMulticast
Definition sis190.h:134
@ AcceptMyPhys
Definition sis190.h:135
@ AcceptBroadcast
Definition sis190.h:133
@ AcceptAllIPMulti
Definition sundance.c:188
@ AcceptAll
Definition sundance.c:188
@ AcceptMultiHash
Definition sundance.c:188

◆ 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};
@ EnbFullDuplex
Definition sundance.c:194
@ EnbPassRxCRC
Definition sundance.c:195
@ EnbFlowCtrl
Definition sundance.c:195
@ EnbRcvLargeFrame
Definition sundance.c:194

◆ 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};
@ TxEnable
Definition 3c515.c:110
@ StatsEnable
Definition 3c515.c:116
@ TxDisable
Definition 3c515.c:110
@ RxEnable
Definition 3c515.c:107
@ StatsDisable
Definition 3c515.c:118
@ RxDisable
Definition 3c515.c:107
@ TxEnabled
Definition sundance.c:199
@ StatsEnabled
Definition sundance.c:198
@ RxEnabled
Definition sundance.c:200

◆ desc_status_bits

Enumerator
DescOwn 
DescEndPacket 
DescEndRing 
LastFrag 
DescIntrOnTx 
DescIntrOnDMADone 
DisableAlign 

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};
@ DescOwn
Definition pcnet32.h:153
@ DisableAlign
Definition sundance.c:222
@ DescIntrOnDMADone
Definition sundance.c:221
@ LastFrag
Definition sundance.c:219
@ DescEndPacket
Definition sundance.c:217
@ DescEndRing
Definition sundance.c:218
@ DescIntrOnTx
Definition sundance.c:220

◆ pci_id_flags_bits

Enumerator
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 

Definition at line 248 of file sundance.c.

248 {
250 PCI_ADDR0 = 0 << 4, PCI_ADDR1 = 1 << 4, PCI_ADDR2 =
251 2 << 4, PCI_ADDR3 = 3 << 4,
252};
@ PCI_USES_MEM
Definition sundance.c:249
@ PCI_USES_MASTER
Definition sundance.c:249
@ PCI_ADDR2
Definition sundance.c:250
@ PCI_ADDR3
Definition sundance.c:251
@ PCI_ADDR1
Definition sundance.c:250
@ PCI_ADDR0
Definition sundance.c:250
@ PCI_USES_IO
Definition sundance.c:249

◆ chip_capability_flags

Enumerator
CanHaveMII 
KendinPktDropBug 

Definition at line 254 of file sundance.c.

254{ CanHaveMII = 1, KendinPktDropBug = 2, };
@ CanHaveMII
Definition sundance.c:254
@ KendinPktDropBug
Definition sundance.c:254

◆ mii_reg_bits

Enumerator
MDIO_ShiftClk 
MDIO_Data 
MDIO_EnbOutput 

Definition at line 780 of file sundance.c.

780 {
781 MDIO_ShiftClk = 0x0001, MDIO_Data = 0x0002, MDIO_EnbOutput =
782 0x0004,
783};
@ MDIO_EnbOutput
Definition sundance.c:781
@ MDIO_ShiftClk
Definition sundance.c:781
@ MDIO_Data
Definition sundance.c:781

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ eeprom_read()

int eeprom_read ( long ioaddr,
int location )
static

Definition at line 753 of file sundance.c.

754{
755 int boguscnt = 10000; /* Typical 1900 ticks */
756 outw(0x0200 | (location & 0xff), ioaddr + EECtrl);
757 do {
758 if (!(inw(ioaddr + EECtrl) & 0x8000)) {
759 return inw(ioaddr + EEData);
760 }
761 }
762 while (--boguscnt > 0);
763 return 0;
764}
static unsigned long ioaddr
Definition davicom.c:129
#define inw(io_addr)
Definition io.h:292
#define outw(data, io_addr)
Definition io.h:320

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

Referenced by sundance_probe().

◆ mdio_read() [1/2]

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

Referenced by check_duplex(), and sundance_probe().

◆ mdio_write() [1/2]

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

References value.

Referenced by sundance_probe().

◆ set_rx_mode() [1/2]

void set_rx_mode ( struct nic * nic)
static

◆ check_duplex()

void check_duplex ( struct nic * nic)
static

Definition at line 292 of file sundance.c.

293{
294 int mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA);
295 int negotiated = mii_lpa & sdc->mii_if.advertising;
296 int duplex;
297
298 /* Force media */
299 if (!sdc->an_enable || mii_lpa == 0xffff) {
300 if (sdc->mii_if.full_duplex)
302 BASE + MACCtrl0);
303 return;
304 }
305
306 /* Autonegotiation */
307 duplex = (negotiated & 0x0100) || (negotiated & 0x01C0) == 0x0040;
308 if (sdc->mii_if.full_duplex != duplex) {
309 sdc->mii_if.full_duplex = duplex;
310 DBG ("%s: Setting %s-duplex based on MII #%d "
311 "negotiated capability %4.4x.\n", sdc->nic_name,
312 duplex ? "full" : "half", sdc->phys[0],
313 negotiated );
314 outw(inw(BASE + MACCtrl0) | duplex ? 0x20 : 0,
315 BASE + MACCtrl0);
316 }
317}
#define BASE
Definition 3c595.h:69
#define MII_LPA
Definition atl1e.h:876
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
duplex
Definition nic.h:40
Definition nic.h:49
static int mdio_read(struct nic *nic, int phy_id, unsigned int location)
static struct sundance_private * sdc
Definition sundance.c:278

References BASE, DBG, EnbFullDuplex, inw, MACCtrl0, mdio_read(), MII_LPA, outw, and sdc.

◆ init_ring()

void init_ring ( struct nic *nic __unused)
static

Definition at line 323 of file sundance.c.

324{
325 int i;
326
327 sdc->cur_rx = 0;
328
329 /* Initialize all the Rx descriptors */
330 for (i = 0; i < RX_RING_SIZE; i++) {
331 rx_ring[i].next_desc = virt_to_le32desc(&rx_ring[i + 1]);
332 rx_ring[i].status = 0;
333 rx_ring[i].length = 0;
334 rx_ring[i].addr = 0;
335 }
336
337 /* Mark the last entry as wrapping the ring */
338 rx_ring[i - 1].next_desc = virt_to_le32desc(&rx_ring[0]);
339
340 for (i = 0; i < RX_RING_SIZE; i++) {
341 rx_ring[i].addr = virt_to_le32desc(&rxb[i * PKT_BUF_SZ]);
342 rx_ring[i].length = cpu_to_le32(PKT_BUF_SZ | LastFrag);
343 }
344
345 /* We only use one transmit buffer, but two
346 * descriptors so transmit engines have somewhere
347 * to point should they feel the need */
348 tx_ring[0].status = 0x00000000;
349 tx_ring[0].addr = virt_to_bus(&txb[0]);
350 tx_ring[0].next_desc = 0; /* virt_to_bus(&tx_ring[1]); */
351
352 /* This descriptor is never used */
353 tx_ring[1].status = 0x00000000;
354 tx_ring[1].addr = 0; /*virt_to_bus(&txb[0]); */
355 tx_ring[1].next_desc = 0;
356
357 /* Mark the last entry as wrapping the ring,
358 * though this should never happen */
359 tx_ring[1].length = cpu_to_le32(LastFrag | PKT_BUF_SZ);
360}
#define PKT_BUF_SZ
Definition 3c515.c:87
#define RX_RING_SIZE
Definition 3c515.c:86
#define rxb
Definition davicom.c:147
#define txb
Definition davicom.c:145
#define tx_ring
Definition epic100.c:99
#define rx_ring
Definition epic100.c:98
#define virt_to_le32desc(addr)
Definition sundance.c:60

References __unused, cpu_to_le32, LastFrag, PKT_BUF_SZ, rx_ring, RX_RING_SIZE, rxb, sdc, tx_ring, txb, virt_to_bus(), and virt_to_le32desc.

◆ sundance_reset()

void sundance_reset ( struct nic * nic)
static

Definition at line 365 of file sundance.c.

366{
367 int i;
368
369 init_ring(nic);
370
372 /* The Tx List Pointer is written as packets are queued */
373
374 /* Initialize other registers. */
375 /* __set_mac_addr(dev); */
376 {
377 u16 addr16;
378
379 addr16 = (nic->node_addr[0] | (nic->node_addr[1] << 8));
380 outw(addr16, BASE + StationAddr);
381 addr16 = (nic->node_addr[2] | (nic->node_addr[3] << 8));
382 outw(addr16, BASE + StationAddr + 2);
383 addr16 = (nic->node_addr[4] | (nic->node_addr[5] << 8));
384 outw(addr16, BASE + StationAddr + 4);
385 }
386
387 outw(sdc->mtu + 14, BASE + MaxFrameSize);
388 if (sdc->mtu > 2047) /* this will never happen with default options */
389 outl(inl(BASE + ASICCtrl) | 0x0c, BASE + ASICCtrl);
390
392
393 outw(0, BASE + DownCounter);
394 /* Set the chip to poll every N*30nsec */
395 outb(100, BASE + RxDMAPollPeriod);
396
397 /* Fix DFE-580TX packet drop issue */
398 if (sdc->pci_rev_id >= 0x14)
399 writeb(0x01, BASE + DebugCtrl1);
400
402
403 /* Construct a perfect filter frame with the mac address as first match
404 * and broadcast for all others */
405 for (i = 0; i < 192; i++)
406 txb[i] = 0xFF;
407
408 txb[0] = nic->node_addr[0];
409 txb[1] = nic->node_addr[1];
410 txb[2] = nic->node_addr[2];
411 txb[3] = nic->node_addr[3];
412 txb[4] = nic->node_addr[4];
413 txb[5] = nic->node_addr[5];
414
415 DBG ( "%s: Done sundance_reset, status: Rx %hX Tx %hX "
416 "MAC Control %hX, %hX %hX\n",
417 sdc->nic_name, (int) inl(BASE + RxStatus),
418 (int) inw(BASE + TxStatus), (int) inl(BASE + MACCtrl0),
419 (int) inw(BASE + MACCtrl1), (int) inw(BASE + MACCtrl0) );
420}
static void set_rx_mode(void)
Definition epic100.c:219
#define inl(io_addr)
Definition io.h:301
#define outl(data, io_addr)
Definition io.h:330
unsigned char * node_addr
Definition nic.h:52
#define u16
Definition vga.h:20
static void init_ring(void)
Definition w89c840.c:921
#define writeb
Definition w89c840.c:158

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

Referenced by sundance_probe().

◆ sundance_irq()

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

Definition at line 425 of file sundance.c.

425 {
426 unsigned int intr_status;
427
428 switch ( action ) {
429 case DISABLE :
430 case ENABLE :
431 intr_status = inw(nic->ioaddr + IntrStatus);
432 intr_status = intr_status & ~DEFAULT_INTR;
433 if ( action == ENABLE )
434 intr_status = intr_status | DEFAULT_INTR;
435 outw(intr_status, nic->ioaddr + IntrEnable);
436 break;
437 case FORCE :
438 outw(0x0200, BASE + ASICCtrl);
439 break;
440 }
441}
@ FORCE
Definition nic.h:37
@ ENABLE
Definition nic.h:36
@ DISABLE
Definition nic.h:35
unsigned int ioaddr
Definition nic.h:55
#define DEFAULT_INTR
Definition sundance.c:282

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

◆ sundance_poll()

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

Definition at line 445 of file sundance.c.

446{
447 /* return true if there's an ethernet packet ready to read */
448 /* nic->packet should contain data on return */
449 /* nic->packetlen should contain length of data */
450 int entry = sdc->cur_rx % RX_RING_SIZE;
451 u32 frame_status = le32_to_cpu(rx_ring[entry].status);
452 int intr_status;
453 int pkt_len = 0;
454
455 if (!(frame_status & DescOwn))
456 return 0;
457
458 /* There is a packet ready */
459 if(!retrieve)
460 return 1;
461
462 intr_status = inw(nic->ioaddr + IntrStatus);
463 outw(intr_status, nic->ioaddr + IntrStatus);
464
465 pkt_len = frame_status & 0x1fff;
466
467 if (frame_status & 0x001f4000) {
468 DBG ( "Polling frame_status error\n" ); /* Do we really care about this */
469 } else {
470 if (pkt_len < rx_copybreak) {
471 /* FIXME: What should happen Will this ever occur */
472 printf("Poll Error: pkt_len < rx_copybreak");
473 } else {
475 memcpy(nic->packet, rxb +
476 (sdc->cur_rx * PKT_BUF_SZ), nic->packetlen);
477
478 }
479 }
480 rx_ring[entry].length = cpu_to_le32(PKT_BUF_SZ | LastFrag);
481 rx_ring[entry].status = 0;
482 entry++;
483 sdc->cur_rx = entry % RX_RING_SIZE;
486 return 1;
487}
uint16_t pkt_len
Definition aqc1xx.h:2
uint8_t status
Status.
Definition ena.h:5
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned char * packet
Definition nic.h:53
unsigned int packetlen
Definition nic.h:54
static int rx_copybreak
Definition sundance.c:74
#define u32
Definition vga.h:21
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

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

◆ sundance_transmit()

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

Definition at line 492 of file sundance.c.

496{ /* Packet */
497 u16 nstype;
498 u32 to;
499
500 /* Disable the Tx */
502
503 memcpy(txb, d, ETH_ALEN);
505 nstype = htons((u16) t);
506 memcpy(txb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
507 memcpy(txb + ETH_HLEN, p, s);
508
509 s += ETH_HLEN;
510 s &= 0x0FFF;
511 while (s < ETH_ZLEN)
512 txb[s++] = '\0';
513
514 /* Setup the transmit descriptor */
515 tx_ring[0].length = cpu_to_le32(s | LastFrag);
516 tx_ring[0].status = cpu_to_le32(0x00000001);
517
518 /* Point to transmit descriptor */
520
521 /* Enable Tx */
523 /* Trigger an immediate send */
524 outw(0, BASE + TxStatus);
525
526 to = currticks() + TX_TIME_OUT;
527 while (!(tx_ring[0].status & 0x00010000) && (currticks() < to)); /* wait */
528
529 if (currticks() >= to) {
530 printf("TX Time Out");
531 }
532 /* Disable Tx */
534
535}
#define TX_TIME_OUT
Definition davicom.c:51
#define ETH_ZLEN
Definition if_ether.h:11
#define ETH_ALEN
Definition if_ether.h:9
#define ETH_HLEN
Definition if_ether.h:10
#define u8
Definition igbvf_osdep.h:40
#define htons(value)
Definition byteswap.h:136
unsigned long currticks(void)
Get current system time in ticks.
Definition timer.c:43

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

◆ sundance_disable()

void sundance_disable ( struct nic *nic __unused,
void *hwdev __unused )
static

Definition at line 540 of file sundance.c.

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

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

Referenced by DRIVER().

◆ sundance_probe()

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

Definition at line 567 of file sundance.c.

567 {
568
570 u16 mii_ctl;
571 int i;
572 int speed;
573
574 if (pci->ioaddr == 0)
575 return 0;
576
577 /* BASE is used throughout to address the card */
578 BASE = pci->ioaddr;
579 printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
580 pci->id->name, pci->vendor, pci->device);
581
582 /* Get the MAC Address by reading the EEPROM */
583 for (i = 0; i < 3; i++) {
584 ((u16 *) ee_data)[i] =
586 }
587 /* Update the nic structure with the MAC Address */
588 for (i = 0; i < ETH_ALEN; i++) {
589 nic->node_addr[i] = ee_data[i];
590 }
591
592 /* Set the card as PCI Bus Master */
594
595// sdc->mii_if.dev = pci;
596// sdc->mii_if.phy_id_mask = 0x1f;
597// sdc->mii_if.reg_num_mask = 0x1f;
598
599 /* point to private storage */
600 sdc = &sdx;
601
602 sdc->nic_name = pci->id->name;
603 sdc->mtu = mtu;
604
605 pci_read_config_byte(pci, PCI_REVISION, &sdc->pci_rev_id);
606
607 DBG ( "Device revision id: %hx\n", sdc->pci_rev_id );
608
609 /* Print out some hardware info */
610 DBG ( "%s: %s at ioaddr %hX, ",
611 pci->id->name, nic->node_addr, (unsigned int) BASE);
612
613 sdc->mii_preamble_required = 0;
614 if (1) {
615 int phy, phy_idx = 0;
616 sdc->phys[0] = 1; /* Default Setting */
617 sdc->mii_preamble_required++;
618 for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
619 int mii_status = mdio_read(nic, phy, MII_BMSR);
620 if (mii_status != 0xffff && mii_status != 0x0000) {
621 sdc->phys[phy_idx++] = phy;
622 sdc->mii_if.advertising =
624 if ((mii_status & 0x0040) == 0)
625 sdc->mii_preamble_required++;
626 DBG
627 ( "%s: MII PHY found at address %d, status " "%hX advertising %hX\n", sdc->nic_name, phy, mii_status, sdc->mii_if.advertising );
628 }
629 }
630 sdc->mii_preamble_required--;
631 if (phy_idx == 0)
632 printf("%s: No MII transceiver found!\n",
633 sdc->nic_name);
634 sdc->mii_if.phy_id = sdc->phys[0];
635 }
636
637 /* Parse override configuration */
638 sdc->an_enable = 1;
639 if (strcasecmp(media, "autosense") != 0) {
640 sdc->an_enable = 0;
641 if (strcasecmp(media, "100mbps_fd") == 0 ||
642 strcasecmp(media, "4") == 0) {
643 sdc->speed = 100;
644 sdc->mii_if.full_duplex = 1;
645 } else if (strcasecmp(media, "100mbps_hd") == 0
646 || strcasecmp(media, "3") == 0) {
647 sdc->speed = 100;
648 sdc->mii_if.full_duplex = 0;
649 } else if (strcasecmp(media, "10mbps_fd") == 0 ||
650 strcasecmp(media, "2") == 0) {
651 sdc->speed = 10;
652 sdc->mii_if.full_duplex = 1;
653 } else if (strcasecmp(media, "10mbps_hd") == 0 ||
654 strcasecmp(media, "1") == 0) {
655 sdc->speed = 10;
656 sdc->mii_if.full_duplex = 0;
657 } else {
658 sdc->an_enable = 1;
659 }
660 }
661 if (flowctrl == 1)
662 sdc->flowctrl = 1;
663
664 /* Fibre PHY? */
665 if (inl(BASE + ASICCtrl) & 0x80) {
666 /* Default 100Mbps Full */
667 if (sdc->an_enable) {
668 sdc->speed = 100;
669 sdc->mii_if.full_duplex = 1;
670 sdc->an_enable = 0;
671 }
672 }
673
674 /* The Linux driver uses flow control and resets the link here. This means the
675 mii section from above would need to be re done I believe. Since it serves
676 no real purpose leave it out. */
677
678 /* Force media type */
679 if (!sdc->an_enable) {
680 mii_ctl = 0;
681 mii_ctl |= (sdc->speed == 100) ? BMCR_SPEED100 : 0;
682 mii_ctl |= (sdc->mii_if.full_duplex) ? BMCR_FULLDPLX : 0;
683 mdio_write(nic, sdc->phys[0], MII_BMCR, mii_ctl);
684 printf("Override speed=%d, %s duplex\n",
685 sdc->speed,
686 sdc->mii_if.full_duplex ? "Full" : "Half");
687 }
688
689 /* Reset the chip to erase previous misconfiguration */
690 DBG ( "ASIC Control is %#x\n", inl(BASE + ASICCtrl) );
691 outw(0x007f, BASE + ASICCtrl + 2);
692
693 /*
694 * wait for reset to complete
695 * this is heavily inspired by the linux sundance driver
696 * according to the linux driver it can take up to 1ms for the reset
697 * to complete
698 */
699 i = 0;
700 while(inl(BASE + ASICCtrl) & (ResetBusy << 16)) {
701 if(i++ >= 10) {
702 DBG("sundance: NIC reset did not complete.\n");
703 break;
704 }
705 udelay(100);
706 }
707
708 DBG ( "ASIC Control is now %#x.\n", inl(BASE + ASICCtrl) );
709
711 if (sdc->an_enable) {
712 u16 mii_advertise, mii_lpa;
713 mii_advertise =
714 mdio_read(nic, sdc->phys[0], MII_ADVERTISE);
715 mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA);
716 mii_advertise &= mii_lpa;
717 if (mii_advertise & ADVERTISE_100FULL)
718 sdc->speed = 100;
719 else if (mii_advertise & ADVERTISE_100HALF)
720 sdc->speed = 100;
721 else if (mii_advertise & ADVERTISE_10FULL)
722 sdc->speed = 10;
723 else if (mii_advertise & ADVERTISE_10HALF)
724 sdc->speed = 10;
725 } else {
726 mii_ctl = mdio_read(nic, sdc->phys[0], MII_BMCR);
727 speed = (mii_ctl & BMCR_SPEED100) ? 100 : 10;
728 sdc->speed = speed;
729 printf("%s: Link changed: %dMbps ,", sdc->nic_name, speed);
730 printf("%s duplex.\n", (mii_ctl & BMCR_FULLDPLX) ?
731 "full" : "half");
732 }
734 if (sdc->flowctrl && sdc->mii_if.full_duplex) {
735 outw(inw(BASE + MulticastFilter1 + 2) | 0x0200,
736 BASE + MulticastFilter1 + 2);
738 }
739 printf("%dMbps, %s-Duplex\n", sdc->speed,
740 sdc->mii_if.full_duplex ? "Full" : "Half");
741
742 /* point to NIC specific routines */
744
745 nic->irqno = pci->irq;
746 nic->ioaddr = BASE;
747
748 return 1;
749}
#define MII_ADVERTISE
Definition atl1e.h:875
#define MII_BMCR
Definition atl1e.h:871
#define MII_BMSR
Definition atl1e.h:872
static unsigned char ee_data[EEPROM_SIZE]
Definition davicom.c:67
#define EEPROM_SIZE
Definition davicom.c:62
uint32_t mtu
Maximum MTU.
Definition ena.h:17
#define le16_to_cpu(value)
Definition byteswap.h:113
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define BMCR_SPEED100
Definition mii.h:51
#define ADVERTISE_10HALF
Definition mii.h:75
#define ADVERTISE_100FULL
Definition mii.h:81
#define ADVERTISE_10FULL
Definition mii.h:77
#define ADVERTISE_100HALF
Definition mii.h:79
#define BMCR_FULLDPLX
Definition mii.h:46
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
#define PCI_REVISION
PCI revision.
Definition pci.h:45
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition string.c:209
unsigned char irqno
Definition nic.h:56
struct nic_operations * nic_op
Definition nic.h:50
const char * name
Name.
Definition pci.h:177
unsigned long ioaddr
I/O address.
Definition pci.h:226
uint8_t irq
Interrupt number.
Definition pci.h:234
struct pci_device_id * id
Driver device ID.
Definition pci.h:248
uint16_t vendor
Vendor ID.
Definition pci.h:228
uint16_t device
Device ID.
Definition pci.h:230
#define MII_CNT
Definition sundance.c:257
#define EEPROM_SA_OFFSET
Definition sundance.c:281
static void mdio_write(struct nic *nic, int phy_id, unsigned int location, int value)
static struct nic_operations sundance_operations
Definition sundance.c:556
static int flowctrl
Definition sundance.c:75
static char media[]
Definition sundance.c:85
static struct sundance_private sdx
static void sundance_reset(struct nic *nic)
Definition sundance.c:365
static int eeprom_read(long ioaddr, int location)
Definition sundance.c:753
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
static void check_duplex(void)
Definition w89c840.c:872

References adjust_pci_device(), ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, 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, 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, MII_LPA, mtu, MulticastFilter1, pci_device_id::name, nic::nic_op, nic::node_addr, outw, pci_read_config_byte(), PCI_REVISION, printf(), ResetBusy, sdc, sdx, strcasecmp(), sundance_operations, sundance_reset(), u16, u8, udelay(), and pci_device::vendor.

Referenced by DRIVER().

◆ mdio_sync()

void mdio_sync ( long mdio_addr)
static

Definition at line 790 of file sundance.c.

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

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

Referenced by mdio_read(), and mdio_write().

◆ mdio_read() [2/2]

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

Definition at line 804 of file sundance.c.

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

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

◆ mdio_write() [2/2]

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

Definition at line 836 of file sundance.c.

838{
839 long mdio_addr = BASE + MIICtrl;
840 int mii_cmd =
841 (0x5002 << 16) | (phy_id << 23) | (location << 18) | value;
842 int i;
843
844 if (sdc->mii_preamble_required)
845 mdio_sync(mdio_addr);
846
847 /* Shift the command bits out. */
848 for (i = 31; i >= 0; i--) {
849 int dataval =
850 (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
851 mdio_out(dataval, mdio_addr);
852 mdio_delay(mdio_addr);
853 mdio_out(dataval | MDIO_ShiftClk, mdio_addr);
854 mdio_delay(mdio_addr);
855 }
856 /* Clear out extra bits. */
857 for (i = 2; i > 0; i--) {
858 mdio_out(MDIO_EnbIn, mdio_addr);
859 mdio_delay(mdio_addr);
860 mdio_out(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
861 mdio_delay(mdio_addr);
862 }
863 return;
864}

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

◆ set_rx_mode() [2/2]

void set_rx_mode ( struct nic *nic __unused)
static

Definition at line 866 of file sundance.c.

867{
868 int i;
869 u16 mc_filter[4]; /* Multicast hash filter */
870 u32 rx_mode;
871
872 memset(mc_filter, 0xff, sizeof(mc_filter));
874
875 if (sdc->mii_if.full_duplex && sdc->flowctrl)
876 mc_filter[3] |= 0x0200;
877 for (i = 0; i < 4; i++)
878 outw(mc_filter[i], BASE + MulticastFilter0 + i * 2);
879 outb(rx_mode, BASE + RxMode);
880 return;
881}
void * memset(void *dest, int character, size_t len) __nonnull

References __unused, AcceptBroadcast, AcceptMulticast, AcceptMyPhys, BASE, memset(), MulticastFilter0, outb, outw, RxMode, sdc, u16, and u32.

◆ PCI_DRIVER()

PCI_DRIVER ( sundance_driver ,
sundance_nics ,
PCI_NO_CLASS  )

References sundance_nics.

◆ DRIVER()

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

Variable Documentation

◆ mtu

int mtu = 1514
static

Definition at line 64 of file sundance.c.

◆ rx_copybreak

int rx_copybreak = 0
static

Definition at line 74 of file sundance.c.

Referenced by sundance_poll().

◆ flowctrl

◆ media

◆ tx_ring

struct netdev_desc tx_ring[TX_RING_SIZE]
static

Definition at line 229 of file sundance.c.

◆ rx_ring

struct netdev_desc rx_ring[RX_RING_SIZE]
static

Definition at line 232 of file sundance.c.

◆ BASE

u32 BASE
static

Definition at line 245 of file sundance.c.

◆ sdx

struct sundance_private sdx
static

Referenced by sundance_probe().

◆ sdc

◆ sundance_operations

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

Definition at line 556 of file sundance.c.

556 {
557 .connect = dummy_connect,
558 .poll = sundance_poll,
559 .transmit = sundance_transmit,
560 .irq = sundance_irq,
561
562};

Referenced by sundance_probe().

◆ sundance_nics

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

Definition at line 883 of file sundance.c.

883 {
884 PCI_ROM(0x1186, 0x1002, "dfe530txs", "D-Link DFE530TXS (Sundance ST201 Alta)", 0),
885 PCI_ROM(0x13f0, 0x0200, "ip100a", "IC+ IP100A", 0),
886 PCI_ROM(0x13f0, 0x0201, "sundance", "ST201 Sundance 'Alta' based Adaptor", 0),
887};

Referenced by PCI_DRIVER().