29 |
struct am79c971_data *port[8]; |
struct am79c971_data *port[8]; |
30 |
}; |
}; |
31 |
|
|
32 |
|
/* Return sub-slot info for integrated WIC slots (on motherboard) */ |
33 |
|
static int dev_c2691_mb_get_sub_info(vm_instance_t *vm,struct cisco_card *card, |
34 |
|
u_int port_id, |
35 |
|
struct cisco_card_driver ***drv_array, |
36 |
|
u_int *subcard_type) |
37 |
|
{ |
38 |
|
/* 3 integrated WIC slots */ |
39 |
|
if ((port_id & 0x0F) >= 3) |
40 |
|
return(-1); |
41 |
|
|
42 |
|
*drv_array = dev_c2691_mb_wic_drivers; |
43 |
|
*subcard_type = CISCO_CARD_TYPE_WIC; |
44 |
|
return(0); |
45 |
|
} |
46 |
|
|
47 |
/* |
/* |
48 |
* dev_c2691_nm_eth_init() |
* dev_c2691_nm_eth_init() |
49 |
* |
* |
50 |
* Add an Ethernet Network Module into specified slot. |
* Add an Ethernet Network Module into specified slot. |
51 |
*/ |
*/ |
52 |
static int dev_c2691_nm_eth_init(c2691_t *router,char *name,u_int nm_bay, |
static int dev_c2691_nm_eth_init(vm_instance_t *vm,struct cisco_card *card, |
53 |
int nr_port,int interface_type, |
int nr_port,int interface_type, |
54 |
const struct cisco_eeprom *eeprom) |
const struct cisco_eeprom *eeprom) |
55 |
{ |
{ |
56 |
struct nm_eth_data *data; |
struct nm_eth_data *data; |
57 |
|
u_int slot = card->slot_id; |
58 |
int i; |
int i; |
59 |
|
|
60 |
/* Allocate the private data structure */ |
/* Allocate the private data structure */ |
61 |
if (!(data = malloc(sizeof(*data)))) { |
if (!(data = malloc(sizeof(*data)))) { |
62 |
fprintf(stderr,"%s: out of memory\n",name); |
vm_error(vm,"%s: out of memory.\n",card->dev_name); |
63 |
return(-1); |
return(-1); |
64 |
} |
} |
65 |
|
|
66 |
memset(data,0,sizeof(*data)); |
memset(data,0,sizeof(*data)); |
67 |
data->nr_port = nr_port; |
data->nr_port = nr_port; |
68 |
|
|
69 |
|
/* Set the PCI bus */ |
70 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
71 |
|
|
72 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
73 |
c2691_nm_set_eeprom(router,nm_bay,eeprom); |
cisco_card_set_eeprom(vm,card,eeprom); |
74 |
|
c2691_set_slot_eeprom(VM_C2691(vm),slot,&card->eeprom); |
75 |
|
|
76 |
/* Create the AMD Am971c971 chip(s) */ |
/* Create the AMD Am971c971 chip(s) */ |
77 |
for(i=0;i<data->nr_port;i++) { |
for(i=0;i<data->nr_port;i++) { |
78 |
data->port[i] = dev_am79c971_init(router->vm,name,interface_type, |
data->port[i] = dev_am79c971_init(vm,card->dev_name,interface_type, |
79 |
router->nm_bay[nm_bay].pci_map, |
card->pci_bus,6+i, |
80 |
6,C2691_NETIO_IRQ); |
c2691_net_irq_for_slot_port(slot,i)); |
81 |
} |
} |
82 |
|
|
83 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
84 |
return(c2691_nm_set_drvinfo(router,nm_bay,data)); |
card->drv_info = data; |
85 |
|
return(0); |
86 |
} |
} |
87 |
|
|
88 |
/* Remove an Ethernet NM from the specified slot */ |
/* Remove an Ethernet NM from the specified slot */ |
89 |
static int dev_c2691_nm_eth_shutdown(c2691_t *router,u_int nm_bay) |
static int dev_c2691_nm_eth_shutdown(vm_instance_t *vm,struct cisco_card *card) |
90 |
{ |
{ |
91 |
struct c2691_nm_bay *bay; |
struct nm_eth_data *data = card->drv_info; |
|
struct nm_eth_data *data; |
|
92 |
int i; |
int i; |
93 |
|
|
|
if (!(bay = c2691_nm_get_info(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
data = bay->drv_info; |
|
|
|
|
94 |
/* Remove the NM EEPROM */ |
/* Remove the NM EEPROM */ |
95 |
c2691_nm_unset_eeprom(router,nm_bay); |
cisco_card_unset_eeprom(card); |
96 |
|
c2691_set_slot_eeprom(VM_C2691(vm),card->slot_id,NULL); |
97 |
|
|
98 |
/* Remove the AMD Am79c971 chips */ |
/* Remove the AMD Am79c971 chips */ |
99 |
for(i=0;i<data->nr_port;i++) |
for(i=0;i<data->nr_port;i++) |
104 |
} |
} |
105 |
|
|
106 |
/* Bind a Network IO descriptor */ |
/* Bind a Network IO descriptor */ |
107 |
static int dev_c2691_nm_eth_set_nio(c2691_t *router,u_int nm_bay, |
static int dev_c2691_nm_eth_set_nio(vm_instance_t *vm,struct cisco_card *card, |
108 |
u_int port_id,netio_desc_t *nio) |
u_int port_id,netio_desc_t *nio) |
109 |
{ |
{ |
110 |
struct nm_eth_data *d; |
struct nm_eth_data *d = card->drv_info; |
|
|
|
|
d = c2691_nm_get_drvinfo(router,nm_bay); |
|
111 |
|
|
112 |
if (!d || (port_id >= d->nr_port)) |
if (!d || (port_id >= d->nr_port)) |
113 |
return(-1); |
return(-1); |
117 |
} |
} |
118 |
|
|
119 |
/* Unbind a Network IO descriptor */ |
/* Unbind a Network IO descriptor */ |
120 |
static int dev_c2691_nm_eth_unset_nio(c2691_t *router,u_int nm_bay, |
static int dev_c2691_nm_eth_unset_nio(vm_instance_t *vm, |
121 |
|
struct cisco_card *card, |
122 |
u_int port_id) |
u_int port_id) |
123 |
{ |
{ |
124 |
struct nm_eth_data *d; |
struct nm_eth_data *d = card->drv_info; |
|
|
|
|
d = c2691_nm_get_drvinfo(router,nm_bay); |
|
125 |
|
|
126 |
if (!d || (port_id >= d->nr_port)) |
if (!d || (port_id >= d->nr_port)) |
127 |
return(-1); |
return(-1); |
130 |
return(0); |
return(0); |
131 |
} |
} |
132 |
|
|
133 |
|
|
134 |
/* ====================================================================== */ |
/* ====================================================================== */ |
135 |
/* NM-1FE-TX */ |
/* NM-1FE-TX */ |
136 |
/* ====================================================================== */ |
/* ====================================================================== */ |
140 |
* |
* |
141 |
* Add a NM-1FE-TX Network Module into specified slot. |
* Add a NM-1FE-TX Network Module into specified slot. |
142 |
*/ |
*/ |
143 |
static int dev_c2691_nm_1fe_tx_init(c2691_t *router,char *name,u_int nm_bay) |
static int dev_c2691_nm_1fe_tx_init(vm_instance_t *vm,struct cisco_card *card) |
144 |
{ |
{ |
145 |
return(dev_c2691_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_100BASE_TX, |
return(dev_c2691_nm_eth_init(vm,card,1,AM79C971_TYPE_100BASE_TX, |
146 |
cisco_eeprom_find_nm("NM-1FE-TX"))); |
cisco_eeprom_find_nm("NM-1FE-TX"))); |
147 |
} |
} |
148 |
|
|
151 |
/* ====================================================================== */ |
/* ====================================================================== */ |
152 |
|
|
153 |
/* Add a NM-16ESW */ |
/* Add a NM-16ESW */ |
154 |
static int dev_c2691_nm_16esw_init(c2691_t *router,char *name,u_int nm_bay) |
static int dev_c2691_nm_16esw_init(vm_instance_t *vm,struct cisco_card *card) |
155 |
{ |
{ |
156 |
struct nm_16esw_data *data; |
struct nm_16esw_data *data; |
157 |
|
u_int slot = card->slot_id; |
158 |
|
|
159 |
|
/* Set the PCI bus */ |
160 |
|
card->pci_bus = vm->slots_pci_bus[slot]; |
161 |
|
|
162 |
/* Set the EEPROM */ |
/* Set the EEPROM */ |
163 |
c2691_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-16ESW")); |
cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm("NM-16ESW")); |
164 |
dev_nm_16esw_burn_mac_addr(router->vm,nm_bay, |
dev_nm_16esw_burn_mac_addr(vm,slot,&card->eeprom); |
165 |
&router->nm_bay[nm_bay].eeprom); |
c2691_set_slot_eeprom(VM_C2691(vm),slot,&card->eeprom); |
166 |
|
|
167 |
/* Create the device */ |
/* Create the device */ |
168 |
data = dev_nm_16esw_init(router->vm,name,nm_bay, |
data = dev_nm_16esw_init(vm,card->dev_name,slot, |
169 |
router->nm_bay[nm_bay].pci_map, |
card->pci_bus,6, |
170 |
6,C2691_NETIO_IRQ); |
c2691_net_irq_for_slot_port(slot,0)); |
171 |
|
|
172 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
173 |
return(c2691_nm_set_drvinfo(router,nm_bay,data)); |
card->drv_info = data; |
174 |
|
return(0); |
175 |
} |
} |
176 |
|
|
177 |
/* Remove a NM-16ESW from the specified slot */ |
/* Remove a NM-16ESW from the specified slot */ |
178 |
static int dev_c2691_nm_16esw_shutdown(c2691_t *router,u_int nm_bay) |
static int |
179 |
|
dev_c2691_nm_16esw_shutdown(vm_instance_t *vm,struct cisco_card *card) |
180 |
{ |
{ |
181 |
struct c2691_nm_bay *bay; |
struct nm_16esw_data *data = card->drv_info; |
|
struct nm_16esw_data *data; |
|
|
|
|
|
if (!(bay = c2691_nm_get_info(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
data = bay->drv_info; |
|
182 |
|
|
183 |
/* Remove the NM EEPROM */ |
/* Remove the NM EEPROM */ |
184 |
c2691_nm_unset_eeprom(router,nm_bay); |
cisco_card_unset_eeprom(card); |
185 |
|
c2691_set_slot_eeprom(VM_C2691(vm),card->slot_id,NULL); |
186 |
|
|
187 |
/* Remove the BCM5600 chip */ |
/* Remove the BCM5600 chip */ |
188 |
dev_nm_16esw_remove(data); |
dev_nm_16esw_remove(data); |
190 |
} |
} |
191 |
|
|
192 |
/* Bind a Network IO descriptor */ |
/* Bind a Network IO descriptor */ |
193 |
static int dev_c2691_nm_16esw_set_nio(c2691_t *router,u_int nm_bay, |
static int |
194 |
u_int port_id,netio_desc_t *nio) |
dev_c2691_nm_16esw_set_nio(vm_instance_t *vm,struct cisco_card *card, |
195 |
|
u_int port_id,netio_desc_t *nio) |
196 |
{ |
{ |
197 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c2691_nm_get_drvinfo(router,nm_bay); |
|
198 |
dev_nm_16esw_set_nio(d,port_id,nio); |
dev_nm_16esw_set_nio(d,port_id,nio); |
199 |
return(0); |
return(0); |
200 |
} |
} |
201 |
|
|
202 |
/* Unbind a Network IO descriptor */ |
/* Unbind a Network IO descriptor */ |
203 |
static int dev_c2691_nm_16esw_unset_nio(c2691_t *router,u_int nm_bay, |
static int dev_c2691_nm_16esw_unset_nio(vm_instance_t *vm, |
204 |
|
struct cisco_card *card, |
205 |
u_int port_id) |
u_int port_id) |
206 |
{ |
{ |
207 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c2691_nm_get_drvinfo(router,nm_bay); |
|
208 |
dev_nm_16esw_unset_nio(d,port_id); |
dev_nm_16esw_unset_nio(d,port_id); |
209 |
return(0); |
return(0); |
210 |
} |
} |
211 |
|
|
212 |
/* Show debug info */ |
/* Show debug info */ |
213 |
static int dev_c2691_nm_16esw_show_info(c2691_t *router,u_int nm_bay) |
static int |
214 |
|
dev_c2691_nm_16esw_show_info(vm_instance_t *vm,struct cisco_card *card) |
215 |
{ |
{ |
216 |
struct nm_16esw_data *d; |
struct nm_16esw_data *d = card->drv_info; |
|
|
|
|
d = c2691_nm_get_drvinfo(router,nm_bay); |
|
217 |
dev_nm_16esw_show_info(d); |
dev_nm_16esw_show_info(d); |
218 |
return(0); |
return(0); |
219 |
} |
} |
223 |
/* ====================================================================== */ |
/* ====================================================================== */ |
224 |
|
|
225 |
/* Initialize Ethernet part of the GT96100 controller */ |
/* Initialize Ethernet part of the GT96100 controller */ |
226 |
static int dev_c2691_gt96100_fe_init(c2691_t *router,char *name,u_int nm_bay) |
static int dev_c2691_gt96100_fe_init(vm_instance_t *vm,struct cisco_card *card) |
227 |
{ |
{ |
228 |
vm_obj_t *obj; |
if (card->slot_id != 0) { |
229 |
|
vm_error(vm,"dev_c2691_gt96100_fe_init: bad slot %u specified.\n", |
230 |
if (nm_bay != 0) { |
card->slot_id); |
|
fprintf(stderr,"dev_c2691_gt96100_fe_init: bad slot specified.\n"); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
if (!(obj = vm_object_find(router->vm,"gt96100"))) { |
|
|
fprintf(stderr,"dev_c2691_gt96100_fe_init: unable to find " |
|
|
"system controller!\n"); |
|
231 |
return(-1); |
return(-1); |
232 |
} |
} |
233 |
|
|
234 |
/* Store device info into the router structure */ |
/* Store device info into the router structure */ |
235 |
return(c2691_nm_set_drvinfo(router,0,obj->data)); |
card->drv_info = VM_C2691(vm)->gt_data; |
236 |
|
return(0); |
237 |
} |
} |
238 |
|
|
239 |
/* Nothing to do, we never remove the system controller */ |
/* Nothing to do, we never remove the system controller */ |
240 |
static int dev_c2691_gt96100_fe_shutdown(c2691_t *router,u_int nm_bay) |
static int |
241 |
|
dev_c2691_gt96100_fe_shutdown(vm_instance_t *vm,struct cisco_card *card) |
242 |
{ |
{ |
243 |
return(0); |
return(0); |
244 |
} |
} |
245 |
|
|
246 |
/* Bind a Network IO descriptor */ |
/* Bind a Network IO descriptor */ |
247 |
static int dev_c2691_gt96100_fe_set_nio(c2691_t *router,u_int nm_bay, |
static int |
248 |
u_int port_id,netio_desc_t *nio) |
dev_c2691_gt96100_fe_set_nio(vm_instance_t *vm,struct cisco_card *card, |
249 |
|
u_int port_id,netio_desc_t *nio) |
250 |
{ |
{ |
251 |
struct gt_data *d; |
struct gt_data *d = card->drv_info; |
252 |
|
dev_gt96100_eth_set_nio(d,port_id,nio); |
|
if (!(d = c2691_nm_get_drvinfo(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
dev_gt96100_set_nio(d,port_id,nio); |
|
253 |
return(0); |
return(0); |
254 |
} |
} |
255 |
|
|
256 |
/* Unbind a Network IO descriptor */ |
/* Unbind a Network IO descriptor */ |
257 |
static int dev_c2691_gt96100_fe_unset_nio(c2691_t *router,u_int nm_bay, |
static int dev_c2691_gt96100_fe_unset_nio(vm_instance_t *vm, |
258 |
u_int port_id) |
struct cisco_card *card, |
259 |
|
u_int port_id) |
260 |
{ |
{ |
261 |
struct gt_data *d; |
struct gt_data *d = card->drv_info; |
262 |
|
dev_gt96100_eth_unset_nio(d,port_id); |
|
if (!(d = c2691_nm_get_drvinfo(router,nm_bay))) |
|
|
return(-1); |
|
|
|
|
|
dev_gt96100_unset_nio(d,port_id); |
|
263 |
return(0); |
return(0); |
264 |
} |
} |
265 |
|
|
266 |
/* ====================================================================== */ |
/* ====================================================================== */ |
267 |
|
|
268 |
/* NM-1FE-TX driver */ |
/* NM-1FE-TX driver */ |
269 |
struct c2691_nm_driver dev_c2691_nm_1fe_tx_driver = { |
struct cisco_card_driver dev_c2691_nm_1fe_tx_driver = { |
270 |
"NM-1FE-TX", 1, 0, |
"NM-1FE-TX", 1, 0, |
271 |
dev_c2691_nm_1fe_tx_init, |
dev_c2691_nm_1fe_tx_init, |
272 |
dev_c2691_nm_eth_shutdown, |
dev_c2691_nm_eth_shutdown, |
273 |
|
NULL, |
274 |
dev_c2691_nm_eth_set_nio, |
dev_c2691_nm_eth_set_nio, |
275 |
dev_c2691_nm_eth_unset_nio, |
dev_c2691_nm_eth_unset_nio, |
276 |
NULL, |
NULL, |
277 |
}; |
}; |
278 |
|
|
279 |
/* NM-16ESW driver */ |
/* NM-16ESW driver */ |
280 |
struct c2691_nm_driver dev_c2691_nm_16esw_driver = { |
struct cisco_card_driver dev_c2691_nm_16esw_driver = { |
281 |
"NM-16ESW", 1, 0, |
"NM-16ESW", 1, 0, |
282 |
dev_c2691_nm_16esw_init, |
dev_c2691_nm_16esw_init, |
283 |
dev_c2691_nm_16esw_shutdown, |
dev_c2691_nm_16esw_shutdown, |
284 |
|
NULL, |
285 |
dev_c2691_nm_16esw_set_nio, |
dev_c2691_nm_16esw_set_nio, |
286 |
dev_c2691_nm_16esw_unset_nio, |
dev_c2691_nm_16esw_unset_nio, |
287 |
dev_c2691_nm_16esw_show_info, |
dev_c2691_nm_16esw_show_info, |
288 |
}; |
}; |
289 |
|
|
290 |
/* GT96100 FastEthernet integrated ports */ |
/* GT96100 FastEthernet integrated ports */ |
291 |
struct c2691_nm_driver dev_c2691_gt96100_fe_driver = { |
struct cisco_card_driver dev_c2691_gt96100_fe_driver = { |
292 |
"GT96100-FE", 1, 0, |
"GT96100-FE", 1, 0, |
293 |
dev_c2691_gt96100_fe_init, |
dev_c2691_gt96100_fe_init, |
294 |
dev_c2691_gt96100_fe_shutdown, |
dev_c2691_gt96100_fe_shutdown, |
295 |
|
dev_c2691_mb_get_sub_info, |
296 |
dev_c2691_gt96100_fe_set_nio, |
dev_c2691_gt96100_fe_set_nio, |
297 |
dev_c2691_gt96100_fe_unset_nio, |
dev_c2691_gt96100_fe_unset_nio, |
298 |
NULL, |
NULL, |