iPXE
Functions | Variables
myson.c File Reference

Myson Technology network card driver. More...

#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/mii.h>
#include "myson.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int myson_soft_reset (struct myson_nic *myson)
 Reset controller chip. More...
 
static int myson_reload_config (struct myson_nic *myson)
 Reload configuration from EEPROM. More...
 
static int myson_reset (struct myson_nic *myson)
 Reset hardware. More...
 
static int myson_create_ring (struct myson_nic *myson, struct myson_ring *ring)
 Create descriptor ring. More...
 
static void myson_destroy_ring (struct myson_nic *myson, struct myson_ring *ring)
 Destroy descriptor ring. More...
 
static void myson_refill_rx (struct net_device *netdev)
 Refill receive descriptor ring. More...
 
static int myson_open (struct net_device *netdev)
 Open network device. More...
 
static int myson_wait_idle (struct myson_nic *myson)
 Wait for transmit and receive to become idle. More...
 
static void myson_close (struct net_device *netdev)
 Close network device. More...
 
static int myson_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void myson_poll_tx (struct net_device *netdev)
 Poll for completed packets. More...
 
static void myson_poll_rx (struct net_device *netdev)
 Poll for received packets. More...
 
static void myson_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static void myson_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts. More...
 
static int myson_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void myson_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static struct net_device_operations myson_operations
 Myson network device operations. More...
 
static struct pci_device_id myson_nics []
 Myson PCI device IDs. More...
 
struct pci_driver myson_driver __pci_driver
 Myson PCI driver. More...
 

Detailed Description

Myson Technology network card driver.

Definition in file myson.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ myson_soft_reset()

static int myson_soft_reset ( struct myson_nic myson)
static

Reset controller chip.

Parameters
mysonMyson device
Return values
rcReturn status code

Definition at line 59 of file myson.c.

59  {
60  uint32_t bcr;
61  unsigned int i;
62 
63  /* Initiate reset */
64  bcr = readl ( myson->regs + MYSON_BCR );
65  writel ( ( bcr | MYSON_BCR_SWR ), myson->regs + MYSON_BCR );
66 
67  /* Wait for reset to complete */
68  for ( i = 0 ; i < MYSON_RESET_MAX_WAIT_MS ; i++ ) {
69 
70  /* If reset is not complete, delay 1ms and retry */
71  if ( readl ( myson->regs + MYSON_BCR ) & MYSON_BCR_SWR ) {
72  mdelay ( 1 );
73  continue;
74  }
75 
76  /* Apply a sensible default bus configuration */
77  bcr = readl ( myson->regs + MYSON_BCR );
78  bcr &= ~MYSON_BCR_PBL_MASK;
81  writel ( bcr, myson->regs + MYSON_BCR );
82  DBGC ( myson, "MYSON %p using configuration %08x\n",
83  myson, bcr );
84 
85  return 0;
86  }
87 
88  DBGC ( myson, "MYSON %p timed out waiting for reset\n", myson );
89  return -ETIMEDOUT;
90 }
#define MYSON_BCR_PBL_MASK
Definition: myson.h:92
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define MYSON_BCR_WIE
Write and invalidate.
Definition: myson.h:90
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define MYSON_BCR_RLE
Read line enable.
Definition: myson.h:88
#define MYSON_BCR_PBL_DEFAULT
Definition: myson.h:93
#define MYSON_BCR
Bus Command Register.
Definition: myson.h:87
unsigned int uint32_t
Definition: stdint.h:12
#define MYSON_BCR_SWR
Software reset.
Definition: myson.h:94
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define MYSON_BCR_RME
Read multiple enable.
Definition: myson.h:89
void * regs
Registers.
Definition: myson.h:170
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define MYSON_RESET_MAX_WAIT_MS
Maximum time to wait for a reset, in milliseconds.
Definition: myson.h:97

References DBGC, ETIMEDOUT, mdelay(), MYSON_BCR, MYSON_BCR_PBL_DEFAULT, MYSON_BCR_PBL_MASK, MYSON_BCR_RLE, MYSON_BCR_RME, MYSON_BCR_SWR, MYSON_BCR_WIE, MYSON_RESET_MAX_WAIT_MS, readl(), myson_nic::regs, and writel().

Referenced by myson_reset().

◆ myson_reload_config()

static int myson_reload_config ( struct myson_nic myson)
static

Reload configuration from EEPROM.

Parameters
mysonMyson device
Return values
rcReturn status code

Definition at line 98 of file myson.c.

98  {
99  unsigned int i;
100 
101  /* Initiate reload */
103 
104  /* Wait for reload to complete */
105  for ( i = 0 ; i < MYSON_AUTOLD_MAX_WAIT_MS ; i++ ) {
106 
107  /* If reload is not complete, delay 1ms and retry */
108  if ( readl ( myson->regs + MYSON_ROM_MII ) & MYSON_ROM_AUTOLD ){
109  mdelay ( 1 );
110  continue;
111  }
112 
113  return 0;
114  }
115 
116  DBGC ( myson, "MYSON %p timed out waiting for configuration "
117  "reload\n", myson );
118  return -ETIMEDOUT;
119 }
#define MYSON_AUTOLD_MAX_WAIT_MS
Maximum time to wait for a configuration reload, in milliseconds.
Definition: myson.h:136
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define MYSON_ROM_MII
Boot ROM / EEPROM / MII Management Register.
Definition: myson.h:132
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
void * regs
Registers.
Definition: myson.h:170
#define MYSON_ROM_AUTOLD
Auto load.
Definition: myson.h:133
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References DBGC, ETIMEDOUT, mdelay(), MYSON_AUTOLD_MAX_WAIT_MS, MYSON_ROM_AUTOLD, MYSON_ROM_MII, readl(), myson_nic::regs, and writel().

Referenced by myson_reset().

◆ myson_reset()

static int myson_reset ( struct myson_nic myson)
static

Reset hardware.

Parameters
mysonMyson device
Return values
rcReturn status code

Definition at line 127 of file myson.c.

127  {
128  int rc;
129 
130  /* Disable all interrupts */
131  writel ( 0, myson->regs + MYSON_IMR );
132 
133  /* Perform soft reset */
134  if ( ( rc = myson_soft_reset ( myson ) ) != 0 )
135  return rc;
136 
137  /* Reload configuration from EEPROM */
138  if ( ( rc = myson_reload_config ( myson ) ) != 0 )
139  return rc;
140 
141  return 0;
142 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int myson_reload_config(struct myson_nic *myson)
Reload configuration from EEPROM.
Definition: myson.c:98
static int myson_soft_reset(struct myson_nic *myson)
Reset controller chip.
Definition: myson.c:59
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void * regs
Registers.
Definition: myson.h:170
#define MYSON_IMR
Interrupt Mask Register.
Definition: myson.h:129

References MYSON_IMR, myson_reload_config(), myson_soft_reset(), rc, myson_nic::regs, and writel().

Referenced by myson_probe(), and myson_remove().

◆ myson_create_ring()

static int myson_create_ring ( struct myson_nic myson,
struct myson_ring ring 
)
static

Create descriptor ring.

Parameters
mysonMyson device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 158 of file myson.c.

159  {
160  size_t len = ( ring->count * sizeof ( ring->desc[0] ) );
161  struct myson_descriptor *desc;
162  struct myson_descriptor *next;
164  unsigned int i;
165  int rc;
166 
167  /* Allocate descriptor ring */
168  ring->desc = malloc_dma ( len, MYSON_RING_ALIGN );
169  if ( ! ring->desc ) {
170  rc = -ENOMEM;
171  goto err_alloc;
172  }
173  address = virt_to_bus ( ring->desc );
174 
175  /* Check address is usable by card */
176  if ( ! myson_address_ok ( address + len ) ) {
177  DBGC ( myson, "MYSON %p cannot support 64-bit ring address\n",
178  myson );
179  rc = -ENOTSUP;
180  goto err_64bit;
181  }
182 
183  /* Initialise descriptor ring */
184  memset ( ring->desc, 0, len );
185  for ( i = 0 ; i < ring->count ; i++ ) {
186  desc = &ring->desc[i];
187  next = &ring->desc[ ( i + 1 ) % ring->count ];
188  desc->next = cpu_to_le32 ( virt_to_bus ( next ) );
189  }
190 
191  /* Program ring address */
192  writel ( address, myson->regs + ring->reg );
193  DBGC ( myson, "MYSON %p ring %02x is at [%08llx,%08llx)\n",
194  myson, ring->reg, ( ( unsigned long long ) address ),
195  ( ( unsigned long long ) address + len ) );
196 
197  return 0;
198 
199  err_64bit:
200  free_dma ( ring->desc, len );
201  ring->desc = NULL;
202  err_alloc:
203  return rc;
204 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t next
Next descriptor address.
Definition: myson.h:18
uint64_t address
Base address.
Definition: ena.h:24
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
#define DBGC(...)
Definition: compiler.h:505
A packet descriptor.
Definition: myson.h:19
#define MYSON_RING_ALIGN
Descriptor ring alignment.
Definition: myson.h:54
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#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
unsigned int reg
Descriptor start address register.
Definition: myson.h:150
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t len
Length.
Definition: ena.h:14
unsigned int count
Number of descriptors.
Definition: myson.h:148
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
void * regs
Registers.
Definition: myson.h:170
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
uint32_t next
Next descriptor address.
Definition: myson.h:27
void * memset(void *dest, int character, size_t len) __nonnull

References address, myson_ring::count, cpu_to_le32, DBGC, myson_ring::desc, ENOMEM, ENOTSUP, free_dma(), len, malloc_dma(), memset(), MYSON_RING_ALIGN, next, myson_descriptor::next, NULL, rc, myson_ring::reg, myson_nic::regs, virt_to_bus(), and writel().

Referenced by myson_open().

◆ myson_destroy_ring()

static void myson_destroy_ring ( struct myson_nic myson,
struct myson_ring ring 
)
static

Destroy descriptor ring.

Parameters
mysonMyson device
ringDescriptor ring

Definition at line 212 of file myson.c.

213  {
214  size_t len = ( ring->count * sizeof ( ring->desc[0] ) );
215 
216  /* Clear ring address */
217  writel ( 0, myson->regs + ring->reg );
218 
219  /* Free descriptor ring */
220  free_dma ( ring->desc, len );
221  ring->desc = NULL;
222  ring->prod = 0;
223  ring->cons = 0;
224 }
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
unsigned int reg
Descriptor start address register.
Definition: myson.h:150
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
unsigned int prod
Producer index.
Definition: myson.h:143
unsigned int cons
Consumer index.
Definition: myson.h:145
uint32_t len
Length.
Definition: ena.h:14
unsigned int count
Number of descriptors.
Definition: myson.h:148
void * regs
Registers.
Definition: myson.h:170
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References myson_ring::cons, myson_ring::count, myson_ring::desc, free_dma(), len, NULL, myson_ring::prod, myson_ring::reg, myson_nic::regs, and writel().

Referenced by myson_close(), and myson_open().

◆ myson_refill_rx()

static void myson_refill_rx ( struct net_device netdev)
static

Refill receive descriptor ring.

Parameters
netdevNetwork device

Definition at line 231 of file myson.c.

231  {
232  struct myson_nic *myson = netdev->priv;
233  struct myson_descriptor *rx;
234  struct io_buffer *iobuf;
235  unsigned int rx_idx;
237 
238  while ( ( myson->rx.prod - myson->rx.cons ) < MYSON_NUM_RX_DESC ) {
239 
240  /* Allocate I/O buffer */
241  iobuf = alloc_iob ( MYSON_RX_MAX_LEN );
242  if ( ! iobuf ) {
243  /* Wait for next refill */
244  return;
245  }
246 
247  /* Check address is usable by card */
248  address = virt_to_bus ( iobuf->data );
249  if ( ! myson_address_ok ( address ) ) {
250  DBGC ( myson, "MYSON %p cannot support 64-bit RX "
251  "buffer address\n", myson );
252  netdev_rx_err ( netdev, iobuf, -ENOTSUP );
253  return;
254  }
255 
256  /* Get next receive descriptor */
257  rx_idx = ( myson->rx.prod++ % MYSON_NUM_RX_DESC );
258  rx = &myson->rx.desc[rx_idx];
259 
260  /* Populate receive descriptor */
261  rx->address = cpu_to_le32 ( address );
262  rx->control =
264  wmb();
265  rx->status = cpu_to_le32 ( MYSON_RX_STAT_OWN );
266  wmb();
267 
268  /* Record I/O buffer */
269  assert ( myson->rx_iobuf[rx_idx] == NULL );
270  myson->rx_iobuf[rx_idx] = iobuf;
271 
272  /* Notify card that there are descriptors available */
273  writel ( 0, myson->regs + MYSON_RXPDR );
274 
275  DBGC2 ( myson, "MYSON %p RX %d is [%llx,%llx)\n", myson,
276  rx_idx, ( ( unsigned long long ) address ),
277  ( ( unsigned long long ) address + MYSON_RX_MAX_LEN ) );
278  }
279 }
#define MYSON_RX_STAT_OWN
Owner.
Definition: myson.h:46
wmb()
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
uint64_t address
Base address.
Definition: ena.h:24
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
#define DBGC(...)
Definition: compiler.h:505
struct io_buffer * rx_iobuf[MYSON_NUM_RX_DESC]
Receive I/O buffers.
Definition: myson.h:177
A packet descriptor.
Definition: myson.h:19
#define MYSON_RX_CTRL_RBS(x)
Receive buffer size.
Definition: myson.h:51
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void * priv
Driver private data.
Definition: netdevice.h:425
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
struct myson_ring rx
Receive descriptor ring.
Definition: myson.h:175
uint32_t rx
Maximum number of receive queues.
Definition: intelvf.h:16
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int prod
Producer index.
Definition: myson.h:143
unsigned int cons
Consumer index.
Definition: myson.h:145
#define MYSON_NUM_RX_DESC
Number of receive descriptors.
Definition: myson.h:115
unsigned long physaddr_t
Definition: stdint.h:20
#define DBGC2(...)
Definition: compiler.h:522
#define MYSON_RX_MAX_LEN
Receive buffer length.
Definition: myson.h:118
void * data
Start of data.
Definition: iobuf.h:44
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define MYSON_RXPDR
Receive Poll Demand Register.
Definition: myson.h:103
A persistent I/O buffer.
Definition: iobuf.h:32

References address, alloc_iob(), assert(), myson_ring::cons, cpu_to_le32, io_buffer::data, DBGC, DBGC2, myson_ring::desc, ENOTSUP, MYSON_NUM_RX_DESC, MYSON_RX_CTRL_RBS, MYSON_RX_MAX_LEN, MYSON_RX_STAT_OWN, MYSON_RXPDR, netdev, netdev_rx_err(), NULL, net_device::priv, myson_ring::prod, myson_nic::regs, rx, myson_nic::rx, myson_nic::rx_iobuf, virt_to_bus(), wmb(), and writel().

Referenced by myson_open(), and myson_poll().

◆ myson_open()

static int myson_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 287 of file myson.c.

287  {
288  struct myson_nic *myson = netdev->priv;
290  int rc;
291 
292  /* Set MAC address */
293  memset ( &mac, 0, sizeof ( mac ) );
294  memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
295  writel ( le32_to_cpu ( mac.reg.low ), myson->regs + MYSON_PAR0 );
296  writel ( le32_to_cpu ( mac.reg.high ), myson->regs + MYSON_PAR4 );
297 
298  /* Create transmit descriptor ring */
299  if ( ( rc = myson_create_ring ( myson, &myson->tx ) ) != 0 )
300  goto err_create_tx;
301 
302  /* Create receive descriptor ring */
303  if ( ( rc = myson_create_ring ( myson, &myson->rx ) ) != 0 )
304  goto err_create_rx;
305 
306  /* Configure transmitter and receiver */
309  myson->regs + MYSON_TCR_RCR );
310 
311  /* Fill receive ring */
313 
314  return 0;
315 
316  myson_destroy_ring ( myson, &myson->rx );
317  err_create_rx:
318  myson_destroy_ring ( myson, &myson->tx );
319  err_create_tx:
320  return rc;
321 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MYSON_RCR_RE
Receive enable.
Definition: myson.h:81
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define MYSON_TCR_RCR
Transmit and Receive Configuration Register.
Definition: myson.h:72
#define MYSON_RCR_ALP
Accept long packet.
Definition: myson.h:80
#define MYSON_RCR_AB
Accept broadcast.
Definition: myson.h:77
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define MYSON_RCR_ARP
Accept runt packet.
Definition: myson.h:79
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * priv
Driver private data.
Definition: netdevice.h:425
#define MYSON_TCR_TE
Transmit enable.
Definition: myson.h:74
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
static void myson_destroy_ring(struct myson_nic *myson, struct myson_ring *ring)
Destroy descriptor ring.
Definition: myson.c:212
struct myson_ring rx
Receive descriptor ring.
Definition: myson.h:175
#define MYSON_PAR4
Physical Address Register 4.
Definition: myson.h:60
struct myson_ring tx
Transmit descriptor ring.
Definition: myson.h:173
#define MYSON_RCR_PROM
Promiscuous mode.
Definition: myson.h:76
static void myson_refill_rx(struct net_device *netdev)
Refill receive descriptor ring.
Definition: myson.c:231
#define MYSON_PAR0
Physical Address Register 0.
Definition: myson.h:57
#define MYSON_RCR_AM
Accept multicast.
Definition: myson.h:78
#define ETH_ALEN
Definition: if_ether.h:8
Physical address.
Definition: myson.h:63
void * regs
Registers.
Definition: myson.h:170
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
A myson network card.
Definition: myson.h:168
static int myson_create_ring(struct myson_nic *myson, struct myson_ring *ring)
Create descriptor ring.
Definition: myson.c:158
void * memset(void *dest, int character, size_t len) __nonnull

References ETH_ALEN, le32_to_cpu, net_device::ll_addr, mac, memcpy(), memset(), myson_create_ring(), myson_destroy_ring(), MYSON_PAR0, MYSON_PAR4, MYSON_RCR_AB, MYSON_RCR_ALP, MYSON_RCR_AM, MYSON_RCR_ARP, MYSON_RCR_PROM, MYSON_RCR_RE, myson_refill_rx(), MYSON_TCR_RCR, MYSON_TCR_TE, netdev, net_device::priv, rc, myson_nic::regs, myson_nic::rx, myson_nic::tx, and writel().

◆ myson_wait_idle()

static int myson_wait_idle ( struct myson_nic myson)
static

Wait for transmit and receive to become idle.

Parameters
mysonMyson device
Return values
rcReturn status code

Definition at line 329 of file myson.c.

329  {
330  uint32_t tcr_rcr;
331  unsigned int i;
332 
333  /* Wait for both transmit and receive to be idle */
334  for ( i = 0 ; i < MYSON_IDLE_MAX_WAIT_MS ; i++ ) {
335 
336  /* If either process is running, delay 1ms and retry */
337  tcr_rcr = readl ( myson->regs + MYSON_TCR_RCR );
338  if ( tcr_rcr & ( MYSON_TCR_TXS | MYSON_RCR_RXS ) ) {
339  mdelay ( 1 );
340  continue;
341  }
342 
343  return 0;
344  }
345 
346  DBGC ( myson, "MYSON %p timed out waiting for idle state (status "
347  "%08x)\n", myson, tcr_rcr );
348  return -ETIMEDOUT;
349 }
#define MYSON_TCR_RCR
Transmit and Receive Configuration Register.
Definition: myson.h:72
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define MYSON_RCR_RXS
Receive status.
Definition: myson.h:75
#define MYSON_IDLE_MAX_WAIT_MS
Maximum time to wait for transmit and receive to be idle, in milliseconds.
Definition: myson.h:84
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define MYSON_TCR_TXS
Transmit status.
Definition: myson.h:73
void * regs
Registers.
Definition: myson.h:170
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References DBGC, ETIMEDOUT, mdelay(), MYSON_IDLE_MAX_WAIT_MS, MYSON_RCR_RXS, MYSON_TCR_RCR, MYSON_TCR_TXS, readl(), and myson_nic::regs.

Referenced by myson_close().

◆ myson_close()

static void myson_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 356 of file myson.c.

356  {
357  struct myson_nic *myson = netdev->priv;
358  unsigned int i;
359 
360  /* Disable receiver and transmitter */
361  writel ( 0, myson->regs + MYSON_TCR_RCR );
362 
363  /* Allow time for receiver and transmitter to become idle */
364  myson_wait_idle ( myson );
365 
366  /* Destroy receive descriptor ring */
367  myson_destroy_ring ( myson, &myson->rx );
368 
369  /* Discard any unused receive buffers */
370  for ( i = 0 ; i < MYSON_NUM_RX_DESC ; i++ ) {
371  if ( myson->rx_iobuf[i] )
372  free_iob ( myson->rx_iobuf[i] );
373  myson->rx_iobuf[i] = NULL;
374  }
375 
376  /* Destroy transmit descriptor ring */
377  myson_destroy_ring ( myson, &myson->tx );
378 }
#define MYSON_TCR_RCR
Transmit and Receive Configuration Register.
Definition: myson.h:72
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
struct io_buffer * rx_iobuf[MYSON_NUM_RX_DESC]
Receive I/O buffers.
Definition: myson.h:177
void * priv
Driver private data.
Definition: netdevice.h:425
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
static void myson_destroy_ring(struct myson_nic *myson, struct myson_ring *ring)
Destroy descriptor ring.
Definition: myson.c:212
struct myson_ring rx
Receive descriptor ring.
Definition: myson.h:175
struct myson_ring tx
Transmit descriptor ring.
Definition: myson.h:173
static int myson_wait_idle(struct myson_nic *myson)
Wait for transmit and receive to become idle.
Definition: myson.c:329
#define MYSON_NUM_RX_DESC
Number of receive descriptors.
Definition: myson.h:115
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References free_iob(), myson_destroy_ring(), MYSON_NUM_RX_DESC, MYSON_TCR_RCR, myson_wait_idle(), netdev, NULL, net_device::priv, myson_nic::regs, myson_nic::rx, myson_nic::rx_iobuf, myson_nic::tx, and writel().

◆ myson_transmit()

static int myson_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 387 of file myson.c.

388  {
389  struct myson_nic *myson = netdev->priv;
390  struct myson_descriptor *tx;
391  unsigned int tx_idx;
393 
394  /* Check address is usable by card */
395  address = virt_to_bus ( iobuf->data );
396  if ( ! myson_address_ok ( address ) ) {
397  DBGC ( myson, "MYSON %p cannot support 64-bit TX buffer "
398  "address\n", myson );
399  return -ENOTSUP;
400  }
401 
402  /* Get next transmit descriptor */
403  if ( ( myson->tx.prod - myson->tx.cons ) >= MYSON_NUM_TX_DESC ) {
404  DBGC ( myson, "MYSON %p out of transmit descriptors\n",
405  myson );
406  return -ENOBUFS;
407  }
408  tx_idx = ( myson->tx.prod++ % MYSON_NUM_TX_DESC );
409  tx = &myson->tx.desc[tx_idx];
410 
411  /* Populate transmit descriptor */
412  tx->address = cpu_to_le32 ( address );
416  MYSON_TX_CTRL_PKTS ( iob_len ( iobuf ) ) |
417  MYSON_TX_CTRL_TBS ( iob_len ( iobuf ) ) );
418  wmb();
419  tx->status = cpu_to_le32 ( MYSON_TX_STAT_OWN );
420  wmb();
421 
422  /* Notify card that there are packets ready to transmit */
423  writel ( 0, myson->regs + MYSON_TXPDR );
424 
425  DBGC2 ( myson, "MYSON %p TX %d is [%llx,%llx)\n", myson, tx_idx,
426  ( ( unsigned long long ) address ),
427  ( ( unsigned long long ) address + iob_len ( iobuf ) ) );
428 
429  return 0;
430 }
wmb()
uint64_t address
Base address.
Definition: ena.h:24
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
#define DBGC(...)
Definition: compiler.h:505
A packet descriptor.
Definition: myson.h:19
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define MYSON_TX_CTRL_TBS(x)
Transmit buffer size.
Definition: myson.h:43
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void * priv
Driver private data.
Definition: netdevice.h:425
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int prod
Producer index.
Definition: myson.h:143
struct myson_ring tx
Transmit descriptor ring.
Definition: myson.h:173
uint32_t tx
Maximum number of transmit queues.
Definition: intelvf.h:14
#define MYSON_TX_CTRL_PAD
Pad control.
Definition: myson.h:40
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#define MYSON_NUM_TX_DESC
Number of transmit descriptors.
Definition: myson.h:109
unsigned int cons
Consumer index.
Definition: myson.h:145
#define MYSON_TXPDR
Transmit Poll Demand Register.
Definition: myson.h:100
#define MYSON_TX_CTRL_FD
First descriptor.
Definition: myson.h:38
unsigned long physaddr_t
Definition: stdint.h:20
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
#define MYSON_TX_CTRL_RTLC
Retry late collision.
Definition: myson.h:41
#define MYSON_TX_CTRL_PKTS(x)
Packet size.
Definition: myson.h:42
#define MYSON_TX_CTRL_LD
Last descriptor.
Definition: myson.h:37
#define MYSON_TX_STAT_OWN
Owner.
Definition: myson.h:31
#define MYSON_TX_CTRL_IC
Interrupt control.
Definition: myson.h:36
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
#define MYSON_TX_CTRL_CRC
CRC append.
Definition: myson.h:39

References address, myson_ring::cons, cpu_to_le32, io_buffer::data, DBGC, DBGC2, myson_ring::desc, ENOBUFS, ENOTSUP, iob_len(), MYSON_NUM_TX_DESC, MYSON_TX_CTRL_CRC, MYSON_TX_CTRL_FD, MYSON_TX_CTRL_IC, MYSON_TX_CTRL_LD, MYSON_TX_CTRL_PAD, MYSON_TX_CTRL_PKTS, MYSON_TX_CTRL_RTLC, MYSON_TX_CTRL_TBS, MYSON_TX_STAT_OWN, MYSON_TXPDR, netdev, net_device::priv, myson_ring::prod, myson_nic::regs, tx, myson_nic::tx, virt_to_bus(), wmb(), and writel().

◆ myson_poll_tx()

static void myson_poll_tx ( struct net_device netdev)
static

Poll for completed packets.

Parameters
netdevNetwork device

Definition at line 437 of file myson.c.

437  {
438  struct myson_nic *myson = netdev->priv;
439  struct myson_descriptor *tx;
440  unsigned int tx_idx;
441 
442  /* Check for completed packets */
443  while ( myson->tx.cons != myson->tx.prod ) {
444 
445  /* Get next transmit descriptor */
446  tx_idx = ( myson->tx.cons % MYSON_NUM_TX_DESC );
447  tx = &myson->tx.desc[tx_idx];
448 
449  /* Stop if descriptor is still in use */
450  if ( tx->status & cpu_to_le32 ( MYSON_TX_STAT_OWN ) )
451  return;
452 
453  /* Complete TX descriptor */
454  if ( tx->status & cpu_to_le32 ( MYSON_TX_STAT_ABORT |
455  MYSON_TX_STAT_CSL ) ) {
456  DBGC ( myson, "MYSON %p TX %d completion error "
457  "(%08x)\n", myson, tx_idx,
458  le32_to_cpu ( tx->status ) );
460  } else {
461  DBGC2 ( myson, "MYSON %p TX %d complete\n",
462  myson, tx_idx );
464  }
465  myson->tx.cons++;
466  }
467 }
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define MYSON_TX_STAT_ABORT
Abort.
Definition: myson.h:32
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:758
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
#define DBGC(...)
Definition: compiler.h:505
A packet descriptor.
Definition: myson.h:19
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
Definition: netdevice.c:434
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define MYSON_TX_STAT_CSL
Carrier sense lost.
Definition: myson.h:33
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int prod
Producer index.
Definition: myson.h:143
struct myson_ring tx
Transmit descriptor ring.
Definition: myson.h:173
uint32_t tx
Maximum number of transmit queues.
Definition: intelvf.h:14
#define MYSON_NUM_TX_DESC
Number of transmit descriptors.
Definition: myson.h:109
unsigned int cons
Consumer index.
Definition: myson.h:145
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
#define MYSON_TX_STAT_OWN
Owner.
Definition: myson.h:31
A myson network card.
Definition: myson.h:168

References myson_ring::cons, cpu_to_le32, DBGC, DBGC2, myson_ring::desc, EIO, le32_to_cpu, MYSON_NUM_TX_DESC, MYSON_TX_STAT_ABORT, MYSON_TX_STAT_CSL, MYSON_TX_STAT_OWN, netdev, netdev_tx_complete_next(), netdev_tx_complete_next_err(), net_device::priv, myson_ring::prod, tx, and myson_nic::tx.

Referenced by myson_poll().

◆ myson_poll_rx()

static void myson_poll_rx ( struct net_device netdev)
static

Poll for received packets.

Parameters
netdevNetwork device

Definition at line 474 of file myson.c.

474  {
475  struct myson_nic *myson = netdev->priv;
476  struct myson_descriptor *rx;
477  struct io_buffer *iobuf;
478  unsigned int rx_idx;
479  size_t len;
480 
481  /* Check for received packets */
482  while ( myson->rx.cons != myson->rx.prod ) {
483 
484  /* Get next receive descriptor */
485  rx_idx = ( myson->rx.cons % MYSON_NUM_RX_DESC );
486  rx = &myson->rx.desc[rx_idx];
487 
488  /* Stop if descriptor is still in use */
489  if ( rx->status & MYSON_RX_STAT_OWN )
490  return;
491 
492  /* Populate I/O buffer */
493  iobuf = myson->rx_iobuf[rx_idx];
494  myson->rx_iobuf[rx_idx] = NULL;
495  len = MYSON_RX_STAT_FLNG ( le32_to_cpu ( rx->status ) );
496  iob_put ( iobuf, len - 4 /* strip CRC */ );
497 
498  /* Hand off to network stack */
499  if ( rx->status & cpu_to_le32 ( MYSON_RX_STAT_ES ) ) {
500  DBGC ( myson, "MYSON %p RX %d error (length %zd, "
501  "status %08x)\n", myson, rx_idx, len,
502  le32_to_cpu ( rx->status ) );
503  netdev_rx_err ( netdev, iobuf, -EIO );
504  } else {
505  DBGC2 ( myson, "MYSON %p RX %d complete (length "
506  "%zd)\n", myson, rx_idx, len );
507  netdev_rx ( netdev, iobuf );
508  }
509  myson->rx.cons++;
510  }
511 }
#define MYSON_RX_STAT_OWN
Owner.
Definition: myson.h:46
#define iob_put(iobuf, len)
Definition: iobuf.h:116
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
#define le32_to_cpu(value)
Definition: byteswap.h:113
struct myson_descriptor * desc
Descriptors.
Definition: myson.h:141
#define DBGC(...)
Definition: compiler.h:505
struct io_buffer * rx_iobuf[MYSON_NUM_RX_DESC]
Receive I/O buffers.
Definition: myson.h:177
A packet descriptor.
Definition: myson.h:19
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
struct myson_ring rx
Receive descriptor ring.
Definition: myson.h:175
uint32_t rx
Maximum number of receive queues.
Definition: intelvf.h:16
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int prod
Producer index.
Definition: myson.h:143
unsigned int cons
Consumer index.
Definition: myson.h:145
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
#define MYSON_NUM_RX_DESC
Number of receive descriptors.
Definition: myson.h:115
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
#define MYSON_RX_STAT_ES
Error summary.
Definition: myson.h:48
#define MYSON_RX_STAT_FLNG(status)
Definition: myson.h:47
A myson network card.
Definition: myson.h:168
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:32

References myson_ring::cons, cpu_to_le32, DBGC, DBGC2, myson_ring::desc, EIO, iob_put, le32_to_cpu, len, MYSON_NUM_RX_DESC, MYSON_RX_STAT_ES, MYSON_RX_STAT_FLNG, MYSON_RX_STAT_OWN, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, myson_ring::prod, rx, myson_nic::rx, and myson_nic::rx_iobuf.

Referenced by myson_poll().

◆ myson_poll()

static void myson_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 518 of file myson.c.

518  {
519  struct myson_nic *myson = netdev->priv;
520  uint32_t isr;
521  unsigned int i;
522 
523  /* Polling the ISR seems to really upset this card; it ends up
524  * getting no useful PCI transfers done and, for some reason,
525  * flooding the network with invalid packets. Work around
526  * this by introducing deliberate delays between ISR reads.
527  */
528  for ( i = 0 ; i < MYSON_ISR_IODELAY_COUNT ; i++ )
529  iodelay();
530 
531  /* Check for and acknowledge interrupts */
532  isr = readl ( myson->regs + MYSON_ISR );
533  if ( ! isr )
534  return;
535  writel ( isr, myson->regs + MYSON_ISR );
536 
537  /* Poll for TX completions, if applicable */
538  if ( isr & MYSON_IRQ_TI )
539  myson_poll_tx ( netdev );
540 
541  /* Poll for RX completionsm, if applicable */
542  if ( isr & MYSON_IRQ_RI )
543  myson_poll_rx ( netdev );
544 
545  /* Refill RX ring */
547 }
static void myson_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: myson.c:437
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define MYSON_ISR_IODELAY_COUNT
Number of I/O delays between ISR reads.
Definition: myson.h:126
#define MYSON_ISR
Interrupt Status Register.
Definition: myson.h:121
void * priv
Driver private data.
Definition: netdevice.h:425
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
Definition: sis900.h:26
static void myson_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: myson.c:474
static void myson_refill_rx(struct net_device *netdev)
Refill receive descriptor ring.
Definition: myson.c:231
unsigned int uint32_t
Definition: stdint.h:12
#define MYSON_IRQ_TI
Transmit interrupt.
Definition: myson.h:122
#define MYSON_IRQ_RI
Receive interrupt.
Definition: myson.h:123
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
void iodelay(void)
Slow down I/O.

References iodelay(), isr, MYSON_IRQ_RI, MYSON_IRQ_TI, MYSON_ISR, MYSON_ISR_IODELAY_COUNT, myson_poll_rx(), myson_poll_tx(), myson_refill_rx(), netdev, net_device::priv, readl(), myson_nic::regs, and writel().

◆ myson_irq()

static void myson_irq ( struct net_device netdev,
int  enable 
)
static

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 555 of file myson.c.

555  {
556  struct myson_nic *myson = netdev->priv;
557  uint32_t imr;
558 
559  imr = ( enable ? ( MYSON_IRQ_TI | MYSON_IRQ_RI ) : 0 );
560  writel ( imr, myson->regs + MYSON_IMR );
561 }
Definition: sis900.h:27
void * priv
Driver private data.
Definition: netdevice.h:425
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned int uint32_t
Definition: stdint.h:12
#define MYSON_IRQ_TI
Transmit interrupt.
Definition: myson.h:122
#define MYSON_IRQ_RI
Receive interrupt.
Definition: myson.h:123
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
#define MYSON_IMR
Interrupt Mask Register.
Definition: myson.h:129

References imr, MYSON_IMR, MYSON_IRQ_RI, MYSON_IRQ_TI, netdev, net_device::priv, myson_nic::regs, and writel().

◆ myson_probe()

static int myson_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 585 of file myson.c.

585  {
586  struct net_device *netdev;
587  struct myson_nic *myson;
589  int rc;
590 
591  /* Allocate and initialise net device */
592  netdev = alloc_etherdev ( sizeof ( *myson ) );
593  if ( ! netdev ) {
594  rc = -ENOMEM;
595  goto err_alloc;
596  }
598  myson = netdev->priv;
599  pci_set_drvdata ( pci, netdev );
600  netdev->dev = &pci->dev;
601  memset ( myson, 0, sizeof ( *myson ) );
602  myson_init_ring ( &myson->tx, MYSON_NUM_TX_DESC, MYSON_TXLBA );
603  myson_init_ring ( &myson->rx, MYSON_NUM_RX_DESC, MYSON_RXLBA );
604 
605  /* Fix up PCI device */
606  adjust_pci_device ( pci );
607 
608  /* Map registers */
609  myson->regs = ioremap ( pci->membase, MYSON_BAR_SIZE );
610  if ( ! myson->regs ) {
611  rc = -ENODEV;
612  goto err_ioremap;
613  }
614 
615  /* Reset the NIC */
616  if ( ( rc = myson_reset ( myson ) ) != 0 )
617  goto err_reset;
618 
619  /* Read MAC address */
620  mac.reg.low = cpu_to_le32 ( readl ( myson->regs + MYSON_PAR0 ) );
621  mac.reg.high = cpu_to_le32 ( readl ( myson->regs + MYSON_PAR4 ) );
622  memcpy ( netdev->hw_addr, mac.raw, ETH_ALEN );
623 
624  /* Register network device */
625  if ( ( rc = register_netdev ( netdev ) ) != 0 )
626  goto err_register_netdev;
627 
628  /* Mark as link up; we don't yet handle link state */
630 
631  return 0;
632 
634  err_register_netdev:
635  myson_reset ( myson );
636  err_reset:
637  iounmap ( myson->regs );
638  err_ioremap:
640  netdev_put ( netdev );
641  err_alloc:
642  return rc;
643 }
unsigned long membase
Memory base.
Definition: pci.h:194
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
static int myson_reset(struct myson_nic *myson)
Reset hardware.
Definition: myson.c:127
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
#define ENOMEM
Not enough space.
Definition: errno.h:534
static struct net_device_operations myson_operations
Myson network device operations.
Definition: myson.c:564
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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
#define MYSON_RXLBA
Receive List Base Address.
Definition: myson.h:112
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
struct myson_ring rx
Receive descriptor ring.
Definition: myson.h:175
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define MYSON_PAR4
Physical Address Register 4.
Definition: myson.h:60
struct myson_ring tx
Transmit descriptor ring.
Definition: myson.h:173
#define MYSON_TXLBA
Transmit List Base Address.
Definition: myson.h:106
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
#define ENODEV
No such device.
Definition: errno.h:509
#define MYSON_NUM_TX_DESC
Number of transmit descriptors.
Definition: myson.h:109
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
#define MYSON_PAR0
Physical Address Register 0.
Definition: myson.h:57
#define ETH_ALEN
Definition: if_ether.h:8
#define MYSON_BAR_SIZE
BAR size.
Definition: myson.h:16
#define MYSON_NUM_RX_DESC
Number of receive descriptors.
Definition: myson.h:115
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
Physical address.
Definition: myson.h:63
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
void * memset(void *dest, int character, size_t len) __nonnull

References adjust_pci_device(), alloc_etherdev(), cpu_to_le32, pci_device::dev, net_device::dev, ENODEV, ENOMEM, ETH_ALEN, net_device::hw_addr, ioremap(), iounmap(), mac, pci_device::membase, memcpy(), memset(), MYSON_BAR_SIZE, MYSON_NUM_RX_DESC, MYSON_NUM_TX_DESC, myson_operations, MYSON_PAR0, MYSON_PAR4, myson_reset(), MYSON_RXLBA, MYSON_TXLBA, netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), pci_set_drvdata(), net_device::priv, rc, readl(), register_netdev(), myson_nic::regs, myson_nic::rx, myson_nic::tx, and unregister_netdev().

◆ myson_remove()

static void myson_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 650 of file myson.c.

650  {
651  struct net_device *netdev = pci_get_drvdata ( pci );
652  struct myson_nic *myson = netdev->priv;
653 
654  /* Unregister network device */
656 
657  /* Reset card */
658  myson_reset ( myson );
659 
660  /* Free network device */
661  iounmap ( myson->regs );
663  netdev_put ( netdev );
664 }
static int myson_reset(struct myson_nic *myson)
Reset hardware.
Definition: myson.c:127
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 net_device * netdev
Definition: gdbudp.c:52
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
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * regs
Registers.
Definition: myson.h:170
A myson network card.
Definition: myson.h:168

References iounmap(), myson_reset(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, myson_nic::regs, and unregister_netdev().

Variable Documentation

◆ myson_operations

struct net_device_operations myson_operations
static
Initial value:
= {
.open = myson_open,
.close = myson_close,
.transmit = myson_transmit,
.poll = myson_poll,
.irq = myson_irq,
}
static void myson_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: myson.c:518
static void myson_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: myson.c:555
static int myson_open(struct net_device *netdev)
Open network device.
Definition: myson.c:287
static void myson_close(struct net_device *netdev)
Close network device.
Definition: myson.c:356
static int myson_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: myson.c:387

Myson network device operations.

Definition at line 564 of file myson.c.

Referenced by myson_probe().

◆ myson_nics

struct pci_device_id myson_nics[]
static
Initial value:
= {
PCI_ROM ( 0x1516, 0x0800, "mtd800", "MTD-8xx", 0 ),
PCI_ROM ( 0x1516, 0x0803, "mtd803", "Surecom EP-320X-S", 0 ),
PCI_ROM ( 0x1516, 0x0891, "mtd891", "MTD-8xx", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

Myson PCI device IDs.

Definition at line 667 of file myson.c.

◆ __pci_driver

struct pci_driver myson_driver __pci_driver
Initial value:
= {
.ids = myson_nics,
.id_count = ( sizeof ( myson_nics ) / sizeof ( myson_nics[0] ) ),
.probe = myson_probe,
}
static void myson_remove(struct pci_device *pci)
Remove PCI device.
Definition: myson.c:650
static struct pci_device_id myson_nics[]
Myson PCI device IDs.
Definition: myson.c:667
static int myson_probe(struct pci_device *pci)
Probe PCI device.
Definition: myson.c:585
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39

Myson PCI driver.

Definition at line 674 of file myson.c.