1544 |
* |
* |
1545 |
* Add a PA-A1 port adapter into specified slot. |
* Add a PA-A1 port adapter into specified slot. |
1546 |
*/ |
*/ |
1547 |
int dev_c7200_pa_a1_init(c7200_t *router,char *name,u_int pa_bay) |
int dev_c7200_pa_a1_init(vm_instance_t *vm,struct cisco_card *card) |
1548 |
{ |
{ |
1549 |
|
u_int slot = card->slot_id; |
1550 |
struct pci_device *pci_dev_ti,*pci_dev_plx; |
struct pci_device *pci_dev_ti,*pci_dev_plx; |
1551 |
struct pa_a1_data *d; |
struct pa_a1_data *d; |
1552 |
struct vdevice *dev; |
struct vdevice *dev; |
1554 |
|
|
1555 |
/* Allocate the private data structure for TI1570 chip */ |
/* Allocate the private data structure for TI1570 chip */ |
1556 |
if (!(d = malloc(sizeof(*d)))) { |
if (!(d = malloc(sizeof(*d)))) { |
1557 |
fprintf(stderr,"%s (TI1570): out of memory\n",name); |
vm_error(vm,"%s: out of memory\n",card->dev_name); |
1558 |
return(-1); |
return(-1); |
1559 |
} |
} |
1560 |
|
|
1561 |
memset(d,0,sizeof(*d)); |
memset(d,0,sizeof(*d)); |
1562 |
|
|
1563 |
|
/* Set the PCI bus */ |
1564 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
1565 |
|
|
1566 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
1567 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-A1")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-A1")); |
1568 |
|
c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); |
1569 |
|
|
1570 |
/* Add PCI device TI1570 */ |
/* Add PCI device TI1570 */ |
1571 |
pci_dev_ti = pci_dev_add(router->pa_bay[pa_bay].pci_map,name, |
pci_dev_ti = pci_dev_add(card->pci_bus,card->dev_name, |
1572 |
TI1570_PCI_VENDOR_ID,TI1570_PCI_PRODUCT_ID, |
TI1570_PCI_VENDOR_ID,TI1570_PCI_PRODUCT_ID, |
1573 |
0,0,c7200_net_irq_for_slot_port(pa_bay,0),d, |
0,0,c7200_net_irq_for_slot_port(slot,0),d, |
1574 |
NULL,pci_ti1570_read,pci_ti1570_write); |
NULL,pci_ti1570_read,pci_ti1570_write); |
1575 |
|
|
1576 |
if (!pci_dev_ti) { |
if (!pci_dev_ti) { |
1577 |
fprintf(stderr,"%s (TI1570): unable to create PCI device TI1570.\n", |
vm_error(vm,"%s: unable to create PCI device TI1570.\n", |
1578 |
name); |
card->dev_name); |
1579 |
return(-1); |
return(-1); |
1580 |
} |
} |
1581 |
|
|
1582 |
/* Add PCI device PLX9060ES */ |
/* Add PCI device PLX9060ES */ |
1583 |
pci_dev_plx = pci_dev_add(router->pa_bay[pa_bay].pci_map,name, |
pci_dev_plx = pci_dev_add(card->pci_bus,card->dev_name, |
1584 |
PLX_9060ES_PCI_VENDOR_ID, |
PLX_9060ES_PCI_VENDOR_ID, |
1585 |
PLX_9060ES_PCI_PRODUCT_ID, |
PLX_9060ES_PCI_PRODUCT_ID, |
1586 |
1,0,-1,d, |
1,0,-1,d, |
1587 |
NULL,pci_plx9060es_read,pci_plx9060es_write); |
NULL,pci_plx9060es_read,pci_plx9060es_write); |
1588 |
|
|
1589 |
if (!pci_dev_plx) { |
if (!pci_dev_plx) { |
1590 |
fprintf(stderr,"%s (PLX_9060ES): unable to create PCI device " |
vm_error(vm,"%s: unable to create PCI device PLX 9060ES.\n", |
1591 |
"PLX 9060ES.\n",name); |
card->dev_name); |
1592 |
return(-1); |
return(-1); |
1593 |
} |
} |
1594 |
|
|
1595 |
/* Create the TI1570 structure */ |
/* Create the TI1570 structure */ |
1596 |
d->name = name; |
d->name = card->dev_name; |
1597 |
d->vm = router->vm; |
d->vm = vm; |
1598 |
d->pci_dev_ti = pci_dev_ti; |
d->pci_dev_ti = pci_dev_ti; |
1599 |
d->pci_dev_plx = pci_dev_plx; |
d->pci_dev_plx = pci_dev_plx; |
1600 |
|
|
1601 |
/* Allocate the control memory */ |
/* Allocate the control memory */ |
1602 |
if (!(d->ctrl_mem_ptr = malloc(TI1570_CTRL_MEM_SIZE))) { |
if (!(d->ctrl_mem_ptr = malloc(TI1570_CTRL_MEM_SIZE))) { |
1603 |
fprintf(stderr,"%s (PA-A1): unable to create control memory.\n",name); |
vm_error(vm,"%s: unable to create control memory.\n",card->dev_name); |
1604 |
return(-1); |
return(-1); |
1605 |
} |
} |
1606 |
|
|
1617 |
ti1570_reset(d,TRUE); |
ti1570_reset(d,TRUE); |
1618 |
|
|
1619 |
/* Create the device itself */ |
/* Create the device itself */ |
1620 |
if (!(dev = dev_create(name))) { |
if (!(dev = dev_create(card->dev_name))) { |
1621 |
fprintf(stderr,"%s (PA-A1): unable to create device.\n",name); |
vm_error(vm,"%s: unable to create device.\n",card->dev_name); |
1622 |
return(-1); |
return(-1); |
1623 |
} |
} |
1624 |
|
|
1631 |
d->dev = dev; |
d->dev = dev; |
1632 |
|
|
1633 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
1634 |
return(c7200_pa_set_drvinfo(router,pa_bay,d)); |
card->drv_info = d; |
1635 |
|
return(0); |
1636 |
} |
} |
1637 |
|
|
1638 |
/* Remove a PA-A1 from the specified slot */ |
/* Remove a PA-A1 from the specified slot */ |
1639 |
int dev_c7200_pa_a1_shutdown(c7200_t *router,u_int pa_bay) |
int dev_c7200_pa_a1_shutdown(vm_instance_t *vm,struct cisco_card *card) |
1640 |
{ |
{ |
1641 |
struct c7200_pa_bay *bay; |
struct pa_a1_data *d = card->drv_info; |
|
struct pa_a1_data *d; |
|
|
|
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
|
|
return(-1); |
|
|
|
|
|
d = bay->drv_info; |
|
1642 |
|
|
1643 |
/* Remove the PA EEPROM */ |
/* Remove the PA EEPROM */ |
1644 |
c7200_pa_unset_eeprom(router,pa_bay); |
cisco_card_unset_eeprom(card); |
1645 |
|
c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL); |
1646 |
|
|
1647 |
/* Remove the PCI devices */ |
/* Remove the PCI devices */ |
1648 |
pci_dev_remove(d->pci_dev_ti); |
pci_dev_remove(d->pci_dev_ti); |
1649 |
pci_dev_remove(d->pci_dev_plx); |
pci_dev_remove(d->pci_dev_plx); |
1650 |
|
|
1651 |
/* Remove the device from the VM address space */ |
/* Remove the device from the VM address space */ |
1652 |
vm_unbind_device(router->vm,d->dev); |
vm_unbind_device(vm,d->dev); |
1653 |
cpu_group_rebuild_mts(router->vm->cpu_group); |
cpu_group_rebuild_mts(vm->cpu_group); |
1654 |
|
|
1655 |
/* Free the control memory */ |
/* Free the control memory */ |
1656 |
free(d->ctrl_mem_ptr); |
free(d->ctrl_mem_ptr); |
1662 |
} |
} |
1663 |
|
|
1664 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
1665 |
int dev_c7200_pa_a1_set_nio(c7200_t *router,u_int pa_bay,u_int port_id, |
int dev_c7200_pa_a1_set_nio(vm_instance_t *vm,struct cisco_card *card, |
1666 |
netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
1667 |
{ |
{ |
1668 |
struct pa_a1_data *d; |
struct pa_a1_data *d = card->drv_info; |
1669 |
|
|
1670 |
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
if (!d || (port_id > 0)) |
1671 |
return(-1); |
return(-1); |
1672 |
|
|
1673 |
if (d->nio != NULL) |
if (d->nio != NULL) |
1680 |
} |
} |
1681 |
|
|
1682 |
/* Unbind a Network IO descriptor to a specific port */ |
/* Unbind a Network IO descriptor to a specific port */ |
1683 |
int dev_c7200_pa_a1_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id) |
int dev_c7200_pa_a1_unset_nio(vm_instance_t *vm,struct cisco_card *card, |
1684 |
|
u_int port_id) |
1685 |
{ |
{ |
1686 |
struct pa_a1_data *d; |
struct pa_a1_data *d = card->drv_info; |
1687 |
|
|
1688 |
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
if (!d || (port_id > 0)) |
1689 |
return(-1); |
return(-1); |
1690 |
|
|
1691 |
if (d->nio) { |
if (d->nio) { |
1697 |
} |
} |
1698 |
|
|
1699 |
/* PA-A1 driver */ |
/* PA-A1 driver */ |
1700 |
struct c7200_pa_driver dev_c7200_pa_a1_driver = { |
struct cisco_card_driver dev_c7200_pa_a1_driver = { |
1701 |
"PA-A1", 1, |
"PA-A1", 1, 0, |
1702 |
dev_c7200_pa_a1_init, |
dev_c7200_pa_a1_init, |
1703 |
dev_c7200_pa_a1_shutdown, |
dev_c7200_pa_a1_shutdown, |
1704 |
|
NULL, |
1705 |
dev_c7200_pa_a1_set_nio, |
dev_c7200_pa_a1_set_nio, |
1706 |
dev_c7200_pa_a1_unset_nio, |
dev_c7200_pa_a1_unset_nio, |
1707 |
NULL, |
NULL, |