/[dynamips]/trunk/cisco_card.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/cisco_card.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 6451 byte(s)
make working copy

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2007 Christophe Fillot (cf@utc.fr)
4 *
5 * Generic Cisco card routines and definitions.
6 */
7
8 #ifndef __CISCO_CARD_H__
9 #define __CISCO_CARD_H__
10
11 #include <pthread.h>
12
13 #include "utils.h"
14 #include "net.h"
15 #include "net_io.h"
16 #include "cisco_eeprom.h"
17
18 #define CISCO_CARD_MAX_WIC 8
19 #define CISCO_CARD_MAX_SUBSLOTS 16
20
21 /* Card types */
22 enum {
23 CISCO_CARD_TYPE_UNDEF = 0,
24 CISCO_CARD_TYPE_PA,
25 CISCO_CARD_TYPE_NM,
26 CISCO_CARD_TYPE_WIC,
27 };
28
29 /* Card flags */
30 enum {
31 CISCO_CARD_FLAG_OVERRIDE = 1,
32 };
33
34 /* Forward declarations */
35 struct cisco_card;
36 struct cisco_card_driver;
37
38 /* Prototype of card driver initialization function */
39 typedef int (*cisco_card_init_fn)(vm_instance_t *vm,struct cisco_card *card);
40
41 /* Prototype of card driver shutdown function */
42 typedef int (*cisco_card_shutdown_fn)(vm_instance_t *vm,
43 struct cisco_card *card);
44
45 /* Prototype of card NIO get sub-slot info function */
46 typedef int
47 (*cisco_card_get_sub_info_fn)(vm_instance_t *vm,struct cisco_card *card,
48 u_int port_id,
49 struct cisco_card_driver ***drv_array,
50 u_int *subcard_type);
51
52 /* Prototype of card NIO set function */
53 typedef int (*cisco_card_set_nio_fn)(vm_instance_t *vm,struct cisco_card *card,
54 u_int port_id,netio_desc_t *nio);
55
56 /* Prototype of card NIO unset function */
57 typedef int (*cisco_card_unset_nio_fn)(vm_instance_t *vm,
58 struct cisco_card *card,
59 u_int port_id);
60
61 /* Prototype of card NIO show info function */
62 typedef int (*cisco_card_show_info_fn)(vm_instance_t *vm,
63 struct cisco_card *card);
64
65 /* Cisco NIO binding to a slot/port */
66 struct cisco_nio_binding {
67 netio_desc_t *nio;
68 u_int port_id,orig_port_id;
69 struct cisco_nio_binding *prev,*next;
70 };
71
72 /* Generic Cisco card driver */
73 struct cisco_card_driver {
74 char *dev_type;
75 int supported;
76 int wic_slots;
77 cisco_card_init_fn card_init;
78 cisco_card_shutdown_fn card_shutdown;
79 cisco_card_get_sub_info_fn card_get_sub_info;
80 cisco_card_set_nio_fn card_set_nio;
81 cisco_card_unset_nio_fn card_unset_nio;
82 cisco_card_show_info_fn card_show_info;
83 };
84
85 /* Generic Cisco card */
86 struct cisco_card {
87 char *dev_name; /* Device name */
88 char *dev_type; /* Device Type */
89 u_int card_type; /* Card type (NM,PA,WIC,...) */
90 u_int card_flags; /* Card flags */
91 u_int card_id; /* Card ID (slot or sub-slot) */
92 u_int slot_id,subslot_id; /* Slot and Sub-slot ID */
93 struct cisco_eeprom eeprom; /* EEPROM */
94 struct pci_bus *pci_bus; /* PCI bus */
95 struct cisco_card_driver *driver; /* Driver */
96 void *drv_info; /* Private driver info */
97 struct cisco_nio_binding *nio_list; /* NIO bindings to ports */
98 struct cisco_card *parent; /* Parent card */
99 struct cisco_card *sub_slots[CISCO_CARD_MAX_SUBSLOTS]; /* Sub-slots */
100 };
101
102 /* Set EEPROM definition for the specified Cisco card */
103 int cisco_card_set_eeprom(vm_instance_t *vm,struct cisco_card *card,
104 const struct cisco_eeprom *eeprom);
105
106 /* Unset EEPROM definition */
107 int cisco_card_unset_eeprom(struct cisco_card *card);
108
109 /* Check if a card has a valid EEPROM defined */
110 int cisco_card_check_eeprom(struct cisco_card *card);
111
112 /* Get slot info */
113 struct cisco_card *vm_slot_get_card_ptr(vm_instance_t *vm,u_int slot_id);
114
115 /* Check if a slot has an active card */
116 int vm_slot_active(vm_instance_t *vm,u_int slot_id,u_int port_id);
117
118 /* Set a flag for a card */
119 int vm_slot_set_flag(vm_instance_t *vm,u_int slot_id,u_int port_id,u_int flag);
120
121 /* Add a slot binding */
122 int vm_slot_add_binding(vm_instance_t *vm,char *dev_type,
123 u_int slot_id,u_int port_id);
124
125 /* Remove a slot binding */
126 int vm_slot_remove_binding(vm_instance_t *vm,u_int slot_id,u_int port_id);
127
128 /* Add a network IO binding */
129 int vm_slot_add_nio_binding(vm_instance_t *vm,u_int slot_id,u_int port_id,
130 char *nio_name);
131
132 /* Remove a NIO binding */
133 int vm_slot_remove_nio_binding(vm_instance_t *vm,u_int slot_id,u_int port_id);
134
135 /* Remove all NIO bindings for the specified slot (sub-slots included) */
136 int vm_slot_remove_all_nio_bindings(vm_instance_t *vm,u_int slot_id);
137
138 /* Enable a Network IO descriptor for the specified slot */
139 int vm_slot_enable_nio(vm_instance_t *vm,u_int slot_id,u_int port_id);
140
141 /* Disable Network IO descriptor for the specified slot */
142 int vm_slot_disable_nio(vm_instance_t *vm,u_int slot_id,u_int port_id);
143
144 /* Enable all NIO for the specified slot (sub-slots included) */
145 int vm_slot_enable_all_nio(vm_instance_t *vm,u_int slot_id);
146
147 /* Disable all NIO for the specified slot (sub-slots included) */
148 int vm_slot_disable_all_nio(vm_instance_t *vm,u_int slot_id);
149
150 /* Initialize the specified slot (sub-slots included) */
151 int vm_slot_init(vm_instance_t *vm,u_int slot_id);
152
153 /* Initialize all slots of a VM */
154 int vm_slot_init_all(vm_instance_t *vm);
155
156 /* Shutdown the specified slot (sub-slots included) */
157 int vm_slot_shutdown(vm_instance_t *vm,u_int slot_id);
158
159 /* Shutdown all slots of a VM */
160 int vm_slot_shutdown_all(vm_instance_t *vm);
161
162 /* Show info about the specified slot (sub-slots included) */
163 int vm_slot_show_info(vm_instance_t *vm,u_int slot_id);
164
165 /* Show info about all slots */
166 int vm_slot_show_all_info(vm_instance_t *vm);
167
168 /* Check if the specified slot has a valid EEPROM defined */
169 int vm_slot_check_eeprom(vm_instance_t *vm,u_int slot_id,u_int port_id);
170
171 /* Returns the EEPROM data of the specified slot */
172 struct cisco_eeprom *
173 vm_slot_get_eeprom(vm_instance_t *vm,u_int slot_id,u_int port_id);
174
175 /* Save config for the specified slot (sub-slots included) */
176 int vm_slot_save_config(vm_instance_t *vm,u_int slot_id,FILE *fd);
177
178 /* Save config for all slots */
179 int vm_slot_save_all_config(vm_instance_t *vm,FILE *fd);
180
181 /* Show slot drivers */
182 int vm_slot_show_drivers(vm_instance_t *vm);
183
184 /* Create a Network Module (command line) */
185 int vm_slot_cmd_create(vm_instance_t *vm,char *str);
186
187 /* Add a Network IO descriptor binding (command line) */
188 int vm_slot_cmd_add_nio(vm_instance_t *vm,char *str);
189
190 #endif

  ViewVC Help
Powered by ViewVC 1.1.26