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