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