• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Create: 2022-05-09
15  */
16 #ifndef __HMAC_TX_MPDU_ADAPT_H__
17 #define __HMAC_TX_MPDU_ADAPT_H__
18 
19 #include "hal_common_ops.h"
20 #include "mac_vap_ext.h"
21 #include "frw_msg_rom.h"
22 #include "dmac_ext_if_device.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 typedef struct {
31     hmac_vap_stru *hmac_vap;
32     hmac_user_stru *user;
33     mac_tx_ctl_stru *tx_ctl;
34 } hmac_tx_data_stat_stru;
35 
36 
37 /*****************************************************************************
38  函 数 名  : hmac_tx_tid_lock_bh
39  功能描述  : 使用锁保护所有tid队列资源
40 *****************************************************************************/
hmac_tx_tid_lock_bh(hmac_device_stru * hmac_device)41 static INLINE__ osal_void hmac_tx_tid_lock_bh(hmac_device_stru *hmac_device)
42 {
43 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS != _PRE_OS_VERSION)
44     osal_spin_lock_bh(&hmac_device->lock);
45 #else
46     unref_param(hmac_device);
47     osal_adapt_kthread_lock();
48 #endif
49 }
50 
51 /*****************************************************************************
52  函 数 名  : hmac_tx_tid_unlock_bh
53  功能描述  : 释放保护所有tid队列资源的锁
54 *****************************************************************************/
hmac_tx_tid_unlock_bh(hmac_device_stru * hmac_device)55 static INLINE__ osal_void hmac_tx_tid_unlock_bh(hmac_device_stru *hmac_device)
56 {
57 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS != _PRE_OS_VERSION)
58     osal_spin_unlock_bh(&hmac_device->lock);
59 #else
60     unref_param(hmac_device);
61     osal_adapt_kthread_unlock();
62 #endif
63 }
64 
hmac_tx_excp_free_netbuf(oal_netbuf_stru * net_buffer)65 static INLINE__ osal_void hmac_tx_excp_free_netbuf(oal_netbuf_stru *net_buffer)
66 {
67     oal_netbuf_stru *netbuf = net_buffer;
68     oal_netbuf_stru *buf_next = OSAL_NULL;
69 
70     while (netbuf != OSAL_NULL) {
71         buf_next = oal_get_netbuf_next(netbuf);
72         oal_netbuf_free(netbuf);
73         netbuf = buf_next;
74     }
75 }
76 
77 #ifdef _PRE_WLAN_FEATURE_ROAM
78 /*****************************************************************************
79  函 数 名  : hmac_tx_enable_in_roaming
80  功能描述  : 判断漫游状态下,是否可以发送帧
81 *****************************************************************************/
hmac_tx_enable_in_roaming(const hal_to_dmac_device_stru * hal_device,const hmac_vap_stru * hmac_vap)82 static INLINE__ oal_bool_enum_uint8 hmac_tx_enable_in_roaming(const hal_to_dmac_device_stru *hal_device,
83     const hmac_vap_stru *hmac_vap)
84 {
85     if (hmac_vap->vap_state == MAC_VAP_STATE_ROAMING) {
86         if (hal_device->current_chan_number != hmac_vap->channel.chan_number) {
87             return OSAL_FALSE;
88         }
89     }
90 
91     return OSAL_TRUE;
92 }
93 #endif
94 
95 /*****************************************************************************
96  函 数 名  : hmac_tx_is_tx_force
97  功能描述  : 判断是否常发模式
98 *****************************************************************************/
hmac_tx_is_tx_force(const hmac_vap_stru * hmac_vap)99 static INLINE__ oal_bool_enum_uint8 hmac_tx_is_tx_force(const hmac_vap_stru *hmac_vap)
100 {
101     /* 常发下返回状态OK */
102     if ((hmac_vap->al_tx_flag == EXT_SWITCH_ON) ||
103         (hmac_vap->al_rx_flag == EXT_SWITCH_ON)) {
104         return OSAL_TRUE;
105     }
106 #ifdef _PRE_WLAN_FEATURE_ROAM
107     /* 漫游状态时,强制发送该数据帧 */
108     if (hmac_vap->vap_state == MAC_VAP_STATE_ROAMING) {
109         return OSAL_TRUE;
110     }
111 #endif
112 
113     return OSAL_FALSE;
114 }
115 
116 /*****************************************************************************
117  函 数 名  : hmac_tx_mgmt_get_txop_para
118  功能描述  : 设置管理帧txop 参数
119 *****************************************************************************/
hmac_tx_mgmt_get_txop_para(hmac_vap_stru * hmac_vap,hal_tx_txop_alg_stru ** txop_alg,const mac_tx_ctl_stru * tx_ctl)120 static INLINE__ osal_void hmac_tx_mgmt_get_txop_para(hmac_vap_stru *hmac_vap,
121     hal_tx_txop_alg_stru **txop_alg, const mac_tx_ctl_stru *tx_ctl)
122 {
123     if (tx_ctl->ismcast == OSAL_TRUE) {
124         /* 获取组播、广播管理帧 发送参数 */
125         *txop_alg = &(hmac_vap->tx_mgmt_bmcast[hmac_vap->channel.band]);
126     } else {
127         /* 获取单播 管理帧 发送参数 */
128         *txop_alg = &(hmac_vap->tx_mgmt_ucast[hmac_vap->channel.band]);
129     }
130 }
131 
132 osal_u32 hmac_tx_update_protection_txop_alg(hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user,
133     hal_tx_txop_alg_stru *txop_alg, osal_u8 do_default_cfg);
134 osal_u32 hmac_tx_process_data(hal_to_dmac_device_stru *hal_device, hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf);
135 
136 osal_void hmac_tx_send_mpdu(hmac_vap_stru *hmac_vap, hcc_msg_type type,
137     oal_netbuf_stru *net_buffer, osal_u8 mpdu_num);
138 osal_void hmac_tx_data_send(hmac_tx_data_stat_stru *tx_data, oal_netbuf_head_stru *buff_head);
139 osal_void hmac_tx_fill_first_cb_info(mac_tx_ctl_stru *tx_ctl, hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user);
140 #ifdef __cplusplus
141 #if __cplusplus
142 }
143 #endif
144 #endif
145 
146 #endif
147