Skip to content

Commit b741f98

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
MCPS Data request API update.
Added Asynch data request extension support for future use. Feature is not supported yet but API is ready. Added flag for check is 2015 MCPS data extension enabled.
1 parent c329f61 commit b741f98

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

nanostack/mac_api.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
extern "C" {
3333
#endif
3434

35+
struct channel_list_s;
36+
3537
typedef struct mac_api_s mac_api_t;
3638

3739
/**
@@ -125,8 +127,11 @@ typedef void mcps_data_request(const mac_api_t* api, const mcps_data_req_t *data
125127
* @param api API to handle the request
126128
* @param data MCPS-DATA.request specific values
127129
* @param ie_ext Information element list to MCPS-DATA.request
130+
* @param asynch_channel_list Optional channel list to asynch data request. Give NULL when normal data request.
131+
*
132+
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
128133
*/
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);
134+
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, const struct channel_list_s *asynch_channel_list);
130135

131136
/**
132137
* @brief mcps_purge_request MCPS_PURGE request call

source/MAC/IEEE802_15_4/mac_defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ typedef struct protocol_interface_rf_mac_setup {
139139
bool macUpState;
140140
bool shortAdressValid: 1; //Define Dynamic src address to mac16 when it is true
141141
bool beaconSrcAddressModeLong: 1; //This force beacon src to mac64 otherwise shortAdressValid will define type
142+
bool mac_extension_enabled:1;
142143
uint16_t mac_short_address;
143144
uint16_t pan_id;
144145
uint8_t mac64[8];

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,17 @@ void mcps_sap_data_req_handler(protocol_interface_rf_mac_setup_s *rf_mac_setup ,
9595
{
9696
mcps_data_req_ie_list_t ie_list;
9797
memset(&ie_list, 0 , sizeof(mcps_data_req_ie_list_t));
98-
mcps_sap_data_req_handler_ext(rf_mac_setup, data_req, &ie_list);
98+
mcps_sap_data_req_handler_ext(rf_mac_setup, data_req, &ie_list, NULL);
9999
}
100100

101101

102-
void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_setup , const mcps_data_req_t *data_req , const mcps_data_req_ie_list_t *ie_list) {
102+
void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_setup , const mcps_data_req_t *data_req , const mcps_data_req_ie_list_t *ie_list, const channel_list_s *asynch_channel_list) {
103103
uint8_t status = MLME_SUCCESS;
104104
mac_pre_build_frame_t *buffer = NULL;
105105

106+
//Asynch Data request will be enabled seperately lare API is defined
107+
108+
106109
if (!rf_mac_setup->mac_security_enabled) {
107110
if (data_req->Key.SecurityLevel) {
108111
status = MLME_UNSUPPORTED_SECURITY;
@@ -123,6 +126,12 @@ void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_set
123126
goto verify_status;
124127
}
125128

129+
if ((ie_header_length || ie_payload_length || asynch_channel_list) && !rf_mac_setup->mac_extension_enabled ) {
130+
//Report error when feature is not enaled yet
131+
status = MLME_INVALID_PARAMETER;
132+
goto verify_status;
133+
}
134+
126135
if ((data_req->msduLength + ie_header_length + ie_payload_length) > rf_mac_setup->dev_driver->phy_driver->phy_MTU - MAC_DATA_PACKET_MIN_HEADER_LENGTH) {
127136
tr_debug("packet %u, %u",data_req->msduLength, rf_mac_setup->dev_driver->phy_driver->phy_MTU);
128137
status = MLME_FRAME_TOO_LONG;
@@ -142,6 +151,13 @@ void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_set
142151
tr_debug("Drop MAC tx packet when mac disabled");
143152
goto verify_status;
144153
}
154+
155+
if (asynch_channel_list ) {
156+
//Copy Asynch data list
157+
buffer->asynch_channel_list = *asynch_channel_list;
158+
buffer->asynch_request = true;
159+
}
160+
145161
buffer->upper_layer_request = true;
146162
buffer->fcf_dsn.frametype = FC_DATA_FRAME;
147163
buffer->fcf_dsn.ackRequested = data_req->TxAckReq;

source/MAC/IEEE802_15_4/mac_mcps_sap.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct arm_phy_sap_msg_s;
3434
struct mcps_purge_s;
3535
struct mcps_data_ie_list;
3636
struct mcps_data_req_ie_list;
37+
struct channel_list_s;
3738

3839
/** Address types */
3940
typedef enum {
@@ -120,10 +121,12 @@ typedef struct mac_pre_build_frame{
120121
uint8_t msduHandle;
121122
uint16_t buffer_ttl;
122123
struct mcps_data_req_ie_list ie_elements;
124+
struct channel_list_s asynch_channel_list;
123125
uint8_t *mac_payload;
124126
uint8_t status;
125127
bool upper_layer_request;
126128
bool mac_allocated_payload_ptr:1;
129+
bool asynch_request:1;
127130
unsigned security_mic_len:5; //Max possible lengths 0, 4, 8, 16 bytes
128131
unsigned priority:2;
129132
struct mac_pre_build_frame *next; //Pointer for queue purpose
@@ -179,7 +182,7 @@ int8_t mac_virtual_sap_data_cb(void *identifier, struct arm_phy_sap_msg_s *messa
179182

180183
void mcps_sap_data_req_handler(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req );
181184

182-
void mcps_sap_data_req_handler_ext(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req , const struct mcps_data_req_ie_list *ie_list);
185+
void mcps_sap_data_req_handler_ext(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req , const struct mcps_data_req_ie_list *ie_list, const channel_list_s *asynch_channel_list);
183186

184187
void mac_mcps_trig_buffer_from_queue(struct protocol_interface_rf_mac_setup *rf_mac_setup);
185188

source/MAC/IEEE802_15_4/sw_mac.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int8_t ns_sw_mac_api_enable_mcps_ext(mac_api_t *api, mcps_data_indication
5353

5454
static void mlme_req(const mac_api_t* api, mlme_primitive id, const void *data);
5555
static void mcps_req(const mac_api_t* api, const mcps_data_req_t *data);
56-
static void mcps_req_ext(const mac_api_t* api, const mcps_data_req_t *data, const const mcps_data_req_ie_list_t *ie_ext);
56+
static void mcps_req_ext(const mac_api_t* api, const mcps_data_req_t *data, const const mcps_data_req_ie_list_t *ie_ext, const channel_list_s *asynch_channel_list);
5757
static void purge_req(const mac_api_t* api, const mcps_purge_t *data);
5858
static int8_t macext_mac64_address_set( const mac_api_t* api, const uint8_t *mac64);
5959
static int8_t macext_mac64_address_get( const mac_api_t* api, mac_extended_address_type type, uint8_t *mac64_buf);
@@ -227,6 +227,7 @@ static int8_t ns_sw_mac_api_enable_mcps_ext(mac_api_t *api, mcps_data_indication
227227

228228
cur->data_conf_ext_cb = data_cnf_cb;
229229
cur->data_ind_ext_cb = data_ind_cb;
230+
mac_store.setup->mac_extension_enabled = true;
230231
return 0;
231232
}
232233

@@ -468,15 +469,15 @@ void mcps_req(const mac_api_t* api, const mcps_data_req_t *data)
468469
/* Call direct new API but without IE extensions */
469470
mcps_data_req_ie_list_t ie_list;
470471
memset(&ie_list, 0 , sizeof(mcps_data_req_ie_list_t));
471-
mcps_sap_data_req_handler_ext(mac_store.setup , data , &ie_list);
472+
mcps_sap_data_req_handler_ext(mac_store.setup , data , &ie_list, NULL);
472473
}
473474
}
474475

475-
void mcps_req_ext(const mac_api_t* api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext)
476+
void mcps_req_ext(const mac_api_t* api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const channel_list_s *asynch_channel_list)
476477
{
477478
//TODO: Populate linked list when present
478479
if (mac_store.mac_api == api) {
479-
mcps_sap_data_req_handler_ext(mac_store.setup , data , ie_ext);
480+
mcps_sap_data_req_handler_ext(mac_store.setup , data , ie_ext, asynch_channel_list);
480481
}
481482
}
482483

test/nanostack/unittest/stub/mac_mcps_sap_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mac_mcps_sap_stub_def mac_mcps_sap_stub;
5555
void mcps_sap_data_req_handler(protocol_interface_rf_mac_setup_s *rf_mac_setup , const mcps_data_req_t *data_req )
5656
{
5757
}
58-
void mcps_sap_data_req_handler_ext(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req , const struct mcps_data_req_ie_list *ie_list)
58+
void mcps_sap_data_req_handler_ext(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req , const struct mcps_data_req_ie_list *ie_list, const channel_list_s *asynch_channel_list)
5959
{
6060

6161
}

0 commit comments

Comments
 (0)