2 * An interface between IEEE802.15.4 device and rest of the kernel.
4 * Copyright (C) 2007-2012 Siemens AG
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.
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.
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.
20 * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
21 * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
22 * Maxim Osipov <maxim.osipov@siemens.com>
23 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
24 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
27 #ifndef IEEE802154_NETDEVICE_H
28 #define IEEE802154_NETDEVICE_H
30 #include <net/af_ieee802154.h>
32 struct ieee802154_frag_info
{
39 * A control block of skb passed between the ARPHRD_IEEE802154 device
40 * and other stack parts.
42 struct ieee802154_mac_cb
{
44 struct ieee802154_addr_sa sa
;
45 struct ieee802154_addr_sa da
;
48 struct ieee802154_frag_info frag_info
;
51 static inline struct ieee802154_mac_cb
*mac_cb(struct sk_buff
*skb
)
53 return (struct ieee802154_mac_cb
*)skb
->cb
;
56 #define MAC_CB_FLAG_TYPEMASK ((1 << 3) - 1)
58 #define MAC_CB_FLAG_ACKREQ (1 << 3)
59 #define MAC_CB_FLAG_SECEN (1 << 4)
60 #define MAC_CB_FLAG_INTRAPAN (1 << 5)
62 static inline int mac_cb_is_ackreq(struct sk_buff
*skb
)
64 return mac_cb(skb
)->flags
& MAC_CB_FLAG_ACKREQ
;
67 static inline int mac_cb_is_secen(struct sk_buff
*skb
)
69 return mac_cb(skb
)->flags
& MAC_CB_FLAG_SECEN
;
72 static inline int mac_cb_is_intrapan(struct sk_buff
*skb
)
74 return mac_cb(skb
)->flags
& MAC_CB_FLAG_INTRAPAN
;
77 static inline int mac_cb_type(struct sk_buff
*skb
)
79 return mac_cb(skb
)->flags
& MAC_CB_FLAG_TYPEMASK
;
82 #define IEEE802154_MAC_SCAN_ED 0
83 #define IEEE802154_MAC_SCAN_ACTIVE 1
84 #define IEEE802154_MAC_SCAN_PASSIVE 2
85 #define IEEE802154_MAC_SCAN_ORPHAN 3
89 * This should be located at net_device->ml_priv
91 * get_phy should increment the reference counting on returned phy.
92 * Use wpan_wpy_put to put that reference.
94 struct ieee802154_mlme_ops
{
95 /* The following fields are optional (can be NULL). */
97 int (*assoc_req
)(struct net_device
*dev
,
98 struct ieee802154_addr_sa
*addr
,
99 u8 channel
, u8 page
, u8 cap
);
100 int (*assoc_resp
)(struct net_device
*dev
,
101 struct ieee802154_addr_sa
*addr
,
102 u16 short_addr
, u8 status
);
103 int (*disassoc_req
)(struct net_device
*dev
,
104 struct ieee802154_addr_sa
*addr
,
106 int (*start_req
)(struct net_device
*dev
,
107 struct ieee802154_addr_sa
*addr
,
108 u8 channel
, u8 page
, u8 bcn_ord
, u8 sf_ord
,
109 u8 pan_coord
, u8 blx
, u8 coord_realign
);
110 int (*scan_req
)(struct net_device
*dev
,
111 u8 type
, u32 channels
, u8 page
, u8 duration
);
113 /* The fields below are required. */
115 struct wpan_phy
*(*get_phy
)(const struct net_device
*dev
);
118 * FIXME: these should become the part of PIB/MIB interface.
119 * However we still don't have IB interface of any kind
121 u16 (*get_pan_id
)(const struct net_device
*dev
);
122 u16 (*get_short_addr
)(const struct net_device
*dev
);
123 u8 (*get_dsn
)(const struct net_device
*dev
);
126 /* The IEEE 802.15.4 standard defines 2 type of the devices:
127 * - FFD - full functionality device
128 * - RFD - reduce functionality device
130 * So 2 sets of mlme operations are needed
132 struct ieee802154_reduced_mlme_ops
{
133 struct wpan_phy
*(*get_phy
)(const struct net_device
*dev
);
136 static inline struct ieee802154_mlme_ops
*
137 ieee802154_mlme_ops(const struct net_device
*dev
)
142 static inline struct ieee802154_reduced_mlme_ops
*
143 ieee802154_reduced_mlme_ops(const struct net_device
*dev
)