blob: 97b2e34d87f7d1d19e0dd258b6694c1d9edaab01 [file] [log] [blame]
Sergey Lapin9ec76712009-06-08 12:18:48 +00001/*
2 * An interface between IEEE802.15.4 device and rest of the kernel.
3 *
alex.bluesman.smirnov@gmail.com74a02fc2012-05-15 20:50:23 +00004 * Copyright (C) 2007-2012 Siemens AG
Sergey Lapin9ec76712009-06-08 12:18:48 +00005 *
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 * Written by:
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>
alex.bluesman.smirnov@gmail.com74a02fc2012-05-15 20:50:23 +000024 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Sergey Lapin9ec76712009-06-08 12:18:48 +000025 */
26
27#ifndef IEEE802154_NETDEVICE_H
28#define IEEE802154_NETDEVICE_H
29
alex.bluesman.smirnov@gmail.com1cd829c2012-05-15 20:50:21 +000030#include <net/af_ieee802154.h>
31
Alexander Aring89745c92014-02-28 07:32:43 +010032struct ieee802154_frag_info {
33 __be16 d_tag;
34 u16 d_size;
35 u8 d_offset;
36};
37
Sergey Lapin9ec76712009-06-08 12:18:48 +000038/*
39 * A control block of skb passed between the ARPHRD_IEEE802154 device
40 * and other stack parts.
41 */
42struct ieee802154_mac_cb {
43 u8 lqi;
44 struct ieee802154_addr sa;
45 struct ieee802154_addr da;
46 u8 flags;
47 u8 seq;
Alexander Aring89745c92014-02-28 07:32:43 +010048 struct ieee802154_frag_info frag_info;
Sergey Lapin9ec76712009-06-08 12:18:48 +000049};
50
51static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb)
52{
53 return (struct ieee802154_mac_cb *)skb->cb;
54}
55
56#define MAC_CB_FLAG_TYPEMASK ((1 << 3) - 1)
57
58#define MAC_CB_FLAG_ACKREQ (1 << 3)
59#define MAC_CB_FLAG_SECEN (1 << 4)
60#define MAC_CB_FLAG_INTRAPAN (1 << 5)
61
62static inline int mac_cb_is_ackreq(struct sk_buff *skb)
63{
64 return mac_cb(skb)->flags & MAC_CB_FLAG_ACKREQ;
65}
66
67static inline int mac_cb_is_secen(struct sk_buff *skb)
68{
69 return mac_cb(skb)->flags & MAC_CB_FLAG_SECEN;
70}
71
72static inline int mac_cb_is_intrapan(struct sk_buff *skb)
73{
74 return mac_cb(skb)->flags & MAC_CB_FLAG_INTRAPAN;
75}
76
77static inline int mac_cb_type(struct sk_buff *skb)
78{
79 return mac_cb(skb)->flags & MAC_CB_FLAG_TYPEMASK;
80}
81
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
86
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +030087struct wpan_phy;
Sergey Lapin9ec76712009-06-08 12:18:48 +000088/*
89 * This should be located at net_device->ml_priv
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +030090 *
91 * get_phy should increment the reference counting on returned phy.
92 * Use wpan_wpy_put to put that reference.
Sergey Lapin9ec76712009-06-08 12:18:48 +000093 */
94struct ieee802154_mlme_ops {
Werner Almesberger56aa0912013-04-04 06:32:35 +000095 /* The following fields are optional (can be NULL). */
96
Sergey Lapin9ec76712009-06-08 12:18:48 +000097 int (*assoc_req)(struct net_device *dev,
98 struct ieee802154_addr *addr,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +040099 u8 channel, u8 page, u8 cap);
Sergey Lapin9ec76712009-06-08 12:18:48 +0000100 int (*assoc_resp)(struct net_device *dev,
101 struct ieee802154_addr *addr,
102 u16 short_addr, u8 status);
103 int (*disassoc_req)(struct net_device *dev,
104 struct ieee802154_addr *addr,
105 u8 reason);
106 int (*start_req)(struct net_device *dev,
107 struct ieee802154_addr *addr,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +0400108 u8 channel, u8 page, u8 bcn_ord, u8 sf_ord,
Sergey Lapin9ec76712009-06-08 12:18:48 +0000109 u8 pan_coord, u8 blx, u8 coord_realign);
110 int (*scan_req)(struct net_device *dev,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +0400111 u8 type, u32 channels, u8 page, u8 duration);
Sergey Lapin9ec76712009-06-08 12:18:48 +0000112
Werner Almesberger56aa0912013-04-04 06:32:35 +0000113 /* The fields below are required. */
114
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +0300115 struct wpan_phy *(*get_phy)(const struct net_device *dev);
116
Sergey Lapin9ec76712009-06-08 12:18:48 +0000117 /*
118 * FIXME: these should become the part of PIB/MIB interface.
119 * However we still don't have IB interface of any kind
120 */
Dmitry Eremin-Solenikova9966b52009-10-02 19:05:00 +0400121 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);
Sergey Lapin9ec76712009-06-08 12:18:48 +0000124};
125
alex.bluesman.smirnov@gmail.com74a02fc2012-05-15 20:50:23 +0000126/* The IEEE 802.15.4 standard defines 2 type of the devices:
127 * - FFD - full functionality device
128 * - RFD - reduce functionality device
129 *
130 * So 2 sets of mlme operations are needed
131 */
132struct ieee802154_reduced_mlme_ops {
133 struct wpan_phy *(*get_phy)(const struct net_device *dev);
134};
135
136static inline struct ieee802154_mlme_ops *
137ieee802154_mlme_ops(const struct net_device *dev)
138{
139 return dev->ml_priv;
140}
141
142static inline struct ieee802154_reduced_mlme_ops *
143ieee802154_reduced_mlme_ops(const struct net_device *dev)
Sergey Lapin9ec76712009-06-08 12:18:48 +0000144{
145 return dev->ml_priv;
146}
147
148#endif