784 |
* |
* |
785 |
* Add a PA-4B/PA-8B port adapter into specified slot. |
* Add a PA-4B/PA-8B port adapter into specified slot. |
786 |
*/ |
*/ |
787 |
int dev_c7200_pa_bri_init(c7200_t *router,char *name,u_int pa_bay) |
int dev_c7200_pa_bri_init(vm_instance_t *vm,struct cisco_card *card) |
788 |
{ |
{ |
789 |
|
u_int slot = card->slot_id; |
790 |
struct pci_device *pci_dev; |
struct pci_device *pci_dev; |
791 |
struct pa_4b_data *d; |
struct pa_4b_data *d; |
792 |
struct vdevice *dev; |
struct vdevice *dev; |
793 |
|
|
794 |
/* Allocate the private data structure for PA-4B chip */ |
/* Allocate the private data structure for PA-4B chip */ |
795 |
if (!(d = malloc(sizeof(*d)))) { |
if (!(d = malloc(sizeof(*d)))) { |
796 |
fprintf(stderr,"%s (PA-4B): out of memory\n",name); |
vm_error(vm,"%s: out of memory\n",card->dev_name); |
797 |
return(-1); |
return(-1); |
798 |
} |
} |
799 |
|
|
800 |
memset(d,0,sizeof(*d)); |
memset(d,0,sizeof(*d)); |
801 |
d->m32_offset = 0x08; |
d->m32_offset = 0x08; |
802 |
d->m32_data.vm = router->vm; |
d->m32_data.vm = vm; |
803 |
|
|
804 |
|
/* Set the PCI bus */ |
805 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
806 |
|
|
807 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
808 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-4B")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-4B")); |
809 |
|
c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); |
810 |
|
|
811 |
/* Add as PCI device PA-4B */ |
/* Add as PCI device PA-4B */ |
812 |
pci_dev = pci_dev_add(router->pa_bay[pa_bay].pci_map,name, |
pci_dev = pci_dev_add(card->pci_bus,card->dev_name, |
813 |
BRI_PCI_VENDOR_ID,BRI_PCI_PRODUCT_ID, |
BRI_PCI_VENDOR_ID,BRI_PCI_PRODUCT_ID, |
814 |
0,0,C7200_NETIO_IRQ,d, |
0,0,C7200_NETIO_IRQ,d, |
815 |
NULL,pci_munich32_read,pci_munich32_write); |
NULL,pci_munich32_read,pci_munich32_write); |
816 |
|
|
817 |
if (!pci_dev) { |
if (!pci_dev) { |
818 |
fprintf(stderr,"%s (PA-4B): unable to create PCI device.\n",name); |
vm_error(vm,"%s: unable to create PCI device.\n",card->dev_name); |
819 |
return(-1); |
return(-1); |
820 |
} |
} |
821 |
|
|
822 |
/* Create the PA-4B structure */ |
/* Create the PA-4B structure */ |
823 |
d->name = name; |
d->name = card->dev_name; |
824 |
d->pci_dev = pci_dev; |
d->pci_dev = pci_dev; |
825 |
d->vm = router->vm; |
d->vm = vm; |
826 |
|
|
827 |
/* Create the device itself */ |
/* Create the device itself */ |
828 |
if (!(dev = dev_create(name))) { |
if (!(dev = dev_create(card->dev_name))) { |
829 |
fprintf(stderr,"%s (PA-4B): unable to create device.\n",name); |
vm_error(vm,"%s: unable to create device.\n",card->dev_name); |
830 |
return(-1); |
return(-1); |
831 |
} |
} |
832 |
|
|
833 |
dev->phys_len = 0x800000; |
dev->phys_len = 0x800000; |
834 |
dev->handler = pa_4b_access; |
dev->handler = pa_4b_access; |
835 |
|
|
836 |
/* Store device info */ |
/* Store device info */ |
837 |
dev->priv_data = d; |
dev->priv_data = d; |
838 |
d->dev = dev; |
d->dev = dev; |
839 |
|
|
|
/* Map this device to the VM */ |
|
|
vm_bind_device(router->vm,dev); |
|
|
|
|
840 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
841 |
return(c7200_pa_set_drvinfo(router,pa_bay,d)); |
card->drv_info = d; |
842 |
|
return(0); |
843 |
} |
} |
844 |
|
|
845 |
/* Remove a PA-4B from the specified slot */ |
/* Remove a PA-4B from the specified slot */ |
846 |
int dev_c7200_pa_bri_shutdown(c7200_t *router,u_int pa_bay) |
int dev_c7200_pa_bri_shutdown(vm_instance_t *vm,struct cisco_card *card) |
847 |
{ |
{ |
848 |
struct c7200_pa_bay *bay; |
struct pa_4b_data *d = card->drv_info; |
|
struct pa_4b_data *d; |
|
|
|
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
|
|
return(-1); |
|
|
|
|
|
d = bay->drv_info; |
|
849 |
|
|
850 |
/* Remove the PA EEPROM */ |
/* Remove the PA EEPROM */ |
851 |
c7200_pa_unset_eeprom(router,pa_bay); |
cisco_card_unset_eeprom(card); |
852 |
|
c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL); |
853 |
|
|
854 |
/* Remove the PCI device */ |
/* Remove the PCI device */ |
855 |
pci_dev_remove(d->pci_dev); |
pci_dev_remove(d->pci_dev); |
856 |
|
|
857 |
/* Remove the device from the CPU address space */ |
/* Remove the device from the CPU address space */ |
858 |
vm_unbind_device(router->vm,d->dev); |
vm_unbind_device(vm,d->dev); |
859 |
cpu_group_rebuild_mts(router->vm->cpu_group); |
cpu_group_rebuild_mts(vm->cpu_group); |
860 |
|
|
861 |
/* Free the device structure itself */ |
/* Free the device structure itself */ |
862 |
free(d->dev); |
free(d->dev); |
865 |
} |
} |
866 |
|
|
867 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
868 |
int dev_c7200_pa_bri_set_nio(c7200_t *router,u_int pa_bay,u_int port_id, |
int dev_c7200_pa_bri_set_nio(vm_instance_t *vm,struct cisco_card *card, |
869 |
netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
870 |
{ |
{ |
871 |
struct pa_4b_data *d; |
struct pa_4b_data *d = card->drv_info; |
872 |
|
|
873 |
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
if (!d || (port_id > 0)) |
874 |
return(-1); |
return(-1); |
875 |
|
|
876 |
if (d->nio != NULL) |
if (d->nio != NULL) |
879 |
d->nio = nio; |
d->nio = nio; |
880 |
|
|
881 |
/* TEST */ |
/* TEST */ |
882 |
d->m32_data.tx_tid = ptask_add((ptask_callback)m32_tx_scan_all_channels,&d->m32_data,NULL); |
d->m32_data.tx_tid = ptask_add((ptask_callback)m32_tx_scan_all_channels, |
883 |
|
&d->m32_data,NULL); |
884 |
|
|
885 |
//netio_rxl_add(nio,(netio_rx_handler_t)dev_pa_4b_handle_rxring,d,NULL); |
//netio_rxl_add(nio,(netio_rx_handler_t)dev_pa_4b_handle_rxring,d,NULL); |
886 |
return(0); |
return(0); |
887 |
} |
} |
888 |
|
|
889 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
890 |
int dev_c7200_pa_bri_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id) |
int dev_c7200_pa_bri_unset_nio(vm_instance_t *vm,struct cisco_card *card, |
891 |
|
u_int port_id) |
892 |
{ |
{ |
893 |
struct pa_4b_data *d; |
struct pa_4b_data *d = card->drv_info; |
894 |
|
|
895 |
if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay))) |
if (!d || (port_id > 0)) |
896 |
return(-1); |
return(-1); |
897 |
|
|
898 |
if (d->nio) { |
if (d->nio) { |
906 |
} |
} |
907 |
|
|
908 |
/* PA-4B driver */ |
/* PA-4B driver */ |
909 |
struct c7200_pa_driver dev_c7200_pa_4b_driver = { |
struct cisco_card_driver dev_c7200_pa_4b_driver = { |
910 |
"PA-4B", 0, |
"PA-4B", 0, 0, |
911 |
dev_c7200_pa_bri_init, |
dev_c7200_pa_bri_init, |
912 |
dev_c7200_pa_bri_shutdown, |
dev_c7200_pa_bri_shutdown, |
913 |
|
NULL, |
914 |
dev_c7200_pa_bri_set_nio, |
dev_c7200_pa_bri_set_nio, |
915 |
dev_c7200_pa_bri_unset_nio, |
dev_c7200_pa_bri_unset_nio, |
916 |
NULL, |
NULL, |