2005-12-25 14:18:55 +00:00
|
|
|
#ifndef __SWITCH_CORE_H
|
|
|
|
#define __SWITCH_CORE_H
|
|
|
|
|
2005-12-25 21:57:14 +00:00
|
|
|
#include <linux/version.h>
|
2005-12-25 14:18:55 +00:00
|
|
|
#include <linux/list.h>
|
|
|
|
#define SWITCH_MAX_BUFSZ 4096
|
|
|
|
|
|
|
|
#define SWITCH_MEDIA_AUTO 1
|
|
|
|
#define SWITCH_MEDIA_100 2
|
|
|
|
#define SWITCH_MEDIA_FD 4
|
|
|
|
|
2005-12-25 21:57:14 +00:00
|
|
|
#ifndef KERNEL_VERSION
|
|
|
|
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
|
|
|
#endif
|
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
typedef int (*switch_handler)(void *driver, char *buf, int nr);
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2008-02-27 22:35:41 +00:00
|
|
|
const char *name;
|
2005-12-25 14:18:55 +00:00
|
|
|
switch_handler read, write;
|
|
|
|
} switch_config;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
struct list_head list;
|
2008-02-27 22:35:41 +00:00
|
|
|
const char *name;
|
|
|
|
const char *version;
|
|
|
|
const char *interface;
|
2006-01-04 19:10:06 +00:00
|
|
|
int cpuport;
|
2005-12-25 14:18:55 +00:00
|
|
|
int ports;
|
|
|
|
int vlans;
|
2008-02-27 22:35:41 +00:00
|
|
|
const switch_config *driver_handlers, *port_handlers, *vlan_handlers;
|
2005-12-25 14:18:55 +00:00
|
|
|
void *data;
|
2006-01-04 19:10:06 +00:00
|
|
|
void *priv;
|
2005-12-25 14:18:55 +00:00
|
|
|
} switch_driver;
|
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
typedef struct {
|
|
|
|
u32 port, untag, pvid;
|
|
|
|
} switch_vlan_config;
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2008-06-15 11:10:27 +00:00
|
|
|
extern int switch_device_registered (char* device);
|
2005-12-25 14:18:55 +00:00
|
|
|
extern int switch_register_driver(switch_driver *driver);
|
|
|
|
extern void switch_unregister_driver(char *name);
|
2006-01-04 19:10:06 +00:00
|
|
|
extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
|
2005-12-25 14:18:55 +00:00
|
|
|
extern int switch_parse_media(char *buf);
|
|
|
|
extern int switch_print_media(char *buf, int media);
|
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
static inline char *strdup(const char *str)
|
2006-03-25 14:31:42 +00:00
|
|
|
{
|
|
|
|
char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
|
|
|
|
strcpy(new, str);
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
#endif
|