wiki:802.11/MAC/Upper/MACHighFramework/TX_queue

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

--

Wireless Transmit Queue

The low-level MAC running in CPU Low handles one packet at a time. The high-level MAC in CPU High manages many packets at once via a series of queues. In the reference implementation one queue is created per associated node plus one queue for all broadcast traffic. Whenever the low-level MAC finishes transmission of a packet the next available packet is dequeued from the appropriate queue and passed to CPU Low for transmission.

The packet queues use the DDR3 SO-DIMM on WARP v3 for storage. If the SO-DIMM is not installed a much smaller queue will be implemented using on-chip BRAM.

The queueing system is implemented in the MAC High Framework. At boot the framework creates a fixed number of free queue elements. When new packets requiring wireless transmission are received or generated a free queue element is checked out from the framework, populated with the new packet, then added to the tail of the queue associated with the node to which the packet is addressed. Multicast and management packets are added to their own dedicated queues.

When the low-level MAC is ready for a new packet the high-level queue framework removes the head element from the next queue and passes it to the low-level MAC for transmission. By default the next queue is selected via round robin. More sophisticated queue management schemes (i.e. to support QoS) can be implemented in place of round robin.

When the low-level MAC completes transmission of a packet the high-level framework clears the associated queue entry and returns it to the pool of available queue entries for future re-use.

Queue API

User code interacts with the transmit queue via the following functions:

  • void queue_checkout(dl_list* new_list, u16 num_packet_bd) - attempts to check out an arbitrary number of packet descriptors from the free pool and delivers them to the calling function by tying those packet descriptors together in a doubly-linked list
    • new_list: a pointer to a doubly-linked list that will be populated by the queue framework.
    • num_packet_bd: number of packet buffer descriptors that should be checked out. The new_list pointed to by the first argument will be populated with num_packet_bd list entries
  • void queue_checkin(dl_list* list) - checks a doubly-linked list of packet descriptors back in to the free pool
    • list: the doubly-linked list of packet buffer descriptors that will be returned to the free pool
  • wlan_mac_queue_poll(u16 queue_sel) - checks a queue identified by the argument and sends a packet from it if one is there
    • queue_sel: identification of queue that should be polled
  • void enqueue_after_end(u16 queue_sel, dl_list* list) - appends the provided doubly-linked list of packet buffer descriptors to the end of the queue identified by the provided argument
    • queue_sel: identification of queue that should be appended to
    • list: doubly-linked list of packet descriptors that should be appended
  • void purge_queue(u16 queue_sel) - remove all packet buffer descriptors from the identified queue and return them to the free pool
    • queue_sel: identification of queue that should be purged

Example Snippets

Adding a single packet to a queue

//Checkout 1 element from the queue;
    queue_checkout(&checkout,1);

    if(checkout.length == 1){ //There was at least 1 free queue element
        tx_queue_entry = checkout.first;

        tx_queue = (tx_queue_buffer*)(tx_queue_entry->data);

                //Here is where you can construct the packet in tx_queue_entry->data and its corresponding 
                //tx_queue_entry->frame_info


        wlan_mac_high_setup_tx_header( &tx_header_common, (u8 *)bcast_addr, wlan_mac_addr );
        tx_length = wlan_create_beacon_frame((void*)(tx_queue->frame),&tx_header_common, BEACON_INTERVAL_MS, strlen(access_point_ssid), (u8*)access_point_ssid, mac_param_chan,1,tim_control,tim_bitmap);

        enqueue_after_end(YOUR_QUEUE_ID, &checkout);
    }

Implementation

The transmit queue is implemented in wlan_mac_queue.c.