
This is a driver-breaking update to the netdriver library, which is used by all network drivers. The aim of this change is to make the library more compatible with NetBSD, and in particular with various features that are expected to be supported by the NetBSD userland. The main changes made by this patch are the following: - each network driver now has a NetBSD-style short device name; - drivers are not expected to receive packets right after startup; - extended support for receipt modes, including multicast lists; - support for multiple parallel send, receive requests; - embedding of I/O vectors in send and receive requests; - support for capabilities, including checksum offloading; - support for reporting link status updates to the TCP/IP stack; - support for setting and retrieving media status; - support for changing the hardware (MAC) address; - support for NetBSD interface flags IFF_DEBUG, IFF_LINK[0-2]; - support for NetBSD error statistics; - support for regular time-based ("tick") callbacks. IMPORTANT: this patch applies a minimal update to the existing drivers in order to make them work at all with the new netdriver library. It however does *not* change all drivers to make use of the new features. In fact, strictly speaking, all drivers are now violating requirements imposed by the new library in one way or another, most notably by enabling packet receipt when starting the driver. Changing all the drivers to be compliant, and to support the newly added options, is left to future patches. The existing drivers should currently *not* be taken as examples of how to implement a new network driver! With that said, a few drivers have already been changed to make use of some of the new features: fxp, e1000, rtl8139, and rtl8169 now report link and media status, and the last three of those now support setting the hardware MAC address on the fly. In addition, dp8390 has been changed to default to PCI autoconfiguration if no configuration is specified through environment variables. Change-Id: I4b3ea9c0b9bc25d5b0609c6ff256fb0db71cdc42
94 lines
2.3 KiB
C
94 lines
2.3 KiB
C
#ifndef LAN8710A_H_
|
|
#define LAN8710A_H_
|
|
|
|
#define LAN8710A_DEBUG (1)
|
|
|
|
#if LAN8710A_DEBUG == 1
|
|
#define LAN8710A_DEBUG_PRINT(args) \
|
|
do { \
|
|
printf("LAN8710A DEBUG: "); \
|
|
printf args; \
|
|
printf("\n"); \
|
|
} while (0)
|
|
#else
|
|
#define LAN8710A_DEBUG_PRINT(args)
|
|
#endif
|
|
|
|
/* Ethernet driver defines */
|
|
#define LAN8710A_NAME_LEN (11)
|
|
|
|
/* Descriptors flags */
|
|
#define LAN8710A_DESC_FLAG_OWN (1 << 29) /* ownership flag */
|
|
#define LAN8710A_DESC_FLAG_SOP (1 << 31) /* start of packet flag */
|
|
#define LAN8710A_DESC_FLAG_EOP (1 << 30) /* end of packet flag */
|
|
|
|
/* Number of Tx and Rx interrupts */
|
|
#define LAN8710A_RX_INTR (41)
|
|
#define LAN8710A_TX_INTR (42)
|
|
|
|
/* Values to be written after interrupt handle and interrupt masks*/
|
|
#define RX_INT (1)
|
|
#define TX_INT (2)
|
|
|
|
/** Numbers of Tx DMA channels */
|
|
#define TX_DMA_CHANNELS (8)
|
|
|
|
/** Number of transmit descriptors */
|
|
#define LAN8710A_NUM_TX_DESC (255)
|
|
|
|
/** Number of receive descriptors */
|
|
#define LAN8710A_NUM_RX_DESC (255)
|
|
|
|
/** Size of each I/O buffer per descriptor. */
|
|
#define LAN8710A_IOBUF_SIZE (1520)
|
|
|
|
/** MAC address override variable. */
|
|
#define LAN8710A_ENVVAR "LAN8710AETH"
|
|
|
|
/** MAX DMA Channels */
|
|
#define DMA_MAX_CHANNELS (8)
|
|
|
|
/* Setting of Tx descriptors */
|
|
#define TX_DESC_TO_PORT1 (1 << 16)
|
|
#define TX_DESC_TO_PORT_EN (1 << 20)
|
|
|
|
typedef struct lan8710a_desc_t
|
|
{
|
|
u32_t next_pointer;
|
|
u32_t buffer_pointer;
|
|
u32_t buffer_length_off;
|
|
u32_t pkt_len_flags;
|
|
} lan8710a_desc_t;
|
|
|
|
typedef struct lan8710a_t
|
|
{
|
|
lan8710a_desc_t *rx_desc;
|
|
lan8710a_desc_t *tx_desc;
|
|
phys_bytes rx_desc_phy;
|
|
phys_bytes tx_desc_phy;
|
|
int irq_rx_hook; /* Rx interrupt Request Vector Hook. */
|
|
int irq_tx_hook; /* Tx interrupt Request Vector Hook. */
|
|
u8_t *regs;
|
|
u32_t phy_address;
|
|
u8_t *p_rx_buf; /* pointer to the buffer with receive frames */
|
|
u8_t *p_tx_buf; /* pointer to the buffer with transmit frames */
|
|
|
|
u16_t tx_desc_idx; /* index of the next transmit desciptor */
|
|
u16_t rx_desc_idx; /* index of the next receive desciptor */
|
|
|
|
/* register mapping */
|
|
vir_bytes regs_cp_per;
|
|
vir_bytes regs_mdio;
|
|
vir_bytes regs_cpsw_cpdma;
|
|
vir_bytes regs_ctrl_mod;
|
|
vir_bytes regs_cpsw_sl;
|
|
vir_bytes regs_cpsw_ss;
|
|
vir_bytes regs_cpsw_stats;
|
|
vir_bytes regs_cpsw_ale;
|
|
vir_bytes regs_cpsw_wr;
|
|
vir_bytes regs_intc;
|
|
vir_bytes regs_cpdma_stram;
|
|
} lan8710a_t;
|
|
|
|
#endif /* LAN8710A_H_ */
|