--- upstream/dynamips-0.2.6-RC1/dev_c3600_eth.c 2007/10/06 16:03:58 2 +++ upstream/dynamips-0.2.7-RC1/dev_c3600_eth.c 2007/10/06 16:23:47 7 @@ -19,6 +19,7 @@ #include "net_io.h" #include "ptask.h" #include "dev_am79c971.h" +#include "dev_nm_16esw.h" #include "dev_c3600.h" #include "dev_c3600_bay.h" @@ -35,7 +36,7 @@ */ static int dev_c3600_nm_eth_init(c3600_t *router,char *name,u_int nm_bay, int nr_port,int interface_type, - const struct c3600_eeprom *eeprom) + const struct cisco_eeprom *eeprom) { struct nm_bay_info *bay_info; struct nm_eth_data *data; @@ -130,17 +131,6 @@ /* NM-1E */ /* ====================================================================== */ -/* 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, -}; - /* * dev_c3600_nm_1e_init() * @@ -149,24 +139,13 @@ static int dev_c3600_nm_1e_init(c3600_t *router,char *name,u_int nm_bay) { return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_10BASE_T, - &eeprom_c3600_nm_1e)); + cisco_eeprom_find_nm("NM-1E"))); } /* ====================================================================== */ /* NM-4E */ /* ====================================================================== */ -/* 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, -}; - /* * dev_c3600_nm_4e_init() * @@ -175,24 +154,13 @@ static int dev_c3600_nm_4e_init(c3600_t *router,char *name,u_int nm_bay) { return(dev_c3600_nm_eth_init(router,name,nm_bay,4,AM79C971_TYPE_10BASE_T, - &eeprom_c3600_nm_4e)); + cisco_eeprom_find_nm("NM-4E"))); } /* ====================================================================== */ /* NM-1FE-TX */ /* ====================================================================== */ -/* 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, -}; - /* * dev_c3600_nm_1fe_tx_init() * @@ -201,7 +169,90 @@ static int dev_c3600_nm_1fe_tx_init(c3600_t *router,char *name,u_int nm_bay) { return(dev_c3600_nm_eth_init(router,name,nm_bay,1,AM79C971_TYPE_100BASE_TX, - &eeprom_c3600_nm_1fe_tx)); + cisco_eeprom_find_nm("NM-1FE-TX"))); +} + +/* ====================================================================== */ +/* NM-16ESW */ +/* ====================================================================== */ + +/* Add a NM-16ESW */ +static int dev_c3600_nm_16esw_init(c3600_t *router,char *name,u_int nm_bay) +{ + struct nm_bay_info *bay_info; + struct nm_16esw_data *data; + + /* Set the EEPROM */ + c3600_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-16ESW")); + dev_nm_16esw_burn_mac_addr(router->vm,nm_bay, + &router->nm_bay[nm_bay].eeprom); + + /* Get PCI bus info about this bay */ + bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay); + + if (!bay_info) { + fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay); + return(-1); + } + + /* Create the device */ + data = dev_nm_16esw_init(router->vm,name,nm_bay, + router->nm_bay[nm_bay].pci_map, + bay_info->pci_device,C3600_NETIO_IRQ); + + /* Store device info into the router structure */ + return(c3600_nm_set_drvinfo(router,nm_bay,data)); +} + +/* Remove a NM-16ESW from the specified slot */ +static int dev_c3600_nm_16esw_shutdown(c3600_t *router,u_int nm_bay) +{ + struct c3600_nm_bay *bay; + struct nm_16esw_data *data; + + if (!(bay = c3600_nm_get_info(router,nm_bay))) + return(-1); + + data = bay->drv_info; + + /* Remove the NM EEPROM */ + c3600_nm_unset_eeprom(router,nm_bay); + + /* Remove the BCM5600 chip */ + dev_nm_16esw_remove(data); + return(0); +} + +/* Bind a Network IO descriptor */ +static int dev_c3600_nm_16esw_set_nio(c3600_t *router,u_int nm_bay, + u_int port_id,netio_desc_t *nio) +{ + struct nm_16esw_data *d; + + d = c3600_nm_get_drvinfo(router,nm_bay); + dev_nm_16esw_set_nio(d,port_id,nio); + return(0); +} + +/* Unbind a Network IO descriptor */ +static int dev_c3600_nm_16esw_unset_nio(c3600_t *router,u_int nm_bay, + u_int port_id) +{ + struct nm_16esw_data *d; + + d = c3600_nm_get_drvinfo(router,nm_bay); + dev_nm_16esw_unset_nio(d,port_id); + return(0); +} + +/* Show debug info */ +static int dev_c3600_nm_16esw_show_info(c3600_t *router,u_int nm_bay) +{ + struct nm_16esw_data *d; + + d = c3600_nm_get_drvinfo(router,nm_bay); + dev_nm_16esw_show_info(d); + return(0); } /* ====================================================================== */ @@ -224,7 +275,7 @@ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFF00, }; -static const struct c3600_eeprom eeprom_c3600_leopard_2fe = { +static const struct cisco_eeprom eeprom_c3600_leopard_2fe = { "Leopard-2FE", (m_uint16_t *)eeprom_c3600_leopard_2fe_data, sizeof(eeprom_c3600_leopard_2fe_data)/2, }; @@ -278,6 +329,16 @@ NULL, }; +/* NM-16ESW driver */ +struct c3600_nm_driver dev_c3600_nm_16esw_driver = { + "NM-16ESW", 1, 0, + dev_c3600_nm_16esw_init, + dev_c3600_nm_16esw_shutdown, + dev_c3600_nm_16esw_set_nio, + dev_c3600_nm_16esw_unset_nio, + dev_c3600_nm_16esw_show_info, +}; + /* Leopard-2FE driver */ struct c3600_nm_driver dev_c3600_leopard_2fe_driver = { "Leopard-2FE", 1, 0,