thp: add pmd paravirt ops
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / phonet.h
blob26c8df7869180d4b94e4daf8b6c3b8988f7070ba
1 /**
2 * file phonet.h
4 * Phonet sockets kernel interface
6 * Copyright (C) 2008 Nokia Corporation. All rights reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
23 #ifndef LINUX_PHONET_H
24 #define LINUX_PHONET_H
26 #include <linux/types.h>
28 /* Automatic protocol selection */
29 #define PN_PROTO_TRANSPORT 0
30 /* Phonet datagram socket */
31 #define PN_PROTO_PHONET 1
32 /* Phonet pipe */
33 #define PN_PROTO_PIPE 2
34 #define PHONET_NPROTO 3
36 /* Socket options for SOL_PNPIPE level */
37 #define PNPIPE_ENCAP 1
38 #define PNPIPE_IFINDEX 2
39 #define PNPIPE_PIPE_HANDLE 3
40 #define PNPIPE_ENABLE 4
41 /* unused slot */
43 #define PNADDR_ANY 0
44 #define PNADDR_BROADCAST 0xFC
45 #define PNPORT_RESOURCE_ROUTING 0
47 /* Values for PNPIPE_ENCAP option */
48 #define PNPIPE_ENCAP_NONE 0
49 #define PNPIPE_ENCAP_IP 1
51 /* ioctls */
52 #define SIOCPNGETOBJECT (SIOCPROTOPRIVATE + 0)
53 #define SIOCPNADDRESOURCE (SIOCPROTOPRIVATE + 14)
54 #define SIOCPNDELRESOURCE (SIOCPROTOPRIVATE + 15)
56 /* Phonet protocol header */
57 struct phonethdr {
58 __u8 pn_rdev;
59 __u8 pn_sdev;
60 __u8 pn_res;
61 __be16 pn_length;
62 __u8 pn_robj;
63 __u8 pn_sobj;
64 } __attribute__((packed));
66 /* Common Phonet payload header */
67 struct phonetmsg {
68 __u8 pn_trans_id; /* transaction ID */
69 __u8 pn_msg_id; /* message type */
70 union {
71 struct {
72 __u8 pn_submsg_id; /* message subtype */
73 __u8 pn_data[5];
74 } base;
75 struct {
76 __u16 pn_e_res_id; /* extended resource ID */
77 __u8 pn_e_submsg_id; /* message subtype */
78 __u8 pn_e_data[3];
79 } ext;
80 } pn_msg_u;
82 #define PN_COMMON_MESSAGE 0xF0
83 #define PN_COMMGR 0x10
84 #define PN_PREFIX 0xE0 /* resource for extended messages */
85 #define pn_submsg_id pn_msg_u.base.pn_submsg_id
86 #define pn_e_submsg_id pn_msg_u.ext.pn_e_submsg_id
87 #define pn_e_res_id pn_msg_u.ext.pn_e_res_id
88 #define pn_data pn_msg_u.base.pn_data
89 #define pn_e_data pn_msg_u.ext.pn_e_data
91 /* data for unreachable errors */
92 #define PN_COMM_SERVICE_NOT_IDENTIFIED_RESP 0x01
93 #define PN_COMM_ISA_ENTITY_NOT_REACHABLE_RESP 0x14
94 #define pn_orig_msg_id pn_data[0]
95 #define pn_status pn_data[1]
96 #define pn_e_orig_msg_id pn_e_data[0]
97 #define pn_e_status pn_e_data[1]
99 /* Phonet socket address structure */
100 struct sockaddr_pn {
101 sa_family_t spn_family;
102 __u8 spn_obj;
103 __u8 spn_dev;
104 __u8 spn_resource;
105 __u8 spn_zero[sizeof(struct sockaddr) - sizeof(sa_family_t) - 3];
106 } __attribute__((packed));
108 /* Well known address */
109 #define PN_DEV_PC 0x10
111 static inline __u16 pn_object(__u8 addr, __u16 port)
113 return (addr << 8) | (port & 0x3ff);
116 static inline __u8 pn_obj(__u16 handle)
118 return handle & 0xff;
121 static inline __u8 pn_dev(__u16 handle)
123 return handle >> 8;
126 static inline __u16 pn_port(__u16 handle)
128 return handle & 0x3ff;
131 static inline __u8 pn_addr(__u16 handle)
133 return (handle >> 8) & 0xfc;
136 static inline void pn_sockaddr_set_addr(struct sockaddr_pn *spn, __u8 addr)
138 spn->spn_dev &= 0x03;
139 spn->spn_dev |= addr & 0xfc;
142 static inline void pn_sockaddr_set_port(struct sockaddr_pn *spn, __u16 port)
144 spn->spn_dev &= 0xfc;
145 spn->spn_dev |= (port >> 8) & 0x03;
146 spn->spn_obj = port & 0xff;
149 static inline void pn_sockaddr_set_object(struct sockaddr_pn *spn,
150 __u16 handle)
152 spn->spn_dev = pn_dev(handle);
153 spn->spn_obj = pn_obj(handle);
156 static inline void pn_sockaddr_set_resource(struct sockaddr_pn *spn,
157 __u8 resource)
159 spn->spn_resource = resource;
162 static inline __u8 pn_sockaddr_get_addr(const struct sockaddr_pn *spn)
164 return spn->spn_dev & 0xfc;
167 static inline __u16 pn_sockaddr_get_port(const struct sockaddr_pn *spn)
169 return ((spn->spn_dev & 0x03) << 8) | spn->spn_obj;
172 static inline __u16 pn_sockaddr_get_object(const struct sockaddr_pn *spn)
174 return pn_object(spn->spn_dev, spn->spn_obj);
177 static inline __u8 pn_sockaddr_get_resource(const struct sockaddr_pn *spn)
179 return spn->spn_resource;
182 /* Phonet device ioctl requests */
183 #ifdef __KERNEL__
184 #define SIOCPNGAUTOCONF (SIOCDEVPRIVATE + 0)
186 struct if_phonet_autoconf {
187 uint8_t device;
190 struct if_phonet_req {
191 char ifr_phonet_name[16];
192 union {
193 struct if_phonet_autoconf ifru_phonet_autoconf;
194 } ifr_ifru;
196 #define ifr_phonet_autoconf ifr_ifru.ifru_phonet_autoconf
197 #endif /* __KERNEL__ */
199 #endif