lantiq: Tune the XWAY subtarget cflags
[openwrt/staging/yousong.git] / package / switch / src / switch-core.h
1 #ifndef __SWITCH_CORE_H
2 #define __SWITCH_CORE_H
3
4 #include <linux/version.h>
5 #include <linux/list.h>
6 #define SWITCH_MAX_BUFSZ 4096
7 #define SWITCH_NAME_BUFSZ 16
8
9 #define SWITCH_MEDIA_AUTO 1
10 #define SWITCH_MEDIA_100 2
11 #define SWITCH_MEDIA_FD 4
12 #define SWITCH_MEDIA_1000 8
13
14 typedef int (*switch_handler)(void *driver, char *buf, int nr);
15
16 typedef struct {
17 const char *name;
18 switch_handler read, write;
19 } switch_config;
20
21 typedef struct {
22 struct list_head list;
23 const char *name;
24 const char *version;
25 const char *interface;
26 int cpuport;
27 int ports;
28 int vlans;
29 const switch_config *driver_handlers, *port_handlers, *vlan_handlers;
30 void *data;
31 void *priv;
32 char dev_name[SWITCH_NAME_BUFSZ];
33 } switch_driver;
34
35 typedef struct {
36 u32 port, untag, pvid;
37 } switch_vlan_config;
38
39
40 extern int switch_device_registered (char* device);
41 extern int switch_register_driver(switch_driver *driver);
42 extern void switch_unregister_driver(char *name);
43 extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
44 extern int switch_parse_media(char *buf);
45 extern int switch_print_media(char *buf, int media);
46
47 static inline char *strdup(const char *str)
48 {
49 char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
50 strcpy(new, str);
51 return new;
52 }
53
54
55 #endif