90 |
/* |
/* |
91 |
* CPU EEPROM array. |
* CPU EEPROM array. |
92 |
*/ |
*/ |
93 |
static struct c7200_eeprom c7200_cpu_eeprom[] = { |
static struct cisco_eeprom c7200_cpu_eeprom[] = { |
94 |
{ "npe-100", eeprom_cpu_npe100_data, sizeof(eeprom_cpu_npe100_data)/2 }, |
{ "npe-100", eeprom_cpu_npe100_data, sizeof(eeprom_cpu_npe100_data)/2 }, |
95 |
{ "npe-150", eeprom_cpu_npe150_data, sizeof(eeprom_cpu_npe150_data)/2 }, |
{ "npe-150", eeprom_cpu_npe150_data, sizeof(eeprom_cpu_npe150_data)/2 }, |
96 |
{ "npe-175", eeprom_cpu_npe175_data, sizeof(eeprom_cpu_npe175_data)/2 }, |
{ "npe-175", eeprom_cpu_npe175_data, sizeof(eeprom_cpu_npe175_data)/2 }, |
125 |
/* |
/* |
126 |
* Midplane EEPROM array. |
* Midplane EEPROM array. |
127 |
*/ |
*/ |
128 |
static struct c7200_eeprom c7200_midplane_eeprom[] = { |
static struct cisco_eeprom c7200_midplane_eeprom[] = { |
129 |
{ "std", eeprom_midplane_data, sizeof(eeprom_midplane_data)/2 }, |
{ "std", eeprom_midplane_data, sizeof(eeprom_midplane_data)/2 }, |
130 |
{ "vxr", eeprom_vxr_midplane_data, sizeof(eeprom_vxr_midplane_data)/2 }, |
{ "vxr", eeprom_vxr_midplane_data, sizeof(eeprom_vxr_midplane_data)/2 }, |
131 |
{ NULL, NULL, 0 }, |
{ NULL, NULL, 0 }, |
150 |
/* |
/* |
151 |
* PEM EEPROM array. |
* PEM EEPROM array. |
152 |
*/ |
*/ |
153 |
static struct c7200_eeprom c7200_pem_eeprom[] = { |
static struct cisco_eeprom c7200_pem_eeprom[] = { |
154 |
{ "npe-175", eeprom_pem_npe175_data, sizeof(eeprom_pem_npe175_data)/2 }, |
{ "npe-175", eeprom_pem_npe175_data, sizeof(eeprom_pem_npe175_data)/2 }, |
155 |
{ "npe-225", eeprom_pem_npe225_data, sizeof(eeprom_pem_npe225_data)/2 }, |
{ "npe-225", eeprom_pem_npe225_data, sizeof(eeprom_pem_npe225_data)/2 }, |
156 |
{ NULL, NULL, 0 }, |
{ NULL, NULL, 0 }, |
201 |
}; |
}; |
202 |
|
|
203 |
/* ======================================================================== */ |
/* ======================================================================== */ |
|
/* Empty EEPROM for PAs */ |
|
|
/* ======================================================================== */ |
|
|
static const m_uint16_t eeprom_pa_empty[64] = { |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
}; |
|
|
|
|
|
/* ======================================================================== */ |
|
204 |
/* Cisco 7200 router instances */ |
/* Cisco 7200 router instances */ |
205 |
/* ======================================================================== */ |
/* ======================================================================== */ |
206 |
|
|
289 |
return(0); |
return(0); |
290 |
} |
} |
291 |
|
|
|
/* Find an EEPROM in the specified array */ |
|
|
struct c7200_eeprom *c7200_get_eeprom(struct c7200_eeprom *eeproms,char *name) |
|
|
{ |
|
|
int i; |
|
|
|
|
|
for(i=0;eeproms[i].name;i++) |
|
|
if (!strcmp(eeproms[i].name,name)) |
|
|
return(&eeproms[i]); |
|
|
|
|
|
return NULL; |
|
|
} |
|
|
|
|
292 |
/* Get an EEPROM for a given NPE model */ |
/* Get an EEPROM for a given NPE model */ |
293 |
struct c7200_eeprom *c7200_get_cpu_eeprom(char *npe_name) |
static const struct cisco_eeprom *c7200_get_cpu_eeprom(char *npe_name) |
294 |
{ |
{ |
295 |
return(c7200_get_eeprom(c7200_cpu_eeprom,npe_name)); |
return(cisco_eeprom_find(c7200_cpu_eeprom,npe_name)); |
296 |
} |
} |
297 |
|
|
298 |
/* Get an EEPROM for a given midplane model */ |
/* Get an EEPROM for a given midplane model */ |
299 |
struct c7200_eeprom *c7200_get_midplane_eeprom(char *midplane_name) |
static const struct cisco_eeprom * |
300 |
|
c7200_get_midplane_eeprom(char *midplane_name) |
301 |
{ |
{ |
302 |
return(c7200_get_eeprom(c7200_midplane_eeprom,midplane_name)); |
return(cisco_eeprom_find(c7200_midplane_eeprom,midplane_name)); |
303 |
} |
} |
304 |
|
|
305 |
/* Get a PEM EEPROM for a given NPE model */ |
/* Get a PEM EEPROM for a given NPE model */ |
306 |
struct c7200_eeprom *c7200_get_pem_eeprom(char *npe_name) |
static const struct cisco_eeprom *c7200_get_pem_eeprom(char *npe_name) |
307 |
{ |
{ |
308 |
return(c7200_get_eeprom(c7200_pem_eeprom,npe_name)); |
return(cisco_eeprom_find(c7200_pem_eeprom,npe_name)); |
309 |
} |
} |
310 |
|
|
311 |
/* Set the base MAC address of the chassis */ |
/* Set the base MAC address of the chassis */ |
312 |
static int c7200_burn_mac_addr(m_uint16_t *data,size_t data_len, |
static int c7200_burn_mac_addr(c7200_t *router,n_eth_addr_t *addr) |
|
n_eth_addr_t *addr) |
|
313 |
{ |
{ |
314 |
m_uint8_t eeprom_ver; |
m_uint8_t eeprom_ver; |
315 |
|
|
316 |
/* Read EEPROM format version */ |
/* Read EEPROM format version */ |
317 |
cisco_eeprom_get_byte(data,data_len,0,&eeprom_ver); |
cisco_eeprom_get_byte(&router->mp_eeprom,0,&eeprom_ver); |
318 |
|
|
319 |
if (eeprom_ver != 1) { |
if (eeprom_ver != 1) { |
320 |
fprintf(stderr,"c7200_burn_mac_addr: unable to handle " |
vm_error(router->vm,"c7200_burn_mac_addr: unable to handle " |
321 |
"EEPROM version %u\n",eeprom_ver); |
"EEPROM version %u\n",eeprom_ver); |
322 |
return(-1); |
return(-1); |
323 |
} |
} |
324 |
|
|
325 |
cisco_eeprom_set_region(data,data_len,12,addr->eth_addr_byte,6); |
cisco_eeprom_set_region(&router->mp_eeprom,12,addr->eth_addr_byte,6); |
326 |
return(0); |
return(0); |
327 |
} |
} |
328 |
|
|
396 |
/* Free specific HW resources */ |
/* Free specific HW resources */ |
397 |
c7200_free_hw_ressources(router); |
c7200_free_hw_ressources(router); |
398 |
|
|
399 |
|
/* Free EEPROMs */ |
400 |
|
cisco_eeprom_free(&router->cpu_eeprom); |
401 |
|
cisco_eeprom_free(&router->mp_eeprom); |
402 |
|
cisco_eeprom_free(&router->pem_eeprom); |
403 |
|
|
404 |
/* Free all resources used by VM */ |
/* Free all resources used by VM */ |
405 |
vm_free(vm); |
vm_free(vm); |
406 |
|
|
479 |
/* Set NPE eeprom definition */ |
/* Set NPE eeprom definition */ |
480 |
static int c7200_npe_set_eeprom(c7200_t *router) |
static int c7200_npe_set_eeprom(c7200_t *router) |
481 |
{ |
{ |
482 |
struct c7200_eeprom *eeprom; |
const struct cisco_eeprom *eeprom; |
483 |
|
|
484 |
if (!(eeprom = c7200_get_cpu_eeprom(router->npe_driver->npe_type))) { |
if (!(eeprom = c7200_get_cpu_eeprom(router->npe_driver->npe_type))) { |
485 |
vm_error(router->vm,"unknown NPE \"%s\" (internal error)!\n", |
vm_error(router->vm,"unknown NPE \"%s\" (internal error)!\n", |
487 |
return(-1); |
return(-1); |
488 |
} |
} |
489 |
|
|
490 |
router->cpu_eeprom.data = eeprom->data; |
if (cisco_eeprom_copy(&router->cpu_eeprom,eeprom) == -1) { |
491 |
router->cpu_eeprom.data_len = eeprom->len; |
vm_error(router->vm,"unable to set NPE EEPROM.\n"); |
492 |
|
return(-1); |
493 |
|
} |
494 |
|
|
495 |
return(0); |
return(0); |
496 |
} |
} |
497 |
|
|
498 |
/* Set PEM eeprom definition */ |
/* Set PEM eeprom definition */ |
499 |
static int c7200_pem_set_eeprom(c7200_t *router) |
static int c7200_pem_set_eeprom(c7200_t *router) |
500 |
{ |
{ |
501 |
struct c7200_eeprom *eeprom; |
const struct cisco_eeprom *eeprom; |
502 |
|
|
503 |
if (!(eeprom = c7200_get_pem_eeprom(router->npe_driver->npe_type))) { |
if (!(eeprom = c7200_get_pem_eeprom(router->npe_driver->npe_type))) { |
504 |
vm_error(router->vm,"no PEM EEPROM found for NPE type \"%s\"!\n", |
vm_error(router->vm,"no PEM EEPROM found for NPE type \"%s\"!\n", |
506 |
return(-1); |
return(-1); |
507 |
} |
} |
508 |
|
|
509 |
router->pem_eeprom.data = eeprom->data; |
if (cisco_eeprom_copy(&router->pem_eeprom,eeprom) == -1) { |
510 |
router->pem_eeprom.data_len = eeprom->len; |
vm_error(router->vm,"unable to set PEM EEPROM.\n"); |
511 |
|
return(-1); |
512 |
|
} |
513 |
|
|
514 |
return(0); |
return(0); |
515 |
} |
} |
516 |
|
|
517 |
/* Set PA EEPROM definition */ |
/* Set PA EEPROM definition */ |
518 |
int c7200_pa_set_eeprom(c7200_t *router,u_int pa_bay, |
int c7200_pa_set_eeprom(c7200_t *router,u_int pa_bay, |
519 |
const struct c7200_eeprom *eeprom) |
const struct cisco_eeprom *eeprom) |
520 |
{ |
{ |
521 |
if (pa_bay >= C7200_MAX_PA_BAYS) { |
if (pa_bay >= C7200_MAX_PA_BAYS) { |
522 |
vm_error(router->vm,"c7200_pa_set_eeprom: invalid PA Bay %u.\n",pa_bay); |
vm_error(router->vm,"c7200_pa_set_eeprom: invalid PA Bay %u.\n",pa_bay); |
523 |
return(-1); |
return(-1); |
524 |
} |
} |
525 |
|
|
526 |
router->pa_bay[pa_bay].eeprom.data = eeprom->data; |
if (cisco_eeprom_copy(&router->pa_bay[pa_bay].eeprom,eeprom) == -1) { |
527 |
router->pa_bay[pa_bay].eeprom.data_len = eeprom->len; |
vm_error(router->vm,"c7200_pa_set_eeprom: no memory.\n"); |
528 |
|
return(-1); |
529 |
|
} |
530 |
|
|
531 |
return(0); |
return(0); |
532 |
} |
} |
533 |
|
|
539 |
return(-1); |
return(-1); |
540 |
} |
} |
541 |
|
|
542 |
router->pa_bay[pa_bay].eeprom.data = (m_uint16_t *)eeprom_pa_empty; |
cisco_eeprom_free(&router->pa_bay[pa_bay].eeprom); |
|
router->pa_bay[pa_bay].eeprom.data_len = sizeof(eeprom_pa_empty)/2; |
|
543 |
return(0); |
return(0); |
544 |
} |
} |
545 |
|
|
546 |
/* Check if a bay has a port adapter */ |
/* Check if a bay has a port adapter */ |
547 |
int c7200_pa_check_eeprom(c7200_t *router,u_int pa_bay) |
int c7200_pa_check_eeprom(c7200_t *router,u_int pa_bay) |
548 |
{ |
{ |
|
struct nmc93c46_eeprom_def *def; |
|
|
|
|
549 |
if (!pa_bay || (pa_bay >= C7200_MAX_PA_BAYS)) |
if (!pa_bay || (pa_bay >= C7200_MAX_PA_BAYS)) |
550 |
return(0); |
return(FALSE); |
551 |
|
|
552 |
def = &router->pa_bay[pa_bay].eeprom; |
return(cisco_eeprom_valid(&router->pa_bay[pa_bay].eeprom)); |
|
|
|
|
if (def->data == eeprom_pa_empty) |
|
|
return(0); |
|
|
|
|
|
return(1); |
|
553 |
} |
} |
554 |
|
|
555 |
/* Get bay info */ |
/* Get bay info */ |
1192 |
/* Set Midplane type */ |
/* Set Midplane type */ |
1193 |
int c7200_midplane_set_type(c7200_t *router,char *midplane_type) |
int c7200_midplane_set_type(c7200_t *router,char *midplane_type) |
1194 |
{ |
{ |
1195 |
struct c7200_eeprom *eeprom; |
const struct cisco_eeprom *eeprom; |
1196 |
m_uint8_t version; |
m_uint8_t version; |
1197 |
|
|
1198 |
if (router->vm->status == VM_STATUS_RUNNING) { |
if (router->vm->status == VM_STATUS_RUNNING) { |
1206 |
return(-1); |
return(-1); |
1207 |
} |
} |
1208 |
|
|
1209 |
memcpy(router->mp_eeprom_data,eeprom->data,eeprom->len << 1); |
/* Copy the midplane EEPROM */ |
1210 |
|
if (cisco_eeprom_copy(&router->mp_eeprom,eeprom) == -1) { |
1211 |
|
vm_error(router->vm,"unable to set midplane EEPROM.\n"); |
1212 |
|
return(-1); |
1213 |
|
} |
1214 |
|
|
1215 |
/* Set the chassis base MAC address */ |
/* Set the chassis base MAC address */ |
1216 |
c7200_burn_mac_addr(router->mp_eeprom_data,sizeof(router->mp_eeprom_data), |
c7200_burn_mac_addr(router,&router->mac_addr); |
|
&router->mac_addr); |
|
|
|
|
|
router->mp_eeprom.data = router->mp_eeprom_data; |
|
|
router->mp_eeprom.data_len = eeprom->len; |
|
|
router->midplane_type = eeprom->name; |
|
1217 |
|
|
1218 |
/* Get the midplane version */ |
/* Get the midplane version */ |
1219 |
cisco_eeprom_get_byte(router->mp_eeprom.data,router->mp_eeprom.data_len*2, |
cisco_eeprom_get_byte(&router->mp_eeprom,2,&version); |
1220 |
2,&version); |
router->midplane_version = version; |
1221 |
router->midplane_version = version; |
router->midplane_type = eeprom->name; |
1222 |
return(0); |
return(0); |
1223 |
} |
} |
1224 |
|
|
1231 |
} |
} |
1232 |
|
|
1233 |
/* Set the chassis base MAC address */ |
/* Set the chassis base MAC address */ |
1234 |
c7200_burn_mac_addr(router->mp_eeprom_data,sizeof(router->mp_eeprom_data), |
c7200_burn_mac_addr(router,&router->mac_addr); |
|
&router->mac_addr); |
|
1235 |
return(0); |
return(0); |
1236 |
} |
} |
1237 |
|
|