| 78 | if(command->header->num_args > 0) { |
| 79 | req_queue_id = Xil_Ntohl(cmd_args_32[0]); |
| 80 | xil_printf("Queue ID %d requested\n", req_queue_id); |
| 81 | |
| 82 | resp_args_32[resp_index++] = Xil_Htonl(req_queue_id); |
| 83 | resp_args_32[resp_index++] = Xil_Htonl(queue_num_queued(req_queue_id)); |
| 84 | |
| 85 | } else { |
| 86 | xil_printf("No queue ID requested - returning status of all queues\n"); |
| 87 | |
| 88 | //Gather status of all Tx queues: |
| 89 | // Multicast queue (MCAST_QID) |
| 90 | // Managment queue (MANAGEMENT_QID) |
| 91 | // Queue per AID |
| 92 | resp_args_32[resp_index++] = Xil_Htonl(MCAST_QID); |
| 93 | resp_args_32[resp_index++] = Xil_Htonl(queue_num_queued(MCAST_QID)); |
| 94 | resp_args_32[resp_index++] = Xil_Htonl(MANAGEMENT_QID); |
| 95 | resp_args_32[resp_index++] = Xil_Htonl(queue_num_queued(MANAGEMENT_QID)); |
| 96 | |
| 97 | if(my_bss_info->associated_stations.length > 0) { |
| 98 | curr_station_info_entry = NULL; |
| 99 | |
| 100 | //Iterating over the dl_list is potentially dangerous, as the list itself might change |
| 101 | // if this function is interrupted. We protect against this by iterating over (at most) |
| 102 | // the number of entries in the list at the time this loop starts. The iteration variable i |
| 103 | // is *not* used for indexing the list - we still traverse entries with entry.next |
| 104 | for(i=0; i<my_bss_info->associated_stations.length; i++) { |
| 105 | |
| 106 | if(curr_station_info_entry == NULL) { |
| 107 | //First iteration - get the head of the dl_list |
| 108 | curr_station_info_entry = my_bss_info->associated_stations.first; |
| 109 | } else { |
| 110 | //Subsequent iteration - get the next entry in the dl_list |
| 111 | curr_station_info_entry = dl_entry_next(curr_station_info_entry); |
| 112 | } |
| 113 | |
| 114 | //Get the station info pointer from the list entry |
| 115 | curr_station_info = (station_info*)(curr_station_info_entry->data); |
| 116 | |
| 117 | //Get the queue ID and queue occupancy |
| 118 | q_id = AID_TO_QID(curr_station_info->AID); |
| 119 | q_occ = queue_num_queued(q_id); |
| 120 | xil_printf("Q: %2d %3d\n", q_id, q_occ); |
| 121 | |
| 122 | |
| 123 | //Add the queue info to the response payload |
| 124 | resp_args_32[resp_index++] = Xil_Htonl(q_id); |
| 125 | resp_args_32[resp_index++] = Xil_Htonl(q_occ); |
| 126 | |
| 127 | //Break out of the for loop on the last station info entry or |
| 128 | // if our response is already reached the max size allowed by the framework |
| 129 | if( (curr_station_info_entry == my_bss_info->associated_stations.last) || |
| 130 | (dl_entry_next(curr_station_info_entry) == NULL) || |
| 131 | (resp_index >= max_resp_len) ) { |
| 132 | break; |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | //All done - resp_args_32 now contains queue status, res_index is length of response arguments array |
| 139 | // Copy these values into the response header struct |
| 140 | resp_hdr->length += (resp_index * sizeof(resp_args_32[0])); |
| 141 | resp_hdr->num_args = resp_index; |
| 142 | |
| 143 | break; |