Changes between Version 1 and Version 2 of 802.11/wlan_exp/app_notes/tutorial_token_mac/CPU_LOW


Ignore:
Timestamp:
Jul 9, 2015, 10:58:26 AM (9 years ago)
Author:
chunter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 802.11/wlan_exp/app_notes/tutorial_token_mac/CPU_LOW

    v1 v2  
    55= Alterations to CPU_LOW =
    66
     7In 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 [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_low_nomac NoMAC] project as a starting point. Unaltered, this project acts as a straight passthrough connection between the high-level MAC and the PHY.
    78
    8 
    9 == Overview of Changes ==
    10 
     9Furthermore, we will make some changes to the MAC Low Framework to handle new inter-processor communication (IPC) messages with CPU_HIGH.
    1110
    1211== Specific Changes ==
     
    1514=== MAC Low Framework ===
    1615
     16Changes should be made to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_low_framework/wlan_mac_low.c wlan_mac_low.c].
     17
    1718----
     19
     20In [wiki:802.11/wlan_exp/app_notes/tutorial_token_mac/CPU_HIGH#CodeCommontoCPU_HIGHandCPU_LOW 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 [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_low_framework/wlan_mac_low.c wlan_mac_low.c]:
    1821
    1922{{{
    2023#!c
    2124
    22 #define
     25static function_ptr_t            new_reservation_callback;
     26static function_ptr_t            adjust_reservation_ts_callback;
     27
     28volatile static u8                       allow_new_mpdu_tx;
     29volatile static s8                       pkt_buf_pending_tx;
     30}}}
     31
     32We should give these values sane defaults in the {{{wlan_mac_low_init()}}} function:
     33
     34{{{
     35#!c
     36
     37        new_reservation_callback = (function_ptr_t)nullCallback;
     38        adjust_reservation_ts_callback = (function_ptr_t)nullCallback;
     39        allow_new_mpdu_tx        = 0;
     40        pkt_buf_pending_tx       = -1;
     41}}}
     42
     43Finally, 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:
     44
     45{{{
     46#!c
     47
     48inline void wlan_mac_low_set_new_reservation_callback(function_ptr_t callback){
     49        new_reservation_callback = callback;
     50}
     51
     52inline void wlan_mac_low_set_adjust_reservation_ts_callback(function_ptr_t callback){
     53        adjust_reservation_ts_callback = callback;
     54}
     55}}}
     56
     57The above updates are primarily bookkeeping. We'll explain the purpose of these additions in the coming sections.
     58
     59----
     60
     61When 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:
     62{{{
     63ipc_token_new_reservation* new_reservation;
     64}}}
     65
     66Next, 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.
     67
     68{{{
     69case IPC_MBOX_TOKEN_NEW_RESERVATION:
     70        new_reservation = (ipc_token_new_reservation*)msg->payload_ptr;
     71        new_reservation_callback(new_reservation);
     72break;
    2373}}}
    2474
    2575----
    2676
     77
     78
     79