# TXU
[UMAC]

UMAC TX Path. More...

Collaboration diagram for TXU:

## Functions
static bool | txu_cntrl_logic_port_filter (uint8_t sta_idx, uint16_t eth_type, uint16_t *flags)
| Perform the logical port filtering based on the STA index and the EtherType of the frame.
static int | txu_cntrl_sechdr_len_compute (struct txdesc *txdesc, int *tail_len)
| Compute the security header and trailer lengths depending on the type of security to be used.
static void | txu_cntrl_umacdesc_prep (struct txdesc *txdesc)
| Compute the size of the different headers and trailers of the frame.
static void | txu_cntrl_umacdesc_mgmt_prep (struct txdesc *txdesc, struct vif_info_tag *vif)
| Compute the header and trailer lengths for a management frame to be transmitted.
static uint32_t | txu_cntrl_mac_hdr_append (struct txdesc *txdesc, uint32_t buf)
| Append the MAC Header to the frame.
static uint32_t | txu_cntrl_sec_hdr_append (struct txdesc *txdesc, uint32_t buf, bool umac_pol)
| Append the Security Header and Trailer to the frame.
static uint32_t | txu_cntrl_llc_hdr_append (struct txdesc *txdesc, uint32_t buf)
| Append the LLC/SNAP to the frame if required.
static uint32_t | txu_cntrl_amsdu_hdr_append (struct txdesc *txdesc, uint32_t buf)
| Append the A-MSDU header to the frame if required.
static void | txu_cntrl_check_rate (struct txdesc *txdesc)
| Call the RC to check if is time to update the policy table.
static void | txu_cntrl_discard (struct txdesc *txdesc, uint8_t access_category, uint32_t status)
| Discard a packet that cannot be transmitted.
void | txu_cntrl_frame_build (struct txdesc *txdesc, uint32_t buf)
| Function called by the LMAC once the data buffer has been allocated.
bool | txu_cntrl_push (struct txdesc *txdesc, uint8_t access_category)
| This is the entry point in UMAC TX path for sending host and send back data frames.
void | txu_cntrl_tkip_mic_append (struct txdesc *txdesc, uint8_t ac)
| Function called by the LMAC once the data buffer has been downloaded.
void | txu_cntrl_cfm (struct txdesc *txdesc)
| NX_FULLY_HOSTED.
void | txu_cntrl_protect_mgmt_frame (struct txdesc *txdesc, struct mac_hdr *mac_hdr, uint16_t hdr_len)
| This function Add security header to a management frame.
## TX Status bits passed to the host upon frame confirmation
#define | TX_STATUS_DONE CO_BIT(0)
| Frame transmission done.
#define | TX_STATUS_RETRY_REQUIRED CO_BIT(1)
| Frame retry required.
#define | TX_STATUS_SW_RETRY_REQUIRED CO_BIT(2)
| Frame sw retry required.
#define | TX_STATUS_ACKNOWLEDGED CO_BIT(3)
| Frame acknoledged.
## TX Flags passed by the host or UMAC
#define | TXU_CNTRL_RETRY CO_BIT(0)
| The frame is a retry.
#define | TXU_CNTRL_UNDER_BA CO_BIT(1)
| The frame is sent under a BlockAck agreement.
#define | TXU_CNTRL_MORE_DATA CO_BIT(2)
| More data are buffered on host side for this STA after this packet.
#define | TXU_CNTRL_MGMT CO_BIT(3)
| TX Frame is a management frame: WLAN header is already provided, no need to transform an ethernet header Frame shall be sent as a singleton.
#define | TXU_CNTRL_MGMT_NO_CCK CO_BIT(4)
| No CCK rate can be used (valid only if TXU_CNTRL_MGMT is set).
#define | TXU_CNTRL_MGMT_PM_MON CO_BIT(5)
| Internal flag indicating that the PM monitoring has been started for this frame.
#define | TXU_CNTRL_AMSDU CO_BIT(6)
| The frame is an A-MSDU.
#define | TXU_CNTRL_MGMT_ROBUST CO_BIT(7)
| The frame is a robust management frame.
#define | TXU_CNTRL_USE_4ADDR CO_BIT(8)
| The frame shall be transmitted using a 4 address MAC Header.
#define | TXU_CNTRL_EOSP CO_BIT(9)
| The frame is the last of the UAPSD service period.
#define | TXU_CNTRL_MESH_FWD CO_BIT(10)
| This frame is forwarded.
#define | TXU_CNTRL_TDLS CO_BIT(11)
| This frame is sent directly to a TDLS peer.
#define | TXU_CNTRL_POSTPONE_PS CO_BIT(12)
| This frame is postponed internally because of PS. (only for AP).
#define | TXU_CNTRL_RC_TRIAL CO_BIT(13)
| Internal flag indicating that this packet should use the trial rate as first or second rate.
#define | TXU_CNTRL_UASPD_TRIGGER CO_BIT(14)
| Internal flag indicating that this is a UAPSD trigger frame.

## Detailed Description

UMAC TX Path.

## Function Documentation

static uint32_t txu_cntrl_amsdu_hdr_append | ( | struct txdesc * | txdesc,
|  | uint32_t | buf |
| ) |  |  | `[static]`

Append the A-MSDU header to the frame if required.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[in]` | buf | Address of the first byte of the LLC/SNAP

Returns:
  The address of the A-MSDU Header in the buffer

Definition at line 736 of file txu_cntrl.c.

References co_htons(), amsdu_hdr::da, hostdesc::eth_dest_addr, hostdesc::eth_src_addr, hostdesc::flags, umacdesc::hdr_len_802_2, txdesc::host, HW2CPU, amsdu_hdr::len, MAC_ADDR_CPY, hostdesc::packet_len, amsdu_hdr::sa, sizeof_b, TXU_CNTRL_AMSDU, and txdesc::umac.

void txu_cntrl_cfm | ( | struct txdesc * | txdesc | ) |

NX_FULLY_HOSTED.

This function handles status of a transmission.

It returns the number of credits allocated to the host for the next transmissions.

Parameters:

  `[in]` | txdesc | Pointer to the packet descriptor

Referenced by txl_cfm_evt(), txl_cfm_flush(), and txl_cfm_flush_desc().

static void txu_cntrl_check_rate | ( | struct txdesc * | txdesc | ) | `[static]`

Call the RC to check if is time to update the policy table.

Attach the buffer control to the packet.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted

Definition at line 767 of file txu_cntrl.c.

References umacdesc::buf_control, txdesc::host, me_update_buffer_control(), umacdesc::phy_flags, txl_buffer_control::policy_tbl, tx_policy_tbl::ratecntrlinfo, rc_check(), umacdesc::rc_control, RC_CONTROL_GET, sta_info_tab, hostdesc::staid, and txdesc::umac.

static void txu_cntrl_discard | ( | struct txdesc * | txdesc,
|  | uint8_t | access_category,
|  | uint32_t | status |
| ) |  |  | `[static]`

Discard a packet that cannot be transmitted.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be discarded
  `[in]` | access_category | Access category of the frame
  `[in]` | status | Status to be passed to the TXL confirmation module

Definition at line 794 of file txu_cntrl.c.

References GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, txl_cfm_push(), and txl_cntrl_inc_pck_cnt().

void txu_cntrl_frame_build | ( | struct txdesc * | txdesc,
|  | uint32_t | buf |
| ) |  |  |

Function called by the LMAC once the data buffer has been allocated.

It is responsible for the different header formatting (MAC Header, IV/EIV, LLC/SNAP).

Parameters:

  `[in]` | txdesc | Pointer to the structure that has the info of the data packet to be transmitted.
  `[in]` | buf | Address of the header in shared RAM

static uint32_t txu_cntrl_llc_hdr_append | ( | struct txdesc * | txdesc,
|  | uint32_t | buf |
| ) |  |  | `[static]`

Append the LLC/SNAP to the frame if required.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[in]` | buf | Address of first byte of the payload

Returns:
  The address of the LLC Header in the buffer

Definition at line 690 of file txu_cntrl.c.

References co_ntohs(), llc_snap::control_oui0, llc_snap::dsap_ssap, hostdesc::ethertype, txdesc::host, HW2CPU, LLC_FRAMELENGTH_MAXVALUE, llc_snap::oui1_2, llc_snap::proto_id, and sizeof_b.

static bool txu_cntrl_logic_port_filter | ( | uint8_t | sta_idx,
|  | uint16_t | eth_type,
|  | uint16_t * | flags |
| ) |  |  | `[static]`

Perform the logical port filtering based on the STA index and the EtherType of the frame.

The function may change the connection flags depending on the EtherType.

Parameters:

  `[in]` | sta_idx | Index of the station the frame has to be transmitted to
  `[in]` | eth_type | EtherType of the frame
  `[in,out]` | flags | Transmission flags

Returns:
  true if the packet can be transmitted, false if it has to be discarded

Definition at line 62 of file txu_cntrl.c.

References PORT_CONTROLED, PORT_OPEN, sta_mgmt_get_port_ethertype(), sta_mgmt_get_port_state(), and TXU_CNTRL_USE_4ADDR.

static uint32_t txu_cntrl_mac_hdr_append | ( | struct txdesc * | txdesc,
|  | uint32_t | buf |
| ) |  |  | `[static]`

Append the MAC Header to the frame.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[in]` | buf | Address of the next byte following the header to be appended

Returns:
  The address of the MAC Header in the buffer

Definition at line 365 of file txu_cntrl.c.

References mac_hdr_qos::addr1, mac_hdr_long_qos::addr1, mac_hdr_qos::addr2, mac_hdr_qos::addr3, mac_hdr_long_qos::addr3, mac_hdr_long_qos::addr4, vif_info_tag::bss_info, me_bss_info::bssid, co_ntohs(), co_write32p(), CONTROL_PORT_NO_ENC, CPU2HW, sta_mgmt_sec_info::cur_key, hostdesc::eth_dest_addr, hostdesc::eth_src_addr, hostdesc::ethertype, mac_hdr_qos::fctl, vif_info_tag::flags, hostdesc::flags, umacdesc::has_mesh_ctrl, txdesc::host, HW2CPU, sta_info_tag::mac_addr, vif_info_tag::mac_addr, MAC_ADDR_CPY, MAC_ADDR_LEN, MAC_FCTRL_DATA_T, MAC_FCTRL_FROMDS, MAC_FCTRL_MOREDATA, MAC_FCTRL_ORDER, MAC_FCTRL_PROTECTEDFRAME, MAC_FCTRL_TODS, MAC_FCTRL_TODS_FROMDS, MAC_HDR_QOS_CTRL_LEN, MAC_HTC_LEN, MAC_LONG_MAC_HDR_LEN, MAC_QOS_ST_BIT, MAC_QOSCTRL_AMSDU_PRESENT, MAC_QOSCTRL_EOSP, MAC_QOSCTRL_MESH_CTRL_PRESENT, MAC_QOSCTRL_UP_OFT, MAC_SEQCTRL_NUM_OFT, MAC_SHORT_MAC_HDR_LEN, umacdesc::nb_ext_addr, NX_REMOTE_STA_MAX, umacdesc::path_idx, mac_hdr_qos::qos, mac_hdr_long_qos::qos, mac_hdr_qos::seq, hostdesc::sn, STA_CAPA, sta_info_tab, sta_mgmt_get_port_ethertype(), sta_info_tag::sta_sec_info, hostdesc::staid, hostdesc::tid, TXU_CNTRL_AMSDU, TXU_CNTRL_EOSP, TXU_CNTRL_MESH_FWD, TXU_CNTRL_MORE_DATA, TXU_CNTRL_TDLS, TXU_CNTRL_USE_4ADDR, vif_info_tag::type, txdesc::umac, VIF_AP, hostdesc::vif_idx, vif_info_tab, VIF_MESH_POINT, and VIF_STA.

void txu_cntrl_protect_mgmt_frame | ( | struct txdesc * | txdesc,
|  | struct mac_hdr * | mac_hdr,
|  | uint16_t | hdr_len |
| ) |  |  |

This function Add security header to a management frame.

If security lengths (head and tail) are not set in txdesc->umac, it will first compute them and update txdesc. Then it adds security header. No check on frame type/subtype is done and it assumes that it has already been checked before.

Parameters:

  `[in,out]` | txdesc | Pointer to the packet descriptor
  `[in]` | mac_hdr | Pointer on MAC header of the frame
  `[in]` | hdr_len | Size of MAC header

Referenced by txl_hwdesc_config_post().

bool txu_cntrl_push | ( | struct txdesc * | txdesc,
|  | uint8_t | access_category |
| ) |  |  |

This is the entry point in UMAC TX path for sending host and send back data frames.

Parameters:

  `[in]` | txdesc | Pointer to the structure that has the info of the data packet to be transmitted.
  `[in]` | access_category | Index of the queue in which the packet is passed

Returns:
  Whether the IPC queue shall be stopped after this call or not

static uint32_t txu_cntrl_sec_hdr_append | ( | struct txdesc * | txdesc,
|  | uint32_t | buf,
|  | bool | umac_pol |
| ) |  |  | `[static]`

Append the Security Header and Trailer to the frame.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[in]` | buf | Address of the next byte following the header to be appended
  `[in]` | umac_pol | Select which policy table to update: true: The one in txdesc->umac false: The one in txdesc->lmac->buffer

For DATA frames, this function is called before the txl_buffer is allocated so it can only update the policy table in txdesc->umac that will be recopied to the txl_buffer once allocated. For MGMT frames, this functions is called after the txl_buffer is allocated so it is necessary to update the policy table in the txl_buffer.

Returns:
  The address of the Security Header in the buffer

Definition at line 578 of file txu_cntrl.c.

References ASSERT_ERR, umacdesc::buf_control, key_info_tag::cipher, co_ntohs(), CONTROL_PORT_NO_ENC, sta_mgmt_sec_info::cur_key, EIV_LEN, hostdesc::ethertype, vif_info_tag::flags, umacdesc::has_mesh_ctrl, txdesc::host, HW2CPU, key_info_tag::hw_key_idx, IV_LEN, key_info_tag::key_idx, KEYSRAM_INDEX_RA_MASK, MAC_ADDR_LEN, MAC_CIPHER_CCMP, MAC_CIPHER_TKIP, MAC_CIPHER_WEP104, MAC_CIPHER_WEP40, MAC_CIPHER_WPI_SMS4, tx_policy_tbl::maccntrlinfo1, vif_info_tag::mvif_idx, umacdesc::nb_ext_addr, hostdesc::pn, txl_buffer_control::policy_tbl, sta_info_tab, sta_mgmt_get_port_ethertype(), sta_info_tag::sta_sec_info, hostdesc::staid, txl_buffer_control_get(), vif_info_tag::type, txdesc::umac, hostdesc::vif_idx, vif_info_tab, VIF_MESH_POINT, and WPI_IV_LEN.

static int txu_cntrl_sechdr_len_compute | ( | struct txdesc * | txdesc,
|  | int * | tail_len |
| ) |  |  | `[static]`

Compute the security header and trailer lengths depending on the type of security to be used.

The function also assigns the PN to the frame whenever required.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[out]` | tail_len | Length of the security trailer

Returns:
  The length of the security header

Definition at line 102 of file txu_cntrl.c.

References ASSERT_ERR, key_info_tag::cipher, co_ntohs(), CONTROL_PORT_NO_ENC, sta_mgmt_sec_info::cur_key, EIV_LEN, hostdesc::ethertype, hostdesc::flags, vif_info_tag::flags, txdesc::host, key_info_tag::hw_key_idx, ICV_LEN, IV_LEN, MAC_CIPHER_CCMP, MAC_CIPHER_TKIP, MAC_CIPHER_WEP104, MAC_CIPHER_WEP40, MAC_CIPHER_WPI_SMS4, MIC_LEN, MM_SEC_DEFAULT_KEY_COUNT, hostdesc::pn, sta_info_tab, sta_mgmt_get_port_ethertype(), sta_info_tag::sta_sec_info, hostdesc::staid, key_info_tag::tx_pn, TXU_CNTRL_RETRY, hostdesc::vif_idx, vif_info_tab, WPI_IV_LEN, and WPI_MIC_LEN.

Referenced by txu_cntrl_umacdesc_mgmt_prep(), and txu_cntrl_umacdesc_prep().

void txu_cntrl_tkip_mic_append | ( | struct txdesc * | txdesc,
|  | uint8_t | ac |
| ) |  |  |

Function called by the LMAC once the data buffer has been downloaded.

It is responsible for the TKIP MIC computing if required.

Parameters:

  `[in]` | txdesc | Pointer to the structure that has the info of the data packet to be transmitted.
  `[in]` | ac | Access category on which the packet is sent

Referenced by txl_hwdesc_config_post().

static void txu_cntrl_umacdesc_mgmt_prep | ( | struct txdesc * | txdesc,
|  | struct vif_info_tag * | vif |
| ) |  |  | `[static]`

Compute the header and trailer lengths for a management frame to be transmitted.

The function also assigns the PN to the frame whenever required.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted
  `[in]` | vif | Pointer to the VIF

Definition at line 289 of file txu_cntrl.c.

References mac_chan_op::band, umacdesc::buf_control, vif_info_tag::chan_ctxt, chan_ctxt_tag::channel, umacdesc::flags, hostdesc::flags, umacdesc::head_len, txdesc::host, MAC_FCTRL_DEAUTHENT, MAC_MGMT_MIC_LEN, umacdesc::machead_len, MFP_MULTICAST_PROT, mfp_protect_mgmt_frame(), MFP_UNICAST_PROT, NX_P2P, vif_info_tag::p2p, PHY_BAND_2G4, umacdesc::phy_flags, txl_buffer_control::policy_tbl, tx_policy_tbl::powercntrlinfo, RATE_CONTROL_STEPS, umacdesc::tail_len, tpc_get_vif_tx_power(), TX_PWR_LEVEL_SET, txl_buffer_control_24G, txl_buffer_control_5G, TXU_CNTRL_MGMT_NO_CCK, TXU_CNTRL_MGMT_ROBUST, txu_cntrl_sechdr_len_compute(), and txdesc::umac.

static void txu_cntrl_umacdesc_prep | ( | struct txdesc * | txdesc | ) | `[static]`

Compute the size of the different headers and trailers of the frame.

The function also assigns the SN to the frame.

Parameters:

  `[in]` | txdesc | TX descriptor attached to the frame to be transmitted

Definition at line 185 of file txu_cntrl.c.

References co_ntohs(), hostdesc::ethertype, umacdesc::flags, hostdesc::flags, umacdesc::hdr_len_802_2, umacdesc::head_len, txdesc::host, LLC_FRAMELENGTH_MAXVALUE, MAC_HTC_LEN, MAC_LONG_MAC_HDR_LEN, MAC_SHORT_MAC_HDR_LEN, MAC_SHORT_QOS_MAC_HDR_LEN, umacdesc::machead_len, hostdesc::packet_cnt, hostdesc::packet_len, umacdesc::payl_len, umacdesc::phy_flags, sizeof_b, hostdesc::sn, STA_CAPA, sta_info_tab, sta_mgmt_get_tx_ssn_and_inc(), hostdesc::staid, umacdesc::tail_len, hostdesc::tid, TXU_CNTRL_AMSDU, TXU_CNTRL_MESH_FWD, TXU_CNTRL_RETRY, txu_cntrl_sechdr_len_compute(), TXU_CNTRL_USE_4ADDR, vif_info_tag::type, txdesc::umac, hostdesc::vif_idx, vif_info_tab, VIF_MESH_POINT, and VIF_STA.