alex.bluesman.smirnov@gmail.com | 0afd7ad | 2012-05-15 20:50:19 +0000 | [diff] [blame] | 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> |
| 23 | |
alex.bluesman.smirnov@gmail.com | 32bad7e | 2012-06-25 23:24:48 +0000 | [diff] [blame] | 24 | /* General MAC frame format: |
| 25 | * 2 bytes: Frame Control |
| 26 | * 1 byte: Sequence Number |
| 27 | * 20 bytes: Addressing fields |
| 28 | * 14 bytes: Auxiliary Security Header |
| 29 | */ |
| 30 | #define MAC802154_FRAME_HARD_HEADER_LEN (2 + 1 + 20 + 14) |
| 31 | |
alex.bluesman.smirnov@gmail.com | 0afd7ad | 2012-05-15 20:50:19 +0000 | [diff] [blame] | 32 | /* The following flags are used to indicate changed address settings from |
| 33 | * the stack to the hardware. |
| 34 | */ |
| 35 | |
| 36 | /* indicates that the Short Address changed */ |
| 37 | #define IEEE802515_AFILT_SADDR_CHANGED 0x00000001 |
| 38 | /* indicates that the IEEE Address changed */ |
| 39 | #define IEEE802515_AFILT_IEEEADDR_CHANGED 0x00000002 |
| 40 | /* indicates that the PAN ID changed */ |
| 41 | #define IEEE802515_AFILT_PANID_CHANGED 0x00000004 |
| 42 | /* indicates that PAN Coordinator status changed */ |
| 43 | #define IEEE802515_AFILT_PANC_CHANGED 0x00000008 |
| 44 | |
| 45 | struct ieee802154_hw_addr_filt { |
| 46 | __le16 pan_id; /* Each independent PAN selects a unique |
| 47 | * identifier. This PAN id allows communication |
| 48 | * between devices within a network using short |
| 49 | * addresses and enables transmissions between |
| 50 | * devices across independent networks. |
| 51 | */ |
| 52 | __le16 short_addr; |
| 53 | u8 ieee_addr[IEEE802154_ADDR_LEN]; |
| 54 | u8 pan_coord; |
| 55 | }; |
| 56 | |
| 57 | struct ieee802154_dev { |
| 58 | /* filled by the driver */ |
| 59 | int extra_tx_headroom; |
| 60 | u32 flags; |
| 61 | struct device *parent; |
| 62 | |
| 63 | /* filled by mac802154 core */ |
| 64 | struct ieee802154_hw_addr_filt hw_filt; |
| 65 | void *priv; |
| 66 | struct wpan_phy *phy; |
| 67 | }; |
| 68 | |
| 69 | /* Checksum is in hardware and is omitted from a packet |
| 70 | * |
| 71 | * These following flags are used to indicate hardware capabilities to |
| 72 | * the stack. Generally, flags here should have their meaning |
| 73 | * done in a way that the simplest hardware doesn't need setting |
| 74 | * any particular flags. There are some exceptions to this rule, |
| 75 | * however, so you are advised to review these flags carefully. |
| 76 | */ |
| 77 | |
| 78 | /* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ |
| 79 | #define IEEE802154_HW_OMIT_CKSUM 0x00000001 |
| 80 | /* Indicates that receiver will autorespond with ACK frames. */ |
| 81 | #define IEEE802154_HW_AACK 0x00000002 |
| 82 | |
| 83 | /* struct ieee802154_ops - callbacks from mac802154 to the driver |
| 84 | * |
| 85 | * This structure contains various callbacks that the driver may |
| 86 | * handle or, in some cases, must handle, for example to transmit |
| 87 | * a frame. |
| 88 | * |
| 89 | * start: Handler that 802.15.4 module calls for device initialization. |
| 90 | * This function is called before the first interface is attached. |
| 91 | * |
| 92 | * stop: Handler that 802.15.4 module calls for device cleanup. |
| 93 | * This function is called after the last interface is removed. |
| 94 | * |
| 95 | * xmit: Handler that 802.15.4 module calls for each transmitted frame. |
| 96 | * skb cntains the buffer starting from the IEEE 802.15.4 header. |
| 97 | * The low-level driver should send the frame based on available |
| 98 | * configuration. |
| 99 | * This function should return zero or negative errno. Called with |
| 100 | * pib_lock held. |
| 101 | * |
| 102 | * ed: Handler that 802.15.4 module calls for Energy Detection. |
| 103 | * This function should place the value for detected energy |
| 104 | * (usually device-dependant) in the level pointer and return |
| 105 | * either zero or negative errno. Called with pib_lock held. |
| 106 | * |
| 107 | * set_channel: |
| 108 | * Set radio for listening on specific channel. |
| 109 | * Set the device for listening on specified channel. |
| 110 | * Returns either zero, or negative errno. Called with pib_lock held. |
| 111 | * |
| 112 | * set_hw_addr_filt: |
| 113 | * Set radio for listening on specific address. |
| 114 | * Set the device for listening on specified address. |
| 115 | * Returns either zero, or negative errno. |
| 116 | */ |
| 117 | struct ieee802154_ops { |
| 118 | struct module *owner; |
| 119 | int (*start)(struct ieee802154_dev *dev); |
| 120 | void (*stop)(struct ieee802154_dev *dev); |
| 121 | int (*xmit)(struct ieee802154_dev *dev, |
| 122 | struct sk_buff *skb); |
| 123 | int (*ed)(struct ieee802154_dev *dev, u8 *level); |
| 124 | int (*set_channel)(struct ieee802154_dev *dev, |
| 125 | int page, |
| 126 | int channel); |
| 127 | int (*set_hw_addr_filt)(struct ieee802154_dev *dev, |
| 128 | struct ieee802154_hw_addr_filt *filt, |
| 129 | unsigned long changed); |
| 130 | int (*ieee_addr)(struct ieee802154_dev *dev, |
| 131 | u8 addr[IEEE802154_ADDR_LEN]); |
| 132 | }; |
| 133 | |
alex.bluesman.smirnov@gmail.com | 1010f54 | 2012-05-15 20:50:20 +0000 | [diff] [blame] | 134 | /* Basic interface to register ieee802154 device */ |
| 135 | struct ieee802154_dev * |
| 136 | ieee802154_alloc_device(size_t priv_data_lex, struct ieee802154_ops *ops); |
| 137 | void ieee802154_free_device(struct ieee802154_dev *dev); |
| 138 | int ieee802154_register_device(struct ieee802154_dev *dev); |
| 139 | void ieee802154_unregister_device(struct ieee802154_dev *dev); |
| 140 | |
alex.bluesman.smirnov@gmail.com | 1cd829c | 2012-05-15 20:50:21 +0000 | [diff] [blame] | 141 | void ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb, |
| 142 | u8 lqi); |
| 143 | |
alex.bluesman.smirnov@gmail.com | 0afd7ad | 2012-05-15 20:50:19 +0000 | [diff] [blame] | 144 | #endif /* NET_MAC802154_H */ |