1 |
dpavlin |
4 |
/* |
2 |
|
|
* Cisco C3725 (Predator) simulation platform. |
3 |
|
|
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
4 |
|
|
* |
5 |
|
|
* Serial Network Modules. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include <stdio.h> |
9 |
|
|
#include <stdlib.h> |
10 |
|
|
#include <string.h> |
11 |
|
|
#include <stdarg.h> |
12 |
|
|
#include <unistd.h> |
13 |
|
|
#include <time.h> |
14 |
|
|
#include <errno.h> |
15 |
|
|
#include <assert.h> |
16 |
|
|
|
17 |
|
|
#include "utils.h" |
18 |
|
|
#include "net.h" |
19 |
|
|
#include "net_io.h" |
20 |
|
|
#include "ptask.h" |
21 |
|
|
#include "dev_mueslix.h" |
22 |
|
|
#include "dev_c3725.h" |
23 |
|
|
|
24 |
|
|
/* ====================================================================== */ |
25 |
|
|
/* NM-4T */ |
26 |
|
|
/* ====================================================================== */ |
27 |
|
|
|
28 |
|
|
/* |
29 |
|
|
* dev_c3725_nm_4t_init() |
30 |
|
|
* |
31 |
|
|
* Add a NM-4T network module into specified slot. |
32 |
|
|
*/ |
33 |
|
|
int dev_c3725_nm_4t_init(c3725_t *router,char *name,u_int nm_bay) |
34 |
|
|
{ |
35 |
|
|
struct mueslix_data *data; |
36 |
|
|
|
37 |
|
|
/* Set the EEPROM */ |
38 |
|
|
c3725_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-4T")); |
39 |
|
|
|
40 |
|
|
/* Create the Mueslix chip */ |
41 |
|
|
data = dev_mueslix_init(router->vm,name,0, |
42 |
|
|
router->nm_bay[nm_bay].pci_map, |
43 |
|
|
c3725_nm_get_pci_device(nm_bay), |
44 |
|
|
C3725_NETIO_IRQ); |
45 |
|
|
|
46 |
|
|
if (!data) return(-1); |
47 |
|
|
|
48 |
|
|
/* Store device info into the router structure */ |
49 |
|
|
return(c3725_nm_set_drvinfo(router,nm_bay,data)); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
/* Remove a NM-4T from the specified slot */ |
53 |
|
|
int dev_c3725_nm_4t_shutdown(c3725_t *router,u_int nm_bay) |
54 |
|
|
{ |
55 |
|
|
struct c3725_nm_bay *bay; |
56 |
|
|
|
57 |
|
|
if (!(bay = c3725_nm_get_info(router,nm_bay))) |
58 |
|
|
return(-1); |
59 |
|
|
|
60 |
|
|
c3725_nm_unset_eeprom(router,nm_bay); |
61 |
|
|
dev_mueslix_remove(bay->drv_info); |
62 |
|
|
return(0); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
/* Bind a Network IO descriptor to a specific port */ |
66 |
|
|
int dev_c3725_nm_4t_set_nio(c3725_t *router,u_int nm_bay,u_int port_id, |
67 |
|
|
netio_desc_t *nio) |
68 |
|
|
{ |
69 |
|
|
struct mueslix_data *data; |
70 |
|
|
|
71 |
|
|
if ((port_id >= MUESLIX_NR_CHANNELS) || |
72 |
|
|
!(data = c3725_nm_get_drvinfo(router,nm_bay))) |
73 |
|
|
return(-1); |
74 |
|
|
|
75 |
|
|
return(dev_mueslix_set_nio(data,port_id,nio)); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
/* Unbind a Network IO descriptor to a specific port */ |
79 |
|
|
int dev_c3725_nm_4t_unset_nio(c3725_t *router,u_int nm_bay,u_int port_id) |
80 |
|
|
{ |
81 |
|
|
struct mueslix_data *d; |
82 |
|
|
|
83 |
|
|
if ((port_id >= MUESLIX_NR_CHANNELS) || |
84 |
|
|
!(d = c3725_nm_get_drvinfo(router,nm_bay))) |
85 |
|
|
return(-1); |
86 |
|
|
|
87 |
|
|
return(dev_mueslix_unset_nio(d,port_id)); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
/* NM-4T driver */ |
91 |
|
|
struct c3725_nm_driver dev_c3725_nm_4t_driver = { |
92 |
|
|
"NM-4T", 1, 0, |
93 |
|
|
dev_c3725_nm_4t_init, |
94 |
|
|
dev_c3725_nm_4t_shutdown, |
95 |
|
|
dev_c3725_nm_4t_set_nio, |
96 |
|
|
dev_c3725_nm_4t_unset_nio, |
97 |
|
|
NULL, |
98 |
|
|
}; |