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