34 |
* |
* |
35 |
* Add an Ethernet Network Module into specified slot. |
* Add an Ethernet Network Module into specified slot. |
36 |
*/ |
*/ |
37 |
static int dev_c3600_nm_eth_init(c3600_t *router,char *name,u_int nm_bay, |
static int dev_c3600_nm_eth_init(vm_instance_t *vm,struct cisco_card *card, |
38 |
int nr_port,int interface_type, |
int nr_port,int interface_type, |
39 |
const struct cisco_eeprom *eeprom) |
const struct cisco_eeprom *eeprom) |
40 |
{ |
{ |
41 |
struct nm_bay_info *bay_info; |
struct nm_bay_info *bay_info; |
42 |
struct nm_eth_data *data; |
struct nm_eth_data *data; |
43 |
|
u_int slot = card->slot_id; |
44 |
|
u_int chassis_id; |
45 |
int i; |
int i; |
46 |
|
|
47 |
/* Allocate the private data structure */ |
/* Allocate the private data structure */ |
48 |
if (!(data = malloc(sizeof(*data)))) { |
if (!(data = malloc(sizeof(*data)))) { |
49 |
fprintf(stderr,"%s: out of memory\n",name); |
vm_error(vm,"%s: out of memory.\n",card->dev_name); |
50 |
return(-1); |
return(-1); |
51 |
} |
} |
52 |
|
|
53 |
memset(data,0,sizeof(*data)); |
memset(data,0,sizeof(*data)); |
54 |
data->nr_port = nr_port; |
data->nr_port = nr_port; |
55 |
|
|
56 |
|
/* Set the PCI bus */ |
57 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
58 |
|
|
59 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
60 |
c3600_nm_set_eeprom(router,nm_bay,eeprom); |
cisco_card_set_eeprom(vm,card,eeprom); |
61 |
|
c3600_set_slot_eeprom(VM_C3600(vm),slot,&card->eeprom); |
62 |
|
|
63 |
/* Get PCI bus info about this bay */ |
/* Get PCI bus info about this bay */ |
64 |
bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay); |
chassis_id = c3600_chassis_get_id(VM_C3600(vm)); |
65 |
|
bay_info = c3600_nm_get_bay_info(chassis_id,slot); |
66 |
|
|
67 |
if (!bay_info) { |
if (!bay_info) { |
68 |
fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay); |
vm_error(vm,"unable to get info for NM bay %u\n",slot); |
69 |
return(-1); |
return(-1); |
70 |
} |
} |
71 |
|
|
72 |
/* Create the AMD Am971c971 chip(s) */ |
/* Create the AMD Am971c971 chip(s) */ |
73 |
for(i=0;i<data->nr_port;i++) { |
for(i=0;i<data->nr_port;i++) { |
74 |
data->port[i] = dev_am79c971_init(router->vm,name,interface_type, |
data->port[i] = dev_am79c971_init(vm,card->dev_name,interface_type, |
75 |
router->nm_bay[nm_bay].pci_map, |
card->pci_bus,bay_info->pci_device+i, |
76 |
bay_info->pci_device + i, |
c3600_net_irq_for_slot_port(slot,i)); |
|
c3600_net_irq_for_slot_port(nm_bay,i)); |
|
77 |
} |
} |
78 |
|
|
79 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
80 |
return(c3600_nm_set_drvinfo(router,nm_bay,data)); |
card->drv_info = data; |
81 |
|
return(0); |
82 |
} |
} |
83 |
|
|
84 |
/* Remove an Ethernet NM from the specified slot */ |
/* Remove an Ethernet NM from the specified slot */ |
85 |
static int dev_c3600_nm_eth_shutdown(c3600_t *router,u_int nm_bay) |
static int dev_c3600_nm_eth_shutdown(vm_instance_t *vm,struct cisco_card *card) |
86 |
{ |
{ |
87 |
struct c3600_nm_bay *bay; |
struct nm_eth_data *data = card->drv_info; |
|
struct nm_eth_data *data; |
|
88 |
int i; |
int i; |
89 |
|
|
|
if (!(bay = c3600_nm_get_info(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
data = bay->drv_info; |
|
|
|
|
90 |
/* Remove the NM EEPROM */ |
/* Remove the NM EEPROM */ |
91 |
c3600_nm_unset_eeprom(router,nm_bay); |
cisco_card_unset_eeprom(card); |
92 |
|
c3600_set_slot_eeprom(VM_C3600(vm),card->slot_id,NULL); |
93 |
|
|
94 |
/* Remove the AMD Am79c971 chips */ |
/* Remove the AMD Am79c971 chips */ |
95 |
for(i=0;i<data->nr_port;i++) |
for(i=0;i<data->nr_port;i++) |
100 |
} |
} |
101 |
|
|
102 |
/* Bind a Network IO descriptor */ |
/* Bind a Network IO descriptor */ |
103 |
static int dev_c3600_nm_eth_set_nio(c3600_t *router,u_int nm_bay, |
static int dev_c3600_nm_eth_set_nio(vm_instance_t *vm,struct cisco_card *card, |
104 |
u_int port_id,netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
105 |
{ |
{ |
106 |
struct nm_eth_data *d; |
struct nm_eth_data *d = card->drv_info; |
|
|
|
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
|
107 |
|
|
108 |
if (!d || (port_id >= d->nr_port)) |
if (!d || (port_id >= d->nr_port)) |
109 |
return(-1); |
return(-1); |
113 |
} |
} |
114 |
|
|
115 |
/* Unbind a Network IO descriptor */ |
/* Unbind a Network IO descriptor */ |
116 |
static int dev_c3600_nm_eth_unset_nio(c3600_t *router,u_int nm_bay, |
static int dev_c3600_nm_eth_unset_nio(vm_instance_t *vm, |
117 |
|
struct cisco_card *card, |
118 |
u_int port_id) |
u_int port_id) |
119 |
{ |
{ |
120 |
struct nm_eth_data *d; |
struct nm_eth_data *d = card->drv_info; |
|
|
|
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
|
121 |
|
|
122 |
if (!d || (port_id >= d->nr_port)) |
if (!d || (port_id >= d->nr_port)) |
123 |
return(-1); |
return(-1); |
135 |
* |
* |
136 |
* Add a NM-1E Network Module into specified slot. |
* Add a NM-1E Network Module into specified slot. |
137 |
*/ |
*/ |
138 |
static int dev_c3600_nm_1e_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_1e_init(vm_instance_t *vm,struct cisco_card *card) |
139 |
{ |
{ |
140 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_10BASE_T, |
return(dev_c3600_nm_eth_init(vm,card,1,AM79C971_TYPE_10BASE_T, |
141 |
cisco_eeprom_find_nm("NM-1E"))); |
cisco_eeprom_find_nm("NM-1E"))); |
142 |
} |
} |
143 |
|
|
150 |
* |
* |
151 |
* Add a NM-4E Network Module into specified slot. |
* Add a NM-4E Network Module into specified slot. |
152 |
*/ |
*/ |
153 |
static int dev_c3600_nm_4e_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_4e_init(vm_instance_t *vm,struct cisco_card *card) |
154 |
{ |
{ |
155 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,4,AM79C971_TYPE_10BASE_T, |
return(dev_c3600_nm_eth_init(vm,card,4,AM79C971_TYPE_10BASE_T, |
156 |
cisco_eeprom_find_nm("NM-4E"))); |
cisco_eeprom_find_nm("NM-4E"))); |
157 |
} |
} |
158 |
|
|
165 |
* |
* |
166 |
* Add a NM-1FE-TX Network Module into specified slot. |
* Add a NM-1FE-TX Network Module into specified slot. |
167 |
*/ |
*/ |
168 |
static int dev_c3600_nm_1fe_tx_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_1fe_tx_init(vm_instance_t *vm,struct cisco_card *card) |
169 |
{ |
{ |
170 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_100BASE_TX, |
return(dev_c3600_nm_eth_init(vm,card,1,AM79C971_TYPE_100BASE_TX, |
171 |
cisco_eeprom_find_nm("NM-1FE-TX"))); |
cisco_eeprom_find_nm("NM-1FE-TX"))); |
172 |
} |
} |
173 |
|
|
176 |
/* ====================================================================== */ |
/* ====================================================================== */ |
177 |
|
|
178 |
/* Add a NM-16ESW */ |
/* Add a NM-16ESW */ |
179 |
static int dev_c3600_nm_16esw_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_16esw_init(vm_instance_t *vm,struct cisco_card *card) |
180 |
{ |
{ |
181 |
struct nm_bay_info *bay_info; |
struct nm_bay_info *bay_info; |
182 |
struct nm_16esw_data *data; |
struct nm_16esw_data *data; |
183 |
|
u_int slot = card->slot_id; |
184 |
|
u_int chassis_id; |
185 |
|
|
186 |
|
/* Set the PCI bus */ |
187 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
188 |
|
|
189 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
190 |
c3600_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-16ESW")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm("NM-16ESW")); |
191 |
dev_nm_16esw_burn_mac_addr(router->vm,nm_bay, |
dev_nm_16esw_burn_mac_addr(vm,slot,&card->eeprom); |
192 |
&router->nm_bay[nm_bay].eeprom); |
c3600_set_slot_eeprom(VM_C3600(vm),slot,&card->eeprom); |
193 |
|
|
194 |
/* Get PCI bus info about this bay */ |
/* Get PCI bus info about this bay */ |
195 |
bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay); |
chassis_id = c3600_chassis_get_id(VM_C3600(vm)); |
196 |
|
bay_info = c3600_nm_get_bay_info(chassis_id,slot); |
197 |
|
|
198 |
if (!bay_info) { |
if (!bay_info) { |
199 |
fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay); |
vm_error(vm,"unable to get info for NM bay %u\n",slot); |
200 |
return(-1); |
return(-1); |
201 |
} |
} |
202 |
|
|
203 |
/* Create the device */ |
/* Create the device */ |
204 |
data = dev_nm_16esw_init(router->vm,name,nm_bay, |
data = dev_nm_16esw_init(vm,card->dev_name,slot, |
205 |
router->nm_bay[nm_bay].pci_map, |
card->pci_bus,bay_info->pci_device, |
206 |
bay_info->pci_device, |
c3600_net_irq_for_slot_port(slot,0)); |
|
c3600_net_irq_for_slot_port(nm_bay,0)); |
|
207 |
|
|
208 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
209 |
return(c3600_nm_set_drvinfo(router,nm_bay,data)); |
card->drv_info = data; |
210 |
|
return(0); |
211 |
} |
} |
212 |
|
|
213 |
/* Remove a NM-16ESW from the specified slot */ |
/* Remove a NM-16ESW from the specified slot */ |
214 |
static int dev_c3600_nm_16esw_shutdown(c3600_t *router,u_int nm_bay) |
static int |
215 |
|
dev_c3600_nm_16esw_shutdown(vm_instance_t *vm,struct cisco_card *card) |
216 |
{ |
{ |
217 |
struct c3600_nm_bay *bay; |
struct nm_16esw_data *data = card->drv_info; |
|
struct nm_16esw_data *data; |
|
|
|
|
|
if (!(bay = c3600_nm_get_info(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
data = bay->drv_info; |
|
218 |
|
|
219 |
/* Remove the NM EEPROM */ |
/* Remove the NM EEPROM */ |
220 |
c3600_nm_unset_eeprom(router,nm_bay); |
cisco_card_unset_eeprom(card); |
221 |
|
c3600_set_slot_eeprom(VM_C3600(vm),card->slot_id,NULL); |
222 |
|
|
223 |
/* Remove the BCM5600 chip */ |
/* Remove the BCM5600 chip */ |
224 |
dev_nm_16esw_remove(data); |
dev_nm_16esw_remove(data); |
226 |
} |
} |
227 |
|
|
228 |
/* Bind a Network IO descriptor */ |
/* Bind a Network IO descriptor */ |
229 |
static int dev_c3600_nm_16esw_set_nio(c3600_t *router,u_int nm_bay, |
static int |
230 |
u_int port_id,netio_desc_t *nio) |
dev_c3600_nm_16esw_set_nio(vm_instance_t *vm,struct cisco_card *card, |
231 |
|
u_int port_id,netio_desc_t *nio) |
232 |
{ |
{ |
233 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
|
234 |
dev_nm_16esw_set_nio(d,port_id,nio); |
dev_nm_16esw_set_nio(d,port_id,nio); |
235 |
return(0); |
return(0); |
236 |
} |
} |
237 |
|
|
238 |
/* Unbind a Network IO descriptor */ |
/* Unbind a Network IO descriptor */ |
239 |
static int dev_c3600_nm_16esw_unset_nio(c3600_t *router,u_int nm_bay, |
static int dev_c3600_nm_16esw_unset_nio(vm_instance_t *vm, |
240 |
|
struct cisco_card *card, |
241 |
u_int port_id) |
u_int port_id) |
242 |
{ |
{ |
243 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
|
244 |
dev_nm_16esw_unset_nio(d,port_id); |
dev_nm_16esw_unset_nio(d,port_id); |
245 |
return(0); |
return(0); |
246 |
} |
} |
247 |
|
|
248 |
/* Show debug info */ |
/* Show debug info */ |
249 |
static int dev_c3600_nm_16esw_show_info(c3600_t *router,u_int nm_bay) |
static int |
250 |
|
dev_c3600_nm_16esw_show_info(vm_instance_t *vm,struct cisco_card *card) |
251 |
{ |
{ |
252 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
|
253 |
dev_nm_16esw_show_info(d); |
dev_nm_16esw_show_info(d); |
254 |
return(0); |
return(0); |
255 |
} |
} |
284 |
* |
* |
285 |
* Add Leopard-2FE (only Cisco 3660, in slot 0). |
* Add Leopard-2FE (only Cisco 3660, in slot 0). |
286 |
*/ |
*/ |
287 |
static int dev_c3600_leopard_2fe_init(c3600_t *router,char *name,u_int nm_bay) |
static int |
288 |
|
dev_c3600_leopard_2fe_init(vm_instance_t *vm,struct cisco_card *card) |
289 |
{ |
{ |
290 |
if (nm_bay != 0) { |
if (card->slot_id != 0) { |
291 |
fprintf(stderr,"C3600 %s: Leopard-2FE can only be put in slot 0\n", |
vm_error(vm,"dev_c3600_leopard_2fe_init: bad slot %u specified.\n", |
292 |
router->vm->name); |
card->slot_id); |
293 |
return(-1); |
return(-1); |
294 |
} |
} |
295 |
|
|
296 |
return(dev_c3600_nm_eth_init(router,name,0,2,AM79C971_TYPE_100BASE_TX, |
return(dev_c3600_nm_eth_init(vm,card,2,AM79C971_TYPE_100BASE_TX, |
297 |
&eeprom_c3600_leopard_2fe)); |
&eeprom_c3600_leopard_2fe)); |
298 |
} |
} |
299 |
|
|
300 |
/* ====================================================================== */ |
/* ====================================================================== */ |
301 |
|
|
302 |
/* NM-1FE-TX driver */ |
/* NM-1FE-TX driver */ |
303 |
struct c3600_nm_driver dev_c3600_nm_1fe_tx_driver = { |
struct cisco_card_driver dev_c3600_nm_1fe_tx_driver = { |
304 |
"NM-1FE-TX", 1, 0, |
"NM-1FE-TX", 1, 0, |
305 |
dev_c3600_nm_1fe_tx_init, |
dev_c3600_nm_1fe_tx_init, |
306 |
dev_c3600_nm_eth_shutdown, |
dev_c3600_nm_eth_shutdown, |
307 |
|
NULL, |
308 |
dev_c3600_nm_eth_set_nio, |
dev_c3600_nm_eth_set_nio, |
309 |
dev_c3600_nm_eth_unset_nio, |
dev_c3600_nm_eth_unset_nio, |
310 |
NULL, |
NULL, |
311 |
}; |
}; |
312 |
|
|
313 |
/* NM-1E driver */ |
/* NM-1E driver */ |
314 |
struct c3600_nm_driver dev_c3600_nm_1e_driver = { |
struct cisco_card_driver dev_c3600_nm_1e_driver = { |
315 |
"NM-1E", 1, 0, |
"NM-1E", 1, 0, |
316 |
dev_c3600_nm_1e_init, |
dev_c3600_nm_1e_init, |
317 |
dev_c3600_nm_eth_shutdown, |
dev_c3600_nm_eth_shutdown, |
318 |
|
NULL, |
319 |
dev_c3600_nm_eth_set_nio, |
dev_c3600_nm_eth_set_nio, |
320 |
dev_c3600_nm_eth_unset_nio, |
dev_c3600_nm_eth_unset_nio, |
321 |
NULL, |
NULL, |
322 |
}; |
}; |
323 |
|
|
324 |
/* NM-4E driver */ |
/* NM-4E driver */ |
325 |
struct c3600_nm_driver dev_c3600_nm_4e_driver = { |
struct cisco_card_driver dev_c3600_nm_4e_driver = { |
326 |
"NM-4E", 1, 0, |
"NM-4E", 1, 0, |
327 |
dev_c3600_nm_4e_init, |
dev_c3600_nm_4e_init, |
328 |
dev_c3600_nm_eth_shutdown, |
dev_c3600_nm_eth_shutdown, |
329 |
|
NULL, |
330 |
dev_c3600_nm_eth_set_nio, |
dev_c3600_nm_eth_set_nio, |
331 |
dev_c3600_nm_eth_unset_nio, |
dev_c3600_nm_eth_unset_nio, |
332 |
NULL, |
NULL, |
333 |
}; |
}; |
334 |
|
|
335 |
/* NM-16ESW driver */ |
/* NM-16ESW driver */ |
336 |
struct c3600_nm_driver dev_c3600_nm_16esw_driver = { |
struct cisco_card_driver dev_c3600_nm_16esw_driver = { |
337 |
"NM-16ESW", 1, 0, |
"NM-16ESW", 1, 0, |
338 |
dev_c3600_nm_16esw_init, |
dev_c3600_nm_16esw_init, |
339 |
dev_c3600_nm_16esw_shutdown, |
dev_c3600_nm_16esw_shutdown, |
340 |
|
NULL, |
341 |
dev_c3600_nm_16esw_set_nio, |
dev_c3600_nm_16esw_set_nio, |
342 |
dev_c3600_nm_16esw_unset_nio, |
dev_c3600_nm_16esw_unset_nio, |
343 |
dev_c3600_nm_16esw_show_info, |
dev_c3600_nm_16esw_show_info, |
344 |
}; |
}; |
345 |
|
|
346 |
/* Leopard-2FE driver */ |
/* Leopard-2FE driver */ |
347 |
struct c3600_nm_driver dev_c3600_leopard_2fe_driver = { |
struct cisco_card_driver dev_c3600_leopard_2fe_driver = { |
348 |
"Leopard-2FE", 1, 0, |
"Leopard-2FE", 1, 0, |
349 |
dev_c3600_leopard_2fe_init, |
dev_c3600_leopard_2fe_init, |
350 |
dev_c3600_nm_eth_shutdown, |
dev_c3600_nm_eth_shutdown, |
351 |
|
NULL, |
352 |
dev_c3600_nm_eth_set_nio, |
dev_c3600_nm_eth_set_nio, |
353 |
dev_c3600_nm_eth_unset_nio, |
dev_c3600_nm_eth_unset_nio, |
354 |
NULL, |
NULL, |