2 * arch/ubicom32/mach-common/switch-core.h
3 * Private data for the switch module
5 * (C) Copyright 2009, Ubicom, Inc.
7 * This file is part of the Ubicom32 Linux Kernel Port.
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
23 * Ubicom32 implementation derived from (with many thanks):
28 #ifndef _SWITCH_CORE_H_
29 #define _SWITCH_CORE_H_
31 struct switch_handler_entry;
32 struct switch_vlan_entry;
34 #define SWITCH_PORT_MASK_SIZE 2
36 struct switch_device {
37 struct list_head node;
44 struct proc_dir_entry *driver_dir;
45 const struct switch_handler *driver_handlers;
47 struct proc_dir_entry *port_dir;
48 struct proc_dir_entry **port_dirs;
49 const struct switch_handler *port_handlers;
51 struct proc_dir_entry *reg_dir;
52 const struct switch_handler *reg_handlers;
54 struct proc_dir_entry *vlan_dir;
55 const struct switch_handler *vlan_handlers;
56 struct list_head vlan_dirs;
58 struct list_head handlers;
60 u32_t port_mask[SWITCH_PORT_MASK_SIZE];
63 typedef int (*switch_handler_fn)(struct switch_device *, char *buf, int nr);
64 struct switch_handler {
67 switch_handler_fn read;
68 switch_handler_fn write;
71 #define SWITCH_MAX_BUFSZ 4096
73 static inline void switch_set_drvdata(struct switch_device *switch_dev, void *drvdata)
75 switch_dev->drvdata = drvdata;
78 static inline void *switch_get_drvdata(struct switch_device *switch_dev)
80 return switch_dev->drvdata;
83 extern int switch_create_vlan_dir(struct switch_device *switch_dev, int vlan_id, const struct switch_handler *handlers);
84 extern int switch_remove_vlan_dir(struct switch_device *switch_dev, int vlan_id);
85 extern void switch_parse_vlan_ports(struct switch_device *switch_dev, char *buf, u32_t *untag, u32_t *ports, u32_t *def);
87 extern void switch_release(struct switch_device *switch_dev);
88 extern struct switch_device *switch_alloc(void);
89 extern int switch_register(struct switch_device *switch_dev);
90 extern void switch_unregister(struct switch_device *switch_dev);