--- upstream/dynamips-0.2.5/dev_c3600_iofpga.c 2007/10/06 16:01:44 1 +++ upstream/dynamips-0.2.6-RC4/dev_c3600_iofpga.c 2007/10/06 16:08:03 5 @@ -39,12 +39,24 @@ #define EEPROM_NM_CLK 2 #define EEPROM_NM_CS 4 +#define C3600_NET_IRQ_CLEARING_DELAY 16 + /* IO FPGA structure */ struct iofpga_data { vm_obj_t vm_obj; struct vdevice dev; c3600_t *router; - + + /* + * Used to introduce a "delay" before clearing the network interrupt + * on 3620/3640 platforms. Added due to a packet loss when using an + * Ethernet NM on these platforms. + * + * Anyway, we should rely on the device information with appropriate IRQ + * routing. + */ + int net_irq_clearing_count; + /* Slot select for EEPROM access */ u_int eeprom_slot; @@ -58,24 +70,22 @@ static const struct nmc93c46_eeprom_def eeprom_mb_def = { EEPROM_MB_CLK, EEPROM_MB_CS, EEPROM_MB_DIN, EEPROM_MB_DOUT, - NULL, 0, }; /* Mainboard EEPROM */ static const struct nmc93c46_group eeprom_mb_group = { - 1, 0, "Mainboard EEPROM", 0, { NULL }, { { 0, 0, 0, 0, 0} }, + 1, 0, "Mainboard EEPROM", 0, { &eeprom_mb_def }, }; /* NM EEPROM definition */ static const struct nmc93c46_eeprom_def eeprom_nm_def = { EEPROM_NM_CLK, EEPROM_NM_CS, EEPROM_NM_DIN, EEPROM_NM_DOUT, - NULL, 0, }; /* NM EEPROM */ static const struct nmc93c46_group eeprom_nm_group = { - 1, 0, "NM EEPROM", 0, { NULL }, { { 0, 0, 0, 0, 0} }, + 1, 0, "NM EEPROM", 0, { &eeprom_nm_def }, }; /* C3660 NM presence masks */ @@ -91,8 +101,7 @@ /* Select the current NM EEPROM */ static void nm_eeprom_select(struct iofpga_data *d,u_int slot) { - d->router->nm_eeprom.data = d->router->nm_bay[slot].eeprom_data; - d->router->nm_eeprom.data_len = d->router->nm_bay[slot].eeprom_data_len; + d->router->nm_eeprom_group.eeprom[0] = &d->router->nm_bay[slot].eeprom; } /* Return the NM status register given the detected EEPROM (3620/3640) */ @@ -232,13 +241,16 @@ case 0x20001: case 0x20002: case 0x20003: - /* XXX Thisn't seem to be correct (at least on 3620) */ + /* XXX This doesn't seem to be correct (at least on 3620) */ slot = offset - 0x20000; if (op_type == MTS_READ) *data = 0xFF; - vm_clear_irq(d->router->vm,C3600_NETIO_IRQ); + if (++d->net_irq_clearing_count == C3600_NET_IRQ_CLEARING_DELAY) { + vm_clear_irq(d->router->vm,C3600_NETIO_IRQ); + d->net_irq_clearing_count = 0; + } break; /* @@ -276,8 +288,10 @@ d->io_mask = *data; break; - /* ??? */ - /* 0: 3640, 4 << 5: 3620, 3 << 5: 3660 */ + /* + * Platform type ? + * 0: 3640, 4 << 5: 3620, 3 << 5: 3660 + */ case 0x30000: if (op_type == MTS_READ) { switch(c3600_chassis_get_id(d->router)) { @@ -584,37 +598,22 @@ /* Initialize EEPROM groups */ void c3600_init_eeprom_groups(c3600_t *router) { - struct nmc93c46_group *g; int i; - /* Copy Mainboard EEPROM definition */ - memcpy(&router->mb_eeprom,&eeprom_mb_def,sizeof(eeprom_mb_def)); + /* Initialize Mainboard EEPROM */ + router->mb_eeprom_group = eeprom_mb_group; + router->mb_eeprom_group.eeprom[0] = &router->mb_eeprom; + router->mb_eeprom.data = NULL; + router->mb_eeprom.len = 0; + + /* Initialize NM EEPROM for 3620/3640 */ + router->nm_eeprom_group = eeprom_nm_group; + router->nm_eeprom_group.eeprom[0] = NULL; - /* Initialize group */ - g = &router->mb_eeprom_group; - memcpy(g,&eeprom_mb_group,sizeof(eeprom_mb_group)); - g->def[0] = &router->mb_eeprom; - - /* Copy NM EEPROM definition (3620/3640) */ - memcpy(&router->nm_eeprom,&eeprom_nm_def,sizeof(eeprom_nm_def)); - router->nm_eeprom.data = NULL; - router->nm_eeprom.data_len = 0; - - /* Initialize group (3620/3640) */ - g = &router->nm_eeprom_group; - memcpy(g,&eeprom_nm_group,sizeof(eeprom_nm_group)); - g->def[0] = &router->nm_eeprom; - - /* 3660 NM EEPROM */ + /* Initialize NM EEPROM for 3660 */ for(i=0;ic3660_nm_eeprom_def[i],&eeprom_nm_def, - sizeof(struct nmc93c46_eeprom_def)); - - memcpy(&router->c3660_nm_eeprom_group[i],&eeprom_nm_group, - sizeof(struct nmc93c46_group)); - - router->c3660_nm_eeprom_group[i].def[0] = - &router->c3660_nm_eeprom_def[i]; + router->c3660_nm_eeprom_group[i] = eeprom_nm_group; + router->c3660_nm_eeprom_group[i].eeprom[0] = &router->nm_bay[i].eeprom; } }