1 | DEC 21140 Driver |
---|
2 | ################ |
---|
3 | |
---|
4 | DEC 21240 Driver Introduction |
---|
5 | ============================= |
---|
6 | |
---|
7 | .. COMMENT: XXX add back in cross reference to list of boards. |
---|
8 | |
---|
9 | One aim of our project is to port RTEMS on a standard PowerPC platform. |
---|
10 | To achieve it, we have chosen a Motorola MCP750 board. This board includes |
---|
11 | an Ethernet controller based on a DEC21140 chip. Because RTEMS has a |
---|
12 | TCP/IP stack, we will |
---|
13 | have to develop the DEC21140 related ethernet driver for the PowerPC port of |
---|
14 | RTEMS. As this controller is able to support 100Mbps network and as there is |
---|
15 | a lot of PCI card using this DEC chip, we have decided to first |
---|
16 | implement this driver on an Intel PC386 target to provide a solution for using |
---|
17 | RTEMS on PC with the 100Mbps network and then to port this code on PowerPC in |
---|
18 | a second phase. |
---|
19 | |
---|
20 | The aim of this document is to give some PCI board generalities and |
---|
21 | to explain the software architecture of the RTEMS driver. Finally, we will see |
---|
22 | what will be done for ChorusOs and Netboot environment . |
---|
23 | |
---|
24 | Document Revision History |
---|
25 | ========================= |
---|
26 | |
---|
27 | *Current release*: |
---|
28 | |
---|
29 | - Current applicable release is 1.0. |
---|
30 | |
---|
31 | *Existing releases*: |
---|
32 | |
---|
33 | - 1.0 : Released the 10/02/98. First version of this document. |
---|
34 | |
---|
35 | - 0.1 : First draft of this document |
---|
36 | |
---|
37 | *Planned releases*: |
---|
38 | |
---|
39 | - None planned today. |
---|
40 | |
---|
41 | DEC21140 PCI Board Generalities |
---|
42 | =============================== |
---|
43 | |
---|
44 | .. COMMENT: XXX add crossreference to PCI Register Figure |
---|
45 | |
---|
46 | This chapter describes rapidely the PCI interface of this Ethernet controller. |
---|
47 | The board we have chosen for our PC386 implementation is a D-Link DFE-500TX. |
---|
48 | This is a dual-speed 10/100Mbps Ethernet PCI adapter with a DEC21140AF chip. |
---|
49 | Like other PCI devices, this board has a PCI device's header containing some |
---|
50 | required configuration registers, as shown in the PCI Register Figure. |
---|
51 | By reading |
---|
52 | or writing these registers, a driver can obtain information about the type of |
---|
53 | the board, the interrupt it uses, the mapping of the chip specific registers, ... |
---|
54 | |
---|
55 | On Intel target, the chip specific registers can be accessed via 2 |
---|
56 | methods : I/O port access or PCI address mapped access. We have chosen to implement |
---|
57 | the PCI address access to obtain compatible source code to the port the driver |
---|
58 | on a PowerPC target. |
---|
59 | |
---|
60 | .. COMMENT: PCI Device's Configuration Header Space Format |
---|
61 | |
---|
62 | |
---|
63 | .. image:: images/PCIreg.jpg |
---|
64 | |
---|
65 | |
---|
66 | .. COMMENT: XXX add crossreference to PCI Register Figure |
---|
67 | |
---|
68 | On RTEMS, a PCI API exists. We have used it to configure the board. After initializing |
---|
69 | this PCI module via the ``pci_initialize()`` function, we try to detect |
---|
70 | the DEC21140 based ethernet board. This board is characterized by its Vendor |
---|
71 | ID (0x1011) and its Device ID (0x0009). We give these arguments to the``pcib_find_by_deviceid`` |
---|
72 | function which returns , if the device is present, a pointer to the configuration |
---|
73 | header space (see PCI Registers Fgure). Once this operation performed, |
---|
74 | the driver |
---|
75 | is able to extract the information it needs to configure the board internal |
---|
76 | registers, like the interrupt line, the base address,... The board internal |
---|
77 | registers will not be detailled here. You can find them in *DIGITAL |
---|
78 | Semiconductor 21140A PCI Fast Ethernet LAN Controller |
---|
79 | - Hardware Reference Manual*. |
---|
80 | |
---|
81 | .. COMMENT: fix citation |
---|
82 | |
---|
83 | RTEMS Driver Software Architecture |
---|
84 | ================================== |
---|
85 | |
---|
86 | In this chapter will see the initialization phase, how the controller uses the |
---|
87 | host memory and the 2 threads launched at the initialization time. |
---|
88 | |
---|
89 | Initialization phase |
---|
90 | -------------------- |
---|
91 | |
---|
92 | The DEC21140 Ethernet driver keeps the same software architecture than the other |
---|
93 | RTEMS ethernet drivers. The only API the programmer can use is the ``rtems_dec21140_driver_attach````(struct rtems_bsdnet_ifconfig \*config)`` function which |
---|
94 | detects the board and initializes the associated data structure (with registers |
---|
95 | base address, entry points to low-level initialization function,...), if the |
---|
96 | board is found. |
---|
97 | |
---|
98 | Once the attach function executed, the driver initializes the DEC |
---|
99 | chip. Then the driver connects an interrupt handler to the interrupt line driven |
---|
100 | by the Ethernet controller (the only interrupt which will be treated is the |
---|
101 | receive interrupt) and launches 2 threads : a receiver thread and a transmitter |
---|
102 | thread. Then the driver waits for incoming frame to give to the protocol stack |
---|
103 | or outcoming frame to send on the physical link. |
---|
104 | |
---|
105 | Memory Buffer |
---|
106 | ------------- |
---|
107 | |
---|
108 | .. COMMENT: XXX add cross reference to Problem |
---|
109 | |
---|
110 | This DEC chip uses the host memory to store the incoming Ethernet frames and |
---|
111 | the descriptor of these frames. We have chosen to use 7 receive buffers and |
---|
112 | 1 transmit buffer to optimize memory allocation due to cache and paging problem |
---|
113 | that will be explained in the section *Encountered Problems*. |
---|
114 | |
---|
115 | To reference these buffers to the DEC chip we use a buffer descriptors |
---|
116 | ring. The descriptor structure is defined in the Buffer Descriptor Figure. |
---|
117 | Each descriptor |
---|
118 | can reference one or two memory buffers. We choose to use only one buffer of |
---|
119 | 1520 bytes per descriptor. |
---|
120 | |
---|
121 | The difference between a receive and a transmit buffer descriptor |
---|
122 | is located in the status and control bits fields. We do not give details here, |
---|
123 | please refer to the \[DEC21140 Hardware Manual]. |
---|
124 | |
---|
125 | .. COMMENT: Buffer Descriptor |
---|
126 | |
---|
127 | |
---|
128 | .. image:: images/recvbd.jpg |
---|
129 | |
---|
130 | |
---|
131 | Receiver Thread |
---|
132 | --------------- |
---|
133 | |
---|
134 | This thread is event driven. Each time a DEC PCI board interrupt occurs, the |
---|
135 | handler checks if this is a receive interrupt and send an event "reception" |
---|
136 | to the receiver thread which looks into the entire buffer descriptors ring the |
---|
137 | ones that contain a valid incoming frame (bit OWN=0 means descriptor belongs |
---|
138 | to host processor). Each valid incoming ethernet frame is sent to the protocol |
---|
139 | stack and the buffer descriptor is given back to the DEC board (the host processor |
---|
140 | reset bit OWN, which means descriptor belongs to 21140). |
---|
141 | |
---|
142 | Transmitter Thread |
---|
143 | ------------------ |
---|
144 | |
---|
145 | This thread is also event driven. Each time an Ethernet frame is put in the |
---|
146 | transmit queue, an event is sent to the transmit thread, which empty the queue |
---|
147 | by sending each outcoming frame. Because we use only one transmit buffer, we |
---|
148 | are sure that the frame is well-sent before sending the next. |
---|
149 | |
---|
150 | Encountered Problems |
---|
151 | ==================== |
---|
152 | |
---|
153 | On Intel PC386 target, we were faced with a problem of memory cache management. |
---|
154 | Because the DEC chip uses the host memory to store the incoming frame and because |
---|
155 | the DEC21140 configuration registers are mapped into the PCI address space, |
---|
156 | we must ensure that the data read (or written) by the host processor are the |
---|
157 | ones written (or read) by the DEC21140 device in the host memory and not old |
---|
158 | data stored in the cache memory. Therefore, we had to provide a way to manage |
---|
159 | the cache. This module is described in the document *RTEMS |
---|
160 | Cache Management For Intel*. On Intel, the |
---|
161 | memory region cache management is available only if the paging unit is enabled. |
---|
162 | We have used this paging mechanism, with 4Kb page. All the buffers allocated |
---|
163 | to store the incoming or outcoming frames, buffer descriptor and also the PCI |
---|
164 | address space of the DEC board are located in a memory space with cache disable. |
---|
165 | |
---|
166 | Concerning the buffers and their descriptors, we have tried to optimize |
---|
167 | the memory space in term of allocated page. One buffer has 1520 bytes, one descriptor |
---|
168 | has 16 bytes. We have 7 receive buffers and 1 transmit buffer, and for each, |
---|
169 | 1 descriptor : (7+1)*(1520+16) = 12288 bytes = 12Kb = 3 entire pages. This |
---|
170 | allows not to lose too much memory or not to disable cache memory for a page |
---|
171 | which contains other data than buffer, which could decrease performance. |
---|
172 | |
---|
173 | ChorusOs DEC Driver |
---|
174 | =================== |
---|
175 | |
---|
176 | Because ChorusOs is used in several Canon CRF projects, we must provide such |
---|
177 | a driver on this OS to ensure compatibility between the RTEMS and ChorusOs developments. |
---|
178 | On ChorusOs, a DEC driver source code already exists but only for a PowerPC |
---|
179 | target. We plan to port this code (which uses ChorusOs API) on Intel target. |
---|
180 | This will allow us to have homogeneous developments. Moreover, the port of the |
---|
181 | development performed with ChorusOs environment to RTEMS environment will be |
---|
182 | easier for the developers. |
---|
183 | |
---|
184 | Netboot DEC driver |
---|
185 | ================== |
---|
186 | |
---|
187 | We use Netboot tool to load our development from a server to the target via |
---|
188 | an ethernet network. Currently, this tool does not support the DEC board. We |
---|
189 | plan to port the DEC driver for the Netboot tool. |
---|
190 | |
---|
191 | But concerning the port of the DEC driver into Netboot, we are faced |
---|
192 | with a problem : in RTEMS environment, the DEC driver is interrupt or event |
---|
193 | driven, in Netboot environment, it must be used in polling mode. It means that |
---|
194 | we will have to re-write some mechanisms of this driver. |
---|
195 | |
---|
196 | List of Ethernet cards using the DEC chip |
---|
197 | ========================================= |
---|
198 | |
---|
199 | Many Ethernet adapter cards use the Tulip chip. Here is a non exhaustive list |
---|
200 | of adapters which support this driver : |
---|
201 | |
---|
202 | - Accton EtherDuo PCI. |
---|
203 | |
---|
204 | - Accton EN1207 All three media types supported. |
---|
205 | |
---|
206 | - Adaptec ANA6911/TX 21140-AC. |
---|
207 | |
---|
208 | - Cogent EM110 21140-A with DP83840 N-Way MII transceiver. |
---|
209 | |
---|
210 | - Cogent EM400 EM100 with 4 21140 100mbps-only ports + PCI Bridge. |
---|
211 | |
---|
212 | - Danpex EN-9400P3. |
---|
213 | |
---|
214 | - D-Link DFE500-Tx 21140-A with DP83840 transceiver. |
---|
215 | |
---|
216 | - Kingston EtherX KNE100TX 21140AE. |
---|
217 | |
---|
218 | - Netgear FX310 TX 10/100 21140AE. |
---|
219 | |
---|
220 | - SMC EtherPower10/100 With DEC21140 and 68836 SYM transceiver. |
---|
221 | |
---|
222 | - SMC EtherPower10/100 With DEC21140-AC and DP83840 MII transceiver. |
---|
223 | Note: The EtherPower II uses the EPIC chip, which requires a different driver. |
---|
224 | |
---|
225 | - Surecom EP-320X DEC 21140. |
---|
226 | |
---|
227 | - Thomas Conrad TC5048. |
---|
228 | |
---|
229 | - Znyx ZX345 21140-A, usually with the DP83840 N-Way MII transciever. Some ZX345 |
---|
230 | cards made in 1996 have an ICS 1890 transciver instead. |
---|
231 | |
---|
232 | - ZNYX ZX348 Two 21140-A chips using ICS 1890 transcievers and either a 21052 |
---|
233 | or 21152 bridge. Early versions used National 83840 transcievers, but later |
---|
234 | versions are depopulated ZX346 boards. |
---|
235 | |
---|
236 | - ZNYX ZX351 21140 chip with a Broadcom 100BaseT4 transciever. |
---|
237 | |
---|
238 | Our DEC driver has not been tested with all these cards, only with the D-Link |
---|
239 | DFE500-TX. |
---|
240 | |
---|
241 | - *[DEC21140 Hardware Manual] DIGITAL, *DIGITAL |
---|
242 | Semiconductor 21140A PCI Fast Ethernet LAN Controller - Hardware |
---|
243 | Reference Manual**. |
---|
244 | |
---|
245 | - *[99.TA.0021.M.ER]Emmanuel Raguet,*RTEMS Cache Management For Intel**. |
---|
246 | |
---|