wiki:802.11/wlan_exp/app_notes/tutorial_token_mac/CPU_LOW

Version 2 (modified by chunter, 9 years ago) (diff)

--

Alterations to CPU_LOW

In this section, we will describe and sicuss the changes needed to the low-level MAC code to realize the design. Here, we will not start off with the DCF code since the vast majority of that DCF behavior is irrelevant to TokenMAC. Instead, we will use the very simple NoMAC project as a starting point. Unaltered, this project acts as a straight passthrough connection between the high-level MAC and the PHY.

Furthermore, we will make some changes to the MAC Low Framework to handle new inter-processor communication (IPC) messages with CPU_HIGH.

Specific Changes

MAC Low Framework

Changes should be made to wlan_mac_low.c.


In the CPU_HIGH alterations section, we created the TOKEN_NEW_RESERVATION and TOKEN_END_RESERVATION IPC messages. Now we need to alter the MAC Low Framework to deal with these messages and pass their contents to whatever CPU_LOW project uses the framework. First, we need to create some new global variables at the top of wlan_mac_low.c:

static function_ptr_t        new_reservation_callback;
static function_ptr_t        adjust_reservation_ts_callback;

volatile static u8           allow_new_mpdu_tx;
volatile static s8           pkt_buf_pending_tx;

We should give these values sane defaults in the wlan_mac_low_init() function:

    new_reservation_callback = (function_ptr_t)nullCallback;
    adjust_reservation_ts_callback = (function_ptr_t)nullCallback;
    allow_new_mpdu_tx        = 0;
    pkt_buf_pending_tx       = -1;

Finally, we should create some setters to allow the CPU_LOW application (e.g. NoMAC) to attach its function to these callbacks. Add the following functions to the MAC Low Framework:

inline void wlan_mac_low_set_new_reservation_callback(function_ptr_t callback){
    new_reservation_callback = callback;
}

inline void wlan_mac_low_set_adjust_reservation_ts_callback(function_ptr_t callback){
    adjust_reservation_ts_callback = callback;
}

The above updates are primarily bookkeeping. We'll explain the purpose of these additions in the coming sections.


When CPU_HIGH (or, more accurately, the AP project) passes CPU_LOW a TOKEN_NEW_RESERVATION message, we should pass the details of that message to the CPU_LOW application via the new_reservation_callback() we just created. The process_ipc_msg_from_high() function contains a large switch statement that covers each type of IPC message as an individual case. We should add a case for the TOKEN_NEW_RESERVATION message. First, we should declare a new local variable at the top of the function:

ipc_token_new_reservation* new_reservation;

Next, we'll assign that pointer to the IPC payload. This will let us access the payload of the IPC message with easy-to-read named structure elements rather than accessing arbitrary low-level bytes.

case IPC_MBOX_TOKEN_NEW_RESERVATION:
	new_reservation = (ipc_token_new_reservation*)msg->payload_ptr;
	new_reservation_callback(new_reservation);
break;