iPXE
Macros | Functions | Variables
sis190.c File Reference
#include "sis190.h"

Go to the source code of this file.

Macros

#define ErrMask   (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)
 
#define TxErrMask   (WND | TABRT | FIFO | LINK)
 

Functions

 FILE_LICENCE (GPL_ANY)
 
static int sis190_isa_bridge_probe (struct pci_device *pdev __unused)
 
static void sis190_isa_bridge_remove (struct pci_device *pdev __unused)
 
static void __mdio_cmd (void *ioaddr, u32 ctl)
 
static void mdio_write (void *ioaddr, int phy_id, int reg, int val)
 
static int mdio_read (void *ioaddr, int phy_id, int reg)
 
static void __mdio_write (struct net_device *dev, int phy_id, int reg, int val)
 
static int __mdio_read (struct net_device *dev, int phy_id, int reg)
 
static u16 mdio_read_latched (void *ioaddr, int phy_id, int reg)
 
static u16 sis190_read_eeprom (void *ioaddr, u32 reg)
 
static void sis190_irq_mask_and_ack (void *ioaddr)
 
static void sis190_asic_down (void *ioaddr)
 
static void sis190_mark_as_last_descriptor (struct RxDesc *desc)
 
static void sis190_give_to_asic (struct RxDesc *desc)
 
static void sis190_map_to_asic (struct RxDesc *desc, u32 mapping)
 
static void sis190_make_unusable_by_asic (struct RxDesc *desc)
 
static struct io_buffersis190_alloc_rx_iob (struct RxDesc *desc)
 
static u32 sis190_rx_fill (struct sis190_private *tp, u32 start, u32 end)
 
static int sis190_rx_pkt_err (u32 status)
 
static int sis190_process_rx (struct sis190_private *tp)
 
static int sis190_tx_pkt_err (u32 status)
 
static void sis190_process_tx (struct sis190_private *tp)
 
static void sis190_poll (struct net_device *dev)
 
static void sis190_init_ring_indexes (struct sis190_private *tp)
 
static int sis190_init_ring (struct net_device *dev)
 
static void sis190_set_rx_mode (struct net_device *dev)
 
static void sis190_soft_reset (void *ioaddr)
 
static void sis190_hw_start (struct net_device *dev)
 
static void sis190_phy_task (struct sis190_private *tp)
 
static int sis190_open (struct net_device *dev)
 
static void sis190_down (struct net_device *dev)
 
static void sis190_free (struct net_device *dev)
 
static void sis190_close (struct net_device *dev)
 
static int sis190_transmit (struct net_device *dev, struct io_buffer *iob)
 
static void sis190_free_phy (struct list_head *first_phy)
 
static u16 sis190_default_phy (struct sis190_private *tp)
 sis190_default_phy - Select default PHY for sis190 mac. More...
 
static void sis190_init_phy (struct sis190_private *tp, struct sis190_phy *phy, unsigned int phy_id, u16 mii_status)
 
static void sis190_mii_probe_88e1111_fixup (struct sis190_private *tp)
 
static int sis190_mii_probe (struct net_device *dev)
 sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for More...
 
static void sis190_mii_remove (struct net_device *dev)
 
static int sis190_init_board (struct pci_device *pdev, struct net_device **netdev)
 
static void sis190_set_rgmii (struct sis190_private *tp, u8 reg)
 
static int sis190_get_mac_addr_from_eeprom (struct pci_device *pdev __unused, struct net_device *dev)
 
static int sis190_get_mac_addr_from_apc (struct pci_device *pdev, struct net_device *dev)
 sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network device to get address for More...
 
static void sis190_init_rxfilter (struct net_device *dev)
 sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize More...
 
static int sis190_get_mac_addr (struct pci_device *pdev, struct net_device *dev)
 
static void sis190_set_speed_auto (struct net_device *dev)
 
static void sis190_irq (struct net_device *dev, int enable)
 
static int sis190_probe (struct pci_device *pdev)
 
static void sis190_remove (struct pci_device *pdev)
 

Variables

static struct pci_device_id sis190_pci_tbl []
 
static struct pci_device_id sis190_isa_bridge_tbl []
 
struct pci_driver sis190_isa_bridge_driver __pci_driver
 
static const u32 sis190_intr_mask
 
static struct net_device_operations sis190_netdev_ops
 

Macro Definition Documentation

◆ ErrMask

#define ErrMask   (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)

◆ TxErrMask

#define TxErrMask   (WND | TABRT | FIFO | LINK)

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL_ANY  )

◆ sis190_isa_bridge_probe()

static int sis190_isa_bridge_probe ( struct pci_device *pdev  __unused)
static

Definition at line 50 of file sis190.c.

51 {
52  return 0;
53 }

◆ sis190_isa_bridge_remove()

static void sis190_isa_bridge_remove ( struct pci_device *pdev  __unused)
static

Definition at line 55 of file sis190.c.

56 {
57  return;
58 }

◆ __mdio_cmd()

static void __mdio_cmd ( void *  ioaddr,
u32  ctl 
)
static

Definition at line 75 of file sis190.c.

76 {
77  unsigned int i;
78 
79  SIS_W32(GMIIControl, ctl);
80 
81  mdelay(1);
82 
83  for (i = 0; i < 100; i++) {
85  break;
86  mdelay(1);
87  }
88 
89  if (i > 99)
90  DBG("sis190: PHY command timed out !\n");
91 }
#define SIS_R32(reg)
Definition: sis190.h:64
#define SIS_W32(reg, val)
Definition: sis190.h:61
#define EhnMIInotDone
Definition: sis190.h:56
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, EhnMIInotDone, GMIIControl, mdelay(), SIS_R32, and SIS_W32.

Referenced by mdio_read(), and mdio_write().

◆ mdio_write()

static void mdio_write ( void *  ioaddr,
int  phy_id,
int  reg,
int  val 
)
static

Definition at line 93 of file sis190.c.

94 {
96  (((u32) reg) << EhnMIIregShift) | (phy_id << EhnMIIpmdShift) |
97  (((u32) val) << EhnMIIdataShift));
98 }
#define EhnMIIdataShift
Definition: sis190.h:52
static unsigned long ioaddr
Definition: davicom.c:129
#define EhnMIIpmdShift
Definition: sis190.h:53
static unsigned int unsigned int reg
Definition: intel.h:245
void __asmcall int val
Definition: setjmp.h:28
static void __mdio_cmd(void *ioaddr, u32 ctl)
Definition: sis190.c:75
#define EhnMIIregShift
Definition: sis190.h:54
#define EhnMIIreq
Definition: sis190.h:55
#define EhnMIIwrite
Definition: sis190.h:51
uint32_t u32
Definition: stdint.h:23

References __mdio_cmd(), EhnMIIdataShift, EhnMIIpmdShift, EhnMIIregShift, EhnMIIreq, EhnMIIwrite, ioaddr, reg, and val.

Referenced by __mdio_write(), sis190_default_phy(), sis190_mii_probe_88e1111_fixup(), sis190_phy_task(), and sis190_set_speed_auto().

◆ mdio_read()

static int mdio_read ( void *  ioaddr,
int  phy_id,
int  reg 
)
static

Definition at line 100 of file sis190.c.

101 {
103  (((u32) reg) << EhnMIIregShift) | (phy_id << EhnMIIpmdShift));
104 
105  return (u16) (SIS_R32(GMIIControl) >> EhnMIIdataShift);
106 }
uint16_t u16
Definition: stdint.h:21
#define EhnMIIdataShift
Definition: sis190.h:52
#define EhnMIIread
Definition: sis190.h:50
#define SIS_R32(reg)
Definition: sis190.h:64
static unsigned long ioaddr
Definition: davicom.c:129
#define EhnMIIpmdShift
Definition: sis190.h:53
static unsigned int unsigned int reg
Definition: intel.h:245
static void __mdio_cmd(void *ioaddr, u32 ctl)
Definition: sis190.c:75
#define EhnMIIregShift
Definition: sis190.h:54
#define EhnMIIreq
Definition: sis190.h:55
uint32_t u32
Definition: stdint.h:23

References __mdio_cmd(), EhnMIIdataShift, EhnMIIpmdShift, EhnMIIread, EhnMIIregShift, EhnMIIreq, GMIIControl, ioaddr, reg, and SIS_R32.

Referenced by __mdio_read(), mdio_read_latched(), sis190_default_phy(), sis190_init_phy(), sis190_phy_task(), and sis190_set_speed_auto().

◆ __mdio_write()

static void __mdio_write ( struct net_device dev,
int  phy_id,
int  reg,
int  val 
)
static

Definition at line 108 of file sis190.c.

109 {
110  struct sis190_private *tp = netdev_priv(dev);
111 
112  mdio_write(tp->mmio_addr, phy_id, reg, val);
113 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct net_device * dev
Definition: sis190.h:253
static struct tulip_private * tp
Definition: tulip.c:441
static unsigned int unsigned int reg
Definition: intel.h:245
void __asmcall int val
Definition: setjmp.h:28
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition: sis190.c:93

References sis190_private::dev, mdio_write(), netdev_priv(), reg, tp, and val.

Referenced by sis190_mii_probe().

◆ __mdio_read()

static int __mdio_read ( struct net_device dev,
int  phy_id,
int  reg 
)
static

Definition at line 115 of file sis190.c.

116 {
117  struct sis190_private *tp = netdev_priv(dev);
118 
119  return mdio_read(tp->mmio_addr, phy_id, reg);
120 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct net_device * dev
Definition: sis190.h:253
static struct tulip_private * tp
Definition: tulip.c:441
static unsigned int unsigned int reg
Definition: intel.h:245
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100

References sis190_private::dev, mdio_read(), netdev_priv(), reg, and tp.

Referenced by sis190_mii_probe().

◆ mdio_read_latched()

static u16 mdio_read_latched ( void *  ioaddr,
int  phy_id,
int  reg 
)
static

Definition at line 122 of file sis190.c.

123 {
124  mdio_read(ioaddr, phy_id, reg);
125  return mdio_read(ioaddr, phy_id, reg);
126 }
static unsigned long ioaddr
Definition: davicom.c:129
static unsigned int unsigned int reg
Definition: intel.h:245
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100

References ioaddr, mdio_read(), and reg.

Referenced by sis190_default_phy(), sis190_mii_probe(), and sis190_phy_task().

◆ sis190_read_eeprom()

static u16 sis190_read_eeprom ( void *  ioaddr,
u32  reg 
)
static

Definition at line 128 of file sis190.c.

129 {
130  u16 data = 0xffff;
131  unsigned int i;
132 
133  if (!(SIS_R32(ROMControl) & 0x0002))
134  return 0;
135 
136  SIS_W32(ROMInterface, EEREQ | EEROP | (reg << 10));
137 
138  for (i = 0; i < 200; i++) {
139  if (!(SIS_R32(ROMInterface) & EEREQ)) {
140  data = (SIS_R32(ROMInterface) & 0xffff0000) >> 16;
141  break;
142  }
143  mdelay(1);
144  }
145 
146  return data;
147 }
uint16_t u16
Definition: stdint.h:21
Definition: sis190.h:232
#define SIS_R32(reg)
Definition: sis190.h:64
#define SIS_W32(reg, val)
Definition: sis190.h:61
static unsigned int unsigned int reg
Definition: intel.h:245
Definition: sis190.h:231
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, EEREQ, EEROP, mdelay(), reg, ROMControl, ROMInterface, SIS_R32, and SIS_W32.

Referenced by sis190_get_mac_addr_from_eeprom().

◆ sis190_irq_mask_and_ack()

static void sis190_irq_mask_and_ack ( void *  ioaddr)
static

Definition at line 149 of file sis190.c.

150 {
151  SIS_W32(IntrMask, 0x00);
152  SIS_W32(IntrStatus, 0xffffffff);
153  SIS_PCI_COMMIT();
154 }
#define SIS_PCI_COMMIT()
Definition: sis190.h:66
#define SIS_W32(reg, val)
Definition: sis190.h:61

References IntrMask, IntrStatus, SIS_PCI_COMMIT, and SIS_W32.

Referenced by sis190_asic_down(), and sis190_init_board().

◆ sis190_asic_down()

static void sis190_asic_down ( void *  ioaddr)
static

Definition at line 156 of file sis190.c.

157 {
158  /* Stop the chip's Tx and Rx DMA processes. */
159 
160  SIS_W32(TxControl, 0x1a00);
161  SIS_W32(RxControl, 0x1a00);
162 
164 }
static unsigned long ioaddr
Definition: davicom.c:129
#define SIS_W32(reg, val)
Definition: sis190.h:61
static void sis190_irq_mask_and_ack(void *ioaddr)
Definition: sis190.c:149

References ioaddr, RxControl, sis190_irq_mask_and_ack(), SIS_W32, and TxControl.

Referenced by sis190_down(), and sis190_soft_reset().

◆ sis190_mark_as_last_descriptor()

static void sis190_mark_as_last_descriptor ( struct RxDesc desc)
inlinestatic

Definition at line 166 of file sis190.c.

167 {
168  desc->size |= cpu_to_le32(RingEnd);
169 }
volatile u32 size
Definition: sis190.h:164
#define cpu_to_le32(value)
Definition: byteswap.h:107

References cpu_to_le32, RingEnd, and RxDesc::size.

Referenced by sis190_init_ring().

◆ sis190_give_to_asic()

static void sis190_give_to_asic ( struct RxDesc desc)
inlinestatic

Definition at line 171 of file sis190.c.

172 {
173  u32 eor = le32_to_cpu(desc->size) & RingEnd;
174 
175  desc->PSize = 0x0;
176  desc->size = cpu_to_le32((RX_BUF_SIZE & RX_BUF_MASK) | eor);
177  wmb();
178  desc->status = cpu_to_le32(OWNbit | INTbit);
179 }
wmb()
#define le32_to_cpu(value)
Definition: byteswap.h:113
Definition: sis190.h:169
#define RX_BUF_SIZE
Definition: 3c90x.h:269
Definition: sis190.h:170
volatile u32 size
Definition: sis190.h:164
volatile u32 status
Definition: sis190.h:162
#define cpu_to_le32(value)
Definition: byteswap.h:107
volatile u32 PSize
Definition: sis190.h:161
#define RX_BUF_MASK
Definition: sis190.h:43
uint32_t u32
Definition: stdint.h:23

References cpu_to_le32, INTbit, le32_to_cpu, OWNbit, RxDesc::PSize, RingEnd, RX_BUF_MASK, RX_BUF_SIZE, RxDesc::size, RxDesc::status, and wmb().

Referenced by sis190_map_to_asic(), and sis190_process_rx().

◆ sis190_map_to_asic()

static void sis190_map_to_asic ( struct RxDesc desc,
u32  mapping 
)
inlinestatic

Definition at line 181 of file sis190.c.

182 {
183  desc->addr = cpu_to_le32(mapping);
184  sis190_give_to_asic(desc);
185 }
#define cpu_to_le32(value)
Definition: byteswap.h:107
static void sis190_give_to_asic(struct RxDesc *desc)
Definition: sis190.c:171
volatile u32 addr
Definition: sis190.h:163

References RxDesc::addr, cpu_to_le32, and sis190_give_to_asic().

Referenced by sis190_alloc_rx_iob().

◆ sis190_make_unusable_by_asic()

static void sis190_make_unusable_by_asic ( struct RxDesc desc)
inlinestatic

Definition at line 187 of file sis190.c.

188 {
189  desc->PSize = 0x0;
190  desc->addr = cpu_to_le32(0xdeadbeef);
191  desc->size &= cpu_to_le32(RingEnd);
192  wmb();
193  desc->status = 0x0;
194 }
wmb()
volatile u32 size
Definition: sis190.h:164
volatile u32 status
Definition: sis190.h:162
#define cpu_to_le32(value)
Definition: byteswap.h:107
volatile u32 PSize
Definition: sis190.h:161
volatile u32 addr
Definition: sis190.h:163

References RxDesc::addr, cpu_to_le32, RxDesc::PSize, RingEnd, RxDesc::size, RxDesc::status, and wmb().

Referenced by sis190_alloc_rx_iob(), and sis190_process_rx().

◆ sis190_alloc_rx_iob()

static struct io_buffer* sis190_alloc_rx_iob ( struct RxDesc desc)
static

Definition at line 196 of file sis190.c.

197 {
198  struct io_buffer *iob;
199 
200  iob = alloc_iob(RX_BUF_SIZE);
201  if (iob) {
202  u32 mapping;
203 
204  mapping = virt_to_bus(iob->data);
205  sis190_map_to_asic(desc, mapping);
206  } else {
207  DBG("sis190: alloc_iob failed\n");
209  }
210 
211  return iob;
212 }
#define RX_BUF_SIZE
Definition: 3c90x.h:269
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static void sis190_make_unusable_by_asic(struct RxDesc *desc)
Definition: sis190.c:187
static void sis190_map_to_asic(struct RxDesc *desc, u32 mapping)
Definition: sis190.c:181
void * data
Start of data.
Definition: iobuf.h:44
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint32_t u32
Definition: stdint.h:23
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob(), io_buffer::data, DBG, RX_BUF_SIZE, sis190_make_unusable_by_asic(), sis190_map_to_asic(), and virt_to_bus().

Referenced by sis190_rx_fill().

◆ sis190_rx_fill()

static u32 sis190_rx_fill ( struct sis190_private tp,
u32  start,
u32  end 
)
static

Definition at line 214 of file sis190.c.

215 {
216  u32 cur;
217 
218  for (cur = start; cur < end; cur++) {
219  unsigned int i = cur % NUM_RX_DESC;
220 
221  if (tp->Rx_iobuf[i])
222  continue;
223 
224  tp->Rx_iobuf[i] = sis190_alloc_rx_iob(tp->RxDescRing + i);
225 
226  if (!tp->Rx_iobuf[i])
227  break;
228  }
229  return cur - start;
230 }
#define NUM_RX_DESC
Definition: igbvf.h:281
uint32_t start
Starting offset.
Definition: netvsc.h:12
static struct tulip_private * tp
Definition: tulip.c:441
static struct io_buffer * sis190_alloc_rx_iob(struct RxDesc *desc)
Definition: sis190.c:196
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint32_t u32
Definition: stdint.h:23

References end, NUM_RX_DESC, sis190_alloc_rx_iob(), start, and tp.

Referenced by sis190_init_ring(), and sis190_process_rx().

◆ sis190_rx_pkt_err()

static int sis190_rx_pkt_err ( u32  status)
inlinestatic

Definition at line 232 of file sis190.c.

233 {
234 #define ErrMask (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)
235 
236  if ((status & CRCOK) && !(status & ErrMask))
237  return 0;
238 
239  return -1;
240 }
uint8_t status
Status.
Definition: ena.h:16
#define ErrMask
Definition: sis190.h:217

References CRCOK, ErrMask, and status.

Referenced by sis190_process_rx().

◆ sis190_process_rx()

static int sis190_process_rx ( struct sis190_private tp)
static

Definition at line 242 of file sis190.c.

243 {
244  u32 rx_left, cur_rx = tp->cur_rx;
245  u32 delta, count;
246 
247  rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx;
248 
249  for (; rx_left > 0; rx_left--, cur_rx++) {
250  unsigned int entry = cur_rx % NUM_RX_DESC;
251  struct RxDesc *desc = tp->RxDescRing + entry;
252  u32 status;
253 
254  if (le32_to_cpu(desc->status) & OWNbit)
255  break;
256 
257  status = le32_to_cpu(desc->PSize);
258 
259  if (sis190_rx_pkt_err(status) < 0) {
260  sis190_give_to_asic(desc);
261  } else {
262  struct io_buffer *iob = tp->Rx_iobuf[entry];
263  unsigned int pkt_size = (status & RxSizeMask) - 4;
264 
265  if (pkt_size > RX_BUF_SIZE) {
266  DBG("sis190: (frag) status = %08x.\n", status);
267  sis190_give_to_asic(desc);
268  continue;
269  }
270 
272 
273  iob_put(iob, pkt_size);
274 
275  DBG2("sis190: received packet. len: %d\n", pkt_size);
276  netdev_rx(tp->dev, iob);
277  DBGIO_HD(iob->data, 60);
278  tp->Rx_iobuf[entry] = NULL;
279  }
280  }
281  count = cur_rx - tp->cur_rx;
282  tp->cur_rx = cur_rx;
283 
284  delta = sis190_rx_fill(tp, tp->dirty_rx, tp->cur_rx);
285  if (!delta && count)
286  DBG("sis190: no Rx buffer allocated.\n");
287  tp->dirty_rx += delta;
288 
289  if (((tp->dirty_rx + NUM_RX_DESC) == tp->cur_rx))
290  DBG("sis190: Rx buffers exhausted.\n");
291 
292  return count;
293 }
#define iob_put(iobuf, len)
Definition: iobuf.h:116
#define le32_to_cpu(value)
Definition: byteswap.h:113
Definition: sis190.h:169
#define RX_BUF_SIZE
Definition: 3c90x.h:269
#define DBGIO_HD(...)
Definition: compiler.h:551
#define NUM_RX_DESC
Definition: igbvf.h:281
uint8_t status
Status.
Definition: ena.h:16
volatile u32 status
Definition: sis190.h:162
static struct tulip_private * tp
Definition: tulip.c:441
volatile u32 PSize
Definition: sis190.h:161
static int sis190_rx_pkt_err(u32 status)
Definition: sis190.c:232
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
static void sis190_give_to_asic(struct RxDesc *desc)
Definition: sis190.c:171
static void sis190_make_unusable_by_asic(struct RxDesc *desc)
Definition: sis190.c:187
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
static unsigned int cur_rx
Definition: epic100.c:84
void * data
Start of data.
Definition: iobuf.h:44
uint16_t count
Number of entries.
Definition: ena.h:22
int cur_rx
Definition: tulip.c:396
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static u32 sis190_rx_fill(struct sis190_private *tp, u32 start, u32 end)
Definition: sis190.c:214
uint32_t u32
Definition: stdint.h:23
Definition: sis190.h:160
#define DBG2(...)
Definition: compiler.h:515
A persistent I/O buffer.
Definition: iobuf.h:32

References count, cur_rx, tulip_private::cur_rx, io_buffer::data, DBG, DBG2, DBGIO_HD, entry, iob_put, le32_to_cpu, netdev_rx(), NULL, NUM_RX_DESC, OWNbit, RxDesc::PSize, RX_BUF_SIZE, RxSizeMask, sis190_give_to_asic(), sis190_make_unusable_by_asic(), sis190_rx_fill(), sis190_rx_pkt_err(), status, RxDesc::status, and tp.

Referenced by sis190_poll().

◆ sis190_tx_pkt_err()

static int sis190_tx_pkt_err ( u32  status)
inlinestatic

Definition at line 295 of file sis190.c.

296 {
297 #define TxErrMask (WND | TABRT | FIFO | LINK)
298 
299  if (!(status & TxErrMask))
300  return 0;
301 
302  return -1;
303 }
uint8_t status
Status.
Definition: ena.h:16
#define TxErrMask

References status, and TxErrMask.

Referenced by sis190_process_tx().

◆ sis190_process_tx()

static void sis190_process_tx ( struct sis190_private tp)
static

Definition at line 305 of file sis190.c.

306 {
307  u32 pending, dirty_tx = tp->dirty_tx;
308 
309  pending = tp->cur_tx - dirty_tx;
310 
311  for (; pending; pending--, dirty_tx++) {
312  unsigned int entry = dirty_tx % NUM_TX_DESC;
313  struct TxDesc *txd = tp->TxDescRing + entry;
314  u32 status = le32_to_cpu(txd->status);
315  struct io_buffer *iob;
316 
317  if (status & OWNbit)
318  break;
319 
320  iob = tp->Tx_iobuf[entry];
321 
322  if (!iob)
323  break;
324 
325  if (sis190_tx_pkt_err(status) == 0) {
326  DBG2("sis190: Transmitted packet: %#08x\n", status);
327  netdev_tx_complete(tp->dev, iob);
328  } else {
329  DBG("sis190: Transmit error: %#08x\n", status);
330  netdev_tx_complete_err(tp->dev, iob, -EINVAL);
331  }
332 
333  tp->Tx_iobuf[entry] = NULL;
334  }
335 
336  if (tp->dirty_tx != dirty_tx)
337  tp->dirty_tx = dirty_tx;
338 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:746
#define le32_to_cpu(value)
Definition: byteswap.h:113
Definition: sis190.h:169
uint32_t pending
Pending events.
Definition: hyperv.h:12
uint8_t status
Status.
Definition: ena.h:16
static struct tulip_private * tp
Definition: tulip.c:441
#define txd
Definition: davicom.c:143
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
static int sis190_tx_pkt_err(u32 status)
Definition: sis190.c:295
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:395
Definition: sis190.h:153
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NUM_TX_DESC
Definition: igbvf.h:280
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
uint32_t u32
Definition: stdint.h:23
#define DBG2(...)
Definition: compiler.h:515
A persistent I/O buffer.
Definition: iobuf.h:32

References DBG, DBG2, EINVAL, entry, le32_to_cpu, netdev_tx_complete(), netdev_tx_complete_err(), NULL, NUM_TX_DESC, OWNbit, pending, sis190_tx_pkt_err(), status, tp, and txd.

Referenced by sis190_poll().

◆ sis190_poll()

static void sis190_poll ( struct net_device dev)
static

Definition at line 344 of file sis190.c.

345 {
346  struct sis190_private *tp = netdev_priv(dev);
347  void *ioaddr = tp->mmio_addr;
348  u32 status;
349 
351 
352  if ((status == 0xffffffff) || !status)
353  return;
354 
356 
357  /* sis190_phy_task() needs to be called in event of a LinkChange and
358  * after auto-negotiation is finished. Finishing auto-neg won't generate
359  * any indication, hence we call it every time if the link is bad. */
360  if ((status & LinkChange) || !netdev_link_ok(dev))
362 
363  if (status & RxQInt)
365 
366  if (status & TxQ0Int)
368 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
Definition: sis190.h:112
static int sis190_process_rx(struct sis190_private *tp)
Definition: sis190.c:242
struct net_device * dev
Definition: sis190.h:253
static void sis190_phy_task(struct sis190_private *tp)
Definition: sis190.c:448
uint8_t status
Status.
Definition: ena.h:16
#define SIS_R32(reg)
Definition: sis190.h:64
static unsigned long ioaddr
Definition: davicom.c:129
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct tulip_private * tp
Definition: tulip.c:441
#define SIS_W32(reg, val)
Definition: sis190.h:61
static void sis190_process_tx(struct sis190_private *tp)
Definition: sis190.c:305
uint32_t u32
Definition: stdint.h:23

References sis190_private::dev, IntrStatus, ioaddr, LinkChange, netdev_link_ok(), netdev_priv(), RxQInt, sis190_phy_task(), sis190_process_rx(), sis190_process_tx(), SIS_R32, SIS_W32, status, tp, and TxQ0Int.

◆ sis190_init_ring_indexes()

static void sis190_init_ring_indexes ( struct sis190_private tp)
inlinestatic

Definition at line 370 of file sis190.c.

371 {
372  tp->dirty_tx = tp->dirty_rx = tp->cur_tx = tp->cur_rx = 0;
373 }
static struct tulip_private * tp
Definition: tulip.c:441
int cur_rx
Definition: tulip.c:396

References tulip_private::cur_rx, and tp.

Referenced by sis190_init_ring().

◆ sis190_init_ring()

static int sis190_init_ring ( struct net_device dev)
static

Definition at line 375 of file sis190.c.

376 {
377  struct sis190_private *tp = netdev_priv(dev);
378 
380 
381  memset(tp->Tx_iobuf, 0, NUM_TX_DESC * sizeof(struct io_buffer *));
382  memset(tp->Rx_iobuf, 0, NUM_RX_DESC * sizeof(struct io_buffer *));
383 
385  goto err;
386 
387  sis190_mark_as_last_descriptor(tp->RxDescRing + NUM_RX_DESC - 1);
388 
389  return 0;
390 
391 err:
392  sis190_free(dev);
393  return -ENOMEM;
394 }
static void sis190_free(struct net_device *dev)
Definition: sis190.c:598
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
static void sis190_mark_as_last_descriptor(struct RxDesc *desc)
Definition: sis190.c:166
#define NUM_RX_DESC
Definition: igbvf.h:281
struct net_device * dev
Definition: sis190.h:253
static void sis190_init_ring_indexes(struct sis190_private *tp)
Definition: sis190.c:370
#define ENOMEM
Not enough space.
Definition: errno.h:534
static struct tulip_private * tp
Definition: tulip.c:441
#define NUM_TX_DESC
Definition: igbvf.h:280
static u32 sis190_rx_fill(struct sis190_private *tp, u32 start, u32 end)
Definition: sis190.c:214
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32

References sis190_private::dev, ENOMEM, memset(), netdev_priv(), NUM_RX_DESC, NUM_TX_DESC, sis190_free(), sis190_init_ring_indexes(), sis190_mark_as_last_descriptor(), sis190_rx_fill(), and tp.

Referenced by sis190_open().

◆ sis190_set_rx_mode()

static void sis190_set_rx_mode ( struct net_device dev)
static

Definition at line 396 of file sis190.c.

397 {
398  struct sis190_private *tp = netdev_priv(dev);
399  void *ioaddr = tp->mmio_addr;
400  u32 mc_filter[2]; /* Multicast hash filter */
401  u16 rx_mode;
402 
404  mc_filter[1] = mc_filter[0] = 0xffffffff;
405 
406  SIS_W16(RxMacControl, rx_mode | 0x2);
407  SIS_W32(RxHashTable, mc_filter[0]);
408  SIS_W32(RxHashTable + 4, mc_filter[1]);
409 
410 }
uint16_t u16
Definition: stdint.h:21
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define SIS_W16(reg, val)
Definition: sis190.h:60
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
#define SIS_W32(reg, val)
Definition: sis190.h:61
uint32_t u32
Definition: stdint.h:23

References AcceptBroadcast, AcceptMulticast, AcceptMyPhys, sis190_private::dev, ioaddr, netdev_priv(), RxHashTable, RxMacControl, SIS_W16, SIS_W32, and tp.

Referenced by sis190_hw_start().

◆ sis190_soft_reset()

static void sis190_soft_reset ( void *  ioaddr)
static

Definition at line 412 of file sis190.c.

413 {
414  SIS_W32(IntrControl, 0x8000);
415  SIS_PCI_COMMIT();
416  SIS_W32(IntrControl, 0x0);
418 }
#define SIS_PCI_COMMIT()
Definition: sis190.h:66
static unsigned long ioaddr
Definition: davicom.c:129
#define SIS_W32(reg, val)
Definition: sis190.h:61
static void sis190_asic_down(void *ioaddr)
Definition: sis190.c:156

References IntrControl, ioaddr, sis190_asic_down(), SIS_PCI_COMMIT, and SIS_W32.

Referenced by sis190_hw_start(), sis190_init_board(), and sis190_remove().

◆ sis190_hw_start()

static void sis190_hw_start ( struct net_device dev)
static

Definition at line 420 of file sis190.c.

421 {
422  struct sis190_private *tp = netdev_priv(dev);
423  void *ioaddr = tp->mmio_addr;
424 
426 
427  SIS_W32(TxDescStartAddr, tp->tx_dma);
428  SIS_W32(RxDescStartAddr, tp->rx_dma);
429 
430  SIS_W32(IntrStatus, 0xffffffff);
431  SIS_W32(IntrMask, 0x0);
432  SIS_W32(GMIIControl, 0x0);
433  SIS_W32(TxMacControl, 0x60);
434  SIS_W16(RxMacControl, 0x02);
435  SIS_W32(RxHashTable, 0x0);
436  SIS_W32(0x6c, 0x0);
437  SIS_W32(RxWolCtrl, 0x0);
438  SIS_W32(RxWolData, 0x0);
439 
440  SIS_PCI_COMMIT();
441 
443 
444  SIS_W32(TxControl, 0x1a00 | CmdTxEnb);
445  SIS_W32(RxControl, 0x1a1d);
446 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define SIS_W16(reg, val)
Definition: sis190.h:60
#define SIS_PCI_COMMIT()
Definition: sis190.h:66
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
#define SIS_W32(reg, val)
Definition: sis190.h:61
static void sis190_set_rx_mode(struct net_device *dev)
Definition: sis190.c:396
static void sis190_soft_reset(void *ioaddr)
Definition: sis190.c:412

References CmdTxEnb, sis190_private::dev, GMIIControl, IntrMask, IntrStatus, ioaddr, netdev_priv(), RxControl, RxDescStartAddr, RxHashTable, RxMacControl, RxWolCtrl, RxWolData, sis190_set_rx_mode(), sis190_soft_reset(), SIS_PCI_COMMIT, SIS_W16, SIS_W32, tp, TxControl, TxDescStartAddr, and TxMacControl.

Referenced by sis190_open().

◆ sis190_phy_task()

static void sis190_phy_task ( struct sis190_private tp)
static

Definition at line 448 of file sis190.c.

449 {
450  struct net_device *dev = tp->dev;
451  void *ioaddr = tp->mmio_addr;
452  int phy_id = tp->mii_if.phy_id;
453  int cnt = 0;
454  u16 val;
455 
456  val = mdio_read(ioaddr, phy_id, MII_BMCR);
457 
458  /* 100ms timeout is completely arbitrary. I have no datasheet to
459  * check whether that's a sensible value or not.
460  */
461  while ((val & BMCR_RESET) && (cnt < 100)) {
462  val = mdio_read(ioaddr, phy_id, MII_BMCR);
463  mdelay(1);
464  cnt++;
465  }
466 
467  if (cnt > 99) {
468  DBG("sis190: BMCR_RESET timeout\n");
469  return;
470  }
471 
472  if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) &
474  DBG("sis190: auto-negotiating...\n");
476  } else {
477  /* Rejoice ! */
478  struct {
479  int val;
480  u32 ctl;
481  const char *msg;
482  } reg31[] = {
483  { LPA_1000FULL, 0x07000c00 | 0x00001000,
484  "1000 Mbps Full Duplex" },
485  { LPA_1000HALF, 0x07000c00,
486  "1000 Mbps Half Duplex" },
487  { LPA_100FULL, 0x04000800 | 0x00001000,
488  "100 Mbps Full Duplex" },
489  { LPA_100HALF, 0x04000800,
490  "100 Mbps Half Duplex" },
491  { LPA_10FULL, 0x04000400 | 0x00001000,
492  "10 Mbps Full Duplex" },
493  { LPA_10HALF, 0x04000400,
494  "10 Mbps Half Duplex" },
495  { 0, 0x04000400, "unknown" }
496  }, *p = NULL;
497  u16 adv, autoexp, gigadv, gigrec;
498 
499  val = mdio_read(ioaddr, phy_id, 0x1f);
500 
501  val = mdio_read(ioaddr, phy_id, MII_LPA);
502  adv = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
503 
504  autoexp = mdio_read(ioaddr, phy_id, MII_EXPANSION);
505 
506  if (val & LPA_NPAGE && autoexp & EXPANSION_NWAY) {
507  /* check for gigabit speed */
508  gigadv = mdio_read(ioaddr, phy_id, MII_CTRL1000);
509  gigrec = mdio_read(ioaddr, phy_id, MII_STAT1000);
510  val = (gigadv & (gigrec >> 2));
511  if (val & ADVERTISE_1000FULL)
512  p = reg31;
513  else if (val & ADVERTISE_1000HALF)
514  p = reg31 + 1;
515  }
516 
517  if (!p) {
518  val &= adv;
519 
520  for (p = reg31; p->val; p++) {
521  if ((val & p->val) == p->val)
522  break;
523  }
524  }
525 
526  p->ctl |= SIS_R32(StationControl) & ~0x0f001c00;
527 
528  if ((tp->features & F_HAS_RGMII) &&
529  (tp->features & F_PHY_BCM5461)) {
530  // Set Tx Delay in RGMII mode.
531  mdio_write(ioaddr, phy_id, 0x18, 0xf1c7);
532  udelay(200);
533  mdio_write(ioaddr, phy_id, 0x1c, 0x8c00);
534  p->ctl |= 0x03000000;
535  }
536 
537  SIS_W32(StationControl, p->ctl);
538 
539  if (tp->features & F_HAS_RGMII) {
540  SIS_W32(RGDelay, 0x0441);
541  SIS_W32(RGDelay, 0x0440);
542  }
543 
544  DBG("sis190: link on %s mode.\n", p->msg);
545  netdev_link_up(dev);
546  }
547 }
#define MII_ADVERTISE
Definition: atl1e.h:875
uint16_t u16
Definition: stdint.h:21
#define LPA_10HALF
Definition: mii.h:95
#define MII_LPA
Definition: atl1e.h:876
#define LPA_1000HALF
Definition: mii.h:138
#define ADVERTISE_1000FULL
Definition: mii.h:131
#define EXPANSION_NWAY
Definition: mii.h:115
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
#define LPA_100HALF
Definition: mii.h:99
static u16 mdio_read_latched(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:122
#define LPA_1000FULL
Definition: mii.h:137
#define SIS_R32(reg)
Definition: sis190.h:64
static unsigned long ioaddr
Definition: davicom.c:129
#define LPA_100FULL
Definition: mii.h:101
#define LPA_10FULL
Definition: mii.h:97
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BMSR_ANEGCOMPLETE
Definition: mii.h:58
static struct tulip_private * tp
Definition: tulip.c:441
#define MII_CTRL1000
Definition: mii.h:24
#define SIS_W32(reg, val)
Definition: sis190.h:61
Definition: sis190.h:91
A network device.
Definition: netdevice.h:348
#define MII_BMCR
Definition: atl1e.h:871
#define ADVERTISE_1000HALF
Definition: mii.h:132
void __asmcall int val
Definition: setjmp.h:28
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define MII_EXPANSION
Definition: atl1e.h:877
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define BMCR_RESET
Definition: mii.h:50
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100
#define LPA_NPAGE
Definition: mii.h:109
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define MII_BMSR
Definition: atl1e.h:872
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition: sis190.c:93
uint32_t u32
Definition: stdint.h:23
#define MII_STAT1000
Definition: mii.h:25
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References ADVERTISE_1000FULL, ADVERTISE_1000HALF, BMCR_RESET, BMSR_ANEGCOMPLETE, DBG, net_device::dev, EXPANSION_NWAY, F_HAS_RGMII, F_PHY_BCM5461, ioaddr, LPA_1000FULL, LPA_1000HALF, LPA_100FULL, LPA_100HALF, LPA_10FULL, LPA_10HALF, LPA_NPAGE, mdelay(), mdio_read(), mdio_read_latched(), mdio_write(), MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CTRL1000, MII_EXPANSION, MII_LPA, MII_STAT1000, msg(), netdev_link_down(), netdev_link_up(), NULL, RGDelay, SIS_R32, SIS_W32, StationControl, tp, udelay(), and val.

Referenced by sis190_poll(), and sis190_probe().

◆ sis190_open()

static int sis190_open ( struct net_device dev)
static

Definition at line 549 of file sis190.c.

550 {
551  struct sis190_private *tp = netdev_priv(dev);
552  int rc;
553 
554  /* Allocate TX ring */
555  tp->TxDescRing = malloc_dma(TX_RING_BYTES, RING_ALIGNMENT);
556  if (!tp->TxDescRing) {
557  DBG("sis190: TX ring allocation failed\n");
558  rc = -ENOMEM;
559  goto out;
560  }
561  tp->tx_dma = cpu_to_le32(virt_to_bus(tp->TxDescRing));
562 
563  /* Allocate RX ring */
564  tp->RxDescRing = malloc_dma(RX_RING_BYTES, RING_ALIGNMENT);
565  if (!tp->RxDescRing) {
566  DBG("sis190: RX ring allocation failed\n");
567  rc = -ENOMEM;
568  goto error;
569  }
570  tp->rx_dma = cpu_to_le32(virt_to_bus(tp->RxDescRing));
571 
573  if (rc < 0)
574  goto error;
575 
576  /* init rx filter, also program MAC address to card */
578 
580 out:
581  return rc;
582 
583 error:
584  sis190_free(dev);
585  goto out;
586 }
static void sis190_free(struct net_device *dev)
Definition: sis190.c:598
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void sis190_init_rxfilter(struct net_device *dev)
sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize
Definition: sis190.c:1019
#define TX_RING_BYTES
Definition: eepro100.h:23
struct arbelprm_completion_with_error error
Definition: arbel.h:12
static void sis190_hw_start(struct net_device *dev)
Definition: sis190.c:420
#define RX_RING_BYTES
Definition: eepro100.h:22
struct net_device * dev
Definition: sis190.h:253
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
__be32 out[4]
Definition: CIB_PRM.h:36
static struct tulip_private * tp
Definition: tulip.c:441
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define RING_ALIGNMENT
Definition: sis190.h:45
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static int sis190_init_ring(struct net_device *dev)
Definition: sis190.c:375

References cpu_to_le32, DBG, sis190_private::dev, ENOMEM, error, malloc_dma(), netdev_priv(), out, rc, RING_ALIGNMENT, RX_RING_BYTES, sis190_free(), sis190_hw_start(), sis190_init_ring(), sis190_init_rxfilter(), tp, TX_RING_BYTES, and virt_to_bus().

◆ sis190_down()

static void sis190_down ( struct net_device dev)
static

Definition at line 588 of file sis190.c.

589 {
590  struct sis190_private *tp = netdev_priv(dev);
591  void *ioaddr = tp->mmio_addr;
592 
593  do {
595  } while (SIS_R32(IntrMask));
596 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct net_device * dev
Definition: sis190.h:253
#define SIS_R32(reg)
Definition: sis190.h:64
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
static void sis190_asic_down(void *ioaddr)
Definition: sis190.c:156

References sis190_private::dev, IntrMask, ioaddr, netdev_priv(), sis190_asic_down(), SIS_R32, and tp.

Referenced by sis190_close().

◆ sis190_free()

static void sis190_free ( struct net_device dev)
static

Definition at line 598 of file sis190.c.

599 {
600  struct sis190_private *tp = netdev_priv(dev);
601  int i;
602 
603  free_dma(tp->TxDescRing, TX_RING_BYTES);
604  free_dma(tp->RxDescRing, RX_RING_BYTES);
605 
606  tp->TxDescRing = NULL;
607  tp->RxDescRing = NULL;
608 
609  tp->tx_dma = 0;
610  tp->rx_dma = 0;
611 
612  tp->cur_tx = tp->dirty_tx = 0;
613  tp->cur_rx = tp->dirty_rx = 0;
614 
615  for (i = 0; i < NUM_RX_DESC; i++) {
616  free_iob(tp->Rx_iobuf[i]);
617  tp->Rx_iobuf[i] = NULL;
618  }
619 
620  /* tx io_buffers aren't owned by the driver, so don't free them */
621  for(i = 0; i < NUM_TX_DESC; i++)
622  tp->Tx_iobuf[i] = NULL;
623 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define TX_RING_BYTES
Definition: eepro100.h:23
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define RX_RING_BYTES
Definition: eepro100.h:22
#define NUM_RX_DESC
Definition: igbvf.h:281
struct net_device * dev
Definition: sis190.h:253
static struct tulip_private * tp
Definition: tulip.c:441
int cur_rx
Definition: tulip.c:396
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NUM_TX_DESC
Definition: igbvf.h:280
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References tulip_private::cur_rx, sis190_private::dev, free_dma(), free_iob(), netdev_priv(), NULL, NUM_RX_DESC, NUM_TX_DESC, RX_RING_BYTES, tp, and TX_RING_BYTES.

Referenced by sis190_close(), sis190_init_ring(), and sis190_open().

◆ sis190_close()

static void sis190_close ( struct net_device dev)
static

Definition at line 625 of file sis190.c.

626 {
627  sis190_down(dev);
628  sis190_free(dev);
629 }
static void sis190_free(struct net_device *dev)
Definition: sis190.c:598
struct net_device * dev
Definition: sis190.h:253
static void sis190_down(struct net_device *dev)
Definition: sis190.c:588

References sis190_private::dev, sis190_down(), and sis190_free().

◆ sis190_transmit()

static int sis190_transmit ( struct net_device dev,
struct io_buffer iob 
)
static

Definition at line 631 of file sis190.c.

632 {
633  struct sis190_private *tp = netdev_priv(dev);
634  void *ioaddr = tp->mmio_addr;
635  u32 len, entry;
636  struct TxDesc *desc;
637 
638  len = iob_len(iob);
639  if (len < ETH_ZLEN) {
640  iob_pad(iob, ETH_ZLEN);
641  len = ETH_ZLEN;
642  }
643 
644  entry = tp->cur_tx % NUM_TX_DESC;
645  desc = tp->TxDescRing + entry;
646 
647  if (le32_to_cpu(desc->status) & OWNbit) {
648  DBG("sis190: Tx Ring full\n");
649  return -EINVAL;
650  }
651 
652  tp->Tx_iobuf[entry] = iob;
653 
654  desc->PSize = cpu_to_le32(len);
655  desc->addr = cpu_to_le32(virt_to_bus(iob->data));
656 
657  desc->size = cpu_to_le32(len);
658  if (entry == (NUM_TX_DESC - 1))
659  desc->size |= cpu_to_le32(RingEnd);
660 
661  wmb();
662 
664 
665  tp->cur_tx++;
666 
667  SIS_W32(TxControl, 0x1a00 | CmdReset | CmdTxEnb);
668 
669  return 0;
670 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
wmb()
#define le32_to_cpu(value)
Definition: byteswap.h:113
Definition: sis190.h:169
volatile u32 addr
Definition: sis190.h:156
Definition: sis190.h:170
struct net_device * dev
Definition: sis190.h:253
volatile u32 size
Definition: sis190.h:157
static unsigned long ioaddr
Definition: davicom.c:129
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
volatile u32 PSize
Definition: sis190.h:154
static struct tulip_private * tp
Definition: tulip.c:441
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define SIS_W32(reg, val)
Definition: sis190.h:61
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#define ETH_ZLEN
Definition: if_ether.h:10
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:44
volatile u32 status
Definition: sis190.h:155
Definition: sis190.h:171
Definition: sis190.h:172
Definition: sis190.h:153
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NUM_TX_DESC
Definition: igbvf.h:280
Definition: sis190.h:203
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition: iobpad.c:49
uint32_t u32
Definition: stdint.h:23

References TxDesc::addr, CmdReset, CmdTxEnb, cpu_to_le32, CRCbit, io_buffer::data, DBG, DEFbit, sis190_private::dev, EINVAL, entry, ETH_ZLEN, INTbit, ioaddr, iob_len(), iob_pad(), le32_to_cpu, len, netdev_priv(), NUM_TX_DESC, OWNbit, PADbit, TxDesc::PSize, RingEnd, SIS_W32, TxDesc::size, TxDesc::status, tp, TxControl, virt_to_bus(), and wmb().

◆ sis190_free_phy()

static void sis190_free_phy ( struct list_head first_phy)
static

Definition at line 672 of file sis190.c.

673 {
674  struct sis190_phy *cur, *next;
675 
676  list_for_each_entry_safe(cur, next, first_phy, list) {
677  free(cur);
678  }
679 }
uint32_t next
Next descriptor address.
Definition: myson.h:18
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
Definition: sis190.h:270

References free, sis190_phy::list, list_for_each_entry_safe, and next.

Referenced by sis190_mii_probe(), and sis190_mii_remove().

◆ sis190_default_phy()

static u16 sis190_default_phy ( struct sis190_private tp)
static

sis190_default_phy - Select default PHY for sis190 mac.

@dev: the net device to probe for

Select first detected PHY with link as default. If no one is link on, select PHY whose types is HOME as default. If HOME doesn't exist, select LAN.

Definition at line 689 of file sis190.c.

690 {
691  struct sis190_phy *phy, *phy_home, *phy_default, *phy_lan;
692  struct mii_if_info *mii_if = &tp->mii_if;
693  void *ioaddr = tp->mmio_addr;
694  u16 status;
695 
696  phy_home = phy_default = phy_lan = NULL;
697 
698  list_for_each_entry(phy, &tp->first_phy, list) {
700 
701  // Link ON & Not select default PHY & not ghost PHY.
702  if ((status & BMSR_LSTATUS) &&
703  !phy_default &&
704  (phy->type != UNKNOWN)) {
705  phy_default = phy;
706  } else {
710  if (phy->type == HOME)
711  phy_home = phy;
712  else if (phy->type == LAN)
713  phy_lan = phy;
714  }
715  }
716 
717  if (!phy_default) {
718  if (phy_home)
719  phy_default = phy_home;
720  else if (phy_lan)
721  phy_default = phy_lan;
722  else
723  phy_default = list_entry(&tp->first_phy,
724  struct sis190_phy, list);
725  }
726 
727  if (mii_if->phy_id != phy_default->phy_id) {
728  mii_if->phy_id = phy_default->phy_id;
729  DBG("sis190: Using transceiver at address %d as default.\n",
730  mii_if->phy_id);
731  }
732 
733  status = mdio_read(ioaddr, mii_if->phy_id, MII_BMCR);
734  status &= (~BMCR_ISOLATE);
735 
736  mdio_write(ioaddr, mii_if->phy_id, MII_BMCR, status);
738 
739  return status;
740 }
uint16_t u16
Definition: stdint.h:21
int phy_id
Definition: mii.h:143
static u16 mdio_read_latched(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:122
Definition: sis190.h:279
uint8_t status
Status.
Definition: ena.h:16
static unsigned long ioaddr
Definition: davicom.c:129
#define BMCR_ISOLATE
Definition: mii.h:45
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
static struct tulip_private * tp
Definition: tulip.c:441
#define BMSR_LSTATUS
Definition: mii.h:55
#define MII_BMCR
Definition: atl1e.h:871
u8 type
Definition: sis190.h:274
int phy_id
Definition: sis190.h:271
Definition: sis190.h:280
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define BMCR_ANENABLE
Definition: mii.h:47
#define MII_BMSR
Definition: atl1e.h:872
#define list_entry(list, type, member)
Get the container of a list entry.
Definition: list.h:321
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition: sis190.c:93

References BMCR_ANENABLE, BMCR_ISOLATE, BMSR_LSTATUS, DBG, HOME, ioaddr, LAN, list_entry, list_for_each_entry, mdio_read(), mdio_read_latched(), mdio_write(), MII_BMCR, MII_BMSR, NULL, mii_if_info::phy_id, sis190_phy::phy_id, status, tp, sis190_phy::type, and UNKNOWN.

Referenced by sis190_mii_probe().

◆ sis190_init_phy()

static void sis190_init_phy ( struct sis190_private tp,
struct sis190_phy phy,
unsigned int  phy_id,
u16  mii_status 
)
static

Definition at line 742 of file sis190.c.

745 {
746  void *ioaddr = tp->mmio_addr;
747  struct mii_chip_info *p;
748 
749  INIT_LIST_HEAD(&phy->list);
750  phy->status = mii_status;
751  phy->phy_id = phy_id;
752 
753  phy->id[0] = mdio_read(ioaddr, phy_id, MII_PHYSID1);
754  phy->id[1] = mdio_read(ioaddr, phy_id, MII_PHYSID2);
755 
756  for (p = mii_chip_table; p->type; p++) {
757  if ((p->id[0] == phy->id[0]) &&
758  (p->id[1] == (phy->id[1] & 0xfff0))) {
759  break;
760  }
761  }
762 
763  if (p->id[1]) {
764  phy->type = (p->type == MIX) ?
765  ((mii_status & (BMSR_100FULL | BMSR_100HALF)) ?
766  LAN : HOME) : p->type;
767  tp->features |= p->feature;
768 
769  DBG("sis190: %s transceiver at address %d.\n", p->name, phy_id);
770  } else {
771  phy->type = UNKNOWN;
772 
773  DBG("sis190: unknown PHY 0x%x:0x%x transceiver at address %d\n",
774  phy->id[0], (phy->id[1] & 0xfff0), phy_id);
775  }
776 }
u16 status
Definition: sis190.h:273
static struct mii_chip_info mii_chip_table[]
u16 id[2]
Definition: sis190.h:286
Definition: sis190.h:279
#define BMSR_100HALF
Definition: mii.h:65
u16 id[2]
Definition: sis190.h:272
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
u8 type
Definition: sis190.h:274
int phy_id
Definition: sis190.h:271
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
Definition: sis190.h:280
struct list_head list
Definition: sis190.h:270
unsigned int type
Definition: sis190.h:287
u32 feature
Definition: sis190.h:288
#define MII_PHYSID2
Definition: atl1e.h:874
const char * name
Definition: sis190.h:285
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
Definition: sis190.h:281
#define MII_PHYSID1
Definition: atl1e.h:873
#define BMSR_100FULL
Definition: mii.h:66

References BMSR_100FULL, BMSR_100HALF, DBG, mii_chip_info::feature, HOME, sis190_phy::id, mii_chip_info::id, INIT_LIST_HEAD, ioaddr, LAN, sis190_phy::list, mdio_read(), mii_chip_table, MII_PHYSID1, MII_PHYSID2, MIX, mii_chip_info::name, sis190_phy::phy_id, sis190_phy::status, tp, sis190_phy::type, mii_chip_info::type, and UNKNOWN.

Referenced by sis190_mii_probe().

◆ sis190_mii_probe_88e1111_fixup()

static void sis190_mii_probe_88e1111_fixup ( struct sis190_private tp)
static

Definition at line 778 of file sis190.c.

779 {
780  if (tp->features & F_PHY_88E1111) {
781  void *ioaddr = tp->mmio_addr;
782  int phy_id = tp->mii_if.phy_id;
783  u16 reg[2][2] = {
784  { 0x808b, 0x0ce1 },
785  { 0x808f, 0x0c60 }
786  }, *p;
787 
788  p = (tp->features & F_HAS_RGMII) ? reg[0] : reg[1];
789 
790  mdio_write(ioaddr, phy_id, 0x1b, p[0]);
791  udelay(200);
792  mdio_write(ioaddr, phy_id, 0x14, p[1]);
793  udelay(200);
794  }
795 }
uint16_t u16
Definition: stdint.h:21
static unsigned long ioaddr
Definition: davicom.c:129
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:441
static unsigned int unsigned int reg
Definition: intel.h:245
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition: sis190.c:93

References F_HAS_RGMII, F_PHY_88E1111, ioaddr, mdio_write(), reg, tp, and udelay().

Referenced by sis190_mii_probe().

◆ sis190_mii_probe()

static int sis190_mii_probe ( struct net_device dev)
static

sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for

Search for total of 32 possible mii phy addresses. Identify and set current phy if found one, return error if it failed to found.

Definition at line 805 of file sis190.c.

806 {
807  struct sis190_private *tp = netdev_priv(dev);
808  struct mii_if_info *mii_if = &tp->mii_if;
809  void *ioaddr = tp->mmio_addr;
810  int phy_id;
811  int rc = 0;
812 
813  INIT_LIST_HEAD(&tp->first_phy);
814 
815  for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
816  struct sis190_phy *phy;
817  u16 status;
818 
820 
821  // Try next mii if the current one is not accessible.
822  if (status == 0xffff || status == 0x0000)
823  continue;
824 
825  phy = zalloc(sizeof(*phy));
826  if (!phy) {
827  sis190_free_phy(&tp->first_phy);
828  rc = -ENOMEM;
829  goto out;
830  }
831 
832  DBG("sis190: found PHY\n");
833 
835 
836  list_add(&tp->first_phy, &phy->list);
837  }
838 
839  if (list_empty(&tp->first_phy)) {
840  DBG("sis190: No MII transceivers found!\n");
841  rc = -EIO;
842  goto out;
843  }
844 
845  /* Select default PHY for mac */
847 
849 
850  mii_if->dev = dev;
851  mii_if->mdio_read = __mdio_read;
852  mii_if->mdio_write = __mdio_write;
853  mii_if->phy_id_mask = PHY_ID_ANY;
854  mii_if->reg_num_mask = MII_REG_ANY;
855 out:
856  return rc;
857 }
uint16_t u16
Definition: stdint.h:21
int phy_id
Definition: mii.h:143
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct net_device * dev
Definition: mii.h:152
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
#define PHY_MAX_ADDR
Definition: sis190.h:27
int(* mdio_read)(struct net_device *dev, int phy_id, int location)
Definition: mii.h:153
static void sis190_mii_probe_88e1111_fixup(struct sis190_private *tp)
Definition: sis190.c:778
static u16 mdio_read_latched(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:122
static void sis190_init_phy(struct sis190_private *tp, struct sis190_phy *phy, unsigned int phy_id, u16 mii_status)
Definition: sis190.c:742
static u16 sis190_default_phy(struct sis190_private *tp)
sis190_default_phy - Select default PHY for sis190 mac.
Definition: sis190.c:689
struct net_device * dev
Definition: sis190.h:253
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
uint8_t status
Status.
Definition: ena.h:16
#define ENOMEM
Not enough space.
Definition: errno.h:534
static unsigned long ioaddr
Definition: davicom.c:129
__be32 out[4]
Definition: CIB_PRM.h:36
static struct tulip_private * tp
Definition: tulip.c:441
static void __mdio_write(struct net_device *dev, int phy_id, int reg, int val)
Definition: sis190.c:108
int reg_num_mask
Definition: mii.h:146
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
void(* mdio_write)(struct net_device *dev, int phy_id, int location, int val)
Definition: mii.h:154
#define PHY_ID_ANY
Definition: sis190.h:28
int phy_id
Definition: sis190.h:271
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct list_head list
Definition: sis190.h:270
static void sis190_free_phy(struct list_head *first_phy)
Definition: sis190.c:672
#define EIO
Input/output error.
Definition: errno.h:433
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define MII_BMSR
Definition: atl1e.h:872
static int __mdio_read(struct net_device *dev, int phy_id, int reg)
Definition: sis190.c:115
int phy_id_mask
Definition: mii.h:145
#define MII_REG_ANY
Definition: sis190.h:29

References __mdio_read(), __mdio_write(), DBG, mii_if_info::dev, sis190_private::dev, EIO, ENOMEM, INIT_LIST_HEAD, ioaddr, sis190_phy::list, list_add, list_empty, mii_if_info::mdio_read, mdio_read_latched(), mii_if_info::mdio_write, MII_BMSR, MII_REG_ANY, netdev_priv(), out, mii_if_info::phy_id, sis190_phy::phy_id, PHY_ID_ANY, mii_if_info::phy_id_mask, PHY_MAX_ADDR, rc, mii_if_info::reg_num_mask, sis190_default_phy(), sis190_free_phy(), sis190_init_phy(), sis190_mii_probe_88e1111_fixup(), status, tp, and zalloc().

Referenced by sis190_probe().

◆ sis190_mii_remove()

static void sis190_mii_remove ( struct net_device dev)
static

Definition at line 859 of file sis190.c.

860 {
861  struct sis190_private *tp = netdev_priv(dev);
862 
863  sis190_free_phy(&tp->first_phy);
864 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct net_device * dev
Definition: sis190.h:253
static struct tulip_private * tp
Definition: tulip.c:441
static void sis190_free_phy(struct list_head *first_phy)
Definition: sis190.c:672

References sis190_private::dev, netdev_priv(), sis190_free_phy(), and tp.

Referenced by sis190_probe(), and sis190_remove().

◆ sis190_init_board()

static int sis190_init_board ( struct pci_device pdev,
struct net_device **  netdev 
)
static

Definition at line 866 of file sis190.c.

867 {
868  struct sis190_private *tp;
869  struct net_device *dev;
870  void *ioaddr;
871  int rc;
872 
873  dev = alloc_etherdev(sizeof(*tp));
874  if (!dev) {
875  DBG("sis190: unable to alloc new etherdev\n");
876  rc = -ENOMEM;
877  goto err;
878  }
879 
880  dev->dev = &pdev->dev;
881 
882  tp = netdev_priv(dev);
883  memset(tp, 0, sizeof(*tp));
884 
885  tp->dev = dev;
886 
887  adjust_pci_device(pdev);
888 
890  if (!ioaddr) {
891  DBG("sis190: cannot remap MMIO, aborting\n");
892  rc = -EIO;
893  goto err;
894  }
895 
896  tp->pci_device = pdev;
897  tp->mmio_addr = ioaddr;
898 
900 
902 
903  *netdev = dev;
904 
905  return 0;
906 
907 err:
908  return rc;
909 }
unsigned long membase
Memory base.
Definition: pci.h:194
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
#define SIS190_REGS_SIZE
Definition: sis190.h:47
struct device dev
Generic device.
Definition: pci.h:189
#define ENOMEM
Not enough space.
Definition: errno.h:534
static unsigned long ioaddr
Definition: davicom.c:129
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tulip_private * tp
Definition: tulip.c:441
static void sis190_irq_mask_and_ack(void *ioaddr)
Definition: sis190.c:149
A network device.
Definition: netdevice.h:348
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static void sis190_soft_reset(void *ioaddr)
Definition: sis190.c:412
#define EIO
Input/output error.
Definition: errno.h:433
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
void * memset(void *dest, int character, size_t len) __nonnull

References adjust_pci_device(), alloc_etherdev(), DBG, pci_device::dev, net_device::dev, EIO, ENOMEM, ioaddr, ioremap(), pci_device::membase, memset(), netdev, netdev_priv(), rc, sis190_irq_mask_and_ack(), SIS190_REGS_SIZE, sis190_soft_reset(), and tp.

Referenced by sis190_probe().

◆ sis190_set_rgmii()

static void sis190_set_rgmii ( struct sis190_private tp,
u8  reg 
)
static

Definition at line 911 of file sis190.c.

912 {
913  tp->features |= (reg & 0x80) ? F_HAS_RGMII : 0;
914 }
static struct tulip_private * tp
Definition: tulip.c:441
static unsigned int unsigned int reg
Definition: intel.h:245

References F_HAS_RGMII, reg, and tp.

Referenced by sis190_get_mac_addr_from_apc(), and sis190_get_mac_addr_from_eeprom().

◆ sis190_get_mac_addr_from_eeprom()

static int sis190_get_mac_addr_from_eeprom ( struct pci_device *pdev  __unused,
struct net_device dev 
)
static

Definition at line 916 of file sis190.c.

918 {
919  struct sis190_private *tp = netdev_priv(dev);
920  void *ioaddr = tp->mmio_addr;
921  u16 sig;
922  int i;
923 
924  DBG("sis190: Read MAC address from EEPROM\n");
925 
926  /* Check to see if there is a sane EEPROM */
928 
929  if ((sig == 0xffff) || (sig == 0x0000)) {
930  DBG("sis190: Error EEPROM read.\n");
931  return -EIO;
932  }
933 
934  /* Get MAC address from EEPROM */
935  for (i = 0; i < ETH_ALEN / 2; i++) {
937 
938  ((u16 *)dev->hw_addr)[i] = cpu_to_le16(w);
939  }
940 
942 
943  return 0;
944 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
static void sis190_set_rgmii(struct sis190_private *tp, u8 reg)
Definition: sis190.c:911
u8 sig
Definition: CIB_PRM.h:43
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
#define ETH_ALEN
Definition: if_ether.h:8
uint32_t w[16]
Definition: md4.c:32
static u16 sis190_read_eeprom(void *ioaddr, u32 reg)
Definition: sis190.c:128
#define EIO
Input/output error.
Definition: errno.h:433
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375

References cpu_to_le16, DBG, sis190_private::dev, EEPROMInfo, EEPROMMACAddr, EEPROMSignature, EIO, ETH_ALEN, net_device::hw_addr, ioaddr, netdev_priv(), sig, sis190_read_eeprom(), sis190_set_rgmii(), tp, u16, and w.

Referenced by sis190_get_mac_addr().

◆ sis190_get_mac_addr_from_apc()

static int sis190_get_mac_addr_from_apc ( struct pci_device pdev,
struct net_device dev 
)
static

sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network device to get address for

SiS96x model, use APC CMOS RAM to store MAC address. APC CMOS RAM is accessed through ISA bridge. MAC address is read into @net_dev->dev_addr.

Definition at line 955 of file sis190.c.

957 {
958  struct sis190_private *tp = netdev_priv(dev);
959  struct pci_device *isa_bridge = NULL;
960  struct device *d;
961  u8 reg, tmp8;
962  unsigned int i;
963 
964  DBG("sis190: Read MAC address from APC.\n");
965 
967  unsigned int i;
968  for(i = 0; i < sis190_isa_bridge_driver.id_count; i++) {
969  isa_bridge = container_of(d, struct pci_device, dev);
970  if(isa_bridge->vendor ==
971  sis190_isa_bridge_driver.ids[i].vendor
972  && isa_bridge->device ==
973  sis190_isa_bridge_driver.ids[i].device) {
974  DBG("sis190: ISA bridge found\n");
975  break;
976  } else {
977  isa_bridge = NULL;
978  }
979  }
980  if(isa_bridge)
981  break;
982  }
983 
984  if (!isa_bridge) {
985  DBG("sis190: Can not find ISA bridge.\n");
986  return -EIO;
987  }
988 
989  /* Enable port 78h & 79h to access APC Registers. */
990  pci_read_config_byte(isa_bridge, 0x48, &tmp8);
991  reg = (tmp8 & ~0x02);
992  pci_write_config_byte(isa_bridge, 0x48, reg);
993  udelay(50);
994  pci_read_config_byte(isa_bridge, 0x48, &reg);
995 
996  for (i = 0; i < ETH_ALEN; i++) {
997  outb(0x9 + i, 0x78);
998  dev->hw_addr[i] = inb(0x79);
999  }
1000 
1001  outb(0x12, 0x78);
1002  reg = inb(0x79);
1003 
1005 
1006  /* Restore the value to ISA Bridge */
1007  pci_write_config_byte(isa_bridge, 0x48, tmp8);
1008 
1009  return 0;
1010 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
static void sis190_set_rgmii(struct sis190_private *tp, u8 reg)
Definition: sis190.c:911
struct device dev
Generic device.
Definition: pci.h:189
struct net_device * dev
Definition: sis190.h:253
A hardware device.
Definition: device.h:73
uint16_t device
Device ID.
Definition: pci.h:204
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:441
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
static unsigned int unsigned int reg
Definition: intel.h:245
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
A PCI device.
Definition: pci.h:187
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define ETH_ALEN
Definition: if_ether.h:8
uint16_t vendor
Vendor ID.
Definition: pci.h:202
#define outb(data, io_addr)
Definition: io.h:309
#define EIO
Input/output error.
Definition: errno.h:433
uint32_t d
Definition: md4.c:31
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
uint8_t u8
Definition: stdint.h:19
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.

References container_of, d, DBG, pci_device::dev, sis190_private::dev, pci_device::device, EIO, ETH_ALEN, net_device::hw_addr, inb(), list_for_each_entry, netdev_priv(), NULL, outb, pci_read_config_byte(), pci_write_config_byte(), reg, device::siblings, sis190_set_rgmii(), tp, udelay(), and pci_device::vendor.

Referenced by sis190_get_mac_addr().

◆ sis190_init_rxfilter()

static void sis190_init_rxfilter ( struct net_device dev)
inlinestatic

sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize

Set receive filter address to our MAC address and enable packet filtering.

Definition at line 1019 of file sis190.c.

1020 {
1021  struct sis190_private *tp = netdev_priv(dev);
1022  void *ioaddr = tp->mmio_addr;
1023  u16 ctl;
1024  int i;
1025 
1026  ctl = SIS_R16(RxMacControl);
1027  /*
1028  * Disable packet filtering before setting filter.
1029  * Note: SiS's driver writes 32 bits but RxMacControl is 16 bits
1030  * only and followed by RxMacAddr (6 bytes). Strange. -- FR
1031  */
1032  SIS_W16(RxMacControl, ctl & ~0x0f00);
1033 
1034  for (i = 0; i < ETH_ALEN; i++)
1035  SIS_W8(RxMacAddr + i, dev->ll_addr[i]);
1036 
1037  SIS_W16(RxMacControl, ctl);
1038  SIS_PCI_COMMIT();
1039 }
uint16_t u16
Definition: stdint.h:21
#define SIS_R16(reg)
Definition: sis190.h:63
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define SIS_W16(reg, val)
Definition: sis190.h:60
#define SIS_PCI_COMMIT()
Definition: sis190.h:66
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static struct tulip_private * tp
Definition: tulip.c:441
#define SIS_W8(reg, val)
Definition: sis190.h:59
#define ETH_ALEN
Definition: if_ether.h:8
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381

References sis190_private::dev, ETH_ALEN, ioaddr, net_device::ll_addr, netdev_priv(), RxMacAddr, RxMacControl, SIS_PCI_COMMIT, SIS_R16, SIS_W16, SIS_W8, and tp.

Referenced by sis190_open().

◆ sis190_get_mac_addr()

static int sis190_get_mac_addr ( struct pci_device pdev,
struct net_device dev 
)
static

Definition at line 1041 of file sis190.c.

1043 {
1044  int rc;
1045 
1047  if (rc < 0) {
1048  u8 reg;
1049 
1050  pci_read_config_byte(pdev, 0x73, &reg);
1051 
1052  if (reg & 0x00000001)
1054  }
1055  return rc;
1056 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct net_device * dev
Definition: sis190.h:253
static int sis190_get_mac_addr_from_eeprom(struct pci_device *pdev __unused, struct net_device *dev)
Definition: sis190.c:916
static unsigned int unsigned int reg
Definition: intel.h:245
uint8_t u8
Definition: stdint.h:19
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
static int sis190_get_mac_addr_from_apc(struct pci_device *pdev, struct net_device *dev)
sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network devic...
Definition: sis190.c:955

References sis190_private::dev, pci_read_config_byte(), rc, reg, sis190_get_mac_addr_from_apc(), and sis190_get_mac_addr_from_eeprom().

Referenced by sis190_probe().

◆ sis190_set_speed_auto()

static void sis190_set_speed_auto ( struct net_device dev)
static

Definition at line 1058 of file sis190.c.

1059 {
1060  struct sis190_private *tp = netdev_priv(dev);
1061  void *ioaddr = tp->mmio_addr;
1062  int phy_id = tp->mii_if.phy_id;
1063  int val;
1064 
1065  DBG("sis190: Enabling Auto-negotiation.\n");
1066 
1067  val = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
1068 
1069  // Enable 10/100 Full/Half Mode, leave MII_ADVERTISE bit4:0
1070  // unchanged.
1074 
1075  // Enable 1000 Full Mode.
1077 
1078  // Enable auto-negotiation and restart auto-negotiation.
1079  mdio_write(ioaddr, phy_id, MII_BMCR,
1081 }
#define MII_ADVERTISE
Definition: atl1e.h:875
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define ADVERTISE_1000FULL
Definition: mii.h:131
#define ADVERTISE_10FULL
Definition: mii.h:74
#define BMCR_ANRESTART
Definition: mii.h:44
#define ADVERTISE_100FULL
Definition: mii.h:78
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
#define ADVERTISE_SLCT
Definition: mii.h:70
static struct tulip_private * tp
Definition: tulip.c:441
#define MII_CTRL1000
Definition: mii.h:24
#define MII_BMCR
Definition: atl1e.h:871
void __asmcall int val
Definition: setjmp.h:28
#define ADVERTISE_10HALF
Definition: mii.h:72
#define BMCR_RESET
Definition: mii.h:50
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition: sis190.c:100
#define ADVERTISE_100HALF
Definition: mii.h:76
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define BMCR_ANENABLE
Definition: mii.h:47
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition: sis190.c:93

References ADVERTISE_1000FULL, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISE_SLCT, BMCR_ANENABLE, BMCR_ANRESTART, BMCR_RESET, DBG, sis190_private::dev, ioaddr, mdio_read(), mdio_write(), MII_ADVERTISE, MII_BMCR, MII_CTRL1000, netdev_priv(), tp, and val.

Referenced by sis190_probe().

◆ sis190_irq()

static void sis190_irq ( struct net_device dev,
int  enable 
)
static

Definition at line 1083 of file sis190.c.

1084 {
1085  struct sis190_private *tp = netdev_priv(dev);
1086  void *ioaddr = tp->mmio_addr;
1087 
1088  SIS_W32(IntrStatus, 0xffffffff);
1089 
1090  if (enable == 0)
1091  SIS_W32(IntrMask, 0x00);
1092  else
1094 
1095  SIS_PCI_COMMIT();
1096 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define SIS_PCI_COMMIT()
Definition: sis190.h:66
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static const u32 sis190_intr_mask
Definition: sis190.c:72
static struct tulip_private * tp
Definition: tulip.c:441
#define SIS_W32(reg, val)
Definition: sis190.h:61

References sis190_private::dev, IntrMask, IntrStatus, ioaddr, netdev_priv(), sis190_intr_mask, SIS_PCI_COMMIT, SIS_W32, and tp.

◆ sis190_probe()

static int sis190_probe ( struct pci_device pdev)
static

Definition at line 1106 of file sis190.c.

1107 {
1108  struct sis190_private *tp;
1109  struct net_device *dev;
1110  int rc;
1111 
1112  rc = sis190_init_board(pdev, &dev);
1113  if (rc < 0)
1114  goto out;
1116 
1117  pci_set_drvdata(pdev, dev);
1118 
1119  tp = netdev_priv(dev);
1120 
1121  rc = sis190_get_mac_addr(pdev, dev);
1122  if (rc < 0)
1123  goto err;
1124 
1125  rc = sis190_mii_probe(dev);
1126  if (rc < 0)
1127  goto err;
1128 
1129  rc = register_netdev(dev);
1130  if (rc < 0)
1131  goto err;
1132 
1135 
1136 out:
1137  return rc;
1138 
1139 err:
1141  iounmap(tp->mmio_addr);
1142  goto out;
1143 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int sis190_mii_probe(struct net_device *dev)
sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for
Definition: sis190.c:805
static struct net_device_operations sis190_netdev_ops
Definition: sis190.c:1098
static void sis190_phy_task(struct sis190_private *tp)
Definition: sis190.c:448
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:338
static int sis190_get_mac_addr(struct pci_device *pdev, struct net_device *dev)
Definition: sis190.c:1041
__be32 out[4]
Definition: CIB_PRM.h:36
static struct tulip_private * tp
Definition: tulip.c:441
static int sis190_init_board(struct pci_device *pdev, struct net_device **netdev)
Definition: sis190.c:866
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static void sis190_set_speed_auto(struct net_device *dev)
Definition: sis190.c:1058
void iounmap(volatile const void *io_addr)
Unmap I/O address.
static void sis190_mii_remove(struct net_device *dev)
Definition: sis190.c:859

References net_device::dev, iounmap(), netdev_init(), netdev_priv(), out, pci_set_drvdata(), rc, register_netdev(), sis190_get_mac_addr(), sis190_init_board(), sis190_mii_probe(), sis190_mii_remove(), sis190_netdev_ops, sis190_phy_task(), sis190_set_speed_auto(), and tp.

◆ sis190_remove()

static void sis190_remove ( struct pci_device pdev)
static

Definition at line 1145 of file sis190.c.

1146 {
1147  struct net_device *dev = pci_get_drvdata(pdev);
1148  struct sis190_private *tp = dev->priv;
1149  void *ioaddr = tp->mmio_addr;
1150 
1152 
1153  /* shutdown chip, disable interrupts, etc */
1155 
1156  iounmap(tp->mmio_addr);
1157 
1160  netdev_put(dev);
1161 }
struct net_device * dev
Definition: sis190.h:253
static unsigned long ioaddr
Definition: davicom.c:129
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
void * priv
Driver private data.
Definition: netdevice.h:425
static struct tulip_private * tp
Definition: tulip.c:441
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
static void sis190_soft_reset(void *ioaddr)
Definition: sis190.c:412
void iounmap(volatile const void *io_addr)
Unmap I/O address.
static void sis190_mii_remove(struct net_device *dev)
Definition: sis190.c:859

References sis190_private::dev, net_device::dev, ioaddr, iounmap(), netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, sis190_mii_remove(), sis190_soft_reset(), tp, and unregister_netdev().

Variable Documentation

◆ sis190_pci_tbl

struct pci_device_id sis190_pci_tbl[]
static
Initial value:
= {
PCI_ROM (0x1039, 0x0190, "sis190", "sis190", 0),
PCI_ROM (0x1039, 0x0191, "sis191", "sis191", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

Definition at line 28 of file sis190.c.

◆ sis190_isa_bridge_tbl

struct pci_device_id sis190_isa_bridge_tbl[]
static
Initial value:
= {
PCI_ID (0x1039, 0x0965, "", "", 0),
PCI_ID (0x1039, 0x0966, "", "", 0),
PCI_ID (0x1039, 0x0968, "", "", 0),
}
#define PCI_ID(_vendor, _device, _name, _description, _data)
Definition: pci.h:277

Definition at line 44 of file sis190.c.

◆ __pci_driver

struct pci_driver sis190_pci_driver __pci_driver
Initial value:
= {
.id_count = (sizeof(sis190_isa_bridge_tbl) /
sizeof(sis190_isa_bridge_tbl[0])),
}
static struct pci_device_id sis190_isa_bridge_tbl[]
Definition: sis190.c:44
static void sis190_isa_bridge_remove(struct pci_device *pdev __unused)
Definition: sis190.c:55
static int sis190_isa_bridge_probe(struct pci_device *pdev __unused)
Definition: sis190.c:50
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39

Definition at line 60 of file sis190.c.

◆ sis190_intr_mask

const u32 sis190_intr_mask
static
Initial value:

Definition at line 72 of file sis190.c.

Referenced by sis190_irq().

◆ sis190_netdev_ops

struct net_device_operations sis190_netdev_ops
static
Initial value:
= {
.open = sis190_open,
.close = sis190_close,
.poll = sis190_poll,
.transmit = sis190_transmit,
.irq = sis190_irq,
}
static void sis190_irq(struct net_device *dev, int enable)
Definition: sis190.c:1083
static int sis190_transmit(struct net_device *dev, struct io_buffer *iob)
Definition: sis190.c:631
static int sis190_open(struct net_device *dev)
Definition: sis190.c:549
static void sis190_close(struct net_device *dev)
Definition: sis190.c:625
static void sis190_poll(struct net_device *dev)
Definition: sis190.c:344

Definition at line 1098 of file sis190.c.

Referenced by sis190_probe().