44 |
* |
* |
45 |
* Add a PA-4T port adapter into specified slot. |
* Add a PA-4T port adapter into specified slot. |
46 |
*/ |
*/ |
47 |
int dev_c7200_pa_4t_init(c7200_t *router,char *name,u_int pa_bay) |
static int dev_c7200_pa_4t_init(vm_instance_t *vm,struct cisco_card *card) |
48 |
{ |
{ |
49 |
struct mueslix_data *data; |
struct mueslix_data *data; |
50 |
|
u_int slot = card->slot_id; |
51 |
|
|
52 |
|
/* Set the PCI bus */ |
53 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
54 |
|
|
55 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
56 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-4T+")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-4T+")); |
57 |
|
c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); |
58 |
|
|
59 |
/* Create the Mueslix chip */ |
/* Create the Mueslix chip */ |
60 |
data = dev_mueslix_init(router->vm,name,1, |
data = dev_mueslix_init(vm,card->dev_name,1, |
61 |
router->pa_bay[pa_bay].pci_map,0, |
card->pci_bus,0, |
62 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
c7200_net_irq_for_slot_port(slot,0)); |
63 |
if (!data) return(-1); |
if (!data) return(-1); |
64 |
|
|
65 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
66 |
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
card->drv_info = data; |
67 |
|
return(0); |
68 |
} |
} |
69 |
|
|
70 |
/* Remove a PA-4T+ from the specified slot */ |
/* Remove a PA-4T+ from the specified slot */ |
71 |
int dev_c7200_pa_4t_shutdown(c7200_t *router,u_int pa_bay) |
static int dev_c7200_pa_4t_shutdown(vm_instance_t *vm,struct cisco_card *card) |
72 |
{ |
{ |
73 |
struct c7200_pa_bay *bay; |
/* Remove the PA EEPROM */ |
74 |
|
cisco_card_unset_eeprom(card); |
75 |
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL); |
76 |
return(-1); |
|
77 |
|
/* Remove the Mueslix chip */ |
78 |
c7200_pa_unset_eeprom(router,pa_bay); |
dev_mueslix_remove(card->drv_info); |
|
dev_mueslix_remove(bay->drv_info); |
|
79 |
return(0); |
return(0); |
80 |
} |
} |
81 |
|
|
82 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
83 |
int dev_c7200_pa_4t_set_nio(c7200_t *router,u_int pa_bay,u_int port_id, |
static int dev_c7200_pa_4t_set_nio(vm_instance_t *vm,struct cisco_card *card, |
84 |
netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
85 |
{ |
{ |
86 |
struct mueslix_data *data; |
struct mueslix_data *data = card->drv_info; |
87 |
|
|
88 |
if ((port_id >= MUESLIX_NR_CHANNELS) || |
if (!data || (port_id >= MUESLIX_NR_CHANNELS)) |
|
!(data = c7200_pa_get_drvinfo(router,pa_bay))) |
|
89 |
return(-1); |
return(-1); |
90 |
|
|
91 |
return(dev_mueslix_set_nio(data,port_id,nio)); |
return(dev_mueslix_set_nio(data,port_id,nio)); |
92 |
} |
} |
93 |
|
|
94 |
/* Unbind a Network IO descriptor to a specific port */ |
/* Unbind a Network IO descriptor to a specific port */ |
95 |
int dev_c7200_pa_4t_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id) |
static int dev_c7200_pa_4t_unset_nio(vm_instance_t *vm,struct cisco_card *card, |
96 |
|
u_int port_id) |
97 |
{ |
{ |
98 |
struct mueslix_data *d; |
struct mueslix_data *data = card->drv_info; |
99 |
|
|
100 |
if ((port_id >= MUESLIX_NR_CHANNELS) || |
if (!data || (port_id >= MUESLIX_NR_CHANNELS)) |
|
!(d = c7200_pa_get_drvinfo(router,pa_bay))) |
|
101 |
return(-1); |
return(-1); |
102 |
|
|
103 |
return(dev_mueslix_unset_nio(d,port_id)); |
return(dev_mueslix_unset_nio(data,port_id)); |
104 |
} |
} |
105 |
|
|
106 |
/* PA-4T+ driver */ |
/* PA-4T+ driver */ |
107 |
struct c7200_pa_driver dev_c7200_pa_4t_driver = { |
struct cisco_card_driver dev_c7200_pa_4t_driver = { |
108 |
"PA-4T+", 1, |
"PA-4T+", 1, 0, |
109 |
dev_c7200_pa_4t_init, |
dev_c7200_pa_4t_init, |
110 |
dev_c7200_pa_4t_shutdown, |
dev_c7200_pa_4t_shutdown, |
111 |
|
NULL, |
112 |
dev_c7200_pa_4t_set_nio, |
dev_c7200_pa_4t_set_nio, |
113 |
dev_c7200_pa_4t_unset_nio, |
dev_c7200_pa_4t_unset_nio, |
114 |
}; |
}; |
127 |
* |
* |
128 |
* Add a PA-8T port adapter into specified slot. |
* Add a PA-8T port adapter into specified slot. |
129 |
*/ |
*/ |
130 |
int dev_c7200_pa_8t_init(c7200_t *router,char *name,u_int pa_bay) |
static int dev_c7200_pa_8t_init(vm_instance_t *vm,struct cisco_card *card) |
131 |
{ |
{ |
132 |
struct pa8t_data *data; |
struct pa8t_data *data; |
133 |
|
u_int slot = card->slot_id; |
134 |
|
|
135 |
/* Allocate the private data structure for the PA-8T */ |
/* Allocate the private data structure for the PA-8T */ |
136 |
if (!(data = malloc(sizeof(*data)))) { |
if (!(data = malloc(sizeof(*data)))) { |
137 |
fprintf(stderr,"%s (PA-8T): out of memory\n",name); |
vm_log(vm,"%s: out of memory\n",card->dev_name); |
138 |
return(-1); |
return(-1); |
139 |
} |
} |
140 |
|
|
141 |
|
/* Set the PCI bus */ |
142 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
143 |
|
|
144 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
145 |
c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-8T")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-8T")); |
146 |
|
c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); |
147 |
|
|
148 |
/* Create the 1st Mueslix chip */ |
/* Create the 1st Mueslix chip */ |
149 |
data->mueslix[0] = dev_mueslix_init(router->vm,name,1, |
data->mueslix[0] = dev_mueslix_init(vm,card->dev_name,1, |
150 |
router->pa_bay[pa_bay].pci_map,0, |
card->pci_bus,0, |
151 |
c7200_net_irq_for_slot_port(pa_bay,0)); |
c7200_net_irq_for_slot_port(slot,0)); |
152 |
if (!data->mueslix[0]) return(-1); |
if (!data->mueslix[0]) return(-1); |
153 |
|
|
154 |
/* Create the 2nd Mueslix chip */ |
/* Create the 2nd Mueslix chip */ |
155 |
data->mueslix[1] = dev_mueslix_init(router->vm,name,1, |
data->mueslix[1] = dev_mueslix_init(vm,card->dev_name,1, |
156 |
router->pa_bay[pa_bay].pci_map,1, |
card->pci_bus,1, |
157 |
c7200_net_irq_for_slot_port(pa_bay,1)); |
c7200_net_irq_for_slot_port(slot,1)); |
158 |
if (!data->mueslix[1]) return(-1); |
if (!data->mueslix[1]) return(-1); |
159 |
|
|
160 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
161 |
return(c7200_pa_set_drvinfo(router,pa_bay,data)); |
card->drv_info = data; |
162 |
|
return(0); |
163 |
} |
} |
164 |
|
|
165 |
/* Remove a PA-8T from the specified slot */ |
/* Remove a PA-8T from the specified slot */ |
166 |
int dev_c7200_pa_8t_shutdown(c7200_t *router,u_int pa_bay) |
static int dev_c7200_pa_8t_shutdown(vm_instance_t *vm,struct cisco_card *card) |
167 |
{ |
{ |
168 |
struct c7200_pa_bay *bay; |
struct pa8t_data *data = card->drv_info; |
|
struct pa8t_data *data; |
|
|
|
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) |
|
|
return(-1); |
|
|
|
|
|
data = bay->drv_info; |
|
169 |
|
|
170 |
/* Remove the PA EEPROM */ |
/* Remove the PA EEPROM */ |
171 |
c7200_pa_unset_eeprom(router,pa_bay); |
cisco_card_unset_eeprom(card); |
172 |
|
c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL); |
173 |
|
|
174 |
/* Remove the two Mueslix chips */ |
/* Remove the two Mueslix chips */ |
175 |
dev_mueslix_remove(data->mueslix[0]); |
dev_mueslix_remove(data->mueslix[0]); |
179 |
} |
} |
180 |
|
|
181 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
182 |
int dev_c7200_pa_8t_set_nio(c7200_t *router,u_int pa_bay,u_int port_id, |
static int dev_c7200_pa_8t_set_nio(vm_instance_t *vm,struct cisco_card *card, |
183 |
netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
184 |
{ |
{ |
185 |
struct pa8t_data *d; |
struct pa8t_data *d = card->drv_info; |
186 |
|
|
187 |
if ((port_id >= (MUESLIX_NR_CHANNELS*2)) || |
if (!d || (port_id >= (MUESLIX_NR_CHANNELS*2))) |
|
!(d = c7200_pa_get_drvinfo(router,pa_bay))) |
|
188 |
return(-1); |
return(-1); |
189 |
|
|
190 |
return(dev_mueslix_set_nio(d->mueslix[port_id>>2],(port_id&0x03),nio)); |
return(dev_mueslix_set_nio(d->mueslix[port_id>>2],(port_id&0x03),nio)); |
191 |
} |
} |
192 |
|
|
193 |
/* Bind a Network IO descriptor to a specific port */ |
/* Bind a Network IO descriptor to a specific port */ |
194 |
int dev_c7200_pa_8t_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id) |
static int dev_c7200_pa_8t_unset_nio(vm_instance_t *vm,struct cisco_card *card, |
195 |
|
u_int port_id) |
196 |
{ |
{ |
197 |
struct pa8t_data *d; |
struct pa8t_data *d = card->drv_info; |
198 |
|
|
199 |
if ((port_id >= (MUESLIX_NR_CHANNELS*2)) || |
if (!d || (port_id >= (MUESLIX_NR_CHANNELS*2))) |
|
!(d = c7200_pa_get_drvinfo(router,pa_bay))) |
|
200 |
return(-1); |
return(-1); |
201 |
|
|
202 |
return(dev_mueslix_unset_nio(d->mueslix[port_id>>2],port_id&0x03)); |
return(dev_mueslix_unset_nio(d->mueslix[port_id>>2],port_id&0x03)); |
203 |
} |
} |
204 |
|
|
205 |
/* PA-8T driver */ |
/* PA-8T driver */ |
206 |
struct c7200_pa_driver dev_c7200_pa_8t_driver = { |
struct cisco_card_driver dev_c7200_pa_8t_driver = { |
207 |
"PA-8T", 1, |
"PA-8T", 1, 0, |
208 |
dev_c7200_pa_8t_init, |
dev_c7200_pa_8t_init, |
209 |
dev_c7200_pa_8t_shutdown, |
dev_c7200_pa_8t_shutdown, |
210 |
|
NULL, |
211 |
dev_c7200_pa_8t_set_nio, |
dev_c7200_pa_8t_set_nio, |
212 |
dev_c7200_pa_8t_unset_nio, |
dev_c7200_pa_8t_unset_nio, |
213 |
}; |
}; |