Skip to content

Commit

Permalink
MCPS Data request API update.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Juha Heiskanen authored and juhhei01 committed Jan 17, 2018
1 parent c329f61 commit b741f98
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
7 changes: 6 additions & 1 deletion nanostack/mac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
extern "C" {
#endif

struct channel_list_s;

typedef struct mac_api_s mac_api_t;

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

/**
* @brief mcps_purge_request MCPS_PURGE request call
Expand Down
1 change: 1 addition & 0 deletions source/MAC/IEEE802_15_4/mac_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ typedef struct protocol_interface_rf_mac_setup {
bool macUpState;
bool shortAdressValid: 1; //Define Dynamic src address to mac16 when it is true
bool beaconSrcAddressModeLong: 1; //This force beacon src to mac64 otherwise shortAdressValid will define type
bool mac_extension_enabled:1;
uint16_t mac_short_address;
uint16_t pan_id;
uint8_t mac64[8];
Expand Down
20 changes: 18 additions & 2 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ void mcps_sap_data_req_handler(protocol_interface_rf_mac_setup_s *rf_mac_setup ,
{
mcps_data_req_ie_list_t ie_list;
memset(&ie_list, 0 , sizeof(mcps_data_req_ie_list_t));
mcps_sap_data_req_handler_ext(rf_mac_setup, data_req, &ie_list);
mcps_sap_data_req_handler_ext(rf_mac_setup, data_req, &ie_list, NULL);
}


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) {
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) {
uint8_t status = MLME_SUCCESS;
mac_pre_build_frame_t *buffer = NULL;

//Asynch Data request will be enabled seperately lare API is defined


if (!rf_mac_setup->mac_security_enabled) {
if (data_req->Key.SecurityLevel) {
status = MLME_UNSUPPORTED_SECURITY;
Expand All @@ -123,6 +126,12 @@ void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_set
goto verify_status;
}

if ((ie_header_length || ie_payload_length || asynch_channel_list) && !rf_mac_setup->mac_extension_enabled ) {
//Report error when feature is not enaled yet
status = MLME_INVALID_PARAMETER;
goto verify_status;
}

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) {
tr_debug("packet %u, %u",data_req->msduLength, rf_mac_setup->dev_driver->phy_driver->phy_MTU);
status = MLME_FRAME_TOO_LONG;
Expand All @@ -142,6 +151,13 @@ void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_set
tr_debug("Drop MAC tx packet when mac disabled");
goto verify_status;
}

if (asynch_channel_list ) {
//Copy Asynch data list
buffer->asynch_channel_list = *asynch_channel_list;
buffer->asynch_request = true;
}

buffer->upper_layer_request = true;
buffer->fcf_dsn.frametype = FC_DATA_FRAME;
buffer->fcf_dsn.ackRequested = data_req->TxAckReq;
Expand Down
5 changes: 4 additions & 1 deletion source/MAC/IEEE802_15_4/mac_mcps_sap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct arm_phy_sap_msg_s;
struct mcps_purge_s;
struct mcps_data_ie_list;
struct mcps_data_req_ie_list;
struct channel_list_s;

/** Address types */
typedef enum {
Expand Down Expand Up @@ -120,10 +121,12 @@ typedef struct mac_pre_build_frame{
uint8_t msduHandle;
uint16_t buffer_ttl;
struct mcps_data_req_ie_list ie_elements;
struct channel_list_s asynch_channel_list;
uint8_t *mac_payload;
uint8_t status;
bool upper_layer_request;
bool mac_allocated_payload_ptr:1;
bool asynch_request:1;
unsigned security_mic_len:5; //Max possible lengths 0, 4, 8, 16 bytes
unsigned priority:2;
struct mac_pre_build_frame *next; //Pointer for queue purpose
Expand Down Expand Up @@ -179,7 +182,7 @@ int8_t mac_virtual_sap_data_cb(void *identifier, struct arm_phy_sap_msg_s *messa

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

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);
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);

void mac_mcps_trig_buffer_from_queue(struct protocol_interface_rf_mac_setup *rf_mac_setup);

Expand Down
9 changes: 5 additions & 4 deletions source/MAC/IEEE802_15_4/sw_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int8_t ns_sw_mac_api_enable_mcps_ext(mac_api_t *api, mcps_data_indication

static void mlme_req(const mac_api_t* api, mlme_primitive id, const void *data);
static void mcps_req(const mac_api_t* api, const mcps_data_req_t *data);
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);
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);
static void purge_req(const mac_api_t* api, const mcps_purge_t *data);
static int8_t macext_mac64_address_set( const mac_api_t* api, const uint8_t *mac64);
static int8_t macext_mac64_address_get( const mac_api_t* api, mac_extended_address_type type, uint8_t *mac64_buf);
Expand Down Expand Up @@ -227,6 +227,7 @@ static int8_t ns_sw_mac_api_enable_mcps_ext(mac_api_t *api, mcps_data_indication

cur->data_conf_ext_cb = data_cnf_cb;
cur->data_ind_ext_cb = data_ind_cb;
mac_store.setup->mac_extension_enabled = true;
return 0;
}

Expand Down Expand Up @@ -468,15 +469,15 @@ void mcps_req(const mac_api_t* api, const mcps_data_req_t *data)
/* Call direct new API but without IE extensions */
mcps_data_req_ie_list_t ie_list;
memset(&ie_list, 0 , sizeof(mcps_data_req_ie_list_t));
mcps_sap_data_req_handler_ext(mac_store.setup , data , &ie_list);
mcps_sap_data_req_handler_ext(mac_store.setup , data , &ie_list, NULL);
}
}

void mcps_req_ext(const mac_api_t* api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext)
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)
{
//TODO: Populate linked list when present
if (mac_store.mac_api == api) {
mcps_sap_data_req_handler_ext(mac_store.setup , data , ie_ext);
mcps_sap_data_req_handler_ext(mac_store.setup , data , ie_ext, asynch_channel_list);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/mac_mcps_sap_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mac_mcps_sap_stub_def mac_mcps_sap_stub;
void mcps_sap_data_req_handler(protocol_interface_rf_mac_setup_s *rf_mac_setup , const mcps_data_req_t *data_req )
{
}
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)
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)
{

}
Expand Down

0 comments on commit b741f98

Please sign in to comment.