
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
139 lines
3.0 KiB
C
139 lines
3.0 KiB
C
#ifndef _NDR_H
|
|
#define _NDR_H
|
|
|
|
/* ======= General Parameter ======= */
|
|
/* Global configure */
|
|
|
|
#include <minix/drivers.h>
|
|
|
|
#define DRIVER_NAME "VT6105"
|
|
|
|
/* Rx/Tx buffer parameter */
|
|
#define RX_BUF_SIZE 1536
|
|
#define TX_BUF_SIZE 1536
|
|
#define RX_BUFFER_NUM 64
|
|
#define TX_BUFFER_NUM 64
|
|
|
|
/* Interrupt status */
|
|
#define INTR_STS_LINK 0x4000
|
|
#define INTR_STS_RX 0x0001
|
|
#define INTR_STS_TX 0x0002
|
|
|
|
/* Link status */
|
|
#define LINK_UP 1
|
|
#define LINK_DOWN 0
|
|
#define LINK_UNKNOWN -1
|
|
|
|
/* Interrupt control */
|
|
#define INTR_ENABLE 1
|
|
#define INTR_DISABLE 0
|
|
|
|
/* Rx status */
|
|
#define RX_ERROR 1
|
|
#define RX_OK 0
|
|
#define RX_SUSPEND -1
|
|
|
|
/* Tx status */
|
|
#define TX_ERROR 1
|
|
#define TX_OK 0
|
|
#define TX_SUSPEND -1
|
|
|
|
/* Rx/Tx control */
|
|
#define RX_TX_ENABLE 1
|
|
#define RX_TX_DISABLE 0
|
|
|
|
/* ======= Self-defined Parameter ======= */
|
|
#define DESC_OWN 0x80000000
|
|
#define DESC_FIRST 0x00000200
|
|
#define DESC_LAST 0x00000100
|
|
#define DESC_RX_LENMASK 0x7fff0000
|
|
#define DESC_RX_ERROR 0x000000bf
|
|
#define DESC_RX_NORMAL (DESC_FIRST | DESC_LAST)
|
|
#define DESC_TX_ERROR 0x00008f10
|
|
|
|
#define REG_ADDR 0x00
|
|
#define REG_RCR 0x06
|
|
#define REG_TCR 0x07
|
|
#define REG_CR 0x08
|
|
#define REG_IMR 0x0e
|
|
#define REG_ISR 0x0c
|
|
#define REG_RX_DESC_BASE 0x18
|
|
#define REG_TX_DESC_BASE 0x1c
|
|
#define REG_MII_PHY 0x6c
|
|
#define REG_BCR 0x6e
|
|
#define REG_MII_CR 0x70
|
|
#define REG_MII_REG 0x71
|
|
#define REG_MII_DATA 0x72
|
|
#define REG_MCR 0x81
|
|
#define REG_STICK 0x83
|
|
|
|
#define CMD_START 0x0002
|
|
#define CMD_STOP 0x0004
|
|
#define CMD_RX_ON 0x0008
|
|
#define CMD_TX_ON 0x0010
|
|
#define CMD_TX_DEMAND 0x0020
|
|
#define CMD_RX_DEMAND 0x0040
|
|
#define CMD_FDUPLEX 0x0400
|
|
#define CMD_NO_POLL 0x0800
|
|
#define CMD_RESET 0x8000
|
|
#define CMD_INTR_ENABLE 0xfeff
|
|
#define CMD_RCR_UNICAST 0x10
|
|
#define CMD_RCR_MULTICAST 0x04
|
|
#define CMD_RCR_BROADCAST 0x08
|
|
#define INTR_STS_CLEAR 0xbfbf
|
|
#define LINK_STATUS 0x0004
|
|
|
|
/* ======= Data Descriptor ======= */
|
|
typedef struct NDR_desc {
|
|
u32_t status;
|
|
u32_t length;
|
|
u32_t addr;
|
|
u32_t next;
|
|
} NDR_desc;
|
|
|
|
/* Driver Data Structure */
|
|
typedef struct NDR_driver {
|
|
char *dev_name; /* Device name */
|
|
u16_t vid, did; /* Vendor and device ID */
|
|
u32_t devind; /* Device index */
|
|
u32_t base[6]; /* Base address */
|
|
char irq; /* IRQ number */
|
|
char revision; /* Revision ID */
|
|
|
|
int mode;
|
|
int link; /* Whether link-up */
|
|
int recv_flag; /* Receive flag */
|
|
int send_flag; /* Send flag */
|
|
int tx_busy; /* Whether Tx is busy */
|
|
|
|
/* Buffer */
|
|
size_t buf_size;
|
|
char *buf;
|
|
|
|
/* Rx data */
|
|
int rx_head;
|
|
struct {
|
|
phys_bytes buf_dma;
|
|
char *buf;
|
|
} rx[RX_BUFFER_NUM];
|
|
|
|
/* Tx data */
|
|
int tx_head;
|
|
int tx_tail;
|
|
struct {
|
|
int busy;
|
|
phys_bytes buf_dma;
|
|
char *buf;
|
|
} tx[TX_BUFFER_NUM];
|
|
int tx_busy_num; /* Number of busy Tx buffer */
|
|
|
|
NDR_desc *rx_desc; /* Rx descriptor buffer */
|
|
phys_bytes rx_desc_dma; /* Rx descriptor DMA buffer */
|
|
NDR_desc *tx_desc; /* Tx descriptor buffer */
|
|
phys_bytes tx_desc_dma; /* Tx descriptor DMA buffer */
|
|
|
|
int hook; /* IRQ hook id at kernel */
|
|
} NDR_driver;
|
|
|
|
#endif
|