vmalloc: fix __GFP_HIGHMEM usage for vmalloc_32 on 32b systems
[linux/fpc-iii.git] / include / net / llc.h
blobdc35f25eb679d4651b59a20c785005aa0cbb4d0f
1 #ifndef LLC_H
2 #define LLC_H
3 /*
4 * Copyright (c) 1997 by Procom Technology, Inc.
5 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7 * This program can be redistributed or modified under the terms of the
8 * GNU General Public License as published by the Free Software Foundation.
9 * This program is distributed without any warranty or implied warranty
10 * of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
15 #include <linux/if.h>
16 #include <linux/if_ether.h>
17 #include <linux/list.h>
18 #include <linux/spinlock.h>
19 #include <linux/rculist_nulls.h>
20 #include <linux/hash.h>
21 #include <linux/jhash.h>
23 #include <linux/atomic.h>
25 struct net_device;
26 struct packet_type;
27 struct sk_buff;
29 struct llc_addr {
30 unsigned char lsap;
31 unsigned char mac[IFHWADDRLEN];
34 #define LLC_SAP_STATE_INACTIVE 1
35 #define LLC_SAP_STATE_ACTIVE 2
37 #define LLC_SK_DEV_HASH_BITS 6
38 #define LLC_SK_DEV_HASH_ENTRIES (1<<LLC_SK_DEV_HASH_BITS)
40 #define LLC_SK_LADDR_HASH_BITS 6
41 #define LLC_SK_LADDR_HASH_ENTRIES (1<<LLC_SK_LADDR_HASH_BITS)
43 /**
44 * struct llc_sap - Defines the SAP component
46 * @station - station this sap belongs to
47 * @state - sap state
48 * @p_bit - only lowest-order bit used
49 * @f_bit - only lowest-order bit used
50 * @laddr - SAP value in this 'lsap'
51 * @node - entry in station sap_list
52 * @sk_list - LLC sockets this one manages
54 struct llc_sap {
55 unsigned char state;
56 unsigned char p_bit;
57 unsigned char f_bit;
58 refcount_t refcnt;
59 int (*rcv_func)(struct sk_buff *skb,
60 struct net_device *dev,
61 struct packet_type *pt,
62 struct net_device *orig_dev);
63 struct llc_addr laddr;
64 struct list_head node;
65 spinlock_t sk_lock;
66 int sk_count;
67 struct hlist_nulls_head sk_laddr_hash[LLC_SK_LADDR_HASH_ENTRIES];
68 struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES];
71 static inline
72 struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex)
74 return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES];
77 static inline
78 u32 llc_sk_laddr_hashfn(struct llc_sap *sap, const struct llc_addr *laddr)
80 return hash_32(jhash(laddr->mac, sizeof(laddr->mac), 0),
81 LLC_SK_LADDR_HASH_BITS);
84 static inline
85 struct hlist_nulls_head *llc_sk_laddr_hash(struct llc_sap *sap,
86 const struct llc_addr *laddr)
88 return &sap->sk_laddr_hash[llc_sk_laddr_hashfn(sap, laddr)];
91 #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */
92 #define LLC_DEST_SAP 1 /* Type 1 goes here */
93 #define LLC_DEST_CONN 2 /* Type 2 goes here */
95 extern struct list_head llc_sap_list;
97 int llc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
98 struct net_device *orig_dev);
100 int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa,
101 const unsigned char *da);
103 void llc_add_pack(int type,
104 void (*handler)(struct llc_sap *sap, struct sk_buff *skb));
105 void llc_remove_pack(int type);
107 void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
109 struct llc_sap *llc_sap_open(unsigned char lsap,
110 int (*rcv)(struct sk_buff *skb,
111 struct net_device *dev,
112 struct packet_type *pt,
113 struct net_device *orig_dev));
114 static inline void llc_sap_hold(struct llc_sap *sap)
116 refcount_inc(&sap->refcnt);
119 void llc_sap_close(struct llc_sap *sap);
121 static inline void llc_sap_put(struct llc_sap *sap)
123 if (refcount_dec_and_test(&sap->refcnt))
124 llc_sap_close(sap);
127 struct llc_sap *llc_sap_find(unsigned char sap_value);
129 int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
130 unsigned char *dmac, unsigned char dsap);
132 void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
133 void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
135 void llc_station_init(void);
136 void llc_station_exit(void);
138 #ifdef CONFIG_PROC_FS
139 int llc_proc_init(void);
140 void llc_proc_exit(void);
141 #else
142 #define llc_proc_init() (0)
143 #define llc_proc_exit() do { } while(0)
144 #endif /* CONFIG_PROC_FS */
145 #ifdef CONFIG_SYSCTL
146 int llc_sysctl_init(void);
147 void llc_sysctl_exit(void);
149 extern int sysctl_llc2_ack_timeout;
150 extern int sysctl_llc2_busy_timeout;
151 extern int sysctl_llc2_p_timeout;
152 extern int sysctl_llc2_rej_timeout;
153 #else
154 #define llc_sysctl_init() (0)
155 #define llc_sysctl_exit() do { } while(0)
156 #endif /* CONFIG_SYSCTL */
157 #endif /* LLC_H */