Annotation of cf/dev_c7200_eth.c, revision 1.1.1.7

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.