Skip to content

Commit

Permalink
MPX and MAC API update
Browse files Browse the repository at this point in the history
Added possibility to set data priority for MAC abd MPX data request.
  • Loading branch information
Juha Heiskanen committed Apr 6, 2021
1 parent 7310cc0 commit d2f5347
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Added support for Anonymous address generation in DHCPv6 server for Wi-SUN Border router
* Improved Wi-SUN Async messaging statics. Time spent in different states and neighbor management changes.
* Created API to get the Wi-SUN Neighbor table with basic information from the neighbor.
* Added support for set MAC and MPX Data Request priority.

### Changes
* Added throttling of number of simultaneous EAPOL authentications based on Border Router TX queue size
Expand Down
3 changes: 2 additions & 1 deletion nanostack/mac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data
* @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.
* @param priority Data request priority level
*
* 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, const struct channel_list_s *asynch_channel_list);
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, mac_data_priority_t priority);

/**
* @brief mcps_purge_request MCPS_PURGE request call
Expand Down
12 changes: 12 additions & 0 deletions nanostack/mac_mcps.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,17 @@ typedef struct mcps_edfe_response_s {
bool use_message_handle_to_discover: 1; /**< EDFE Data request message ID is valid at message_handle. */
} mcps_edfe_response_t;

/**
* @brief enum mac_data_priority_t Data request priority level
*
* Data request priority level may affect CCA process and MAC queue process
*/
typedef enum mac_data_priority_e {
MAC_DATA_NORMAL_PRIORITY = 0, /**< Normal MCPS DATA REQ */
MAC_DATA_MEDIUM_PRIORITY = 1, /**< Indirect Data which is polled */
MAC_DATA_HIGH_PRIORITY = 2, /**< MAC command usually use this and beacon */
MAC_DATA_EXPEDITE_FORWARD = 3 /**< Expedite forward level give highest priority */
} mac_data_priority_t;


#endif // MAC_MCPS_H
5 changes: 3 additions & 2 deletions source/6LoWPAN/MAC/mpx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#ifndef MPX_API_H_
#define MPX_API_H_

#include "mac_mcps.h"
struct mcps_data_req_s;
struct mcps_data_conf_s;
struct mcps_data_ind_s;
Expand All @@ -30,9 +30,10 @@ typedef struct mpx_api_s mpx_api_t;
* @param api API to handle the request
* @param data MCPS-DATA.request specific values
* @param user_id MPX user ID
* @param priority priority level
*
*/
typedef void mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id);
typedef void mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id, mac_data_priority_t priority);

/**
* @brief mpx_data_queue_clean clean MPX user data
Expand Down
26 changes: 24 additions & 2 deletions source/6LoWPAN/adaptation_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,12 +1060,34 @@ static void lowpan_data_request_to_mac(protocol_interface_info_entry_t *cur, buf
buf->link_specific.ieee802_15_4.rf_channel_switch = false;
}
}
//Define data priority
mac_data_priority_t data_priority;

switch (buf->priority) {
case QOS_HIGH:
data_priority = MAC_DATA_MEDIUM_PRIORITY;
break;
case QOS_NETWORK_CTRL:
data_priority = MAC_DATA_HIGH_PRIORITY;
break;
case QOS_EXPEDITE_FORWARD:
data_priority = MAC_DATA_EXPEDITE_FORWARD;
break;
case QOS_MAC_BEACON:
data_priority = MAC_DATA_HIGH_PRIORITY;
break;
default:
data_priority = MAC_DATA_NORMAL_PRIORITY;
break;
}

if (interface_ptr->mpx_api) {
dataReq.ExtendedFrameExchange = buf->options.edfe_mode;
interface_ptr->mpx_api->mpx_data_request(interface_ptr->mpx_api, &dataReq, interface_ptr->mpx_user_id);
interface_ptr->mpx_api->mpx_data_request(interface_ptr->mpx_api, &dataReq, interface_ptr->mpx_user_id, data_priority);
} else {
cur->mac_api->mcps_data_req(cur->mac_api, &dataReq);
mcps_data_req_ie_list_t ie_list;
memset(&ie_list, 0, sizeof(mcps_data_req_ie_list_t));
cur->mac_api->mcps_data_req_ext(cur->mac_api, &dataReq, &ie_list, NULL, data_priority);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_eapol_pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int8_t ws_eapol_pdu_send_to_mpx(protocol_interface_info_entry_t *interface_ptr,

eapol_pdu_data->msdu_handle++;

eapol_pdu_data->mpx_api->mpx_data_request(eapol_pdu_data->mpx_api, &data_request, eapol_pdu_data->mpx_user_id);
eapol_pdu_data->mpx_api->mpx_data_request(eapol_pdu_data->mpx_api, &data_request, eapol_pdu_data->mpx_user_id, MAC_DATA_NORMAL_PRIORITY);
return 0;
}

Expand Down
22 changes: 13 additions & 9 deletions source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef struct {
uint8_t mpx_user_handle; /**< This MPX user defined handle */
ns_ie_iovec_t ie_vector_list[3]; /**< IE vectors: 1 for Header's, 1 for Payload and for MPX payload */
mcps_data_req_ie_list_t ie_ext;
mac_data_priority_t priority;
ns_list_link_t link; /**< List link entry */
uint8_t ie_buffer[]; /**< Trailing buffer data */
} llc_message_t;
Expand Down Expand Up @@ -162,7 +163,7 @@ static llc_data_base_t *ws_llc_base_allocate(void);
static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *data, const mcps_data_conf_payload_t *conf_data);
static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t *data, const mcps_data_ie_list_t *ie_ext);
static uint16_t ws_mpx_header_size_get(llc_data_base_t *base, uint16_t user_id);
static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id);
static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id, mac_data_priority_t priority);
static int8_t ws_llc_mpx_data_cb_register(const mpx_api_t *api, mpx_data_confirm *confirm_cb, mpx_data_indication *indication_cb, uint16_t user_id);
static uint16_t ws_llc_mpx_header_size_get(const mpx_api_t *api, uint16_t user_id);
static uint8_t ws_llc_mpx_data_purge_request(const mpx_api_t *api, struct mcps_purge_s *purge, uint16_t user_id);
Expand Down Expand Up @@ -290,6 +291,7 @@ static llc_message_t *llc_message_allocate(uint16_t ie_buffer_size, llc_data_bas
}
message->ack_requested = false;
message->eapol_temporary = false;
message->priority = MAC_DATA_NORMAL_PRIORITY;
return message;
}

Expand Down Expand Up @@ -975,7 +977,7 @@ static void ws_llc_lowpan_mpx_header_set(llc_message_t *message, uint16_t user_i
message->ie_vector_list[1].iovLen = ptr - (uint8_t *)message->ie_vector_list[1].ieBase;
}

static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *user_cb, const struct mcps_data_req_s *data)
static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *user_cb, const struct mcps_data_req_s *data, mac_data_priority_t priority)
{
wh_ie_sub_list_t ie_header_mask;
memset(&ie_header_mask, 0, sizeof(wh_ie_sub_list_t));
Expand Down Expand Up @@ -1026,6 +1028,7 @@ static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *us
//Add To active list
llc_message_id_allocate(message, base, true);
base->llc_message_list_size++;
message->priority = priority;
random_early_detetction_aq_calc(base->interface_ptr->llc_random_early_detection, base->llc_message_list_size);
ns_list_add_to_end(&base->llc_message_list, message);

Expand Down Expand Up @@ -1104,7 +1107,7 @@ static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *us
message->ie_ext.payloadIovLength = 0; //Set Back 2 at response handler
}

base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, NULL);
base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, NULL, message->priority);
}

static bool ws_llc_eapol_temp_entry_set(llc_data_base_t *base, const uint8_t *mac64)
Expand Down Expand Up @@ -1159,11 +1162,11 @@ static void ws_llc_mpx_eapol_send(llc_data_base_t *base, llc_message_t *message)
message->eapol_temporary = ws_llc_eapol_temp_entry_set(base, message->dst_address);
ws_llc_eapol_data_req_init(&data_req, message);
base->temp_entries->active_eapol_session = true;
base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, NULL);
base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, NULL, message->priority);
}


static void ws_llc_mpx_eapol_request(llc_data_base_t *base, mpx_user_t *user_cb, const struct mcps_data_req_s *data)
static void ws_llc_mpx_eapol_request(llc_data_base_t *base, mpx_user_t *user_cb, const struct mcps_data_req_s *data, mac_data_priority_t priority)
{
wh_ie_sub_list_t ie_header_mask;
memset(&ie_header_mask, 0, sizeof(wh_ie_sub_list_t));
Expand Down Expand Up @@ -1198,6 +1201,7 @@ static void ws_llc_mpx_eapol_request(llc_data_base_t *base, mpx_user_t *user_cb,
user_cb->data_confirm(&base->mpx_data_base.mpx_api, &data_conf);
return;
}
message->priority = priority;
message->mpx_user_handle = data->msduHandle;
message->ack_requested = data->TxAckReq;

Expand Down Expand Up @@ -1257,7 +1261,7 @@ static void ws_llc_mpx_eapol_request(llc_data_base_t *base, mpx_user_t *user_cb,
}


static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id)
static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id, mac_data_priority_t priority)
{
llc_data_base_t *base = ws_llc_discover_by_mpx(api);
if (!base) {
Expand All @@ -1280,9 +1284,9 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
}

if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
ws_llc_mpx_eapol_request(base, user_cb, data);
ws_llc_mpx_eapol_request(base, user_cb, data, priority);
} else if (user_id == MPX_LOWPAN_ENC_USER_ID) {
ws_llc_lowpan_mpx_data_request(base, user_cb, data);
ws_llc_lowpan_mpx_data_request(base, user_cb, data, priority);
}
}

Expand Down Expand Up @@ -1800,7 +1804,7 @@ int8_t ws_llc_asynch_request(struct protocol_interface_info_entry *interface, as
}
}

base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, &request->channel_list);
base->interface_ptr->mac_api->mcps_data_req_ext(base->interface_ptr->mac_api, &data_req, &message->ie_ext, &request->channel_list, message->priority);

return 0;
}
Expand Down
21 changes: 19 additions & 2 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ 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, NULL);
mcps_sap_data_req_handler_ext(rf_mac_setup, data_req, &ie_list, NULL, MAC_DATA_NORMAL_PRIORITY);
}

static bool mac_ie_vector_length_validate(ns_ie_iovec_t *ie_vector, uint16_t iov_length, uint16_t *length_out)
Expand Down Expand Up @@ -193,7 +193,7 @@ static bool mac_ie_vector_length_validate(ns_ie_iovec_t *ie_vector, uint16_t iov
}


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)
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, mac_data_priority_t priority)
{
uint8_t status = MLME_SUCCESS;
mac_pre_build_frame_t *buffer = NULL;
Expand Down Expand Up @@ -265,6 +265,23 @@ void mcps_sap_data_req_handler_ext(protocol_interface_rf_mac_setup_s *rf_mac_set
buffer->asynch_request = true;
}

//Set Priority level
switch (priority) {
case MAC_DATA_EXPEDITE_FORWARD:
buffer->priority = MAC_PD_DATA_EF_PRIORITY;
break;
case MAC_DATA_HIGH_PRIORITY:
buffer->priority = MAC_PD_DATA_HIGH_PRIOTITY;
break;
case MAC_DATA_MEDIUM_PRIORITY:
buffer->priority = MAC_PD_DATA_MEDIUM_PRIORITY;
break;
default:
buffer->priority = MAC_PD_DATA_NORMAL_PRIORITY;
break;
}


buffer->upper_layer_request = true;
buffer->fcf_dsn.frametype = FC_DATA_FRAME;
buffer->ExtendedFrameExchange = data_req->ExtendedFrameExchange;
Expand Down
2 changes: 1 addition & 1 deletion source/MAC/IEEE802_15_4/mac_mcps_sap.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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, const channel_list_s *asynch_channel_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, mac_data_priority_t priority);

void mac_mcps_trig_buffer_from_queue(struct protocol_interface_rf_mac_setup *rf_mac_setup);

Expand Down
10 changes: 5 additions & 5 deletions source/MAC/IEEE802_15_4/sw_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int8_t ns_sw_mac_api_enable_edfe_ext(mac_api_t *api, mcps_edfe_handler *e

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 mcps_data_req_ie_list_t *ie_ext, const channel_list_s *asynch_channel_list);
static 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, mac_data_priority_t priority);
static uint8_t 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 @@ -575,22 +575,22 @@ void mlme_req(const mac_api_t *api, mlme_primitive id, const void *data)
}
}

void mcps_req(const mac_api_t *api, const mcps_data_req_t *data)
static void mcps_req(const mac_api_t *api, const mcps_data_req_t *data)
{
//TODO: Populate linked list when present
if (mac_store.mac_api == api) {
/* 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, NULL);
mcps_sap_data_req_handler_ext(mac_store.setup, data, &ie_list, NULL, MAC_DATA_NORMAL_PRIORITY);
}
}

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)
static 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, mac_data_priority_t priority)
{
//TODO: Populate linked list when present
if (mac_store.mac_api == api) {
mcps_sap_data_req_handler_ext(mac_store.setup, data, ie_ext, asynch_channel_list);
mcps_sap_data_req_handler_ext(mac_store.setup, data, ie_ext, asynch_channel_list, priority);
}
}

Expand Down
Loading

0 comments on commit d2f5347

Please sign in to comment.