1 |
/* |
/* |
2 |
* Cisco C7200 (Predator) simulation platform. |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
4 |
* |
* |
5 |
* Ethernet Port Adapters. |
* Ethernet Port Adapters. |
20 |
#include "ptask.h" |
#include "ptask.h" |
21 |
#include "dev_am79c971.h" |
#include "dev_am79c971.h" |
22 |
#include "dev_dec21140.h" |
#include "dev_dec21140.h" |
23 |
|
#include "dev_i8254x.h" |
24 |
#include "dev_c7200.h" |
#include "dev_c7200.h" |
25 |
|
|
26 |
/* ====================================================================== */ |
/* ====================================================================== */ |
165 |
} |
} |
166 |
|
|
167 |
/* C7200-IO-FE driver */ |
/* C7200-IO-FE driver */ |
168 |
struct c7200_pa_driver dev_c7200_io_fe_driver = { |
struct c7200_pa_driver dev_c7200_iocard_fe_driver = { |
169 |
"C7200-IO-FE", 1, |
"C7200-IO-FE", 1, |
170 |
dev_c7200_iocard_init, |
dev_c7200_iocard_init, |
171 |
dev_c7200_iocard_shutdown, |
dev_c7200_iocard_shutdown, |
184 |
NULL, |
NULL, |
185 |
}; |
}; |
186 |
|
|
187 |
|
/* ====================================================================== */ |
188 |
|
/* 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 |
|
C7200_NETIO_IRQ); |
281 |
|
} |
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 |
|
C7200_NETIO_IRQ); |
327 |
|
|
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 |
|
C7200_NETIO_IRQ); |
389 |
|
|
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 |
|
C7200_NETIO_IRQ); |
394 |
|
|
395 |
|
/* Store device info into the router structure */ |
396 |
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
397 |
|
} |
398 |
|
|
399 |
|
/* C7200-IO-2FE driver */ |
400 |
|
struct c7200_pa_driver dev_c7200_iocard_2fe_driver = { |
401 |
|
"C7200-IO-2FE", 0, |
402 |
|
dev_c7200_iocard_2fe_init, |
403 |
|
dev_c7200_pa_i8254x_shutdown, |
404 |
|
dev_c7200_pa_i8254x_set_nio, |
405 |
|
dev_c7200_pa_i8254x_unset_nio, |
406 |
|
NULL, |
407 |
|
}; |
408 |
|
|
409 |
|
/* ====================================================================== */ |
410 |
|
/* C7200-IO-GE-E */ |
411 |
|
/* ====================================================================== */ |
412 |
|
|
413 |
|
/* |
414 |
|
* C7200-IO-GE+E: C7200 IOCard with 1 GigatEthernet ports |
415 |
|
* and 1 Ethernet port EEPROM. |
416 |
|
*/ |
417 |
|
static const m_uint16_t eeprom_c7200_io_ge_e_data[] = { |
418 |
|
0x04FF, 0x4002, 0x1641, 0x0201, 0xC046, 0x0320, 0x001B, 0xCA06, |
419 |
|
0x8249, 0x138B, 0x0642, 0x4230, 0xC18B, 0x3030, 0x3030, 0x3030, |
420 |
|
0x3030, 0x0000, 0x0004, 0x0002, 0x0385, 0x1C0D, 0x7F03, 0xCB8F, |
421 |
|
0x4337, 0x3230, 0x302D, 0x492F, 0x4F2D, 0x3246, 0x452F, 0x4580, |
422 |
|
0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
423 |
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
424 |
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
425 |
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
426 |
|
}; |
427 |
|
|
428 |
|
static const struct cisco_eeprom eeprom_c7200_io_ge_e = { |
429 |
|
"C7200-IO-GE-E", (m_uint16_t *)eeprom_c7200_io_ge_e_data, |
430 |
|
sizeof(eeprom_c7200_io_ge_e_data)/2, |
431 |
|
}; |
432 |
|
|
433 |
|
/* |
434 |
|
* dev_c7200_pa_ge_e_tx_init() |
435 |
|
* |
436 |
|
* Add a C7200-I/O-GE+E port adapter into specified slot. |
437 |
|
*/ |
438 |
|
static int dev_c7200_iocard_ge_e_init(c7200_t *router,char *name,u_int pa_bay) |
439 |
|
{ |
440 |
|
struct pa_i8254x_data *data; |
441 |
|
|
442 |
|
/* Allocate the private data structure for the iocard */ |
443 |
|
if (!(data = malloc(sizeof(*data)))) { |
444 |
|
fprintf(stderr,"%s (C7200-IO-GE+E): out of memory\n",name); |
445 |
|
return(-1); |
446 |
|
} |
447 |
|
|
448 |
|
/* 2 Ethernet ports */ |
449 |
|
memset(data,0,sizeof(*data)); |
450 |
|
data->nr_port = 2; |
451 |
|
|
452 |
|
/* Set the EEPROM */ |
453 |
|
c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_ge_e); |
454 |
|
|
455 |
|
/* Port Gi0/0 is on PCI Device 1 */ |
456 |
|
data->port[0] = dev_i8254x_init(router->vm,name,0, |
457 |
|
router->pa_bay[pa_bay].pci_map,1, |
458 |
|
C7200_NETIO_IRQ); |
459 |
|
|
460 |
|
/* Port e0/0 is on PCI Device 0 */ |
461 |
|
data->port[1] = dev_i8254x_init(router->vm,name,0, |
462 |
|
router->pa_bay[pa_bay].pci_map,0, |
463 |
|
C7200_NETIO_IRQ); |
464 |
|
|
465 |
|
/* Store device info into the router structure */ |
466 |
|
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
467 |
|
} |
468 |
|
|
469 |
|
/* C7200-IO-GE-E driver */ |
470 |
|
struct c7200_pa_driver dev_c7200_iocard_ge_e_driver = { |
471 |
|
"C7200-IO-GE-E", 0, |
472 |
|
dev_c7200_iocard_ge_e_init, |
473 |
|
dev_c7200_pa_i8254x_shutdown, |
474 |
|
dev_c7200_pa_i8254x_set_nio, |
475 |
|
dev_c7200_pa_i8254x_unset_nio, |
476 |
|
NULL, |
477 |
|
}; |
478 |
|
|
479 |
/* ====================================================================== */ |
/* ====================================================================== */ |
480 |
/* PA-4E / PA-8E */ |
/* PA-4E / PA-8E */ |
481 |
/* ====================================================================== */ |
/* ====================================================================== */ |