Root/target/linux/ubicom32/files/arch/ubicom32/mach-common/switch-core.h

1/*
2 * arch/ubicom32/mach-common/switch-core.h
3 * Private data for the switch module
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
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.
13 *
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.
18 *
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/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28#ifndef _SWITCH_CORE_H_
29#define _SWITCH_CORE_H_
30
31struct switch_handler_entry;
32struct switch_vlan_entry;
33
34#define SWITCH_PORT_MASK_SIZE 2
35
36struct switch_device {
37    struct list_head node;
38
39    const char *name;
40    void *drvdata;
41
42    u8_t ports;
43
44    struct proc_dir_entry *driver_dir;
45    const struct switch_handler *driver_handlers;
46
47    struct proc_dir_entry *port_dir;
48    struct proc_dir_entry **port_dirs;
49    const struct switch_handler *port_handlers;
50
51    struct proc_dir_entry *reg_dir;
52    const struct switch_handler *reg_handlers;
53
54    struct proc_dir_entry *vlan_dir;
55    const struct switch_handler *vlan_handlers;
56    struct list_head vlan_dirs;
57
58    struct list_head handlers;
59
60    u32_t port_mask[SWITCH_PORT_MASK_SIZE];
61};
62
63typedef int (*switch_handler_fn)(struct switch_device *, char *buf, int nr);
64struct switch_handler {
65    const char *name;
66
67    switch_handler_fn read;
68    switch_handler_fn write;
69};
70
71#define SWITCH_MAX_BUFSZ 4096
72
73static inline void switch_set_drvdata(struct switch_device *switch_dev, void *drvdata)
74{
75    switch_dev->drvdata = drvdata;
76}
77
78static inline void *switch_get_drvdata(struct switch_device *switch_dev)
79{
80    return switch_dev->drvdata;
81}
82
83extern int switch_create_vlan_dir(struct switch_device *switch_dev, int vlan_id, const struct switch_handler *handlers);
84extern int switch_remove_vlan_dir(struct switch_device *switch_dev, int vlan_id);
85extern void switch_parse_vlan_ports(struct switch_device *switch_dev, char *buf, u32_t *untag, u32_t *ports, u32_t *def);
86
87extern void switch_release(struct switch_device *switch_dev);
88extern struct switch_device *switch_alloc(void);
89extern int switch_register(struct switch_device *switch_dev);
90extern void switch_unregister(struct switch_device *switch_dev);
91
92#endif
93

Archive Download this file



interactive