# CO_LIST
[COMMON]

List management. More...

Collaboration diagram for CO_LIST:

## Data Structures
struct | co_list_hdr
| structure of a list element header More...
struct | co_list
| structure of a list More...
## Functions
void | co_list_init (struct co_list *list)
| Initialize a list to defaults values.
void | co_list_pool_init (struct co_list *list, void *pool, size_t elmt_size, uint32_t elmt_cnt, void *default_value)
| Initialize a pool to default values, and initialize the relative free list.
void | co_list_push_back (struct co_list *list, struct co_list_hdr *list_hdr)
| Add an element as last on the list.
void | co_list_push_front (struct co_list *list, struct co_list_hdr *list_hdr)
| Add an element as first on the list.
struct co_list_hdr * | co_list_pop_front (struct co_list *list)
| Extract the first element of the list.
void | co_list_extract (struct co_list *list, struct co_list_hdr *list_hdr)
| Search for a given element in the list, and extract it if found.
bool | co_list_find (struct co_list *list, struct co_list_hdr *list_hdr)
| Searched a given element in the list.
uint32_t | co_list_cnt (const struct co_list *const list)
| Return the number of element of the list.
void | co_list_insert (struct co_list *const list, struct co_list_hdr *const element, bool(*cmp)(struct co_list_hdr const *elementA, struct co_list_hdr const *elementB))
| Insert an element in a sorted list.
void | co_list_insert_after (struct co_list *const list, struct co_list_hdr *const prev_element, struct co_list_hdr *const element)
| Insert an element in a sorted list after the provided element.
void | co_list_insert_before (struct co_list *const list, struct co_list_hdr *const next_element, struct co_list_hdr *const element)
| Insert an element in a sorted list before the provided element.
void | co_list_concat (struct co_list *list1, struct co_list *list2)
| Concatenate two lists.
void | co_list_remove (struct co_list *list, struct co_list_hdr *prev_element, struct co_list_hdr *element)
| Remove the element in the list after the provided element.
__INLINE bool | co_list_is_empty (const struct co_list *const list)
| Test if the list is empty.
__INLINE struct co_list_hdr * | co_list_pick (const struct co_list *const list)
| Pick the first element from the list without removing it.
__INLINE struct co_list_hdr * | co_list_pick_last (const struct co_list *const list)
| Pick the last element from the list without removing it.
__INLINE struct co_list_hdr * | co_list_next (const struct co_list_hdr *const list_hdr)
| Return following element of a list element.

## Detailed Description

List management.

This module contains the list structures and handling functions.

## Function Documentation

uint32_t co_list_cnt | ( | const struct co_list *const | list | ) |

Return the number of element of the list.

Parameters:

  `[in]` | list | Pointer to the list structure.

Returns:
  The number of elements in the list.

Referenced by me_config_monitor_req_handler().

void co_list_concat | ( | struct co_list * | list1,
|  | struct co_list * | list2 |
| ) |  |  |

Concatenate two lists.

The resulting list is the list passed as the first parameter. The second list is emptied.

Parameters:

  `[in]` | list1 | First list (will get the result of the concatenation)
  `[in]` | list2 | Second list (will be emptied after the concatenation)

Referenced by txl_frame_exchange_done(), and txl_mumimo_convert().

void co_list_extract | ( | struct co_list * | list,
|  | struct co_list_hdr * | list_hdr |
| ) |  |  |

Search for a given element in the list, and extract it if found.

Parameters:

  `[in]` | list | Pointer to the list structure
  `[in]` | list_hdr | Pointer to the searched element

Returns:
  CO_EMPTY if the list is empty, CO_FAIL if the element not found in the list, CO_OK else.

Referenced by bfr_calibrate(), bfr_remove_node(), chan_tbtt_remove(), rxu_cntrl_defrag_check(), and rxu_cntrl_defrag_timeout_cb().

bool co_list_find | ( | struct co_list * | list,
|  | struct co_list_hdr * | list_hdr |
| ) |  |  |

Searched a given element in the list.

Parameters:

  `[in]` | list | Pointer to the list structure
  `[in]` | list_hdr | Pointer to the searched element

Returns:
  true if the element is found in the list, false otherwise

void co_list_init | ( | struct co_list * | list | ) |

Initialize a list to defaults values.

Parameters:

  `[in]` | list | Pointer to the list structure.

Referenced by apm_bss_config_init(), chan_reset_tbtt_list(), rxl_cntrl_init(), sm_bss_config_init(), txl_agg_hwdesc_reset(), txl_cfm_init(), and txl_frame_init().

void co_list_insert | ( | struct co_list *const | list,
|  | struct co_list_hdr *const | element,
|  | bool(*)(struct co_list_hdr const *elementA, struct co_list_hdr const *elementB) | cmp |
| ) |  |  |

Insert an element in a sorted list.

This primitive use a comparison function from the parameter list to select where the element must be inserted.

Parameters:

  `[in]` | list | Pointer to the list.
  `[in]` | element | Pointer to the element to insert.
  `[in]` | cmp | Comparison function (return true if first element has to be inserted before the second one).

Returns:
  Pointer to the element found and removed (NULL otherwise).

void co_list_insert_after | ( | struct co_list *const | list,
|  | struct co_list_hdr *const | prev_element,
|  | struct co_list_hdr *const | element |
| ) |  |  |

Insert an element in a sorted list after the provided element.

This primitive use a comparison function from the parameter list to select where the element must be inserted.

Parameters:

  `[in]` | list | Pointer to the list.
  `[in]` | prev_element | Pointer to the element to find in the list
  `[in]` | element | Pointer to the element to insert.

If prev_element is not found, the provided element is not inserted

Referenced by bfr_get_node().

void co_list_insert_before | ( | struct co_list *const | list,
|  | struct co_list_hdr *const | next_element,
|  | struct co_list_hdr *const | element |
| ) |  |  |

Insert an element in a sorted list before the provided element.

This primitive use a comparison function from the parameter list to select where the element must be inserted.

Parameters:

  `[in]` | list | Pointer to the list.
  `[in]` | next_element | Pointer to the element to find in the list
  `[in]` | element | Pointer to the element to insert.

If next_element is not found, the provided element is not inserted

Referenced by bfr_calibrate(), and chan_tbtt_insert_before().

__INLINE bool co_list_is_empty | ( | const struct co_list *const | list | ) |

Test if the list is empty.

Parameters:

  `[in]` | list | Pointer to the list structure.

Returns:
  true if the list is empty, false else otherwise.

Definition at line 246 of file co_list.h.

References co_list::first.

Referenced by apm_bss_config_init(), chan_switch_no_schedule(), me_set_active_cfm_handler(), mm_bcn_transmitted(), mm_remove_if_req_handler(), rxl_upload_pending(), sm_bss_config_init(), sta_mgmt_entry_init(), and txl_frame_exchange_done().

__INLINE struct co_list_hdr* co_list_next | ( | const struct co_list_hdr *const | list_hdr | ) | `[read]`

Return following element of a list element.

Parameters:

  `[in]` | list_hdr | Pointer to the list element.

Returns:
  The pointer to the next element.

Definition at line 301 of file co_list.h.

References co_list_hdr::next.

Referenced by bfr_start_next_calibration(), chan_switch_channel(), me_beacon_check(), ps_disable_cfm(), ps_dpsm_update(), ps_enable_cfm(), ps_sleep_check(), ps_uapsd_timer_handle(), rxu_mgt_search_rx_vif(), tpc_set_vif_tx_power(), tx_desc_next(), txl_frame_exchange_done(), and vif_mgmt_next().

__INLINE struct co_list_hdr* co_list_pick | ( | const struct co_list *const | list | ) | `[read]`

Pick the first element from the list without removing it.

Parameters:

  `[in]` | list | Pointer to the list structure.

Returns:
  First element address. Returns NULL pointer if the list is empty.

Definition at line 273 of file co_list.h.

References co_list::first.

Referenced by bfr_calibrate(), bfr_get_node(), bfr_start_next_calibration(), chan_switch_pick(), chan_tbtt_pick(), macif_rx_desc_upload(), me_beacon_check(), mm_ap_tbtt(), ps_disable_cfm(), ps_dpsm_update(), ps_enable_cfm(), ps_sleep_check(), ps_uapsd_timer_handle(), rxl_upload_cntrl_pick_pending(), rxu_cntrl_defrag_get(), rxu_cntrl_reord_timeout_cb(), tpc_set_vif_tx_power(), txl_cfm_evt(), txl_frame_exchange_done(), txl_mumimo_convert(), txl_mumimo_secondary_done(), and vif_mgmt_first_used().

__INLINE struct co_list_hdr* co_list_pick_last | ( | const struct co_list *const | list | ) | `[read]`

Pick the last element from the list without removing it.

Parameters:

  `[in]` | list | Pointer to the list structure.

Returns:
  Last element address. Returns invalid value if the list is empty.

Definition at line 287 of file co_list.h.

References co_list::last.

Referenced by chan_switch_last(), and txl_mumimo_convert().

void co_list_pool_init | ( | struct co_list * | list,
|  | void * | pool,
|  | size_t | elmt_size,
|  | uint32_t | elmt_cnt,
|  | void * | default_value |
| ) |  |  |

Initialize a pool to default values, and initialize the relative free list.

Parameters:

  `[in]` | list | Pointer to the list structure
  `[in]` | pool | Pointer to the pool to be initialized
  `[in]` | elmt_size | Size of one element of the pool
  `[in]` | elmt_cnt | Nb of elements available in the pool
  `[in]` | default_value | Pointer to the default value of each element (may be NULL)

struct co_list_hdr * co_list_pop_front | ( | struct co_list * | list | ) | `[read]`

Extract the first element of the list.

Parameters:

  `[in]` | list | Pointer to the list structure

Returns:
  The pointer to the element extracted, and NULL if the list is empty.

Referenced by bfr_get_node(), bfr_start_next_calibration(), chan_switch_alloc(), chan_switch_pop(), ke_queue_pop(), macif_rx_desc_upload(), mm_bcn_transmitted(), rxl_upload_cntrl_pop_pending(), rxu_cntrl_defrag_alloc(), sta_mgmt_entry_init(), txl_agg_desc_alloc(), txl_ba_push(), txl_cfm_evt(), txl_cfm_flush(), txl_frame_evt(), txl_frame_exchange_done(), txl_frame_get(), and txl_mumimo_secondary_done().

void co_list_push_back | ( | struct co_list * | list,
|  | struct co_list_hdr * | list_hdr |
| ) |  |  |

Add an element as last on the list.

Parameters:

  `[in]` | list | Pointer to the list structure
  `[in]` | list_hdr | Pointer to the header to add at the end of the list

Referenced by apm_bss_config_push(), bfr_calibrate(), bfr_remove_node(), bfr_start_next_calibration(), chan_switch_free(), chan_switch_push_back(), ke_queue_push(), macif_init(), rxl_upload_cntrl_push_pending(), rxu_cntrl_defrag_check(), rxu_cntrl_defrag_timeout_cb(), rxu_cntrl_desc_prepare(), sm_bss_config_push(), txl_agg_desc_free(), txl_agg_hwdesc_init(), txl_agg_hwdesc_reset(), txl_cfm_push(), txl_cntrl_postpone(), txl_frame_cfm(), txl_frame_evt(), txl_frame_init(), txl_frame_release(), txl_mumimo_convert(), and txl_mumimo_secondary_done().

void co_list_push_front | ( | struct co_list * | list,
|  | struct co_list_hdr * | list_hdr |
| ) |  |  |

Add an element as first on the list.

Parameters:

  `[in]` | list | Pointer to the list structure
  `[in]` | list_hdr | Pointer to the header to add at the beginning of the list

void co_list_remove | ( | struct co_list * | list,
|  | struct co_list_hdr * | prev_element,
|  | struct co_list_hdr * | element |
| ) |  |  |

Remove the element in the list after the provided element.

This primitive removes an element in the list. It is assume that element is part of the list.

Parameters:

  `[in]` | list | Pointer to the list.
  `[in]` | prev_element | Pointer to the previous element. NULL if `element` is the first element in the list
  `[in]` | element | Pointer to the element to remove.