OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [net/] [br.h] - Blame information for rev 1633

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * Constants and structure definitions for the bridging code
3
 */
4
 
5
#if !defined(One)
6
#define Zero    0
7
#define One     1
8
#endif  /* !defined(One) */
9
 
10
#if !defined(TRUE)
11
#define FALSE   0
12
#define TRUE    1
13
#endif /* !defined(TRUE) */
14
 
15
/** port states. **/
16
#define Disabled        0                          /* (4.4 5)     */
17
#define Listening       1                         /* (4.4.2)     */
18
#define Learning        2                         /* (4.4.3)     */
19
#define Forwarding      3                         /* (4 4 4)     */
20
#define Blocking        4                         /* (4.4.1)     */
21
 
22
#define No_of_ports 8
23
/* arbitrary choice, to allow the code below to compile */
24
 
25
#define All_ports (No_of_ports + 1)
26
 
27
/*
28
 * We time out our entries in the FDB after this many seconds.
29
 */
30
#define FDB_TIMEOUT     300
31
 
32
/*
33
 * the following defines are the initial values used when the
34
 * bridge is booted.  These may be overridden when this bridge is
35
 * not the root bridge.  These are the recommended default values
36
 * from the 802.1d specification.
37
 */
38
#define BRIDGE_MAX_AGE          20
39
#define BRIDGE_HELLO_TIME       2
40
#define BRIDGE_FORWARD_DELAY    15
41
#define HOLD_TIME               1
42
 
43
#define Default_path_cost 10
44
 
45
/*
46
 * minimum increment possible to avoid underestimating age, allows for BPDU
47
 * transmission time
48
 */
49
#define Message_age_increment 1
50
 
51
#define No_port 0
52
/*
53
 * reserved value for Bridge's root port parameter indicating no root port,
54
 * used when Bridge is the root - also used to indicate the source when
55
 * a frame is being generated by a higher layer protocol on this host
56
 */
57
 
58
/** Configuration BPDU Parameters (4.5.1) **/
59
 
60
typedef struct {
61
        union {
62
                struct {
63
                        unsigned short priority;
64
                        unsigned char ula[6];
65
                } p_u;
66
                unsigned int id[2];
67
        } bi;
68
} bridge_id_t;
69
 
70
#define BRIDGE_PRIORITY bi.p_u.priority
71
#define BRIDGE_ID_ULA   bi.p_u.ula
72
#define BRIDGE_ID       bi.id
73
 
74
typedef struct {
75
        unsigned short  protocol_id;
76
        unsigned char   protocol_version_id;
77
        unsigned char   type;
78
        unsigned char   flags;
79
#define TOPOLOGY_CHANGE         0x01
80
#define TOPOLOGY_CHANGE_ACK     0x80
81
        bridge_id_t      root_id;                 /* (4.5.1.1)   */
82
        unsigned int     root_path_cost;          /* (4.5.1.2)   */
83
        bridge_id_t      bridge_id;               /* (4.5.1.3)   */
84
        unsigned short   port_id;                 /* (4.5.1.4)   */
85
        unsigned short   message_age;             /* (4.5.1.5)   */
86
        unsigned short   max_age;                 /* (4.5.1.6)   */
87
        unsigned short   hello_time;              /* (4.5.1.7)   */
88
        unsigned short   forward_delay;           /* (4.5.1.8)   */
89
} Config_bpdu;
90
 
91
 
92
/** Topology Change Notification BPDU Parameters (4.5.2) **/
93
 
94
typedef struct {
95
        unsigned short  protocol_id;
96
        unsigned char   protocol_version_id;
97
        unsigned char   type;
98
} Tcn_bpdu;
99
 
100
#define BPDU_TYPE_CONFIG        0
101
#define BPDU_TYPE_TOPO_CHANGE   128
102
 
103
/** Bridge Parameters (4.5.3) **/
104
typedef struct {
105
        bridge_id_t      designated_root;         /* (4.5.3.1)   */
106
        unsigned int     root_path_cost;          /* (4.5.3.2)   */
107
        unsigned int     root_port;               /* (4.5.3.3)   */
108
        unsigned short   max_age;                 /* (4.5.3.4)   */
109
        unsigned short   hello_time;              /* (4.5.3.5)   */
110
        unsigned short   forward_delay;           /* (4.5.3.6)   */
111
        bridge_id_t      bridge_id;               /* (4.5.3.7)   */
112
        unsigned short   bridge_max_age;          /* (4.5.3.8)   */
113
        unsigned short   bridge_hello_time;       /* (4.5.3.9)   */
114
        unsigned short   bridge_forward_delay;    /* (4.5.3.10)  */
115
        unsigned int     topology_change_detected; /* (4.5.3.11) */
116
        unsigned int     topology_change;         /* (4.5.3.12)  */
117
        unsigned short   topology_change_time;    /* (4.5.3.13)  */
118
        unsigned short   hold_time;               /* (4.5.3.14)  */
119
        unsigned int     top_change;
120
        unsigned int     top_change_detected;
121
} Bridge_data;
122
 
123
/** Port Parameters (4.5.5) **/
124
typedef struct {
125
        unsigned short   port_id;                 /* (4.5.5.1)   */
126
        unsigned int     state;                   /* (4.5.5.2)   */
127
        unsigned int     path_cost;               /* (4.5.5.3)   */
128
        bridge_id_t      designated_root;         /* (4.5.5.4)   */
129
        unsigned int     designated_cost;         /* (4.5.5.5)   */
130
        bridge_id_t      designated_bridge;       /* (4.5.5.6)   */
131
        unsigned short   designated_port;         /* (4.5.5.7)   */
132
        unsigned int     top_change_ack;          /* (4.5.5.8)   */
133
        unsigned int     config_pending;          /* (4.5.5.9)   */
134
        struct device *dev;
135
        struct fdb *fdb;        /* head of per port fdb chain */
136
} Port_data;
137
 
138
 
139
 
140
/** types to support timers for this pseudo-implementation. **/
141
typedef struct {
142
        unsigned int     active;                          /* timer in use. */
143
        unsigned int     value;                   /* current value of timer,
144
                                                   * counting up. */
145
} Timer;
146
 
147
struct fdb {
148
        unsigned char ula[6];
149
        unsigned char pad[2];
150
        unsigned short port;
151
        unsigned int timer;
152
        unsigned int flags;
153
#define FDB_ENT_VALID   0x01
154
/* AVL tree of all addresses, sorted by address */
155
        short fdb_avl_height;
156
        struct fdb *fdb_avl_left;
157
        struct fdb *fdb_avl_right;
158
/* linked list of addresses for each port */
159
        struct fdb *fdb_next;
160
};
161
 
162
#define IS_BRIDGED      0x2e
163
 
164
struct br_stat {
165
        unsigned int flags;
166
        Bridge_data bridge_data;
167
        Port_data port_data[No_of_ports];
168
};
169
 
170
/* defined flags for br_stat.flags */
171
#define BR_UP           0x0001  /* bridging enabled */
172
#define BR_DEBUG        0x0002  /* debugging enabled */
173
 
174
struct br_cf {
175
        unsigned int cmd;
176
        unsigned int arg1;
177
        unsigned int arg2;
178
};
179
 
180
/* defined cmds */
181
#define BRCMD_BRIDGE_ENABLE     1
182
#define BRCMD_BRIDGE_DISABLE    2
183
#define BRCMD_PORT_ENABLE       3       /* arg1 = port */
184
#define BRCMD_PORT_DISABLE      4       /* arg1 = port */
185
#define BRCMD_SET_BRIDGE_PRIORITY       5       /* arg1 = priority */
186
#define BRCMD_SET_PORT_PRIORITY 6       /* arg1 = port, arg2 = priority */
187
#define BRCMD_SET_PATH_COST     7       /* arg1 = port, arg2 = cost */
188
#define BRCMD_DISPLAY_FDB       8       /* arg1 = port */
189
#define BRCMD_ENABLE_DEBUG      9
190
#define BRCMD_DISABLE_DEBUG     10
191
 
192
/* prototypes of all bridging functions... */
193
 
194
void transmit_config(int port_no);
195
int root_bridge(void);
196
int supersedes_port_info(int port_no, Config_bpdu *config);
197
void record_config_information(int port_no, Config_bpdu *config);
198
void record_config_timeout_values(Config_bpdu *config);
199
void config_bpdu_generation(void);
200
int designated_port(int port_no);
201
void reply(int port_no);
202
void transmit_tcn(void);
203
void configuration_update(void);
204
void root_selection(void);
205
void designated_port_selection(void);
206
void become_designated_port(int port_no);
207
void port_state_selection(void);
208
void make_forwarding(int port_no);
209
void topology_change_detection(void);
210
void topology_change_acknowledged(void);
211
void acknowledge_topology_change(int port_no);
212
void make_blocking(int port_no);
213
void set_port_state(int port_no, int state);
214
void received_config_bpdu(int port_no, Config_bpdu *config);
215
void received_tcn_bpdu(int port_no, Tcn_bpdu *tcn);
216
void hello_timer_expiry(void);
217
void message_age_timer_expiry(int port_no);
218
void forward_delay_timer_expiry(int port_no);
219
int designated_for_some_port(void);
220
void tcn_timer_expiry(void);
221
void topology_change_timer_expiry(void);
222
void hold_timer_expiry(int port_no);
223
void br_init(void);
224
void br_init_port(int port_no);
225
void enable_port(int port_no);
226
void disable_port(int port_no);
227
void set_bridge_priority(bridge_id_t *new_bridge_id);
228
void set_port_priority(int port_no, unsigned short new_port_id);
229
void set_path_cost(int port_no, unsigned short path_cost);
230
void start_hello_timer(void);
231
void stop_hello_timer(void);
232
int hello_timer_expired(void);
233
void start_tcn_timer(void);
234
void stop_tcn_timer(void);
235
int tcn_timer_expired(void);
236
void start_topology_change_timer(void);
237
void stop_topology_change_timer(void);
238
int topology_change_timer_expired(void);
239
void start_message_age_timer(int port_no, unsigned short message_age);
240
void stop_message_age_timer(int port_no);
241
int message_age_timer_expired(int port_no);
242
void start_forward_delay_timer(int port_no);
243
void stop_forward_delay_timer(int port_no);
244
int forward_delay_timer_expired(int port_no);
245
void start_hold_timer(int port_no);
246
void stop_hold_timer(int port_no);
247
int hold_timer_expired(int port_no);
248
 
249
struct fdb *br_avl_find_addr(unsigned char addr[6]);
250
int br_avl_insert (struct fdb * new_node);
251
int br_avl_remove (struct fdb * node_to_delete);
252
 
253
int send_tcn_bpdu(int port_no, Tcn_bpdu *bpdu);
254
int send_config_bpdu(int port_no, Config_bpdu *config_bpdu);
255
int find_port(struct device *dev);
256
int br_flood(struct sk_buff *skb, int port);
257
int br_drop(struct sk_buff *skb);
258
int br_learn(struct sk_buff *skb, int port);    /* 3.8 */
259
 
260
int br_receive_frame(struct sk_buff *skb);      /* 3.5 */
261
int br_tx_frame(struct sk_buff *skb);
262
int br_ioctl(unsigned int cmd, void *arg);
263
 
264
void free_fdb(struct fdb *);
265
struct fdb *get_fdb(void);
266
 
267
/* externs */
268
 
269
extern struct br_stat br_stats;
270
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.