Changes between Version 4 and Version 5 of 802.11/wlan_exp/app_notes/tutorial_token_mac/CPU_HIGH


Ignore:
Timestamp:
Jul 8, 2015, 2:17:53 PM (9 years ago)
Author:
chunter
Comment:

--

Legend:

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

    v4 v5  
    1414
    1515== Specific Changes ==
     16
     17
     18=== Code Common to CPU_HIGH and CPU_LOW ===
     19Changes should be made to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_common/include/wlan_mac_ipc_util.h wlan_mac_ipc_util.h].
     20
     21----
     22
     23We need to define two new types of IPC messages between CPU_LOW and CPU_HIGH. The first, which we will call {{{TOKEN_NEW_RESERVATION}}}, will primarily be used by an AP when it decrees that a token reservation period now belongs to one of the devices on its network. The second, which we will call {{{TOKEN_END_RESERVATION}}}, will primarily be used by an AP's CPU_LOW project to indicate to the AP that the current reservation period has ended and it should move on to the next device in its association table. Add the following snippet of code to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_common/include/wlan_mac_ipc_util.h wlan_mac_ipc_util.h]:
     24
     25{{{
     26#!c
     27
     28#define IPC_MBOX_TOKEN_NEW_RESERVATION  20
     29#define IPC_MBOX_TOKEN_END_RESERVATION  21
     30
     31typedef struct{
     32        u32 res_duration;
     33        u8      addr[6];
     34        u16 reserved;
     35} ipc_token_new_reservation;
     36
     37typedef enum {TOKEN_DURATION_COMPLETE, TOKEN_TIMEOUT, TOKEN_OFFER_REJECTION} token_end_reservation_reason_t;
     38
     39typedef struct{
     40        token_end_reservation_reason_t reason;
     41        wlan_mac_low_tx_details low_tx_details;
     42} ipc_token_end_reservation;
     43}}}
     44
     45The values of 20 and 21 are arbitrary. The key part is that you choose numbers that do not overlap with any of the other definitions that are prepended by {{{IPC_MBOX_}}}. It is these definitions that the processors use to determine what type of IPC message is currently being received. Next, {{{ipc_token_new_reservation}}} and {{{ipc_token_end_reservation}}} are structs that we will use to more easily fill in and process IPC payloads.
     46
     47----
    1648
    1749=== Access Point (AP) ===
     
    117149----
    118150
    119 === Code Common to CPU_HIGH and CPU_LOW ===
    120 Changes should be made to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_common/include/wlan_mac_ipc_util.h wlan_mac_ipc_util.h].
    121 
    122 ----
    123 
    124 We need to define two new types of IPC messages between CPU_LOW and CPU_HIGH. The first, which we will call {{{TOKEN_NEW_RESERVATION}}}, will primarily be used by an AP when it decrees that a token reservation period now belongs to one of the devices on its network. The second, which we will call {{{TOKEN_END_RESERVATION}}}, will primarily be used by an AP's CPU_LOW project to indicate to the AP that the current reservation period has ended and it should move on to the next device in its association table. Add the following snippet of code to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_common/include/wlan_mac_ipc_util.h wlan_mac_ipc_util.h]:
    125 
    126 {{{
    127 #!c
    128 
    129 #define IPC_MBOX_TOKEN_NEW_RESERVATION  20
    130 #define IPC_MBOX_TOKEN_END_RESERVATION  21
    131 
    132 typedef struct{
    133         u32 res_duration;
    134         u8      addr[6];
    135         u16 reserved;
    136 } ipc_token_new_reservation;
    137 
    138 typedef enum {TOKEN_DURATION_COMPLETE, TOKEN_TIMEOUT, TOKEN_OFFER_REJECTION} token_end_reservation_reason_t;
    139 
    140 typedef struct{
    141         token_end_reservation_reason_t reason;
    142         wlan_mac_low_tx_details low_tx_details;
    143 } ipc_token_end_reservation;
    144 }}}
    145 
    146 The values of 20 and 21 are arbitrary. The key part is that you choose numbers that do not overlap with any of the other definitions that are prepended by {{{IPC_MBOX_}}}. It is these definitions that the processors use to determine what type of IPC message is currently being received. Next, {{{ipc_token_new_reservation}}} and {{{ipc_token_end_reservation}}} are structs that we will use to more easily fill in and process IPC payloads.
    147 
    148 ----
    149 
    150151=== MAC High Framework ===
    151152Changes should be made to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/wlan_mac_high.c wlan_mac_high.c].
     
    153154----
    154155
    155 The first thing we need to do
     156The first thing we need to do implement the callback structure that we assumed in our AP modifications. First, we should add a new top-level global to [browser:ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/wlan_mac_high.c wlan_mac_high.c] at the top of the file:
     157
     158{{{
     159#!c
     160
     161volatile function_ptr_t      token_new_reservation_callback;
     162}}}
     163
     164This variable will serve to hold the pointer to a function that should be called when the framework wants the AP to issue a new token reservation. For safety, we should explicitly set this function pointer to the nullCallback at boot so calling this function pointer does not crash the CPU. To do this, add the following line to {{{wlan_mac_high_init()}}}:
     165
     166{{{
     167#!c
     168
     169token_new_reservation_callback = (function_ptr_t)nullCallback;
     170}}}
     171
     172Finally, we should create a function that allows the AP code (or whatever other high-level project) assign the new callback. Add this function to the MAC High Framework:
     173
     174{{{
     175#!c
     176
     177void wlan_mac_high_set_token_new_reservation_callback(function_ptr_t callback){
     178        token_new_reservation_callback = callback;
     179}
     180}}}
     181
     182We have now implemented the {{{wlan_mac_high_set_token_new_reservation_callback()}}} function that we called in our AP modifications.
     183
     184----
     185
     186Finally, we need to actually call the {{{token_new_reservation_callback()}}} function pointer. We need to establish a contract with CPU_LOW. Specifically, we will assume that every time the AP sends down a {{{TOKEN_NEW_RESERVATION}}} IPC message to CPU_LOW, there will be a response of a {{{TOKEN_END_RESERVATION}}} IPC message at some point after that event. In other words, CPU_HIGH will not be responsible for determining when any given reservation period is over. We will assume (and will subsequently have to build) CPU_LOW will tell CPU_HIGH when a new token reservation period should be issued. As such, we just need to call {{{token_new_reservation_callback()}}} whenever we get a {{{TOKEN_END_RESERVATION}}} IPC message from CPU_LOW. This is an easy modification to make. In {{{wlan_mac_high_process_ipc_msg()}}}, there is a big switch statement that handled every type of IPC message ID. All we need to do as add a new case to this switch:
     187
     188{{{
     189#!c
     190
     191                case IPC_MBOX_TOKEN_END_RESERVATION:
     192                        token_new_reservation_callback();
     193                break;
     194}}}
     195
     196----
     197
     198
     199