blob: 12a7ee4b855eff556d5a2e6c1fe3cb55f57cf08a [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 *
4 * Copyright (C) 2007, 2008, 2009 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 * 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>
24 */
25
26#ifndef IEEE802154_NETDEVICE_H
27#define IEEE802154_NETDEVICE_H
28
alex.bluesman.smirnov@gmail.com1cd829c2012-05-15 20:50:21 +000029#include <net/af_ieee802154.h>
30
Sergey Lapin9ec76712009-06-08 12:18:48 +000031/*
32 * A control block of skb passed between the ARPHRD_IEEE802154 device
33 * and other stack parts.
34 */
35struct ieee802154_mac_cb {
36 u8 lqi;
37 struct ieee802154_addr sa;
38 struct ieee802154_addr da;
39 u8 flags;
40 u8 seq;
41};
42
43static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb)
44{
45 return (struct ieee802154_mac_cb *)skb->cb;
46}
47
48#define MAC_CB_FLAG_TYPEMASK ((1 << 3) - 1)
49
50#define MAC_CB_FLAG_ACKREQ (1 << 3)
51#define MAC_CB_FLAG_SECEN (1 << 4)
52#define MAC_CB_FLAG_INTRAPAN (1 << 5)
53
54static inline int mac_cb_is_ackreq(struct sk_buff *skb)
55{
56 return mac_cb(skb)->flags & MAC_CB_FLAG_ACKREQ;
57}
58
59static inline int mac_cb_is_secen(struct sk_buff *skb)
60{
61 return mac_cb(skb)->flags & MAC_CB_FLAG_SECEN;
62}
63
64static inline int mac_cb_is_intrapan(struct sk_buff *skb)
65{
66 return mac_cb(skb)->flags & MAC_CB_FLAG_INTRAPAN;
67}
68
69static inline int mac_cb_type(struct sk_buff *skb)
70{
71 return mac_cb(skb)->flags & MAC_CB_FLAG_TYPEMASK;
72}
73
74#define IEEE802154_MAC_SCAN_ED 0
75#define IEEE802154_MAC_SCAN_ACTIVE 1
76#define IEEE802154_MAC_SCAN_PASSIVE 2
77#define IEEE802154_MAC_SCAN_ORPHAN 3
78
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +030079struct wpan_phy;
Sergey Lapin9ec76712009-06-08 12:18:48 +000080/*
81 * This should be located at net_device->ml_priv
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +030082 *
83 * get_phy should increment the reference counting on returned phy.
84 * Use wpan_wpy_put to put that reference.
Sergey Lapin9ec76712009-06-08 12:18:48 +000085 */
86struct ieee802154_mlme_ops {
87 int (*assoc_req)(struct net_device *dev,
88 struct ieee802154_addr *addr,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +040089 u8 channel, u8 page, u8 cap);
Sergey Lapin9ec76712009-06-08 12:18:48 +000090 int (*assoc_resp)(struct net_device *dev,
91 struct ieee802154_addr *addr,
92 u16 short_addr, u8 status);
93 int (*disassoc_req)(struct net_device *dev,
94 struct ieee802154_addr *addr,
95 u8 reason);
96 int (*start_req)(struct net_device *dev,
97 struct ieee802154_addr *addr,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +040098 u8 channel, u8 page, u8 bcn_ord, u8 sf_ord,
Sergey Lapin9ec76712009-06-08 12:18:48 +000099 u8 pan_coord, u8 blx, u8 coord_realign);
100 int (*scan_req)(struct net_device *dev,
Dmitry Eremin-Solenikov16eea492009-08-19 19:32:24 +0400101 u8 type, u32 channels, u8 page, u8 duration);
Sergey Lapin9ec76712009-06-08 12:18:48 +0000102
Dmitry Eremin-Solenikov42723442009-11-04 17:53:23 +0300103 struct wpan_phy *(*get_phy)(const struct net_device *dev);
104
Sergey Lapin9ec76712009-06-08 12:18:48 +0000105 /*
106 * FIXME: these should become the part of PIB/MIB interface.
107 * However we still don't have IB interface of any kind
108 */
Dmitry Eremin-Solenikova9966b52009-10-02 19:05:00 +0400109 u16 (*get_pan_id)(const struct net_device *dev);
110 u16 (*get_short_addr)(const struct net_device *dev);
111 u8 (*get_dsn)(const struct net_device *dev);
112 u8 (*get_bsn)(const struct net_device *dev);
Sergey Lapin9ec76712009-06-08 12:18:48 +0000113};
114
115static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops(
Dmitry Eremin-Solenikova9966b52009-10-02 19:05:00 +0400116 const struct net_device *dev)
Sergey Lapin9ec76712009-06-08 12:18:48 +0000117{
118 return dev->ml_priv;
119}
120
121#endif
122
123