# TD
[LMAC]

TD module. More...

Collaboration diagram for TD:

## Data Structures
struct | td_env_tag
| Structure containing all information about traffic detection for a given interface. More...
struct | td_sta_env_tag
| Structure containing all information about traffic detection for a given link. More...
## Defines
#define | TD_DEBUG_TRACES_EN (0)
| Debug Configuration for TD Module 0 - Traces are disabled 1.
#define | TD_DEBUG_PRINT(lvl, format,...)
#define | TD_GET_VIF_INDEX(td_env) ((td_env - &td_env_tab[0]) / sizeof(struct td_env_tag))
| Return the VIF index of a Traffic Detection environment.
#define | TD_DEFAULT_INTV_US (100000)
| Traffic Detection Interval default value (in microseconds).
#define | TD_DEFAULT_PCK_NB_THRES (3)
| Traffic Detection default threshold (number of RX or TX packets needed to consider that traffi is occurring).
## Enumerations
enum | td_status_bit { TD_STATUS_TX = 0, TD_STATUS_RX, TD_STATUS_TX_PS, TD_STATUS_RX_PS }
| Bit index for Traffic Status. More...
## Functions
static void | td_update_sta_status (uint8_t sta_idx)
static void | td_timer_end (void *env)
void | td_init (void)
| Initialize the traffic detection module.
void | td_reset (uint8_t vif_index)
| Reset Traffic Detection status for a given VIF.
void | td_sta_reset (uint8_t sta_index)
| Reset Traffic Detection status for a given STA.
void | td_start (uint8_t vif_index)
| Start Traffic Detection on a given VIF.
void | td_pck_ind (uint8_t vif_index, uint8_t sta_index, bool rx)
| Handle reception or transmission of a packet on a given interface.
void | td_pck_ps_ind (uint8_t vif_index, bool rx)
| Handle reception or transmission of a packet on a given interface in a PS context.
__INLINE uint8_t | td_get_status (uint8_t vif_index)
__INLINE uint8_t | td_get_ps_status (uint8_t vif_index)
__INLINE bool | td_sta_has_tx_traffic (uint8_t sta_idx)
| Check if there is TX traffic for a given STA.
__INLINE bool | td_sta_has_traffic (uint8_t sta_idx)
| Check if there is TX or RX traffic for a given STA.
## Variables
struct td_env_tag | td_env_tab [NX_VIRT_DEV_MAX]
| List of TD Environment Entries, one for each VIF that can be created.
struct td_sta_env_tag | td_sta_env [NX_REMOTE_STA_MAX]
| List of TD Environment Entries used for per-STA traffic detection.
struct td_env_tag | td_env_tab [NX_VIRT_DEV_MAX]
| List of TD Environment Entries, one for each VIF that can be created.
struct td_sta_env_tag | td_sta_env [NX_REMOTE_STA_MAX]
| List of TD Environment Entries used for per-STA traffic detection.

## Detailed Description

TD module.

## Define Documentation

#define TD_DEBUG_TRACES_EN (0)

Debug Configuration for TD Module 0 - Traces are disabled 1.

. - Level of verbosity

Definition at line 58 of file td.c.

## Enumeration Type Documentation

enum td_status_bit

Bit index for Traffic Status.

Enumerator:

  TD_STATUS_TX | TX Traffic Detected (overall).
  TD_STATUS_RX | RX Traffic Detected (overall).
  TD_STATUS_TX_PS | TX Traffic Detected (with PS filtering).
  TD_STATUS_RX_PS | RX Traffic Detected (with PS filtering).

Definition at line 49 of file td.h.

## Function Documentation

void td_pck_ind | ( | uint8_t | vif_index,
|  | uint8_t | sta_index,
|  | bool | rx |
| ) |  |  |

Handle reception or transmission of a packet on a given interface.

Parameters:

  `[in]` | vif_index | Index of the VIF on which packet has been received/transmitted
  `[in]` | sta_index | Index of the STA on which packet has been received/transmitted
  `[in]` | rx | True if packet has been received, false if it has been transmitted

Referenced by rxl_frame_handle().

void td_pck_ps_ind | ( | uint8_t | vif_index,
|  | bool | rx |
| ) |  |  |

Handle reception or transmission of a packet on a given interface in a PS context.

This function should not be called for packet whose queue is UAPSD enabled.

Parameters:

  `[in]` | vif_index | Index of the VIF on which packet has been received/transmitted
  `[in]` | rx | True if packet has been received, false if it has been transmitted

void td_reset | ( | uint8_t | vif_index | ) |

Reset Traffic Detection status for a given VIF.

Parameters:

  `[in]` | vif_index | Index of VIF on which traffic status has to be reseted

__INLINE bool td_sta_has_traffic | ( | uint8_t | sta_idx | ) |

Check if there is TX or RX traffic for a given STA.

Parameters:

  `[in]` | sta_index | Index of STA for which the TX and RX status is checked.

Returns:
  Whether the STA has TX or RX traffic

Definition at line 232 of file td.h.

References CO_BIT, td_sta_env, TD_STATUS_RX, and TD_STATUS_TX.

Referenced by tdls_check_frame_action().

__INLINE bool td_sta_has_tx_traffic | ( | uint8_t | sta_idx | ) |

Check if there is TX traffic for a given STA.

Parameters:

  `[in]` | sta_index | Index of STA for which the TX status is checked.

Returns:
  Whether the STA has TX traffic

Definition at line 219 of file td.h.

References CO_BIT, td_sta_env, and TD_STATUS_TX.

Referenced by bfr_calibrate().

void td_sta_reset | ( | uint8_t | sta_index | ) |

Reset Traffic Detection status for a given STA.

Parameters:

  `[in]` | sta_index | Index of STA on which traffic status has to be reset.

void td_start | ( | uint8_t | vif_index | ) |

Start Traffic Detection on a given VIF.

Parameters:

  `[in]` | vif_index | Index of VIF on which traffic has to be monitored