Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / include / net / mac802154.h
CommitLineData
0afd7ad9 1/*
2 * IEEE802.15.4-2003 specification
3 *
4 * Copyright (C) 2007-2012 Siemens AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#ifndef NET_MAC802154_H
20#define NET_MAC802154_H
21
22#include <net/af_ieee802154.h>
94b4f6c2 23#include <linux/skbuff.h>
0afd7ad9 24
32bad7e3 25/* General MAC frame format:
26 * 2 bytes: Frame Control
27 * 1 byte: Sequence Number
28 * 20 bytes: Addressing fields
29 * 14 bytes: Auxiliary Security Header
30 */
31#define MAC802154_FRAME_HARD_HEADER_LEN (2 + 1 + 20 + 14)
32
0afd7ad9 33/* The following flags are used to indicate changed address settings from
34 * the stack to the hardware.
35 */
36
37/* indicates that the Short Address changed */
38#define IEEE802515_AFILT_SADDR_CHANGED 0x00000001
39/* indicates that the IEEE Address changed */
40#define IEEE802515_AFILT_IEEEADDR_CHANGED 0x00000002
41/* indicates that the PAN ID changed */
42#define IEEE802515_AFILT_PANID_CHANGED 0x00000004
43/* indicates that PAN Coordinator status changed */
44#define IEEE802515_AFILT_PANC_CHANGED 0x00000008
45
46struct ieee802154_hw_addr_filt {
47 __le16 pan_id; /* Each independent PAN selects a unique
48 * identifier. This PAN id allows communication
49 * between devices within a network using short
50 * addresses and enables transmissions between
51 * devices across independent networks.
52 */
53 __le16 short_addr;
b70ab2e8 54 __le64 ieee_addr;
0afd7ad9 55 u8 pan_coord;
56};
57
58struct ieee802154_dev {
59 /* filled by the driver */
60 int extra_tx_headroom;
61 u32 flags;
62 struct device *parent;
63
64 /* filled by mac802154 core */
65 struct ieee802154_hw_addr_filt hw_filt;
66 void *priv;
67 struct wpan_phy *phy;
68};
69
70/* Checksum is in hardware and is omitted from a packet
71 *
72 * These following flags are used to indicate hardware capabilities to
73 * the stack. Generally, flags here should have their meaning
74 * done in a way that the simplest hardware doesn't need setting
75 * any particular flags. There are some exceptions to this rule,
76 * however, so you are advised to review these flags carefully.
77 */
78
79/* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */
80#define IEEE802154_HW_OMIT_CKSUM 0x00000001
81/* Indicates that receiver will autorespond with ACK frames. */
82#define IEEE802154_HW_AACK 0x00000002
640985ec
AA
83/* Indicates that transceiver will support transmit power setting. */
84#define IEEE802154_HW_TXPOWER 0x00000004
85/* Indicates that transceiver will support listen before transmit. */
86#define IEEE802154_HW_LBT 0x00000008
87/* Indicates that transceiver will support cca mode setting. */
88#define IEEE802154_HW_CCA_MODE 0x00000010
89/* Indicates that transceiver will support cca ed level setting. */
90#define IEEE802154_HW_CCA_ED_LEVEL 0x00000020
91/* Indicates that transceiver will support csma (max_be, min_be, csma retries)
92 * settings. */
93#define IEEE802154_HW_CSMA_PARAMS 0x00000040
94/* Indicates that transceiver will support ARET frame retries setting. */
95#define IEEE802154_HW_FRAME_RETRIES 0x00000080
96
97/* This groups the most common CSMA support fields into one. */
98#define IEEE802154_HW_CSMA (IEEE802154_HW_CCA_MODE | \
99 IEEE802154_HW_CCA_ED_LEVEL | \
100 IEEE802154_HW_CSMA_PARAMS | \
101 IEEE802154_HW_FRAME_RETRIES)
0afd7ad9 102
103/* struct ieee802154_ops - callbacks from mac802154 to the driver
104 *
105 * This structure contains various callbacks that the driver may
106 * handle or, in some cases, must handle, for example to transmit
107 * a frame.
108 *
109 * start: Handler that 802.15.4 module calls for device initialization.
110 * This function is called before the first interface is attached.
111 *
112 * stop: Handler that 802.15.4 module calls for device cleanup.
113 * This function is called after the last interface is removed.
114 *
115 * xmit: Handler that 802.15.4 module calls for each transmitted frame.
116 * skb cntains the buffer starting from the IEEE 802.15.4 header.
117 * The low-level driver should send the frame based on available
118 * configuration.
119 * This function should return zero or negative errno. Called with
120 * pib_lock held.
121 *
122 * ed: Handler that 802.15.4 module calls for Energy Detection.
123 * This function should place the value for detected energy
124 * (usually device-dependant) in the level pointer and return
125 * either zero or negative errno. Called with pib_lock held.
126 *
127 * set_channel:
128 * Set radio for listening on specific channel.
129 * Set the device for listening on specified channel.
130 * Returns either zero, or negative errno. Called with pib_lock held.
131 *
132 * set_hw_addr_filt:
133 * Set radio for listening on specific address.
134 * Set the device for listening on specified address.
135 * Returns either zero, or negative errno.
9b2777d6
PB
136 *
137 * set_txpower:
138 * Set radio transmit power in dB. Called with pib_lock held.
139 * Returns either zero, or negative errno.
84dda3c6
PB
140 *
141 * set_lbt
142 * Enables or disables listen before talk on the device. Called with
143 * pib_lock held.
144 * Returns either zero, or negative errno.
ba08fea5
PB
145 *
146 * set_cca_mode
147 * Sets the CCA mode used by the device. Called with pib_lock held.
148 * Returns either zero, or negative errno.
6ca00197
PB
149 *
150 * set_cca_ed_level
151 * Sets the CCA energy detection threshold in dBm. Called with pib_lock
152 * held.
153 * Returns either zero, or negative errno.
4244db1b
PB
154 *
155 * set_csma_params
156 * Sets the CSMA parameter set for the PHY. Called with pib_lock held.
157 * Returns either zero, or negative errno.
158 *
159 * set_frame_retries
160 * Sets the retransmission attempt limit. Called with pib_lock held.
161 * Returns either zero, or negative errno.
0afd7ad9 162 */
163struct ieee802154_ops {
164 struct module *owner;
165 int (*start)(struct ieee802154_dev *dev);
166 void (*stop)(struct ieee802154_dev *dev);
167 int (*xmit)(struct ieee802154_dev *dev,
168 struct sk_buff *skb);
169 int (*ed)(struct ieee802154_dev *dev, u8 *level);
170 int (*set_channel)(struct ieee802154_dev *dev,
171 int page,
172 int channel);
173 int (*set_hw_addr_filt)(struct ieee802154_dev *dev,
174 struct ieee802154_hw_addr_filt *filt,
175 unsigned long changed);
b70ab2e8 176 int (*ieee_addr)(struct ieee802154_dev *dev, __le64 addr);
9b2777d6 177 int (*set_txpower)(struct ieee802154_dev *dev, int db);
84dda3c6 178 int (*set_lbt)(struct ieee802154_dev *dev, bool on);
ba08fea5 179 int (*set_cca_mode)(struct ieee802154_dev *dev, u8 mode);
6ca00197
PB
180 int (*set_cca_ed_level)(struct ieee802154_dev *dev,
181 s32 level);
4244db1b
PB
182 int (*set_csma_params)(struct ieee802154_dev *dev,
183 u8 min_be, u8 max_be, u8 retries);
184 int (*set_frame_retries)(struct ieee802154_dev *dev,
185 s8 retries);
0afd7ad9 186};
187
1010f540 188/* Basic interface to register ieee802154 device */
189struct ieee802154_dev *
7e4d8a19 190ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops);
1010f540 191void ieee802154_free_device(struct ieee802154_dev *dev);
192int ieee802154_register_device(struct ieee802154_dev *dev);
193void ieee802154_unregister_device(struct ieee802154_dev *dev);
194
1cd829c8 195void ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb,
196 u8 lqi);
197
0afd7ad9 198#endif /* NET_MAC802154_H */
This page took 0.187583 seconds and 5 git commands to generate.