iPXE
Functions | Variables
axge.c File Reference

Asix 10/100/1000 USB Ethernet driver. More...

#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/profile.h>
#include <ipxe/usb.h>
#include "axge.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int axge_read_register (struct axge_device *axge, unsigned int offset, void *data, size_t len)
 Read register. More...
 
static int axge_read_byte (struct axge_device *axge, unsigned int offset, uint8_t *value)
 Read one-byte register. More...
 
static int axge_read_word (struct axge_device *axge, unsigned int offset, uint16_t *value)
 Read two-byte register. More...
 
static int axge_read_dword (struct axge_device *axge, unsigned int offset, uint32_t *value)
 Read four-byte register. More...
 
static int axge_write_register (struct axge_device *axge, unsigned int offset, void *data, size_t len)
 Write register. More...
 
static int axge_write_byte (struct axge_device *axge, unsigned int offset, uint8_t value)
 Write one-byte register. More...
 
static int axge_write_word (struct axge_device *axge, unsigned int offset, uint16_t value)
 Write two-byte register. More...
 
static int axge_write_dword (struct axge_device *axge, unsigned int offset, uint32_t value)
 Write one-byte register. More...
 
static int axge_check_link (struct axge_device *axge)
 Get link status. More...
 
static void axge_intr_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete interrupt transfer. More...
 
static void axge_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk IN transfer. More...
 
static int axge_out_transmit (struct axge_device *axge, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void axge_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk OUT transfer. More...
 
static int axge_open (struct net_device *netdev)
 Open network device. More...
 
static void axge_close (struct net_device *netdev)
 Close network device. More...
 
static int axge_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void axge_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static int axge_probe (struct usb_function *func, struct usb_configuration_descriptor *config)
 Probe device. More...
 
static void axge_remove (struct usb_function *func)
 Remove device. More...
 

Variables

static struct profiler axge_intr_profiler __profiler
 Interrupt completion profiler. More...
 
static struct axge_bulk_in_control axge_bicr
 Default bulk IN configuration. More...
 
static struct usb_endpoint_driver_operations axge_intr_operations
 Interrupt endpoint operations. More...
 
static struct usb_endpoint_driver_operations axge_in_operations
 Bulk IN endpoint operations. More...
 
static struct usb_endpoint_driver_operations axge_out_operations
 Bulk OUT endpoint operations. More...
 
static struct net_device_operations axge_operations
 AXGE network device operations. More...
 
static struct usb_device_id axge_ids []
 AXGE device IDs. More...
 
struct usb_driver axge_driver __usb_driver
 AXGE driver. More...
 

Detailed Description

Asix 10/100/1000 USB Ethernet driver.

Large chunks of functionality are undocumented in the available datasheets. The gaps are deduced from combinations of the Linux driver, the FreeBSD driver, and experimentation with the hardware.

Definition in file axge.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ axge_read_register()

static int axge_read_register ( struct axge_device axge,
unsigned int  offset,
void *  data,
size_t  len 
)
inlinestatic

Read register.

Parameters
asixAXGE device
offsetRegister offset
dataData buffer
lenLength of data
Return values
rcReturn status code

Definition at line 91 of file axge.c.

93  {
94 
95  return usb_control ( axge->usb, AXGE_READ_MAC_REGISTER,
96  offset, len, data, len );
97 }
struct usb_device * usb
USB device.
Definition: axge.h:141
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:783
#define AXGE_READ_MAC_REGISTER
Read MAC register.
Definition: axge.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
uint32_t len
Length.
Definition: ena.h:14

References AXGE_READ_MAC_REGISTER, data, len, offset, axge_device::usb, and usb_control().

Referenced by axge_probe(), axge_read_byte(), axge_read_dword(), and axge_read_word().

◆ axge_read_byte()

static int axge_read_byte ( struct axge_device axge,
unsigned int  offset,
uint8_t value 
)
inlinestatic

Read one-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue to fill in
Return values
rcReturn status code

Definition at line 107 of file axge.c.

108  {
109 
110  return axge_read_register ( axge, offset, value, sizeof ( *value ) );
111 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static int axge_read_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Read register.
Definition: axge.c:91
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

References axge_read_register(), offset, and value.

Referenced by axge_check_link().

◆ axge_read_word()

static int axge_read_word ( struct axge_device axge,
unsigned int  offset,
uint16_t value 
)
inlinestatic

Read two-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue to fill in
Return values
rcReturn status code

Definition at line 121 of file axge.c.

122  {
123 
124  return axge_read_register ( axge, offset, value, sizeof ( *value ) );
125 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static int axge_read_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Read register.
Definition: axge.c:91
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

References axge_read_register(), offset, and value.

◆ axge_read_dword()

static int axge_read_dword ( struct axge_device axge,
unsigned int  offset,
uint32_t value 
)
inlinestatic

Read four-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue to fill in
Return values
rcReturn status code

Definition at line 135 of file axge.c.

136  {
137 
138  return axge_read_register ( axge, offset, value, sizeof ( *value ) );
139 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static int axge_read_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Read register.
Definition: axge.c:91
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

References axge_read_register(), offset, and value.

◆ axge_write_register()

static int axge_write_register ( struct axge_device axge,
unsigned int  offset,
void *  data,
size_t  len 
)
inlinestatic

Write register.

Parameters
asixAXGE device
offsetRegister offset
dataData buffer
lenLength of data
Return values
rcReturn status code

Definition at line 150 of file axge.c.

152  {
153 
154  return usb_control ( axge->usb, AXGE_WRITE_MAC_REGISTER,
155  offset, len, data, len );
156 }
struct usb_device * usb
USB device.
Definition: axge.h:141
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:783
#define AXGE_WRITE_MAC_REGISTER
Write MAC register.
Definition: axge.h:21
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
uint32_t len
Length.
Definition: ena.h:14

References AXGE_WRITE_MAC_REGISTER, data, len, offset, axge_device::usb, and usb_control().

Referenced by axge_open(), axge_probe(), axge_write_byte(), axge_write_dword(), and axge_write_word().

◆ axge_write_byte()

static int axge_write_byte ( struct axge_device axge,
unsigned int  offset,
uint8_t  value 
)
inlinestatic

Write one-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue
Return values
rcReturn status code

Definition at line 166 of file axge.c.

167  {
168 
169  return axge_write_register ( axge, offset, &value, sizeof ( value ));
170 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
static int axge_write_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Write register.
Definition: axge.c:150

References axge_write_register(), offset, and value.

Referenced by axge_probe().

◆ axge_write_word()

static int axge_write_word ( struct axge_device axge,
unsigned int  offset,
uint16_t  value 
)
inlinestatic

Write two-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue
Return values
rcReturn status code

Definition at line 180 of file axge.c.

181  {
182 
183  return axge_write_register ( axge, offset, &value, sizeof ( value ));
184 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
static int axge_write_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Write register.
Definition: axge.c:150

References axge_write_register(), offset, and value.

Referenced by axge_check_link(), axge_close(), axge_open(), and axge_probe().

◆ axge_write_dword()

static int axge_write_dword ( struct axge_device axge,
unsigned int  offset,
uint32_t  value 
)
inlinestatic

Write one-byte register.

Parameters
asixAXGE device
offsetRegister offset
valueValue
Return values
rcReturn status code

Definition at line 194 of file axge.c.

195  {
196 
197  return axge_write_register ( axge, offset, &value, sizeof ( value ));
198 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
static int axge_write_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Write register.
Definition: axge.c:150

References axge_write_register(), offset, and value.

◆ axge_check_link()

static int axge_check_link ( struct axge_device axge)
static

Get link status.

Parameters
asixAXGE device
Return values
rcReturn status code

Definition at line 213 of file axge.c.

213  {
214  struct net_device *netdev = axge->netdev;
215  uint8_t plsr;
216  uint16_t msr;
217  int rc;
218 
219  /* Read physical link status register */
220  if ( ( rc = axge_read_byte ( axge, AXGE_PLSR, &plsr ) ) != 0 ) {
221  DBGC ( axge, "AXGE %p could not read PLSR: %s\n",
222  axge, strerror ( rc ) );
223  return rc;
224  }
225 
226  /* Write medium status register */
228  AXGE_MSR_RE );
229  if ( plsr & AXGE_PLSR_EPHY_1000 ) {
230  msr |= cpu_to_le16 ( AXGE_MSR_GM );
231  } else if ( plsr & AXGE_PLSR_EPHY_100 ) {
232  msr |= cpu_to_le16 ( AXGE_MSR_PS );
233  }
234  if ( ( rc = axge_write_word ( axge, AXGE_MSR, msr ) ) != 0 ) {
235  DBGC ( axge, "AXGE %p could not write MSR: %s\n",
236  axge, strerror ( rc ) );
237  return rc;
238  }
239 
240  /* Update link status */
241  if ( plsr & AXGE_PLSR_EPHY_ANY ) {
242  DBGC ( axge, "AXGE %p link up (PLSR %02x MSR %04x)\n",
243  axge, plsr, msr );
245  } else {
246  DBGC ( axge, "AXGE %p link down (PLSR %02x MSR %04x)\n",
247  axge, plsr, msr );
249  }
250 
251  return 0;
252 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
static int axge_read_byte(struct axge_device *axge, unsigned int offset, uint8_t *value)
Read one-byte register.
Definition: axge.c:107
#define AXGE_PLSR_EPHY_100
Ethernet at 100Mbps.
Definition: axge.h:28
#define DBGC(...)
Definition: compiler.h:505
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define AXGE_MSR_RFC
RX flow control enable.
Definition: axge.h:49
#define AXGE_MSR
Medium Status Register.
Definition: axge.h:46
#define AXGE_PLSR
Physical Link Status Register.
Definition: axge.h:26
struct net_device * netdev
Network device.
Definition: axge.h:145
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
static struct net_device * netdev
Definition: gdbudp.c:52
#define AXGE_MSR_PS
100Mbps port speed
Definition: axge.h:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:352
unsigned char uint8_t
Definition: stdint.h:10
#define AXGE_PLSR_EPHY_ANY
Definition: axge.h:30
#define AXGE_MSR_GM
Gigabit mode.
Definition: axge.h:47
static int axge_write_word(struct axge_device *axge, unsigned int offset, uint16_t value)
Write two-byte register.
Definition: axge.c:180
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define AXGE_PLSR_EPHY_1000
Ethernet at 1000Mbps.
Definition: axge.h:29
#define AXGE_MSR_TFC
TX flow control enable.
Definition: axge.h:50
#define AXGE_MSR_FD
Full duplex.
Definition: axge.h:48
#define AXGE_MSR_RE
Receive enable.
Definition: axge.h:51

References AXGE_MSR, AXGE_MSR_FD, AXGE_MSR_GM, AXGE_MSR_PS, AXGE_MSR_RE, AXGE_MSR_RFC, AXGE_MSR_TFC, AXGE_PLSR, AXGE_PLSR_EPHY_100, AXGE_PLSR_EPHY_1000, AXGE_PLSR_EPHY_ANY, axge_read_byte(), axge_write_word(), cpu_to_le16, DBGC, netdev, axge_device::netdev, netdev_link_down(), netdev_link_up(), rc, and strerror().

Referenced by axge_open(), axge_poll(), and axge_probe().

◆ axge_intr_complete()

static void axge_intr_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete interrupt transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 268 of file axge.c.

269  {
270  struct axge_device *axge = container_of ( ep, struct axge_device,
271  usbnet.intr );
272  struct net_device *netdev = axge->netdev;
273  struct axge_interrupt *intr;
274  size_t len = iob_len ( iobuf );
275  unsigned int link_ok;
276 
277  /* Profile completions */
278  profile_start ( &axge_intr_profiler );
279 
280  /* Ignore packets cancelled when the endpoint closes */
281  if ( ! ep->open )
282  goto ignore;
283 
284  /* Drop packets with errors */
285  if ( rc != 0 ) {
286  DBGC ( axge, "AXGE %p interrupt failed: %s\n",
287  axge, strerror ( rc ) );
288  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
289  goto error;
290  }
291 
292  /* Extract message header */
293  if ( len < sizeof ( *intr ) ) {
294  DBGC ( axge, "AXGE %p underlength interrupt:\n", axge );
295  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
296  rc = -EINVAL;
297  goto error;
298  }
299  intr = iobuf->data;
300 
301  /* Check magic signature */
302  if ( intr->magic != cpu_to_le16 ( AXGE_INTR_MAGIC ) ) {
303  DBGC ( axge, "AXGE %p malformed interrupt:\n", axge );
304  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
305  rc = -EINVAL;
306  goto error;
307  }
308 
309  /* Extract link status */
310  link_ok = ( intr->link & cpu_to_le16 ( AXGE_INTR_LINK_PPLS ) );
311  if ( ( !! link_ok ) ^ ( !! netdev_link_ok ( netdev ) ) )
312  axge->check_link = 1;
313 
314  /* Free I/O buffer */
315  free_iob ( iobuf );
316  profile_stop ( &axge_intr_profiler );
317 
318  return;
319 
320  error:
321  netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
322  ignore:
323  free_iob ( iobuf );
324  return;
325 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define AXGE_INTR_MAGIC
Interrupt magic signature.
Definition: axge.h:133
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
Interrupt data.
Definition: axge.h:121
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
struct arbelprm_completion_with_error error
Definition: arbel.h:12
#define DBGC(...)
Definition: compiler.h:505
int open
Endpoint is open.
Definition: usb.h:418
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:173
struct usb_endpoint intr
Interrupt endpoint.
Definition: usbnet.h:27
An AXGE network device.
Definition: axge.h:139
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:212
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
struct net_device * netdev
Network device.
Definition: axge.h:145
#define DBGC_HDA(...)
Definition: compiler.h:506
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:636
static struct net_device * netdev
Definition: gdbudp.c:52
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:160
int check_link
Link state has changed.
Definition: axge.h:151
#define AXGE_INTR_LINK_PPLS
Link is up.
Definition: axge.h:136
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
A network device.
Definition: netdevice.h:352
void * data
Start of data.
Definition: iobuf.h:48
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
uint32_t len
Length.
Definition: ena.h:14

References AXGE_INTR_LINK_PPLS, AXGE_INTR_MAGIC, axge_device::check_link, container_of, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, EINVAL, error, free_iob(), intr, usbnet_device::intr, iob_disown, iob_len(), len, netdev, axge_device::netdev, netdev_link_ok(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and axge_device::usbnet.

◆ axge_in_complete()

static void axge_in_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete bulk IN transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 346 of file axge.c.

347  {
348  struct axge_device *axge = container_of ( ep, struct axge_device,
349  usbnet.in );
350  struct net_device *netdev = axge->netdev;
351  struct axge_rx_footer *ftr;
352  struct axge_rx_descriptor *desc;
353  struct io_buffer *pkt;
354  unsigned int count;
355  unsigned int offset;
356  size_t len;
357  size_t padded_len;
358 
359  /* Profile receive completions */
360  profile_start ( &axge_in_profiler );
361 
362  /* Ignore packets cancelled when the endpoint closes */
363  if ( ! ep->open )
364  goto ignore;
365 
366  /* Record USB errors against the network device */
367  if ( rc != 0 ) {
368  DBGC ( axge, "AXGE %p bulk IN failed: %s\n",
369  axge, strerror ( rc ) );
370  goto error;
371  }
372 
373  /* Sanity check */
374  if ( iob_len ( iobuf ) < sizeof ( *ftr ) ) {
375  DBGC ( axge, "AXGE %p underlength bulk IN:\n", axge );
376  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
377  rc = -EINVAL;
378  goto error;
379  }
380 
381  /* Parse ftr, strip ftr and descriptors */
382  iob_unput ( iobuf, sizeof ( *ftr ) );
383  ftr = ( iobuf->data + iob_len ( iobuf ) );
384  count = le16_to_cpu ( ftr->count );
385  if ( count == 0 ) {
386  DBGC ( axge, "AXGE %p zero-packet bulk IN:\n", axge );
387  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
388  goto ignore;
389  }
390  offset = le16_to_cpu ( ftr->offset );
391  if ( ( iob_len ( iobuf ) < offset ) ||
392  ( ( iob_len ( iobuf ) - offset ) < ( count * sizeof ( *desc ) ) )){
393  DBGC ( axge, "AXGE %p malformed bulk IN footer:\n", axge );
394  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
395  rc = -EINVAL;
396  goto error;
397  }
398  desc = ( iobuf->data + offset );
399  iob_unput ( iobuf, ( iob_len ( iobuf ) - offset ) );
400 
401  /* Process packets */
402  for ( ; count-- ; desc++ ) {
403 
404  /* Parse descriptor */
405  len = ( le16_to_cpu ( desc->len_flags ) & AXGE_RX_LEN_MASK );
406  padded_len = ( ( len + AXGE_RX_LEN_PAD_ALIGN - 1 ) &
407  ~( AXGE_RX_LEN_PAD_ALIGN - 1 ) );
408  if ( iob_len ( iobuf ) < padded_len ) {
409  DBGC ( axge, "AXGE %p malformed bulk IN descriptor:\n",
410  axge );
411  DBGC_HDA ( axge, 0, iobuf->data, iob_len ( iobuf ) );
412  rc = -EINVAL;
413  goto error;
414  }
415 
416  /* Check for previous dropped packets */
417  if ( desc->len_flags & cpu_to_le16 ( AXGE_RX_CRC_ERROR ) )
418  netdev_rx_err ( netdev, NULL, -EIO );
419  if ( desc->len_flags & cpu_to_le16 ( AXGE_RX_DROP_ERROR ) )
421 
422  /* Allocate new I/O buffer, if applicable */
423  if ( count ) {
424 
425  /* More packets remain: allocate a new buffer */
426  pkt = alloc_iob ( AXGE_IN_RESERVE + len );
427  if ( ! pkt ) {
428  /* Record error and continue */
430  iob_pull ( iobuf, padded_len );
431  continue;
432  }
433  iob_reserve ( pkt, AXGE_IN_RESERVE );
434  memcpy ( iob_put ( pkt, len ), iobuf->data, len );
435  iob_pull ( iobuf, padded_len );
436 
437  } else {
438 
439  /* This is the last (or only) packet: use this buffer */
440  iob_unput ( iobuf, ( padded_len - len ) );
441  pkt = iob_disown ( iobuf );
442  }
443 
444  /* Hand off to network stack */
445  netdev_rx ( netdev, iob_disown ( pkt ) );
446  }
447 
448  assert ( iobuf == NULL );
449  profile_stop ( &axge_in_profiler );
450  return;
451 
452  error:
453  netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
454  ignore:
455  free_iob ( iobuf );
456 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
#define AXGE_RX_DROP_ERROR
Receive packet dropped error.
Definition: axge.h:118
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
struct arbelprm_completion_with_error error
Definition: arbel.h:12
uint64_t desc
Microcode descriptor list physical address.
Definition: ucode.h:12
#define DBGC(...)
Definition: compiler.h:505
#define AXGE_IN_RESERVE
Amount of space to reserve at start of bulk IN buffers.
Definition: axge.h:177
#define AXGE_RX_CRC_ERROR
Receive packet CRC error.
Definition: axge.h:115
#define AXGE_RX_LEN_PAD_ALIGN
Receive packet length alignment.
Definition: axge.h:112
int open
Endpoint is open.
Definition: usb.h:418
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:173
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
An AXGE network device.
Definition: axge.h:139
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:212
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct net_device * netdev
Network device.
Definition: axge.h:145
#define DBGC_HDA(...)
Definition: compiler.h:506
static struct net_device * netdev
Definition: gdbudp.c:52
uint16_t count
Number of entries.
Definition: ena.h:22
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:160
#define iob_unput(iobuf, len)
Definition: iobuf.h:135
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
A network device.
Definition: netdevice.h:352
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
#define le16_to_cpu(value)
Definition: byteswap.h:112
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
#define iob_reserve(iobuf, len)
Definition: iobuf.h:67
#define AXGE_RX_LEN_MASK
Receive packet length mask.
Definition: axge.h:109
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
Receive packet descriptor.
Definition: axge.h:101
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33

References alloc_iob(), assert(), AXGE_IN_RESERVE, AXGE_RX_CRC_ERROR, AXGE_RX_DROP_ERROR, AXGE_RX_LEN_MASK, AXGE_RX_LEN_PAD_ALIGN, container_of, count, axge_rx_footer::count, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, desc, EINVAL, EIO, ENOBUFS, ENOMEM, error, free_iob(), usbnet_device::in, iob_disown, iob_len(), iob_pull, iob_put, iob_reserve, iob_unput, le16_to_cpu, len, memcpy(), netdev, axge_device::netdev, netdev_rx(), netdev_rx_err(), NULL, offset, axge_rx_footer::offset, usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and axge_device::usbnet.

◆ axge_out_transmit()

static int axge_out_transmit ( struct axge_device axge,
struct io_buffer iobuf 
)
static

Transmit packet.

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

Definition at line 470 of file axge.c.

471  {
472  struct axge_tx_header *hdr;
473  size_t len = iob_len ( iobuf );
474  int rc;
475 
476  /* Profile transmissions */
477  profile_start ( &axge_out_profiler );
478 
479  /* Prepend header */
480  if ( ( rc = iob_ensure_headroom ( iobuf, sizeof ( *hdr ) ) ) != 0 )
481  return rc;
482  hdr = iob_push ( iobuf, sizeof ( *hdr ) );
483  hdr->len = cpu_to_le32 ( len );
484  hdr->wtf = 0;
485 
486  /* Enqueue I/O buffer */
487  if ( ( rc = usb_stream ( &axge->usbnet.out, iobuf, 0 ) ) != 0 )
488  return rc;
489 
490  profile_stop ( &axge_out_profiler );
491  return 0;
492 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
#define iob_push(iobuf, len)
Definition: iobuf.h:84
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:545
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:173
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
Transmit packet header.
Definition: axge.h:85
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:160
#define cpu_to_le32(value)
Definition: byteswap.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition: iobuf.c:228
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
uint32_t len
Length.
Definition: ena.h:14

References cpu_to_le32, hdr, iob_ensure_headroom(), iob_len(), iob_push, len, usbnet_device::out, profile_start(), profile_stop(), rc, usb_stream(), and axge_device::usbnet.

Referenced by axge_transmit().

◆ axge_out_complete()

static void axge_out_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete bulk OUT transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 501 of file axge.c.

502  {
503  struct axge_device *axge = container_of ( ep, struct axge_device,
504  usbnet.out );
505  struct net_device *netdev = axge->netdev;
506 
507  /* Report TX completion */
508  netdev_tx_complete_err ( netdev, iobuf, rc );
509 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An AXGE network device.
Definition: axge.h:139
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct net_device * netdev
Network device.
Definition: axge.h:145
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:352
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:470
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147

References container_of, netdev, axge_device::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and axge_device::usbnet.

◆ axge_open()

static int axge_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 529 of file axge.c.

529  {
530  struct axge_device *axge = netdev->priv;
531  uint16_t rcr;
532  int rc;
533 
534  /* Reapply device configuration to avoid transaction errors */
535  if ( ( rc = usb_set_configuration ( axge->usb, axge->config ) ) != 0 ) {
536  DBGC ( axge, "AXGE %p could not set configuration: %s\n",
537  axge, strerror ( rc ) );
538  goto err_set_configuration;
539  }
540 
541  /* Open USB network device */
542  if ( ( rc = usbnet_open ( &axge->usbnet ) ) != 0 ) {
543  DBGC ( axge, "AXGE %p could not open: %s\n",
544  axge, strerror ( rc ) );
545  goto err_open;
546  }
547 
548  /* Set MAC address */
549  if ( ( rc = axge_write_register ( axge, AXGE_NIDR,
550  netdev->ll_addr, ETH_ALEN ) ) !=0){
551  DBGC ( axge, "AXGE %p could not set MAC address: %s\n",
552  axge, strerror ( rc ) );
553  goto err_write_mac;
554  }
555 
556  /* Enable receiver */
559  if ( ( rc = axge_write_word ( axge, AXGE_RCR, rcr ) ) != 0 ) {
560  DBGC ( axge, "AXGE %p could not write RCR: %s\n",
561  axge, strerror ( rc ) );
562  goto err_write_rcr;
563  }
564 
565  /* Update link status */
566  if ( ( rc = axge_check_link ( axge ) ) != 0 )
567  goto err_check_link;
568 
569  return 0;
570 
571  err_check_link:
572  axge_write_word ( axge, AXGE_RCR, 0 );
573  err_write_rcr:
574  err_write_mac:
575  usbnet_close ( &axge->usbnet );
576  err_open:
577  err_set_configuration:
578  return rc;
579 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
static int usb_set_configuration(struct usb_device *usb, unsigned int index)
Set USB configuration.
Definition: usb.h:1241
struct usb_device * usb
USB device.
Definition: axge.h:141
#define AXGE_RCR
RX Control Register.
Definition: axge.h:36
#define DBGC(...)
Definition: compiler.h:505
#define AXGE_RCR_SO
Start operation.
Definition: axge.h:40
#define AXGE_RCR_PRO
Promiscuous mode.
Definition: axge.h:37
An AXGE network device.
Definition: axge.h:139
static int axge_check_link(struct axge_device *axge)
Get link status.
Definition: axge.c:213
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define ETH_ALEN
Definition: if_ether.h:8
static int axge_write_word(struct axge_device *axge, unsigned int offset, uint16_t value)
Write two-byte register.
Definition: axge.c:180
#define AXGE_NIDR
Node ID Register.
Definition: axge.h:43
#define AXGE_RCR_AMALL
Accept all multicasts.
Definition: axge.h:38
#define cpu_to_le16(value)
Definition: byteswap.h:106
unsigned int config
Device configuration.
Definition: axge.h:149
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
static int axge_write_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Write register.
Definition: axge.c:150
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
#define AXGE_RCR_AB
Accept broadcasts.
Definition: axge.h:39
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:54

References axge_check_link(), AXGE_NIDR, AXGE_RCR, AXGE_RCR_AB, AXGE_RCR_AMALL, AXGE_RCR_PRO, AXGE_RCR_SO, axge_write_register(), axge_write_word(), axge_device::config, cpu_to_le16, DBGC, ETH_ALEN, net_device::ll_addr, netdev, net_device::priv, rc, strerror(), axge_device::usb, usb_set_configuration(), axge_device::usbnet, usbnet_close(), and usbnet_open().

◆ axge_close()

static void axge_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 586 of file axge.c.

586  {
587  struct axge_device *axge = netdev->priv;
588 
589  /* Disable receiver */
590  axge_write_word ( axge, AXGE_RCR, 0 );
591 
592  /* Close USB network device */
593  usbnet_close ( &axge->usbnet );
594 }
#define AXGE_RCR
RX Control Register.
Definition: axge.h:36
An AXGE network device.
Definition: axge.h:139
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int axge_write_word(struct axge_device *axge, unsigned int offset, uint16_t value)
Write two-byte register.
Definition: axge.c:180
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147

References AXGE_RCR, axge_write_word(), netdev, net_device::priv, axge_device::usbnet, and usbnet_close().

◆ axge_transmit()

static int axge_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 603 of file axge.c.

604  {
605  struct axge_device *axge = netdev->priv;
606  int rc;
607 
608  /* Transmit packet */
609  if ( ( rc = axge_out_transmit ( axge, iobuf ) ) != 0 )
610  return rc;
611 
612  return 0;
613 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An AXGE network device.
Definition: axge.h:139
static int axge_out_transmit(struct axge_device *axge, struct io_buffer *iobuf)
Transmit packet.
Definition: axge.c:470
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52

References axge_out_transmit(), netdev, net_device::priv, and rc.

◆ axge_poll()

static void axge_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 620 of file axge.c.

620  {
621  struct axge_device *axge = netdev->priv;
622  int rc;
623 
624  /* Poll USB bus */
625  usb_poll ( axge->bus );
626 
627  /* Refill endpoints */
628  if ( ( rc = usbnet_refill ( &axge->usbnet ) ) != 0 )
629  netdev_rx_err ( netdev, NULL, rc );
630 
631  /* Update link state, if applicable */
632  if ( axge->check_link ) {
633  if ( ( rc = axge_check_link ( axge ) ) == 0 ) {
634  axge->check_link = 0;
635  } else {
636  netdev_rx_err ( netdev, NULL, rc );
637  }
638  }
639 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
struct usb_bus * bus
USB bus.
Definition: axge.h:143
An AXGE network device.
Definition: axge.h:139
static int axge_check_link(struct axge_device *axge)
Get link status.
Definition: axge.c:213
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:151
int check_link
Link state has changed.
Definition: axge.h:151
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1071
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References axge_check_link(), axge_device::bus, axge_device::check_link, netdev, netdev_rx_err(), NULL, net_device::priv, rc, usb_poll(), axge_device::usbnet, and usbnet_refill().

◆ axge_probe()

static int axge_probe ( struct usb_function func,
struct usb_configuration_descriptor config 
)
static

Probe device.

Parameters
funcUSB function
configConfiguration descriptor
Return values
rcReturn status code

Definition at line 663 of file axge.c.

664  {
665  struct usb_device *usb = func->usb;
666  struct net_device *netdev;
667  struct axge_device *axge;
668  uint16_t epprcr;
669  uint8_t csr;
670  int rc;
671 
672  /* Allocate and initialise structure */
673  netdev = alloc_etherdev ( sizeof ( *axge ) );
674  if ( ! netdev ) {
675  rc = -ENOMEM;
676  goto err_alloc;
677  }
679  netdev->dev = &func->dev;
680  axge = netdev->priv;
681  memset ( axge, 0, sizeof ( *axge ) );
682  axge->usb = usb;
683  axge->bus = usb->port->hub->bus;
684  axge->netdev = netdev;
685  axge->config = config->config;
686  usbnet_init ( &axge->usbnet, func, &axge_intr_operations,
688  usb_refill_init ( &axge->usbnet.intr, 0, 0, AXGE_INTR_MAX_FILL );
691  DBGC ( axge, "AXGE %p on %s\n", axge, func->name );
692 
693  /* Describe USB network device */
694  if ( ( rc = usbnet_describe ( &axge->usbnet, config ) ) != 0 ) {
695  DBGC ( axge, "AXGE %p could not describe: %s\n",
696  axge, strerror ( rc ) );
697  goto err_describe;
698  }
699 
700  /* Fetch MAC address */
701  if ( ( rc = axge_read_register ( axge, AXGE_NIDR, netdev->hw_addr,
702  ETH_ALEN ) ) != 0 ) {
703  DBGC ( axge, "AXGE %p could not fetch MAC address: %s\n",
704  axge, strerror ( rc ) );
705  goto err_read_mac;
706  }
707 
708  /* Power up PHY */
709  if ( ( rc = axge_write_word ( axge, AXGE_EPPRCR, 0 ) ) != 0 ) {
710  DBGC ( axge, "AXGE %p could not write EPPRCR: %s\n",
711  axge, strerror ( rc ) );
712  goto err_write_epprcr_off;
713  }
714  epprcr = cpu_to_le16 ( AXGE_EPPRCR_IPRL );
715  if ( ( rc = axge_write_word ( axge, AXGE_EPPRCR, epprcr ) ) != 0){
716  DBGC ( axge, "AXGE %p could not write EPPRCR: %s\n",
717  axge, strerror ( rc ) );
718  goto err_write_epprcr_on;
719  }
721 
722  /* Select clocks */
723  csr = ( AXGE_CSR_BCS | AXGE_CSR_ACS );
724  if ( ( rc = axge_write_byte ( axge, AXGE_CSR, csr ) ) != 0){
725  DBGC ( axge, "AXGE %p could not write CSR: %s\n",
726  axge, strerror ( rc ) );
727  goto err_write_csr;
728  }
730 
731  /* Configure bulk IN pipeline */
732  if ( ( rc = axge_write_register ( axge, AXGE_BICR, &axge_bicr,
733  sizeof ( axge_bicr ) ) ) != 0 ){
734  DBGC ( axge, "AXGE %p could not write BICR: %s\n",
735  axge, strerror ( rc ) );
736  goto err_write_bicr;
737  }
738 
739  /* Register network device */
740  if ( ( rc = register_netdev ( netdev ) ) != 0 )
741  goto err_register;
742 
743  /* Update link status */
744  if ( ( rc = axge_check_link ( axge ) ) != 0 )
745  goto err_check_link;
746 
747  usb_func_set_drvdata ( func, axge );
748  return 0;
749 
750  err_check_link:
752  err_register:
753  err_write_bicr:
754  err_write_csr:
755  err_write_epprcr_on:
756  err_write_epprcr_off:
757  err_read_mac:
758  err_describe:
760  netdev_put ( netdev );
761  err_alloc:
762  return rc;
763 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
#define AXGE_EPPRCR_IPRL
Undocumented.
Definition: axge.h:56
const char * name
Name.
Definition: usb.h:675
struct usb_device * usb
USB device.
Definition: axge.h:141
#define AXGE_EPPRCR_DELAY_MS
Delay after initialising EPPRCR.
Definition: axge.h:59
struct usb_bus * bus
USB bus.
Definition: axge.h:143
#define DBGC(...)
Definition: compiler.h:505
#define AXGE_IN_RESERVE
Amount of space to reserve at start of bulk IN buffers.
Definition: axge.h:177
#define AXGE_INTR_MAX_FILL
Interrupt maximum fill level.
Definition: axge.h:158
struct usb_endpoint intr
Interrupt endpoint.
Definition: usbnet.h:27
static struct axge_bulk_in_control axge_bicr
Default bulk IN configuration.
Definition: axge.c:68
static struct net_device_operations axge_operations
AXGE network device operations.
Definition: axge.c:642
An AXGE network device.
Definition: axge.h:139
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
#define ENOMEM
Not enough space.
Definition: errno.h:534
static int axge_check_link(struct axge_device *axge)
Get link status.
Definition: axge.c:213
struct usb_port * port
USB port.
Definition: usb.h:726
#define AXGE_CSR_DELAY_MS
Delay after initialising CSR.
Definition: axge.h:82
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
struct net_device * netdev
Network device.
Definition: axge.h:145
#define AXGE_CSR
Clock Select Register (undocumented)
Definition: axge.h:77
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition: usb.h:616
static struct net_device * netdev
Definition: gdbudp.c:52
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:706
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A USB device.
Definition: usb.h:722
#define AXGE_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: axge.h:164
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
#define AXGE_CSR_BCS
Undocumented.
Definition: axge.h:78
#define AXGE_BICR
Bulk IN Control Register (undocumented)
Definition: axge.h:62
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
unsigned char uint8_t
Definition: stdint.h:10
#define ETH_ALEN
Definition: if_ether.h:8
struct usb_device * usb
USB device.
Definition: usb.h:677
static struct usb_endpoint_driver_operations axge_intr_operations
Interrupt endpoint operations.
Definition: axge.c:328
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static int axge_write_word(struct axge_device *axge, unsigned int offset, uint16_t value)
Write two-byte register.
Definition: axge.c:180
#define AXGE_NIDR
Node ID Register.
Definition: axge.h:43
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define AXGE_CSR_ACS
Undocumented.
Definition: axge.h:79
static int axge_read_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Read register.
Definition: axge.c:91
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
Definition: usbnet.h:44
struct usb_hub * hub
USB hub.
Definition: usb.h:814
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
static struct usb_endpoint_driver_operations axge_out_operations
Bulk OUT endpoint operations.
Definition: axge.c:512
#define cpu_to_le16(value)
Definition: byteswap.h:106
unsigned int config
Device configuration.
Definition: axge.h:149
static struct usb_endpoint_driver_operations axge_in_operations
Bulk IN endpoint operations.
Definition: axge.c:459
#define AXGE_EPPRCR
Ethernet PHY Power and Reset Control Register.
Definition: axge.h:55
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:277
struct device dev
Generic device.
Definition: usb.h:681
static int axge_write_register(struct axge_device *axge, unsigned int offset, void *data, size_t len)
Write register.
Definition: axge.c:150
struct usb_bus * bus
USB bus.
Definition: usb.h:844
static int axge_write_byte(struct axge_device *axge, unsigned int offset, uint8_t value)
Write one-byte register.
Definition: axge.c:166
struct usbnet_device usbnet
USB network device.
Definition: axge.h:147
#define AXGE_IN_MTU
Bulk IN buffer size.
Definition: axge.h:170
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_etherdev(), axge_bicr, AXGE_BICR, axge_check_link(), AXGE_CSR, AXGE_CSR_ACS, AXGE_CSR_BCS, AXGE_CSR_DELAY_MS, AXGE_EPPRCR, AXGE_EPPRCR_DELAY_MS, AXGE_EPPRCR_IPRL, AXGE_IN_MAX_FILL, AXGE_IN_MTU, axge_in_operations, AXGE_IN_RESERVE, AXGE_INTR_MAX_FILL, axge_intr_operations, AXGE_NIDR, axge_operations, axge_out_operations, axge_read_register(), axge_write_byte(), axge_write_register(), axge_write_word(), axge_device::bus, usb_hub::bus, axge_device::config, cpu_to_le16, DBGC, net_device::dev, usb_function::dev, ENOMEM, ETH_ALEN, usb_port::hub, net_device::hw_addr, usbnet_device::in, usbnet_device::intr, mdelay(), memset(), usb_function::name, netdev, axge_device::netdev, netdev_init(), netdev_nullify(), netdev_put(), usb_device::port, net_device::priv, rc, register_netdev(), strerror(), unregister_netdev(), axge_device::usb, usb_function::usb, usb_func_set_drvdata(), usb_refill_init(), axge_device::usbnet, usbnet_describe(), and usbnet_init().

◆ axge_remove()

static void axge_remove ( struct usb_function func)
static

Remove device.

Parameters
funcUSB function

Definition at line 770 of file axge.c.

770  {
771  struct axge_device *axge = usb_func_get_drvdata ( func );
772  struct net_device *netdev = axge->netdev;
773 
776  netdev_put ( netdev );
777 }
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:717
An AXGE network device.
Definition: axge.h:139
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
struct net_device * netdev
Network device.
Definition: axge.h:145
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528

References netdev, axge_device::netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().

Variable Documentation

◆ __profiler

struct profiler axge_out_profiler __profiler
static
Initial value:
=
{ .name = "axge.intr" }

Interrupt completion profiler.

Bulk OUT profiler.

Bulk IN completion profiler.

Definition at line 47 of file axge.c.

◆ axge_bicr

struct axge_bulk_in_control axge_bicr
static
Initial value:
= {
.ctrl = 7,
.timer = cpu_to_le16 ( 0 ),
.size = 0,
.ifg = 0,
}
#define cpu_to_le16(value)
Definition: byteswap.h:106

Default bulk IN configuration.

The Linux and FreeBSD drivers have set of magic constants which are chosen based on both the Ethernet and USB link speeds.

Experimentation shows that setting the "timer" value to zero seems to prevent the device from ever coalescing multiple packets into a single bulk IN transfer. This allows us to get away with using a 2kB receive I/O buffer and a zerocopy receive path.

Definition at line 68 of file axge.c.

Referenced by axge_probe().

◆ axge_intr_operations

struct usb_endpoint_driver_operations axge_intr_operations
static
Initial value:
= {
.complete = axge_intr_complete,
}
static void axge_intr_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
Definition: axge.c:268

Interrupt endpoint operations.

Definition at line 328 of file axge.c.

Referenced by axge_probe().

◆ axge_in_operations

struct usb_endpoint_driver_operations axge_in_operations
static
Initial value:
= {
.complete = axge_in_complete,
}
static void axge_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition: axge.c:346

Bulk IN endpoint operations.

Definition at line 459 of file axge.c.

Referenced by axge_probe().

◆ axge_out_operations

struct usb_endpoint_driver_operations axge_out_operations
static
Initial value:
= {
.complete = axge_out_complete,
}
static void axge_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
Definition: axge.c:501

Bulk OUT endpoint operations.

Definition at line 512 of file axge.c.

Referenced by axge_probe().

◆ axge_operations

struct net_device_operations axge_operations
static
Initial value:
= {
.open = axge_open,
.close = axge_close,
.transmit = axge_transmit,
.poll = axge_poll,
}
static void axge_close(struct net_device *netdev)
Close network device.
Definition: axge.c:586
static void axge_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: axge.c:620
static int axge_open(struct net_device *netdev)
Open network device.
Definition: axge.c:529
static int axge_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: axge.c:603

AXGE network device operations.

Definition at line 642 of file axge.c.

Referenced by axge_probe().

◆ axge_ids

struct usb_device_id axge_ids[]
static

AXGE device IDs.

Definition at line 780 of file axge.c.

◆ __usb_driver

struct usb_driver axge_driver __usb_driver
Initial value:
= {
.ids = axge_ids,
.id_count = ( sizeof ( axge_ids ) / sizeof ( axge_ids[0] ) ),
.score = USB_SCORE_NORMAL,
.probe = axge_probe,
.remove = axge_remove,
}
static void axge_remove(struct usb_function *func)
Remove device.
Definition: axge.c:770
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1388
static int axge_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: axge.c:663
Normal driver.
Definition: usb.h:1452
#define USB_ANY_ID
Match-anything ID.
Definition: usb.h:1372
static struct usb_device_id axge_ids[]
AXGE device IDs.
Definition: axge.c:780

AXGE driver.

Definition at line 814 of file axge.c.