Browse Source

[eepro100] Convert to native gPXE API

This version is Based on Michael Decker's GSoC 2008 code.
A number cleanups and fixes were applied.

Earlier-version-reviewed-by: Marty Connor <mdc@etherboot.org>
Earlier-version-tested-by: Marty Connor <mdc@etherboot.org>
Earlier-version-tested-by: Shao Miller <Shao.Miller@yrdsb.edu.on.ca>
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
Reviewed-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Thomas Miletich 14 years ago
parent
commit
cdcb4165bd
2 changed files with 1197 additions and 639 deletions
  1. 993
    639
      src/drivers/net/eepro100.c
  2. 204
    0
      src/drivers/net/eepro100.h

+ 993
- 639
src/drivers/net/eepro100.c
File diff suppressed because it is too large
View File


+ 204
- 0
src/drivers/net/eepro100.h View File

@@ -0,0 +1,204 @@
1
+
2
+#ifndef __EEPRO100_H_
3
+#define __EEPRO100_H_
4
+
5
+#define CONGENB         0	/* Enable congestion control in the DP83840. */
6
+#define TX_FIFO         8	/* Tx FIFO threshold in 4 byte units, 0-15 */
7
+#define RX_FIFO         8	/* Rx FIFO threshold, default 32 bytes. */
8
+#define TX_DMA_COUNT    0	/* Tx DMA burst length, 0-127, default 0. */
9
+#define RX_DMA_COUNT    0	/* Rx DMA length, 0 means no preemption. */
10
+#define CU_CMD_TIMEOUT  1000	/* CU command accept timeout in microseconds */
11
+#define LINK_CHECK_PERIOD 1000	/* # of poll() calls between link checks */
12
+
13
+#define RFD_PACKET_LEN  1518
14
+#define RFD_IOB_LEN     1536
15
+#define RFD_HEADER_LEN  16
16
+#define CB_ALIGN        2	/* Alignment of command blocks */
17
+
18
+#define RFD_COUNT       4
19
+#define TCB_COUNT       4
20
+#define RX_RING_BYTES   ( RFD_COUNT * sizeof ( struct ifec_rfd ) )
21
+#define TX_RING_BYTES   ( TCB_COUNT * sizeof ( struct ifec_tcb ) )
22
+
23
+/* some EEPROM addresses */
24
+#define EEPROM_ADDR_MAC_0		0
25
+#define EEPROM_ADDR_MDIO_REGISTER	6
26
+
27
+/* Control / Status Register byte offsets - SDM Table 11 */
28
+enum CSROffsets {
29
+	SCBStatus=0,             SCBCmd=2,              SCBPointer = 4,
30
+	CSRPort=8,               CSRFlash=12,           CSREeprom = 14,
31
+	CSRCtrlMDI=16,           CSREarlyRx=20
32
+};
33
+
34
+/* System Control Block Command Word - SDM Table 12 */
35
+enum SCBCmdBits {
36
+	/* SCB Interrupt Masks - SDM Table 14 */
37
+	SCBMaskCmdDone=0x8000,   SCBMaskRxDone=0x4000,  SCBMaskCmdIdle=0x2000,
38
+	SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
39
+	SCBTriggerIntr=0x0200,   SCBMaskAll=0x0100,
40
+	/* SCB Control Commands - SDM Table 14-16 */
41
+	CUStart=0x0010,          CUResume=0x0020,       CUStatsAddr=0x0040,
42
+	CUShowStats=0x0050,      CUCmdBase=0x0060,      CUDumpStats=0x0070,
43
+	RUStart=0x0001,          RUResume=0x0002,       RUAbort=0x0004,
44
+	RUAddrLoad=0x0006,       RUResumeNoResources=0x0007
45
+};
46
+
47
+enum SCBPortCmds {
48
+	PortReset=0, PortSelfTest=1, PortPartialReset=2, PortDump=3
49
+};
50
+
51
+/* Action Commands - SDM Table 14,37 */
52
+enum ActionCommands {
53
+	CmdNOp = 0,              CmdIASetup = 1,        CmdConfigure = 2,
54
+	CmdMulticastList = 3,    CmdTx = 4,             CmdTDR = 5,
55
+	CmdDump = 6,             CmdDiagnose = 7,
56
+	/* And some extra flags: */
57
+	CmdEndOfList = 0x8000,
58
+	CmdSuspend = 0x4000,     CmdIntr = 0x2000,      CmdTxFlex = 0x0008
59
+};
60
+
61
+enum TCBBits {
62
+	TCB_C=0x8000,            TCB_OK=0x2000,         TCB_U=0x1000
63
+};
64
+
65
+enum RFDBits {
66
+	/* Status Word Bits */
67
+	RFDRxCol=0x0001,         RFDIAMatch=0x0002,     RFDNoMatch=0x0004,
68
+	RFDReserved3=0x0008,     RFDRxErr=0x0010,       RFDEthType=0x0020,
69
+	RFDReserved6=0x0040,     RFDShort=0x0080,       RFDDMAOverrun=0x0100,
70
+	RFDNoBufs=0x0200,        RFDCRCAlign=0x0400,    RFDCRCError=0x0800,
71
+	RFDReserved12=0x1000,    RFD_OK=0x2000,         RFDComplete=0x8000,
72
+	/* Command Word Bits */
73
+	//RFD_SF=0x0008,           RFDSuspend=0x4000,     RFDEndOfList=0x8000,
74
+	/* Other */
75
+	RFDMaskCount=0x3FFF
76
+};
77
+
78
+enum phy_chips {
79
+	NonSuchPhy=0,            I82553AB,              I82553C,
80
+	I82503,                  DP83840,               S80C240,
81
+	S80C24,                  PhyUndefined,          DP83840A=10
82
+};
83
+
84
+/* Serial EEPROM section.
85
+   A "bit" grungy, but we work our way through bit-by-bit :->. */
86
+/*  EEPROM_Ctrl bits. */
87
+#define EE_SHIFT_CLK    0x01    /* EEPROM shift clock. */
88
+#define EE_CS           0x02    /* EEPROM chip select. */
89
+#define EE_DATA_WRITE   0x04    /* EEPROM chip data in. */
90
+#define EE_DATA_READ    0x08    /* EEPROM chip data out. */
91
+#define EE_ENB          ( 0x4800 | EE_CS )
92
+
93
+/* Elements of the dump_statistics block. This block must be lword aligned. */
94
+struct ifec_stats {
95
+	u32
96
+	tx_good_frames,          tx_coll16_errs,        tx_late_colls,
97
+	tx_underruns,            tx_lost_carrier,       tx_deferred,
98
+	tx_one_colls,            tx_multi_colls,        tx_total_colls,
99
+	rx_good_frames,          rx_crc_errs,           rx_align_errs,
100
+	rx_resource_errs,        rx_overrun_errs,       rx_colls_errs,
101
+	rx_runt_errs,            done_marker;
102
+};
103
+
104
+struct ifec_tcb {                  /* A Transmit Command Block & TBD. Must be */
105
+	volatile s16 status;       /*             word (even address) aligned */
106
+	u16          command;
107
+	u32          link;         /* PHYSICAL next ifec_tcb, doesn't change */
108
+	u32          tbda_addr;    /* TBD Array, points to TBD below */
109
+	s32          count;        /* # of TBD, Tx start thresh., etc. */
110
+	/* The following constitutes a Transmit Buffer Descriptor (TBD).
111
+	 * TBDs must be aligned on an even address (word-aligned). */
112
+	u32          tbd_addr0;    /* PHYSICAL ptr to Tx data */
113
+	s32          tbd_size0;    /* Length of Tx data */
114
+	/* Driver-specific data; not part of TCB format. */
115
+	struct io_buffer *iob;     /* Exists from tx() to completion poll() */
116
+	struct ifec_tcb  *next;    /* VIRTUAL next ifec_tcb, doesn't change */
117
+};
118
+
119
+struct ifec_rfd {              /* A Receive Frame Descriptor. Must be aligned */
120
+	volatile s16 status;   /*           on a physical word (even address) */
121
+	s16          command;
122
+	u32          link;          /* PHYSICAL next ifec_rfd, doesn't change */
123
+	u32          rx_buf_addr;   /* Unused. Flex rx mode is not documented */
124
+	u16          count;         /*                  and may be impossible */
125
+	u16          size;
126
+	char         packet[RFD_PACKET_LEN];
127
+};
128
+
129
+struct ifec_ias {              /* Individual Address Setup command block. */
130
+	volatile s16 status;   /* Must be word (even address) aligned. */
131
+	u16          command;
132
+	u32          link;     /* PHYSICAL next command block to process */
133
+	u8           ia[6];
134
+};
135
+
136
+struct ifec_cfg {                   /* The configure command format. */
137
+	volatile s16 status;
138
+	u16          command;
139
+	u32          link;          /* PHYSICAL next command block to process */
140
+	u8           byte[22];      /* 22 configuration bytes */
141
+};
142
+
143
+struct ifec_private {
144
+	unsigned long         ioaddr;
145
+	struct ifec_stats     stats;
146
+	unsigned short        mdio_register;
147
+
148
+	struct ifec_tcb      *tcbs;
149
+	struct ifec_rfd      *rfds[RFD_COUNT];
150
+	struct ifec_tcb      *tcb_head, *tcb_tail;
151
+	struct io_buffer     *tx_iobs[TCB_COUNT];
152
+	struct io_buffer     *rx_iobs[RFD_COUNT];
153
+	int		      cur_rx;
154
+	int		      tx_curr;
155
+	int		      tx_tail;
156
+	int		      tx_cnt;
157
+	/*
158
+	 * The configured flag indicates if a Config command was last issued.
159
+	 * The following attempt to issue a command (in ifec_tx_wake) will
160
+	 * use a START rather than RESUME SCB command. It seems the card won't
161
+	 * RESUME after a configure command.
162
+	 */
163
+	int                   configured;
164
+	struct spi_bit_basher spi;
165
+	struct spi_device     eeprom;
166
+	
167
+};
168
+
169
+/**************************** Function prototypes ****************************/
170
+
171
+/* PCI device API prototypes */
172
+static int  ifec_pci_probe  ( struct pci_device*, const struct pci_device_id*);
173
+static void ifec_pci_remove ( struct pci_device *pci );
174
+
175
+/* Network device API prototypes */
176
+static void ifec_net_close    ( struct net_device* );
177
+static void ifec_net_irq      ( struct net_device*, int enable );
178
+static int  ifec_net_open     ( struct net_device* );
179
+static void ifec_net_poll     ( struct net_device* );
180
+static int  ifec_net_transmit ( struct net_device*, struct io_buffer *iobuf );
181
+
182
+/* Local function prototypes */
183
+static void ifec_init_eeprom     ( struct net_device * );
184
+static int  ifec_link_check      ( struct net_device * );
185
+static void ifec_link_update     ( struct net_device * );
186
+static int  ifec_mdio_read       ( struct net_device *, int phy, int location );
187
+static void ifec_mdio_setup      ( struct net_device *, int options );
188
+static int  ifec_mdio_write      ( struct net_device *, int phy, int loc, int val);
189
+static void ifec_reset           ( struct net_device * );
190
+static void ifec_free            ( struct net_device * );
191
+static void ifec_rfd_init        ( struct ifec_rfd *rfd, s16 command, u32 link );
192
+static void  ifec_rx_process     ( struct net_device * );
193
+static void ifec_reprime_ru      ( struct net_device * );
194
+static void ifec_check_ru_status ( struct net_device *, unsigned short );
195
+static int  ifec_get_rx_desc     ( struct net_device *, int ,int ,int );
196
+static void ifec_refill_rx_ring  ( struct net_device * );
197
+static int  ifec_rx_setup        ( struct net_device * );
198
+static int  ifec_scb_cmd         ( struct net_device *, u32 ptr, u8 cmd );
199
+static int  ifec_scb_cmd_wait    ( struct net_device * );
200
+static void ifec_tx_process      ( struct net_device * );
201
+static int  ifec_tx_setup        ( struct net_device * );
202
+static void ifec_tx_wake         ( struct net_device * );
203
+
204
+#endif

Loading…
Cancel
Save