19 |
#include "net_io.h" |
#include "net_io.h" |
20 |
#include "ptask.h" |
#include "ptask.h" |
21 |
#include "dev_am79c971.h" |
#include "dev_am79c971.h" |
22 |
|
#include "dev_nm_16esw.h" |
23 |
#include "dev_c3600.h" |
#include "dev_c3600.h" |
24 |
#include "dev_c3600_bay.h" |
#include "dev_c3600_bay.h" |
25 |
|
|
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(c3600_t *router,char *name,u_int nm_bay, |
38 |
int nr_port,int interface_type, |
int nr_port,int interface_type, |
39 |
const struct c3600_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; |
131 |
/* NM-1E */ |
/* NM-1E */ |
132 |
/* ====================================================================== */ |
/* ====================================================================== */ |
133 |
|
|
|
/* NM-1E: 1 Ethernet Network Module EEPROM */ |
|
|
static const m_uint16_t eeprom_c3600_nm_1e_data[16] = { |
|
|
0x0143, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000, |
|
|
0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
}; |
|
|
|
|
|
static const struct c3600_eeprom eeprom_c3600_nm_1e = { |
|
|
"NM-1E", (m_uint16_t *)eeprom_c3600_nm_1e_data, |
|
|
sizeof(eeprom_c3600_nm_1e_data)/2, |
|
|
}; |
|
|
|
|
134 |
/* |
/* |
135 |
* dev_c3600_nm_1e_init() |
* dev_c3600_nm_1e_init() |
136 |
* |
* |
139 |
static int dev_c3600_nm_1e_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_1e_init(c3600_t *router,char *name,u_int nm_bay) |
140 |
{ |
{ |
141 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_10BASE_T, |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_10BASE_T, |
142 |
&eeprom_c3600_nm_1e)); |
cisco_eeprom_find_nm("NM-1E"))); |
143 |
} |
} |
144 |
|
|
145 |
/* ====================================================================== */ |
/* ====================================================================== */ |
146 |
/* NM-4E */ |
/* NM-4E */ |
147 |
/* ====================================================================== */ |
/* ====================================================================== */ |
148 |
|
|
|
/* NM-4E: 4 Ethernet Network Module EEPROM */ |
|
|
static const m_uint16_t eeprom_c3600_nm_4e_data[16] = { |
|
|
0x0142, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000, |
|
|
0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
}; |
|
|
|
|
|
static const struct c3600_eeprom eeprom_c3600_nm_4e = { |
|
|
"NM-4E", (m_uint16_t *)eeprom_c3600_nm_4e_data, |
|
|
sizeof(eeprom_c3600_nm_4e_data)/2, |
|
|
}; |
|
|
|
|
149 |
/* |
/* |
150 |
* dev_c3600_nm_4e_init() |
* dev_c3600_nm_4e_init() |
151 |
* |
* |
154 |
static int dev_c3600_nm_4e_init(c3600_t *router,char *name,u_int nm_bay) |
static int dev_c3600_nm_4e_init(c3600_t *router,char *name,u_int nm_bay) |
155 |
{ |
{ |
156 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,4,AM79C971_TYPE_10BASE_T, |
return(dev_c3600_nm_eth_init(router,name,nm_bay,4,AM79C971_TYPE_10BASE_T, |
157 |
&eeprom_c3600_nm_4e)); |
cisco_eeprom_find_nm("NM-4E"))); |
158 |
} |
} |
159 |
|
|
160 |
/* ====================================================================== */ |
/* ====================================================================== */ |
161 |
/* NM-1FE-TX */ |
/* NM-1FE-TX */ |
162 |
/* ====================================================================== */ |
/* ====================================================================== */ |
163 |
|
|
|
/* NM-1FE-TX: 1 FastEthernet Network Module EEPROM */ |
|
|
static const m_uint16_t eeprom_c3600_nm_1fe_tx_data[16] = { |
|
|
0x0144, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000, |
|
|
0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
}; |
|
|
|
|
|
static const struct c3600_eeprom eeprom_c3600_nm_1fe_tx = { |
|
|
"NM-1FE-TX", (m_uint16_t *)eeprom_c3600_nm_1fe_tx_data, |
|
|
sizeof(eeprom_c3600_nm_1fe_tx_data)/2, |
|
|
}; |
|
|
|
|
164 |
/* |
/* |
165 |
* dev_c3600_nm_1fe_tx_init() |
* dev_c3600_nm_1fe_tx_init() |
166 |
* |
* |
169 |
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(c3600_t *router,char *name,u_int nm_bay) |
170 |
{ |
{ |
171 |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_100BASE_TX, |
return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_100BASE_TX, |
172 |
&eeprom_c3600_nm_1fe_tx)); |
cisco_eeprom_find_nm("NM-1FE-TX"))); |
173 |
|
} |
174 |
|
|
175 |
|
/* ====================================================================== */ |
176 |
|
/* NM-16ESW */ |
177 |
|
/* ====================================================================== */ |
178 |
|
|
179 |
|
/* Add a NM-16ESW */ |
180 |
|
static int dev_c3600_nm_16esw_init(c3600_t *router,char *name,u_int nm_bay) |
181 |
|
{ |
182 |
|
struct nm_bay_info *bay_info; |
183 |
|
struct nm_16esw_data *data; |
184 |
|
|
185 |
|
/* Set the EEPROM */ |
186 |
|
c3600_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-16ESW")); |
187 |
|
dev_nm_16esw_burn_mac_addr(router->vm,nm_bay, |
188 |
|
&router->nm_bay[nm_bay].eeprom); |
189 |
|
|
190 |
|
/* Get PCI bus info about this bay */ |
191 |
|
bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay); |
192 |
|
|
193 |
|
if (!bay_info) { |
194 |
|
fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay); |
195 |
|
return(-1); |
196 |
|
} |
197 |
|
|
198 |
|
/* Create the device */ |
199 |
|
data = dev_nm_16esw_init(router->vm,name,nm_bay, |
200 |
|
router->nm_bay[nm_bay].pci_map, |
201 |
|
bay_info->pci_device,C3600_NETIO_IRQ); |
202 |
|
|
203 |
|
/* Store device info into the router structure */ |
204 |
|
return(c3600_nm_set_drvinfo(router,nm_bay,data)); |
205 |
|
} |
206 |
|
|
207 |
|
/* Remove a NM-16ESW from the specified slot */ |
208 |
|
static int dev_c3600_nm_16esw_shutdown(c3600_t *router,u_int nm_bay) |
209 |
|
{ |
210 |
|
struct c3600_nm_bay *bay; |
211 |
|
struct nm_16esw_data *data; |
212 |
|
|
213 |
|
if (!(bay = c3600_nm_get_info(router,nm_bay))) |
214 |
|
return(-1); |
215 |
|
|
216 |
|
data = bay->drv_info; |
217 |
|
|
218 |
|
/* Remove the NM EEPROM */ |
219 |
|
c3600_nm_unset_eeprom(router,nm_bay); |
220 |
|
|
221 |
|
/* Remove the BCM5600 chip */ |
222 |
|
dev_nm_16esw_remove(data); |
223 |
|
return(0); |
224 |
|
} |
225 |
|
|
226 |
|
/* Bind a Network IO descriptor */ |
227 |
|
static int dev_c3600_nm_16esw_set_nio(c3600_t *router,u_int nm_bay, |
228 |
|
u_int port_id,netio_desc_t *nio) |
229 |
|
{ |
230 |
|
struct nm_16esw_data *d; |
231 |
|
|
232 |
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
233 |
|
dev_nm_16esw_set_nio(d,port_id,nio); |
234 |
|
return(0); |
235 |
|
} |
236 |
|
|
237 |
|
/* Unbind a Network IO descriptor */ |
238 |
|
static int dev_c3600_nm_16esw_unset_nio(c3600_t *router,u_int nm_bay, |
239 |
|
u_int port_id) |
240 |
|
{ |
241 |
|
struct nm_16esw_data *d; |
242 |
|
|
243 |
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
244 |
|
dev_nm_16esw_unset_nio(d,port_id); |
245 |
|
return(0); |
246 |
|
} |
247 |
|
|
248 |
|
/* Show debug info */ |
249 |
|
static int dev_c3600_nm_16esw_show_info(c3600_t *router,u_int nm_bay) |
250 |
|
{ |
251 |
|
struct nm_16esw_data *d; |
252 |
|
|
253 |
|
d = c3600_nm_get_drvinfo(router,nm_bay); |
254 |
|
dev_nm_16esw_show_info(d); |
255 |
|
return(0); |
256 |
} |
} |
257 |
|
|
258 |
/* ====================================================================== */ |
/* ====================================================================== */ |
275 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFF00, |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFF00, |
276 |
}; |
}; |
277 |
|
|
278 |
static const struct c3600_eeprom eeprom_c3600_leopard_2fe = { |
static const struct cisco_eeprom eeprom_c3600_leopard_2fe = { |
279 |
"Leopard-2FE", (m_uint16_t *)eeprom_c3600_leopard_2fe_data, |
"Leopard-2FE", (m_uint16_t *)eeprom_c3600_leopard_2fe_data, |
280 |
sizeof(eeprom_c3600_leopard_2fe_data)/2, |
sizeof(eeprom_c3600_leopard_2fe_data)/2, |
281 |
}; |
}; |
329 |
NULL, |
NULL, |
330 |
}; |
}; |
331 |
|
|
332 |
|
/* NM-16ESW driver */ |
333 |
|
struct c3600_nm_driver dev_c3600_nm_16esw_driver = { |
334 |
|
"NM-16ESW", 1, 0, |
335 |
|
dev_c3600_nm_16esw_init, |
336 |
|
dev_c3600_nm_16esw_shutdown, |
337 |
|
dev_c3600_nm_16esw_set_nio, |
338 |
|
dev_c3600_nm_16esw_unset_nio, |
339 |
|
dev_c3600_nm_16esw_show_info, |
340 |
|
}; |
341 |
|
|
342 |
/* Leopard-2FE driver */ |
/* Leopard-2FE driver */ |
343 |
struct c3600_nm_driver dev_c3600_leopard_2fe_driver = { |
struct c3600_nm_driver dev_c3600_leopard_2fe_driver = { |
344 |
"Leopard-2FE", 1, 0, |
"Leopard-2FE", 1, 0, |