1 |
dpavlin |
1 |
/* |
2 |
dpavlin |
7 |
* Cisco router simulation platform. |
3 |
dpavlin |
1 |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
4 |
|
|
* |
5 |
|
|
* Ethernet Port Adapters. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include <stdio.h> |
9 |
|
|
#include <stdlib.h> |
10 |
|
|
#include <string.h> |
11 |
|
|
#include <stdarg.h> |
12 |
|
|
#include <unistd.h> |
13 |
|
|
#include <time.h> |
14 |
|
|
#include <errno.h> |
15 |
|
|
#include <assert.h> |
16 |
|
|
|
17 |
|
|
#include "utils.h" |
18 |
|
|
#include "net.h" |
19 |
|
|
#include "net_io.h" |
20 |
|
|
#include "ptask.h" |
21 |
|
|
#include "dev_am79c971.h" |
22 |
|
|
#include "dev_dec21140.h" |
23 |
dpavlin |
7 |
#include "dev_i8254x.h" |
24 |
dpavlin |
1 |
#include "dev_c7200.h" |
25 |
|
|
|
26 |
|
|
/* ====================================================================== */ |
27 |
dpavlin |
3 |
/* C7200-IO-FE EEPROM */ |
28 |
dpavlin |
1 |
/* ====================================================================== */ |
29 |
|
|
|
30 |
|
|
/* C7200-IO-FE: C7200 IOCard with one FastEthernet port EEPROM */ |
31 |
|
|
static const m_uint16_t eeprom_c7200_io_fe_data[16] = { |
32 |
|
|
0x0183, 0x010E, 0xffff, 0xffff, 0x490B, 0x8C02, 0x0000, 0x0000, |
33 |
|
|
0x5000, 0x0000, 0x9812, 0x2800, 0x00FF, 0xFFFF, 0xFFFF, 0xFFFF, |
34 |
|
|
}; |
35 |
|
|
|
36 |
dpavlin |
3 |
static const struct cisco_eeprom eeprom_c7200_io_fe = { |
37 |
dpavlin |
1 |
"C7200-IO-FE", (m_uint16_t *)eeprom_c7200_io_fe_data, |
38 |
|
|
sizeof(eeprom_c7200_io_fe_data)/2, |
39 |
|
|
}; |
40 |
|
|
|
41 |
|
|
/* |
42 |
|
|
* dev_c7200_iocard_init() |
43 |
|
|
* |
44 |
|
|
* Add an IOcard into slot 0. |
45 |
|
|
*/ |
46 |
|
|
static int dev_c7200_iocard_init(c7200_t *router,char *name,u_int pa_bay) |
47 |
|
|
{ |
48 |
|
|
struct dec21140_data *data; |
49 |
|
|
|
50 |
|
|
if (pa_bay != 0) { |
51 |
|
|
fprintf(stderr,"C7200 '%s': cannot put IOCARD in PA bay %u!\n", |
52 |
|
|
router->vm->name,pa_bay); |
53 |
|
|
return(-1); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
/* Set the EEPROM */ |
57 |
|
|
c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_fe); |
58 |
|
|
|
59 |
|
|
/* Create the DEC21140 chip */ |
60 |
|
|
data = dev_dec21140_init(router->vm,name, |
61 |
|
|
router->pa_bay[pa_bay].pci_map, |
62 |
|
|
router->npe_driver->dec21140_pci_dev, |
63 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
64 |
dpavlin |
1 |
if (!data) return(-1); |
65 |
|
|
|
66 |
|
|
/* Store device info into the router structure */ |
67 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
/* Remove an IOcard from slot 0 */ |
71 |
|
|
static int dev_c7200_iocard_shutdown(c7200_t *router,u_int pa_bay) |
72 |
|
|
{ |
73 |
|
|
struct c7200_pa_bay *bay; |
74 |
|
|
|
75 |
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
76 |
|
|
return(-1); |
77 |
|
|
|
78 |
|
|
c7200_pa_unset_eeprom(router,pa_bay); |
79 |
|
|
dev_dec21140_remove(bay->drv_info); |
80 |
|
|
return(0); |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
/* Bind a Network IO descriptor */ |
84 |
|
|
static int dev_c7200_iocard_set_nio(c7200_t *router,u_int pa_bay,u_int port_id, |
85 |
|
|
netio_desc_t *nio) |
86 |
|
|
{ |
87 |
|
|
struct dec21140_data *d; |
88 |
|
|
|
89 |
|
|
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
90 |
|
|
return(-1); |
91 |
|
|
|
92 |
|
|
return(dev_dec21140_set_nio(d,nio)); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
/* Unbind a Network IO descriptor */ |
96 |
|
|
static int dev_c7200_iocard_unset_nio(c7200_t *router,u_int pa_bay, |
97 |
|
|
u_int port_id) |
98 |
|
|
{ |
99 |
|
|
struct dec21140_data *d; |
100 |
|
|
|
101 |
|
|
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
102 |
|
|
return(-1); |
103 |
|
|
|
104 |
|
|
dev_dec21140_unset_nio(d); |
105 |
|
|
return(0); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
/* |
109 |
|
|
* dev_c7200_pa_fe_tx_init() |
110 |
|
|
* |
111 |
|
|
* Add a PA-FE-TX port adapter into specified slot. |
112 |
|
|
*/ |
113 |
|
|
static int dev_c7200_pa_fe_tx_init(c7200_t *router,char *name,u_int pa_bay) |
114 |
|
|
{ |
115 |
|
|
struct dec21140_data *data; |
116 |
|
|
|
117 |
|
|
/* Set the EEPROM */ |
118 |
dpavlin |
3 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-FE-TX")); |
119 |
dpavlin |
1 |
|
120 |
|
|
/* Create the DEC21140 chip */ |
121 |
|
|
data = dev_dec21140_init(router->vm,name,router->pa_bay[pa_bay].pci_map,0, |
122 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
123 |
dpavlin |
1 |
if (!data) return(-1); |
124 |
|
|
|
125 |
|
|
/* Store device info into the router structure */ |
126 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
/* Remove a PA-FE-TX from the specified slot */ |
130 |
|
|
static int dev_c7200_pa_fe_tx_shutdown(c7200_t *router,u_int pa_bay) |
131 |
|
|
{ |
132 |
|
|
struct c7200_pa_bay *bay; |
133 |
|
|
|
134 |
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
135 |
|
|
return(-1); |
136 |
|
|
|
137 |
|
|
c7200_pa_unset_eeprom(router,pa_bay); |
138 |
|
|
dev_dec21140_remove(bay->drv_info); |
139 |
|
|
return(0); |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
/* Bind a Network IO descriptor */ |
143 |
|
|
static int dev_c7200_pa_fe_tx_set_nio(c7200_t *router,u_int pa_bay, |
144 |
|
|
u_int port_id,netio_desc_t *nio) |
145 |
|
|
{ |
146 |
|
|
struct dec21140_data *d; |
147 |
|
|
|
148 |
|
|
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
149 |
|
|
return(-1); |
150 |
|
|
|
151 |
|
|
return(dev_dec21140_set_nio(d,nio)); |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
/* Unbind a Network IO descriptor */ |
155 |
|
|
static int dev_c7200_pa_fe_tx_unset_nio(c7200_t *router,u_int pa_bay, |
156 |
|
|
u_int port_id) |
157 |
|
|
{ |
158 |
|
|
struct dec21140_data *d; |
159 |
|
|
|
160 |
|
|
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
161 |
|
|
return(-1); |
162 |
|
|
|
163 |
|
|
dev_dec21140_unset_nio(d); |
164 |
|
|
return(0); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
/* C7200-IO-FE driver */ |
168 |
dpavlin |
7 |
struct c7200_pa_driver dev_c7200_iocard_fe_driver = { |
169 |
dpavlin |
1 |
"C7200-IO-FE", 1, |
170 |
|
|
dev_c7200_iocard_init, |
171 |
|
|
dev_c7200_iocard_shutdown, |
172 |
|
|
dev_c7200_iocard_set_nio, |
173 |
|
|
dev_c7200_iocard_unset_nio, |
174 |
dpavlin |
2 |
NULL, |
175 |
dpavlin |
1 |
}; |
176 |
|
|
|
177 |
|
|
/* PA-FE-TX driver */ |
178 |
|
|
struct c7200_pa_driver dev_c7200_pa_fe_tx_driver = { |
179 |
|
|
"PA-FE-TX", 1, |
180 |
|
|
dev_c7200_pa_fe_tx_init, |
181 |
|
|
dev_c7200_pa_fe_tx_shutdown, |
182 |
|
|
dev_c7200_pa_fe_tx_set_nio, |
183 |
|
|
dev_c7200_pa_fe_tx_unset_nio, |
184 |
dpavlin |
2 |
NULL, |
185 |
dpavlin |
1 |
}; |
186 |
|
|
|
187 |
|
|
/* ====================================================================== */ |
188 |
dpavlin |
7 |
/* PA based on Intel i8254x chips */ |
189 |
|
|
/* ====================================================================== */ |
190 |
|
|
|
191 |
|
|
struct pa_i8254x_data { |
192 |
|
|
u_int nr_port; |
193 |
|
|
struct i8254x_data *port[2]; |
194 |
|
|
}; |
195 |
|
|
|
196 |
|
|
/* Remove a PA-2FE-TX from the specified slot */ |
197 |
|
|
static int dev_c7200_pa_i8254x_shutdown(c7200_t *router,u_int pa_bay) |
198 |
|
|
{ |
199 |
|
|
struct c7200_pa_bay *bay; |
200 |
|
|
struct pa_i8254x_data *data; |
201 |
|
|
int i; |
202 |
|
|
|
203 |
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
204 |
|
|
return(-1); |
205 |
|
|
|
206 |
|
|
data = bay->drv_info; |
207 |
|
|
|
208 |
|
|
/* Remove the PA EEPROM */ |
209 |
|
|
c7200_pa_unset_eeprom(router,pa_bay); |
210 |
|
|
|
211 |
|
|
/* Remove the AMD Am79c971 chips */ |
212 |
|
|
for(i=0;i<data->nr_port;i++) |
213 |
|
|
dev_i8254x_remove(data->port[i]); |
214 |
|
|
|
215 |
|
|
free(data); |
216 |
|
|
return(0); |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
/* Bind a Network IO descriptor */ |
220 |
|
|
static int dev_c7200_pa_i8254x_set_nio(c7200_t *router,u_int pa_bay, |
221 |
|
|
u_int port_id,netio_desc_t *nio) |
222 |
|
|
{ |
223 |
|
|
struct pa_i8254x_data *d; |
224 |
|
|
|
225 |
|
|
d = c7200_pa_get_drvinfo(router,pa_bay); |
226 |
|
|
|
227 |
|
|
if (!d || (port_id >= d->nr_port)) |
228 |
|
|
return(-1); |
229 |
|
|
|
230 |
|
|
dev_i8254x_set_nio(d->port[port_id],nio); |
231 |
|
|
return(0); |
232 |
|
|
} |
233 |
|
|
|
234 |
|
|
/* Unbind a Network IO descriptor */ |
235 |
|
|
static int dev_c7200_pa_i8254x_unset_nio(c7200_t *router,u_int pa_bay, |
236 |
|
|
u_int port_id) |
237 |
|
|
{ |
238 |
|
|
struct pa_i8254x_data *d; |
239 |
|
|
|
240 |
|
|
d = c7200_pa_get_drvinfo(router,pa_bay); |
241 |
|
|
|
242 |
|
|
if (!d || (port_id >= d->nr_port)) |
243 |
|
|
return(-1); |
244 |
|
|
|
245 |
|
|
dev_i8254x_unset_nio(d->port[port_id]); |
246 |
|
|
return(0); |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
/* ====================================================================== */ |
250 |
|
|
/* PA-2FE-TX */ |
251 |
|
|
/* ====================================================================== */ |
252 |
|
|
|
253 |
|
|
/* |
254 |
|
|
* dev_c7200_pa_2fe_tx_init() |
255 |
|
|
* |
256 |
|
|
* Add a PA-2FE-TX port adapter into specified slot. |
257 |
|
|
*/ |
258 |
|
|
static int dev_c7200_pa_2fe_tx_init(c7200_t *router,char *name,u_int pa_bay) |
259 |
|
|
{ |
260 |
|
|
struct pa_i8254x_data *data; |
261 |
|
|
int i; |
262 |
|
|
|
263 |
|
|
/* Allocate the private data structure for the PA-2FE-TX */ |
264 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
265 |
|
|
fprintf(stderr,"%s (PA-2FE-TX): out of memory\n",name); |
266 |
|
|
return(-1); |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
/* 2 Ethernet ports */ |
270 |
|
|
memset(data,0,sizeof(*data)); |
271 |
|
|
data->nr_port = 2; |
272 |
|
|
|
273 |
|
|
/* Set the EEPROM */ |
274 |
|
|
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-2FE-TX")); |
275 |
|
|
|
276 |
|
|
/* Create the Intel i8254x chips */ |
277 |
|
|
for(i=0;i<data->nr_port;i++) { |
278 |
|
|
data->port[i] = dev_i8254x_init(router->vm,name,0, |
279 |
|
|
router->pa_bay[pa_bay].pci_map,i, |
280 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,i)); |
281 |
dpavlin |
7 |
} |
282 |
|
|
|
283 |
|
|
/* Store device info into the router structure */ |
284 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
285 |
|
|
} |
286 |
|
|
|
287 |
|
|
/* PA-2FE-TX driver */ |
288 |
|
|
struct c7200_pa_driver dev_c7200_pa_2fe_tx_driver = { |
289 |
|
|
"PA-2FE-TX", 0, |
290 |
|
|
dev_c7200_pa_2fe_tx_init, |
291 |
|
|
dev_c7200_pa_i8254x_shutdown, |
292 |
|
|
dev_c7200_pa_i8254x_set_nio, |
293 |
|
|
dev_c7200_pa_i8254x_unset_nio, |
294 |
|
|
NULL, |
295 |
|
|
}; |
296 |
|
|
|
297 |
|
|
/* ====================================================================== */ |
298 |
|
|
/* PA-GE */ |
299 |
|
|
/* ====================================================================== */ |
300 |
|
|
|
301 |
|
|
/* |
302 |
|
|
* dev_c7200_pa_ge_init() |
303 |
|
|
* |
304 |
|
|
* Add a PA-GE port adapter into specified slot. |
305 |
|
|
*/ |
306 |
|
|
static int dev_c7200_pa_ge_init(c7200_t *router,char *name,u_int pa_bay) |
307 |
|
|
{ |
308 |
|
|
struct pa_i8254x_data *data; |
309 |
|
|
|
310 |
|
|
/* Allocate the private data structure for the PA-2FE-TX */ |
311 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
312 |
|
|
fprintf(stderr,"%s (PA-GE): out of memory\n",name); |
313 |
|
|
return(-1); |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
/* 2 Ethernet ports */ |
317 |
|
|
memset(data,0,sizeof(*data)); |
318 |
|
|
data->nr_port = 1; |
319 |
|
|
|
320 |
|
|
/* Set the EEPROM */ |
321 |
|
|
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-GE")); |
322 |
|
|
|
323 |
|
|
/* Create the Intel i8254x chip */ |
324 |
|
|
data->port[0] = dev_i8254x_init(router->vm,name,0, |
325 |
|
|
router->pa_bay[pa_bay].pci_map,0, |
326 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
327 |
dpavlin |
7 |
|
328 |
|
|
/* Store device info into the router structure */ |
329 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
330 |
|
|
} |
331 |
|
|
|
332 |
|
|
/* PA-GE driver */ |
333 |
|
|
struct c7200_pa_driver dev_c7200_pa_ge_driver = { |
334 |
|
|
"PA-GE", 0, |
335 |
|
|
dev_c7200_pa_ge_init, |
336 |
|
|
dev_c7200_pa_i8254x_shutdown, |
337 |
|
|
dev_c7200_pa_i8254x_set_nio, |
338 |
|
|
dev_c7200_pa_i8254x_unset_nio, |
339 |
|
|
NULL, |
340 |
|
|
}; |
341 |
|
|
|
342 |
|
|
/* ====================================================================== */ |
343 |
|
|
/* C7200-IO-2FE */ |
344 |
|
|
/* ====================================================================== */ |
345 |
|
|
|
346 |
|
|
/* C7200-IO-2FE/E: C7200 IOCard with two FastEthernet ports EEPROM */ |
347 |
|
|
static const m_uint16_t eeprom_c7200_io_2fe_data[] = { |
348 |
|
|
0x04FF, 0x4002, 0x1541, 0x0201, 0xC046, 0x0320, 0x001B, 0xCA06, |
349 |
|
|
0x8249, 0x138B, 0x0642, 0x4230, 0xC18B, 0x3030, 0x3030, 0x3030, |
350 |
|
|
0x3030, 0x0000, 0x0004, 0x0002, 0x0385, 0x1C0D, 0x7F03, 0xCB8F, |
351 |
|
|
0x4337, 0x3230, 0x302D, 0x492F, 0x4F2D, 0x3246, 0x452F, 0x4580, |
352 |
|
|
0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
353 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
354 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
355 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
356 |
|
|
}; |
357 |
|
|
|
358 |
|
|
static const struct cisco_eeprom eeprom_c7200_io_2fe = { |
359 |
|
|
"C7200-IO-2FE", (m_uint16_t *)eeprom_c7200_io_2fe_data, |
360 |
|
|
sizeof(eeprom_c7200_io_2fe_data)/2, |
361 |
|
|
}; |
362 |
|
|
|
363 |
|
|
/* |
364 |
|
|
* dev_c7200_pa_2fe_tx_init() |
365 |
|
|
* |
366 |
|
|
* Add a C7200-IO-2FE/E port adapter into specified slot. |
367 |
|
|
*/ |
368 |
|
|
static int dev_c7200_iocard_2fe_init(c7200_t *router,char *name,u_int pa_bay) |
369 |
|
|
{ |
370 |
|
|
struct pa_i8254x_data *data; |
371 |
|
|
|
372 |
|
|
/* Allocate the private data structure for the iocard */ |
373 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
374 |
|
|
fprintf(stderr,"%s (C7200-IO-2FE): out of memory\n",name); |
375 |
|
|
return(-1); |
376 |
|
|
} |
377 |
|
|
|
378 |
|
|
/* 2 Ethernet ports */ |
379 |
|
|
memset(data,0,sizeof(*data)); |
380 |
|
|
data->nr_port = 2; |
381 |
|
|
|
382 |
|
|
/* Set the EEPROM */ |
383 |
|
|
c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_2fe); |
384 |
|
|
|
385 |
|
|
/* Port Fa0/0 is on PCI Device 1 */ |
386 |
|
|
data->port[0] = dev_i8254x_init(router->vm,name,0, |
387 |
|
|
router->pa_bay[pa_bay].pci_map,1, |
388 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,1)); |
389 |
dpavlin |
7 |
|
390 |
|
|
/* Port Fa0/1 is on PCI Device 0 */ |
391 |
|
|
data->port[1] = dev_i8254x_init(router->vm,name,0, |
392 |
|
|
router->pa_bay[pa_bay].pci_map,0, |
393 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
394 |
dpavlin |
7 |
|
395 |
dpavlin |
8 |
if (!data->port[0] || !data->port[1]) { |
396 |
|
|
dev_i8254x_remove(data->port[0]); |
397 |
|
|
dev_i8254x_remove(data->port[1]); |
398 |
|
|
free(data); |
399 |
|
|
return(-1); |
400 |
|
|
} |
401 |
|
|
|
402 |
dpavlin |
7 |
/* Store device info into the router structure */ |
403 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
404 |
|
|
} |
405 |
|
|
|
406 |
|
|
/* C7200-IO-2FE driver */ |
407 |
|
|
struct c7200_pa_driver dev_c7200_iocard_2fe_driver = { |
408 |
|
|
"C7200-IO-2FE", 0, |
409 |
|
|
dev_c7200_iocard_2fe_init, |
410 |
|
|
dev_c7200_pa_i8254x_shutdown, |
411 |
|
|
dev_c7200_pa_i8254x_set_nio, |
412 |
|
|
dev_c7200_pa_i8254x_unset_nio, |
413 |
|
|
NULL, |
414 |
|
|
}; |
415 |
|
|
|
416 |
|
|
/* ====================================================================== */ |
417 |
|
|
/* C7200-IO-GE-E */ |
418 |
|
|
/* ====================================================================== */ |
419 |
|
|
|
420 |
|
|
/* |
421 |
|
|
* C7200-IO-GE+E: C7200 IOCard with 1 GigatEthernet ports |
422 |
|
|
* and 1 Ethernet port EEPROM. |
423 |
|
|
*/ |
424 |
|
|
static const m_uint16_t eeprom_c7200_io_ge_e_data[] = { |
425 |
|
|
0x04FF, 0x4002, 0x1641, 0x0201, 0xC046, 0x0320, 0x001B, 0xCA06, |
426 |
|
|
0x8249, 0x138B, 0x0642, 0x4230, 0xC18B, 0x3030, 0x3030, 0x3030, |
427 |
|
|
0x3030, 0x0000, 0x0004, 0x0002, 0x0385, 0x1C0D, 0x7F03, 0xCB8F, |
428 |
|
|
0x4337, 0x3230, 0x302D, 0x492F, 0x4F2D, 0x3246, 0x452F, 0x4580, |
429 |
|
|
0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
430 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
431 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
432 |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
433 |
|
|
}; |
434 |
|
|
|
435 |
|
|
static const struct cisco_eeprom eeprom_c7200_io_ge_e = { |
436 |
|
|
"C7200-IO-GE-E", (m_uint16_t *)eeprom_c7200_io_ge_e_data, |
437 |
|
|
sizeof(eeprom_c7200_io_ge_e_data)/2, |
438 |
|
|
}; |
439 |
|
|
|
440 |
|
|
/* |
441 |
|
|
* dev_c7200_pa_ge_e_tx_init() |
442 |
|
|
* |
443 |
|
|
* Add a C7200-I/O-GE+E port adapter into specified slot. |
444 |
|
|
*/ |
445 |
|
|
static int dev_c7200_iocard_ge_e_init(c7200_t *router,char *name,u_int pa_bay) |
446 |
|
|
{ |
447 |
|
|
struct pa_i8254x_data *data; |
448 |
|
|
|
449 |
|
|
/* Allocate the private data structure for the iocard */ |
450 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
451 |
|
|
fprintf(stderr,"%s (C7200-IO-GE+E): out of memory\n",name); |
452 |
|
|
return(-1); |
453 |
|
|
} |
454 |
|
|
|
455 |
|
|
/* 2 Ethernet ports */ |
456 |
|
|
memset(data,0,sizeof(*data)); |
457 |
|
|
data->nr_port = 2; |
458 |
|
|
|
459 |
|
|
/* Set the EEPROM */ |
460 |
|
|
c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_ge_e); |
461 |
|
|
|
462 |
|
|
/* Port Gi0/0 is on PCI Device 1 */ |
463 |
|
|
data->port[0] = dev_i8254x_init(router->vm,name,0, |
464 |
|
|
router->pa_bay[pa_bay].pci_map,1, |
465 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,1)); |
466 |
dpavlin |
7 |
|
467 |
|
|
/* Port e0/0 is on PCI Device 0 */ |
468 |
|
|
data->port[1] = dev_i8254x_init(router->vm,name,0, |
469 |
|
|
router->pa_bay[pa_bay].pci_map,0, |
470 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
471 |
dpavlin |
7 |
|
472 |
|
|
/* Store device info into the router structure */ |
473 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
474 |
|
|
} |
475 |
|
|
|
476 |
|
|
/* C7200-IO-GE-E driver */ |
477 |
|
|
struct c7200_pa_driver dev_c7200_iocard_ge_e_driver = { |
478 |
|
|
"C7200-IO-GE-E", 0, |
479 |
|
|
dev_c7200_iocard_ge_e_init, |
480 |
|
|
dev_c7200_pa_i8254x_shutdown, |
481 |
|
|
dev_c7200_pa_i8254x_set_nio, |
482 |
|
|
dev_c7200_pa_i8254x_unset_nio, |
483 |
|
|
NULL, |
484 |
|
|
}; |
485 |
|
|
|
486 |
|
|
/* ====================================================================== */ |
487 |
dpavlin |
1 |
/* PA-4E / PA-8E */ |
488 |
|
|
/* ====================================================================== */ |
489 |
|
|
|
490 |
|
|
/* PA-4E/PA-8E data */ |
491 |
|
|
struct pa_4e8e_data { |
492 |
|
|
u_int nr_port; |
493 |
|
|
struct am79c971_data *port[8]; |
494 |
|
|
}; |
495 |
|
|
|
496 |
|
|
/* |
497 |
|
|
* dev_c7200_pa_4e_init() |
498 |
|
|
* |
499 |
|
|
* Add a PA-4E port adapter into specified slot. |
500 |
|
|
*/ |
501 |
|
|
static int dev_c7200_pa_4e_init(c7200_t *router,char *name,u_int pa_bay) |
502 |
|
|
{ |
503 |
|
|
struct pa_4e8e_data *data; |
504 |
|
|
int i; |
505 |
|
|
|
506 |
|
|
/* Allocate the private data structure for the PA-4E */ |
507 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
508 |
|
|
fprintf(stderr,"%s (PA-4E): out of memory\n",name); |
509 |
|
|
return(-1); |
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
/* 4 Ethernet ports */ |
513 |
|
|
memset(data,0,sizeof(*data)); |
514 |
|
|
data->nr_port = 4; |
515 |
|
|
|
516 |
|
|
/* Set the EEPROM */ |
517 |
dpavlin |
3 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-4E")); |
518 |
dpavlin |
1 |
|
519 |
|
|
/* Create the AMD Am79c971 chips */ |
520 |
|
|
for(i=0;i<data->nr_port;i++) { |
521 |
|
|
data->port[i] = dev_am79c971_init(router->vm,name,AM79C971_TYPE_10BASE_T, |
522 |
|
|
router->pa_bay[pa_bay].pci_map,i, |
523 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,i)); |
524 |
dpavlin |
1 |
} |
525 |
|
|
|
526 |
|
|
/* Store device info into the router structure */ |
527 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
528 |
|
|
} |
529 |
|
|
|
530 |
|
|
/* |
531 |
|
|
* dev_c7200_pa_8e_init() |
532 |
|
|
* |
533 |
|
|
* Add a PA-8E port adapter into specified slot. |
534 |
|
|
*/ |
535 |
|
|
static int dev_c7200_pa_8e_init(c7200_t *router,char *name,u_int pa_bay) |
536 |
|
|
{ |
537 |
|
|
struct pa_4e8e_data *data; |
538 |
|
|
int i; |
539 |
|
|
|
540 |
|
|
/* Allocate the private data structure for the PA-8E */ |
541 |
|
|
if (!(data = malloc(sizeof(*data)))) { |
542 |
|
|
fprintf(stderr,"%s (PA-8E): out of memory\n",name); |
543 |
|
|
return(-1); |
544 |
|
|
} |
545 |
|
|
|
546 |
|
|
/* 4 Ethernet ports */ |
547 |
|
|
memset(data,0,sizeof(*data)); |
548 |
|
|
data->nr_port = 8; |
549 |
|
|
|
550 |
|
|
/* Set the EEPROM */ |
551 |
dpavlin |
3 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-8E")); |
552 |
dpavlin |
1 |
|
553 |
|
|
/* Create the AMD Am79c971 chips */ |
554 |
|
|
for(i=0;i<data->nr_port;i++) { |
555 |
|
|
data->port[i] = dev_am79c971_init(router->vm,name,AM79C971_TYPE_10BASE_T, |
556 |
|
|
router->pa_bay[pa_bay].pci_map,i, |
557 |
dpavlin |
8 |
c7200_net_irq_for_slot_port(pa_bay,i)); |
558 |
dpavlin |
1 |
} |
559 |
|
|
|
560 |
|
|
/* Store device info into the router structure */ |
561 |
|
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
562 |
|
|
} |
563 |
|
|
|
564 |
|
|
/* Remove a PA-4E/PA-8E from the specified slot */ |
565 |
|
|
static int dev_c7200_pa_4e8e_shutdown(c7200_t *router,u_int pa_bay) |
566 |
|
|
{ |
567 |
|
|
struct c7200_pa_bay *bay; |
568 |
|
|
struct pa_4e8e_data *data; |
569 |
|
|
int i; |
570 |
|
|
|
571 |
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
572 |
|
|
return(-1); |
573 |
|
|
|
574 |
|
|
data = bay->drv_info; |
575 |
|
|
|
576 |
|
|
/* Remove the PA EEPROM */ |
577 |
|
|
c7200_pa_unset_eeprom(router,pa_bay); |
578 |
|
|
|
579 |
|
|
/* Remove the AMD Am79c971 chips */ |
580 |
|
|
for(i=0;i<data->nr_port;i++) |
581 |
|
|
dev_am79c971_remove(data->port[i]); |
582 |
|
|
|
583 |
|
|
free(data); |
584 |
|
|
return(0); |
585 |
|
|
} |
586 |
|
|
|
587 |
|
|
/* Bind a Network IO descriptor */ |
588 |
|
|
static int dev_c7200_pa_4e8e_set_nio(c7200_t *router,u_int pa_bay, |
589 |
|
|
u_int port_id,netio_desc_t *nio) |
590 |
|
|
{ |
591 |
|
|
struct pa_4e8e_data *d; |
592 |
|
|
|
593 |
|
|
d = c7200_pa_get_drvinfo(router,pa_bay); |
594 |
|
|
|
595 |
|
|
if (!d || (port_id >= d->nr_port)) |
596 |
|
|
return(-1); |
597 |
|
|
|
598 |
|
|
dev_am79c971_set_nio(d->port[port_id],nio); |
599 |
|
|
return(0); |
600 |
|
|
} |
601 |
|
|
|
602 |
|
|
/* Unbind a Network IO descriptor */ |
603 |
|
|
static int dev_c7200_pa_4e8e_unset_nio(c7200_t *router,u_int pa_bay, |
604 |
|
|
u_int port_id) |
605 |
|
|
{ |
606 |
|
|
struct pa_4e8e_data *d; |
607 |
|
|
|
608 |
|
|
d = c7200_pa_get_drvinfo(router,pa_bay); |
609 |
|
|
|
610 |
|
|
if (!d || (port_id >= d->nr_port)) |
611 |
|
|
return(-1); |
612 |
|
|
|
613 |
|
|
dev_am79c971_unset_nio(d->port[port_id]); |
614 |
|
|
return(0); |
615 |
|
|
} |
616 |
|
|
|
617 |
|
|
/* PA-4E driver */ |
618 |
|
|
struct c7200_pa_driver dev_c7200_pa_4e_driver = { |
619 |
|
|
"PA-4E", 1, |
620 |
|
|
dev_c7200_pa_4e_init, |
621 |
|
|
dev_c7200_pa_4e8e_shutdown, |
622 |
|
|
dev_c7200_pa_4e8e_set_nio, |
623 |
|
|
dev_c7200_pa_4e8e_unset_nio, |
624 |
dpavlin |
2 |
NULL, |
625 |
dpavlin |
1 |
}; |
626 |
|
|
|
627 |
|
|
/* PA-8E driver */ |
628 |
|
|
struct c7200_pa_driver dev_c7200_pa_8e_driver = { |
629 |
|
|
"PA-8E", 1, |
630 |
|
|
dev_c7200_pa_8e_init, |
631 |
|
|
dev_c7200_pa_4e8e_shutdown, |
632 |
|
|
dev_c7200_pa_4e8e_set_nio, |
633 |
|
|
dev_c7200_pa_4e8e_unset_nio, |
634 |
dpavlin |
2 |
NULL, |
635 |
dpavlin |
1 |
}; |