Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * An interface between IEEE802.15.4 device and rest of the kernel. |
| 3 | * |
alex.bluesman.smirnov@gmail.com | 74a02fc | 2012-05-15 20:50:23 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2012 Siemens AG |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 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> |
alex.bluesman.smirnov@gmail.com | 74a02fc | 2012-05-15 20:50:23 +0000 | [diff] [blame] | 24 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #ifndef IEEE802154_NETDEVICE_H |
| 28 | #define IEEE802154_NETDEVICE_H |
| 29 | |
alex.bluesman.smirnov@gmail.com | 1cd829c | 2012-05-15 20:50:21 +0000 | [diff] [blame] | 30 | #include <net/af_ieee802154.h> |
| 31 | |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 32 | /* |
| 33 | * A control block of skb passed between the ARPHRD_IEEE802154 device |
| 34 | * and other stack parts. |
| 35 | */ |
| 36 | struct ieee802154_mac_cb { |
| 37 | u8 lqi; |
| 38 | struct ieee802154_addr sa; |
| 39 | struct ieee802154_addr da; |
| 40 | u8 flags; |
| 41 | u8 seq; |
| 42 | }; |
| 43 | |
| 44 | static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb) |
| 45 | { |
| 46 | return (struct ieee802154_mac_cb *)skb->cb; |
| 47 | } |
| 48 | |
| 49 | #define MAC_CB_FLAG_TYPEMASK ((1 << 3) - 1) |
| 50 | |
| 51 | #define MAC_CB_FLAG_ACKREQ (1 << 3) |
| 52 | #define MAC_CB_FLAG_SECEN (1 << 4) |
| 53 | #define MAC_CB_FLAG_INTRAPAN (1 << 5) |
| 54 | |
| 55 | static inline int mac_cb_is_ackreq(struct sk_buff *skb) |
| 56 | { |
| 57 | return mac_cb(skb)->flags & MAC_CB_FLAG_ACKREQ; |
| 58 | } |
| 59 | |
| 60 | static inline int mac_cb_is_secen(struct sk_buff *skb) |
| 61 | { |
| 62 | return mac_cb(skb)->flags & MAC_CB_FLAG_SECEN; |
| 63 | } |
| 64 | |
| 65 | static inline int mac_cb_is_intrapan(struct sk_buff *skb) |
| 66 | { |
| 67 | return mac_cb(skb)->flags & MAC_CB_FLAG_INTRAPAN; |
| 68 | } |
| 69 | |
| 70 | static inline int mac_cb_type(struct sk_buff *skb) |
| 71 | { |
| 72 | return mac_cb(skb)->flags & MAC_CB_FLAG_TYPEMASK; |
| 73 | } |
| 74 | |
| 75 | #define IEEE802154_MAC_SCAN_ED 0 |
| 76 | #define IEEE802154_MAC_SCAN_ACTIVE 1 |
| 77 | #define IEEE802154_MAC_SCAN_PASSIVE 2 |
| 78 | #define IEEE802154_MAC_SCAN_ORPHAN 3 |
| 79 | |
Dmitry Eremin-Solenikov | 4272344 | 2009-11-04 17:53:23 +0300 | [diff] [blame] | 80 | struct wpan_phy; |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 81 | /* |
| 82 | * This should be located at net_device->ml_priv |
Dmitry Eremin-Solenikov | 4272344 | 2009-11-04 17:53:23 +0300 | [diff] [blame] | 83 | * |
| 84 | * get_phy should increment the reference counting on returned phy. |
| 85 | * Use wpan_wpy_put to put that reference. |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 86 | */ |
| 87 | struct ieee802154_mlme_ops { |
Werner Almesberger | 56aa091 | 2013-04-04 06:32:35 +0000 | [diff] [blame] | 88 | /* The following fields are optional (can be NULL). */ |
| 89 | |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 90 | int (*assoc_req)(struct net_device *dev, |
| 91 | struct ieee802154_addr *addr, |
Dmitry Eremin-Solenikov | 16eea49 | 2009-08-19 19:32:24 +0400 | [diff] [blame] | 92 | u8 channel, u8 page, u8 cap); |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 93 | int (*assoc_resp)(struct net_device *dev, |
| 94 | struct ieee802154_addr *addr, |
| 95 | u16 short_addr, u8 status); |
| 96 | int (*disassoc_req)(struct net_device *dev, |
| 97 | struct ieee802154_addr *addr, |
| 98 | u8 reason); |
| 99 | int (*start_req)(struct net_device *dev, |
| 100 | struct ieee802154_addr *addr, |
Dmitry Eremin-Solenikov | 16eea49 | 2009-08-19 19:32:24 +0400 | [diff] [blame] | 101 | u8 channel, u8 page, u8 bcn_ord, u8 sf_ord, |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 102 | u8 pan_coord, u8 blx, u8 coord_realign); |
| 103 | int (*scan_req)(struct net_device *dev, |
Dmitry Eremin-Solenikov | 16eea49 | 2009-08-19 19:32:24 +0400 | [diff] [blame] | 104 | u8 type, u32 channels, u8 page, u8 duration); |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 105 | |
Werner Almesberger | 56aa091 | 2013-04-04 06:32:35 +0000 | [diff] [blame] | 106 | /* The fields below are required. */ |
| 107 | |
Dmitry Eremin-Solenikov | 4272344 | 2009-11-04 17:53:23 +0300 | [diff] [blame] | 108 | struct wpan_phy *(*get_phy)(const struct net_device *dev); |
| 109 | |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 110 | /* |
| 111 | * FIXME: these should become the part of PIB/MIB interface. |
| 112 | * However we still don't have IB interface of any kind |
| 113 | */ |
Dmitry Eremin-Solenikov | a9966b5 | 2009-10-02 19:05:00 +0400 | [diff] [blame] | 114 | u16 (*get_pan_id)(const struct net_device *dev); |
| 115 | u16 (*get_short_addr)(const struct net_device *dev); |
| 116 | u8 (*get_dsn)(const struct net_device *dev); |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
alex.bluesman.smirnov@gmail.com | 74a02fc | 2012-05-15 20:50:23 +0000 | [diff] [blame] | 119 | /* The IEEE 802.15.4 standard defines 2 type of the devices: |
| 120 | * - FFD - full functionality device |
| 121 | * - RFD - reduce functionality device |
| 122 | * |
| 123 | * So 2 sets of mlme operations are needed |
| 124 | */ |
| 125 | struct ieee802154_reduced_mlme_ops { |
| 126 | struct wpan_phy *(*get_phy)(const struct net_device *dev); |
| 127 | }; |
| 128 | |
| 129 | static inline struct ieee802154_mlme_ops * |
| 130 | ieee802154_mlme_ops(const struct net_device *dev) |
| 131 | { |
| 132 | return dev->ml_priv; |
| 133 | } |
| 134 | |
| 135 | static inline struct ieee802154_reduced_mlme_ops * |
| 136 | ieee802154_reduced_mlme_ops(const struct net_device *dev) |
Sergey Lapin | 9ec7671 | 2009-06-08 12:18:48 +0000 | [diff] [blame] | 137 | { |
| 138 | return dev->ml_priv; |
| 139 | } |
| 140 | |
| 141 | #endif |