/[dynamips]/upstream/dynamips-0.2.6-RC3/dev_c3600_eth.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /upstream/dynamips-0.2.6-RC3/dev_c3600_eth.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.5/dev_c3600_eth.c revision 1 by dpavlin, Sat Oct 6 16:01:44 2007 UTC upstream/dynamips-0.2.6-RC3/dev_c3600_eth.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC
# Line 1  Line 1 
1  /*    /*  
2   * Cisco C3600 (Predator) simulation platform.   * Cisco C3600 simulation platform.
3   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4   *   *
5   * Ethernet Network Modules.   * Ethernet Network Modules.
# Line 19  Line 19 
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    
# Line 35  struct nm_eth_data { Line 36  struct nm_eth_data {
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;
# Line 130  static int dev_c3600_nm_eth_unset_nio(c3 Line 131  static int dev_c3600_nm_eth_unset_nio(c3
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   *   *
# Line 149  static const struct c3600_eeprom eeprom_ Line 139  static const struct c3600_eeprom eeprom_
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   *   *
# Line 175  static const struct c3600_eeprom eeprom_ Line 154  static const struct c3600_eeprom eeprom_
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   *   *
# Line 201  static const struct c3600_eeprom eeprom_ Line 169  static const struct c3600_eeprom eeprom_
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  /* ====================================================================== */  /* ====================================================================== */
# Line 224  static m_uint16_t eeprom_c3600_leopard_2 Line 275  static m_uint16_t eeprom_c3600_leopard_2
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  };  };
# Line 255  struct c3600_nm_driver dev_c3600_nm_1fe_ Line 306  struct c3600_nm_driver dev_c3600_nm_1fe_
306     dev_c3600_nm_eth_shutdown,     dev_c3600_nm_eth_shutdown,
307     dev_c3600_nm_eth_set_nio,     dev_c3600_nm_eth_set_nio,
308     dev_c3600_nm_eth_unset_nio,     dev_c3600_nm_eth_unset_nio,
309       NULL,
310  };  };
311    
312  /* NM-1E driver */  /* NM-1E driver */
# Line 264  struct c3600_nm_driver dev_c3600_nm_1e_d Line 316  struct c3600_nm_driver dev_c3600_nm_1e_d
316     dev_c3600_nm_eth_shutdown,     dev_c3600_nm_eth_shutdown,
317     dev_c3600_nm_eth_set_nio,     dev_c3600_nm_eth_set_nio,
318     dev_c3600_nm_eth_unset_nio,     dev_c3600_nm_eth_unset_nio,
319       NULL,
320  };  };
321    
322  /* NM-4E driver */  /* NM-4E driver */
# Line 273  struct c3600_nm_driver dev_c3600_nm_4e_d Line 326  struct c3600_nm_driver dev_c3600_nm_4e_d
326     dev_c3600_nm_eth_shutdown,     dev_c3600_nm_eth_shutdown,
327     dev_c3600_nm_eth_set_nio,     dev_c3600_nm_eth_set_nio,
328     dev_c3600_nm_eth_unset_nio,     dev_c3600_nm_eth_unset_nio,
329       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 */
# Line 282  struct c3600_nm_driver dev_c3600_leopard Line 346  struct c3600_nm_driver dev_c3600_leopard
346     dev_c3600_nm_eth_shutdown,     dev_c3600_nm_eth_shutdown,
347     dev_c3600_nm_eth_set_nio,     dev_c3600_nm_eth_set_nio,
348     dev_c3600_nm_eth_unset_nio,     dev_c3600_nm_eth_unset_nio,
349       NULL,
350  };  };

Legend:
Removed from v.1  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.26