Skip to content

Commit c329f61

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
MAC API update and internal update
MAC API extension update: * mcps_data_request_ext() add support for 2015 MAC IE support * mcps_data_indication_ext() API for receive 2015 messages with IE * mcps_data_confirm_ext() API for rceive Enhanced ack payload with normal conf * mac_api_enable_mcps_ext() enable 2015 support and data indication SW MAC Update: Added support for new MCPS data extensions. Old Data request call internally new API with empty IE list, 2015 MAC frame type is only used when message include IE elements. Added MAC 2015 support for generic FCF parse and build. Also Code size should be smaller and code more readable. Updated unit test and stub's Change-Id: I4e7a614aec3603c4546bcc3801300f1a21f00a74
1 parent ad5a1e1 commit c329f61

27 files changed

+1644
-575
lines changed

nanostack/mac_api.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ typedef void mlme_request(const mac_api_t* api, mlme_primitive id, const void *d
120120
*/
121121
typedef void mcps_data_request(const mac_api_t* api, const mcps_data_req_t *data);
122122

123+
/**
124+
* @brief mcps_request MCPS_DATA with IE extions request call
125+
* @param api API to handle the request
126+
* @param data MCPS-DATA.request specific values
127+
* @param ie_ext Information element list to MCPS-DATA.request
128+
*/
129+
typedef void mcps_data_request_ext(const mac_api_t* api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext);
130+
123131
/**
124132
* @brief mcps_purge_request MCPS_PURGE request call
125133
* @param api API to handle the request
@@ -136,13 +144,29 @@ typedef void mcps_purge_request(const mac_api_t* api, const mcps_purge_t *data);
136144
*/
137145
typedef void mcps_data_confirm(const mac_api_t* api, const mcps_data_conf_t *data);
138146

147+
/**
148+
* @brief mcps_data_confirm_ext MCPS-DATA confirm with Enhanced ACK payload is called as a response to MCPS-DATA request
149+
* @param api The API which handled the response
150+
* @param data MCPS-DATA.confirm specific values
151+
* @param conf_data Possible Confirmation Data
152+
*/
153+
typedef void mcps_data_confirm_ext(const mac_api_t* api, const mcps_data_conf_t *data, const mcps_data_conf_payload_t *conf_data);
154+
139155
/**
140156
* @brief mcps_data_indication MCPS-DATA indication is called when MAC layer has received data
141157
* @param api The API which handled the response
142158
* @param data MCPS-DATA.indication specific values
143159
*/
144160
typedef void mcps_data_indication(const mac_api_t* api, const mcps_data_ind_t *data);
145161

162+
/**
163+
* @brief mcps_data_indication MCPS-DATA indication is called when MAC layer has received data
164+
* @param api The API which handled the response
165+
* @param data MCPS-DATA.indication specific values
166+
* @param ie_ext Information element list
167+
*/
168+
typedef void mcps_data_indication_ext(const mac_api_t* api, const mcps_data_ind_t *data, const mcps_data_ie_list_t *ie_ext);
169+
146170
/**
147171
* @brief mcps_purge_confirm MCPS-PURGE confirm is called as a response to MCPS-PURGE request
148172
* @param api The API which handled the request
@@ -201,6 +225,17 @@ typedef int8_t mac_api_initialize(mac_api_t *api, mcps_data_confirm *data_conf_c
201225
mcps_data_indication *data_ind_cb, mcps_purge_confirm *purge_conf_cb, mlme_confirm *mlme_conf_cb,
202226
mlme_indication *mlme_ind_cb, int8_t parent_id);
203227

228+
/**
229+
* @brief mac_api_enable_mcps_ext Initialises MAC 2015 extension for MCPS layer into use, callbacks must be non-NULL.
230+
* @param api mac_api_t pointer, which is created by application.
231+
* @param data_ind_cb Upper layer function to handle MCPS indications
232+
* @param data_cnf_cb Upper layer function to handle MCPS confirmation
233+
* @return -1 if error, -2 if OOM, 0 otherwise
234+
*/
235+
typedef int8_t mac_api_enable_mcps_ext(mac_api_t *api,
236+
mcps_data_indication_ext *data_ind_cb,
237+
mcps_data_confirm_ext *data_cnf_cb);
238+
204239
/**
205240
* \brief Struct mac_api_s defines functions for two-way communications between external MAC and Upper layer.
206241
* Application creates mac_api_t object by calling external MAC's creator function.
@@ -209,14 +244,18 @@ typedef int8_t mac_api_initialize(mac_api_t *api, mcps_data_confirm *data_conf_c
209244
*/
210245
struct mac_api_s {
211246
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
247+
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
212248
//External MAC callbacks
213249
mlme_request *mlme_req; /**< MAC MLME request function to use */
214250
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
251+
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
215252
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
216253

217254
//Upper layer callbacksMLME_ASSOCIATE
218255
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
256+
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
219257
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
258+
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
220259
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
221260
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */
222261
mlme_indication *mlme_ind_cb; /**< MAC MLME indication callback function */

nanostack/mac_common_defines.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#define MAC_FRAME_VERSION_2003 0 /**< FCF - IEEE 802.15.4-2003 compatible */
3232
#define MAC_FRAME_VERSION_2006 1 /**< FCF - IEEE 802.15.4-2006 (big payload or new security) */
33+
#define MAC_FRAME_VERSION_2015 2 /**< FCF - IEEE 802.15.4-2015 (IE element support) */
3334

3435
//See IEEE standard 802.15.4-2006 (table 96) for more details about identifiers
3536
#define MAC_KEY_ID_MODE_IMPLICIT 0 /**< Key identifier mode implicit */
@@ -66,4 +67,36 @@ typedef struct mlme_security_s {
6667
uint8_t Keysource[8]; /**< Key source */
6768
} mlme_security_t;
6869

70+
#define MAC_HEADER_VENDOR_SPESIFIC_IE_ID 0x00
71+
#define MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID 0x2a
72+
#define MAC_HEADER_TERMINATION1_IE_ID 0x7e
73+
#define MAC_HEADER_TERMINATION2_IE_ID 0x7f
74+
75+
76+
/**
77+
* @brief struct mac_header_IE_t Mac Header information element structure for parsing or write operation
78+
* This structure encapsulates security related variables,
79+
*/
80+
typedef struct mac_header_IE_s {
81+
const uint8_t *content_ptr; /**< Content data */
82+
unsigned length:7; /**< Element length 0- 127 */
83+
uint8_t id; /**< Element ID */
84+
} mac_header_IE_t;
85+
86+
#define MAC_PAYLOAD_IE_ESDU_GROUP_ID 0x00
87+
#define MAC_PAYLOAD_MLME_IE_GROUP_ID 0x01
88+
#define MAC_PAYLOAD_VENDOR_IE_GROUP_ID 0x02
89+
#define MAC_PAYLOAD_MPX_IE_GROUP_ID 0x03
90+
#define MAC_PAYLOAD_TERMINATION_IE_GROUP_ID 0x0f
91+
92+
/**
93+
* @brief struct mac_header_IE_t Mac Payload information element structure for parsing or write operation
94+
* This structure encapsulates security related variables,
95+
*/
96+
typedef struct mac_payload_IE_s {
97+
const uint8_t *content_ptr; /**< Content data */
98+
unsigned length:11; /**< Element length 0- 2047 */
99+
unsigned id:4; /**< Group ID */
100+
} mac_payload_IE_t;
101+
69102
#endif /* MAC_COMMON_DEFINES_H_ */

nanostack/mac_mcps.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ typedef struct mcps_data_conf_s {
5858
uint8_t tx_retries; /**< Number of retries done during sending, 0 means no retries */
5959
} mcps_data_conf_t;
6060

61+
62+
typedef struct mcps_data_conf_payload_s {
63+
uint8_t *headerIeList; /**< Header information IE's list without terminator*/
64+
uint8_t *payloadIeList; /**< Payload information IE's list without terminator*/
65+
uint8_t *payloadPtr; /**< Ack payload pointer */
66+
uint16_t headerIeListLength; /**< Header information IE's list length in bytes */
67+
uint16_t payloadIeListLength; /**< Payload information IE's list length in bytes */
68+
uint16_t payloadLength; /**< Payload length in bytes */
69+
} mcps_data_conf_payload_t;
70+
6171
/**
6272
* @brief struct mcps_data_ind_t Data indication structure
6373
*
@@ -79,6 +89,45 @@ typedef struct mcps_data_ind_s {
7989
uint8_t *msdu_ptr; /**< Data unit */
8090
} mcps_data_ind_t;
8191

92+
/**
93+
* @brief struct mcps_data_ie_list_t MCPS data Information element list stucture
94+
*
95+
* Structure for IEEE 802.15.4-2015 MCPS data extension to Indication and confirmation
96+
*/
97+
typedef struct mcps_data_ie_list {
98+
uint8_t *headerIeList; /**< Header information IE's list without terminator*/
99+
uint8_t *payloadIeList; /**< Payload information IE's list without terminator*/
100+
uint16_t headerIeListLength; /**< Header information IE's list length in bytes */
101+
uint16_t payloadIeListLength; /**< Payload information IE's list length in bytes */
102+
} mcps_data_ie_list_t;
103+
104+
/** \brief Scatter-gather descriptor for MCPS request IE Element list
105+
*
106+
* Slightly optimised for small platforms - we assume we won't need any
107+
* element bigger than 64K.
108+
*/
109+
typedef struct ns_ie_iovec {
110+
void *ieBase; /**< IE element pointer */
111+
uint_fast16_t iovLen; /**< IE element length */
112+
} ns_ie_iovec_t;
113+
114+
115+
/**
116+
* @brief struct mcps_data_req_ie_list MCPS data Information element list stuctrure
117+
*
118+
* Structure for IEEE 802.15.4-2015 MCPS data extension to Request
119+
*
120+
* IE element could be divided to multiple vector which MAC just write to message direct.
121+
*/
122+
typedef struct mcps_data_req_ie_list {
123+
ns_ie_iovec_t *headerIeVectorList; /**< Header IE element list */
124+
ns_ie_iovec_t *payloadIeVectorList; /**< Payload IE element list */
125+
uint16_t headerIovLength; /**< Header IE element list size, set 0 when no elements */
126+
uint16_t payloadIovLength; /**< Payload IE element list size, set 0 when no elements */
127+
} mcps_data_req_ie_list_t;
128+
129+
130+
82131
/**
83132
* @brief struct mcps_purge_t Purge request structure
84133
*

source/MAC/IEEE802_15_4/mac_defines.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,26 @@ typedef struct protocol_interface_rf_mac_setup {
250250
} protocol_interface_rf_mac_setup_s;
251251

252252

253-
#define MAC_FCF_FRAME_TYPE_MASK 0x0007
254-
#define MAC_FCF_FRAME_TYPE_SHIFT 0
255-
#define MAC_FCF_SECURITY_BIT_MASK 0x0008
256-
#define MAC_FCF_SECURITY_BIT_SHIFT 3
257-
#define MAC_FCF_PENDING_BIT_MASK 0x0010
258-
#define MAC_FCF_PENDING_BIT_SHIFT 4
259-
#define MAC_FCF_ACK_REQ_BIT_MASK 0x0020
260-
#define MAC_FCF_ACK_REQ_BIT_SHIFT 5
261-
#define MAC_FCF_INTRA_PANID_MASK 0x0040
262-
#define MAC_FCF_INTRA_PANID_SHIFT 6
263-
#define MAC_FCF_DST_ADDR_MASK 0x0c00
264-
#define MAC_FCF_DST_ADDR_SHIFT 10
265-
#define MAC_FCF_VERSION_MASK 0x3000
266-
#define MAC_FCF_VERSION_SHIFT 12
267-
#define MAC_FCF_SRC_ADDR_MASK 0xc000
268-
#define MAC_FCF_SRC_ADDR_SHIFT 14
253+
#define MAC_FCF_FRAME_TYPE_MASK 0x0007
254+
#define MAC_FCF_FRAME_TYPE_SHIFT 0
255+
#define MAC_FCF_SECURITY_BIT_MASK 0x0008
256+
#define MAC_FCF_SECURITY_BIT_SHIFT 3
257+
#define MAC_FCF_PENDING_BIT_MASK 0x0010
258+
#define MAC_FCF_PENDING_BIT_SHIFT 4
259+
#define MAC_FCF_ACK_REQ_BIT_MASK 0x0020
260+
#define MAC_FCF_ACK_REQ_BIT_SHIFT 5
261+
#define MAC_FCF_INTRA_PANID_MASK 0x0040
262+
#define MAC_FCF_INTRA_PANID_SHIFT 6
263+
#define MAC_FCF_SEQ_NUM_SUPPRESS_MASK 0x0100
264+
#define MAC_FCF_SEQ_NUM_SUPPRESS_SHIFT 8
265+
#define MAC_FCF_IE_PRESENTS_MASK 0x0200
266+
#define MAC_FCF_IE_PRESENTS_SHIFT 9
267+
#define MAC_FCF_DST_ADDR_MASK 0x0c00
268+
#define MAC_FCF_DST_ADDR_SHIFT 10
269+
#define MAC_FCF_VERSION_MASK 0x3000
270+
#define MAC_FCF_VERSION_SHIFT 12
271+
#define MAC_FCF_SRC_ADDR_MASK 0xc000
272+
#define MAC_FCF_SRC_ADDR_SHIFT 14
269273

270274
/* MAC supported frame types */
271275
#define FC_BEACON_FRAME 0x00

source/MAC/IEEE802_15_4/mac_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "mac_filter.h"
2727
#include "mac_common_defines.h"
2828

29+
#include "mac_mcps.h"
2930
#include "MAC/IEEE802_15_4/mac_mcps_sap.h"
3031
#include "MAC/IEEE802_15_4/mac_header_helper_functions.h"
3132

0 commit comments

Comments
 (0)