• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 /* ****************************************************************************
20   1 头文件包含
21 **************************************************************************** */
22 #include "oal_ext_if.h"
23 #include "hmac_ext_if.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30 
31 #ifdef _PRE_WLAN_FEATURE_FLOWCTL
32 
33 /* ****************************************************************************
34   2 全局变量定义
35 **************************************************************************** */
36 /* ****************************************************************************
37   3 函数实现
38 **************************************************************************** */
39 /* ****************************************************************************
40  函 数 名  : wal_netdev_select_queue
41  功能描述  : kernel给skb选择合适的tx subqueue;
42  输入参数  :
43  输出参数  : 无
44  返 回 值  : 无
45  调用函数  :
46  被调函数  :
47 
48  修改历史      :
49   1.日    期   : 2014年3月4日
50     作    者   : HiSilicon
51     修改内容   : 新生成函数
52 
53 **************************************************************************** */
wal_netdev_select_queue(oal_net_device_stru * netdev,oal_netbuf_stru * netbuf,hi_void * accel_priv,select_queue_fallback_t fallback)54 hi_u16 wal_netdev_select_queue(oal_net_device_stru *netdev, oal_netbuf_stru *netbuf, hi_void *accel_priv,
55     select_queue_fallback_t fallback)
56 {
57     oal_ether_header_stru   *ether_header   = HI_NULL;
58     mac_vap_stru            *mac_vap            = HI_NULL;
59     hi_u8                assoc_id        = 0;
60     hi_u8                tos             = 0;
61     hi_u8                ac;
62     hi_u16               us_subq;
63     hi_u32               ret;
64 
65     /* 获取以太网头 */
66     ether_header = (oal_ether_header_stru *)oal_netbuf_data(netbuf);
67 
68     mac_vap = (mac_vap_stru *)oal_net_dev_priv(netdev);
69     /* 没有用户限速,则全部入index = 0 的subq, 并直接返回 */
70     if (mac_vap->has_user_bw_limit == HI_FALSE) {
71         return 0;
72     }
73 
74     ret = mac_vap_find_user_by_macaddr(mac_vap, ether_header->auc_ether_dhost, ETHER_ADDR_LEN, &assoc_id);
75     if (ret != HI_SUCCESS) {
76         /* 没有找到用户的报文,均统一放入subq = 0的队列中 */
77         oam_info_log0(mac_vap->vap_id, OAM_SF_ANY, "{mac_vap_find_user_by_macaddr::failed!}\r\n");
78         return 0;
79     }
80 
81     /* 获取skb的tos字段 */
82     oal_netbuf_get_txtid(netbuf, &tos);
83 
84     /* 根据tos字段选择合适的队列 */
85     ac = mac_tos_to_subq(tos);
86 
87     us_subq = (hi_u16)((assoc_id * WAL_NETDEV_SUBQUEUE_PER_USE) + ac);
88     if (us_subq >= WAL_NETDEV_SUBQUEUE_MAX_NUM) {
89         return 0;
90     }
91     return us_subq;
92 }
93 
94 /* ****************************************************************************
95  函 数 名  : wal_flowctl_backp_event_handler
96  功能描述  : stop或者wake某个用户的某个subqueue
97  输入参数  :
98  输出参数  : 无
99  返 回 值  : 无
100  调用函数  :
101  被调函数  :
102 
103  修改历史      :
104   1.日    期   : 2014年3月4日
105     作    者   : HiSilicon
106     修改内容   : 新生成函数
107 
108 **************************************************************************** */
wal_flowctl_backp_event_handler(frw_event_mem_stru * event_mem)109 hi_u32 wal_flowctl_backp_event_handler(frw_event_mem_stru *event_mem)
110 {
111     frw_event_stru             *event               = (frw_event_stru *)event_mem->puc_data;
112     mac_ioctl_queue_backp_stru *flowctl_backp_event = (mac_ioctl_queue_backp_stru *)(event->auc_event_data);
113     hi_u8                       vap_id              = flowctl_backp_event->vap_id;
114 
115     /* 获取net_device */
116     oal_net_device_stru *netdev = hmac_vap_get_net_device(vap_id);
117     if (netdev == HI_NULL) {
118         oam_error_log0(vap_id, OAM_SF_ANY, "{wal_flowctl_backp_event_handler::failed!}\r\n");
119         return HI_ERR_CODE_PTR_NULL;
120     }
121 
122     /* 如果对整个VAP stop或者wake */
123     if (flowctl_backp_event->us_assoc_id == 0xFFFF) {
124         if (flowctl_backp_event->is_stop == 1) {
125             oal_net_tx_stop_all_queues(netdev);
126         } else {
127             oal_net_tx_wake_all_queues();
128         }
129         oam_info_log3(vap_id, OAM_SF_ANY,
130             "{wal_flowctl_backp_event_handler::oal_net_tx_queues,stop_flag=%d,vap_id=%d,assoc_id=%d,tid=%d}",
131             flowctl_backp_event->is_stop, flowctl_backp_event->vap_id, flowctl_backp_event->us_assoc_id,
132             flowctl_backp_event->tidno);
133 
134         return HI_SUCCESS;
135     }
136 
137     /* 如果对某个user stop或者wake */
138     if (flowctl_backp_event->tidno == WLAN_TID_MAX_NUM) {
139         for (hi_u8 ac = 0; ac <= MAC_LINUX_SUBQ_VO; ac++) {
140             if (flowctl_backp_event->is_stop == 1) {
141                 oal_net_stop_subqueue(netdev);
142             } else {
143                 oal_net_wake_subqueue(netdev);
144             }
145             oam_info_log3(vap_id, OAM_SF_ANY,
146                 "{wal_flowctl_backp_event_handler::oal_net_subqueue,stop=%d,vap_id=%d,assoc_id=%d,tid=%d}",
147                 flowctl_backp_event->is_stop, flowctl_backp_event->vap_id, flowctl_backp_event->us_assoc_id,
148                 flowctl_backp_event->tidno);
149         }
150         return HI_SUCCESS;
151     }
152 
153     if (flowctl_backp_event->is_stop == 1) {
154         oal_net_stop_subqueue(netdev);
155     } else {
156         oal_net_wake_subqueue(netdev);
157     }
158     oam_info_log3(vap_id, OAM_SF_ANY,
159         "{wal_flowctl_backp_event_handler::oal_net_subqueue,stop_flag=%d,vap_id=%d,assoc_id=%d,tid=%d}",
160         flowctl_backp_event->is_stop, flowctl_backp_event->vap_id, flowctl_backp_event->us_assoc_id,
161         flowctl_backp_event->tidno);
162 
163     return HI_SUCCESS;
164 }
165 
166 #endif /* endif of _PRE_WLAN_FEATURE_FLOWCTL */
167 #ifdef _PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL
168 /* ****************************************************************************
169  函 数 名  : wal_netdev_select_queue
170  功能描述  : kernel给skb选择合适的tx subqueue;
171  输入参数  :
172  输出参数  : 无
173  返 回 值  : 无
174  调用函数  :
175  被调函数  :
176 
177  修改历史      :
178   1.日    期   : 2015年3月17日
179     作    者   : HiSilicon
180     修改内容   : 新生成函数
181 
182 **************************************************************************** */
wal_netdev_select_queue(oal_net_device_stru * netdev,oal_netbuf_stru * netbuf,hi_void * accel_priv,select_queue_fallback_t fallback)183 hi_u16 wal_netdev_select_queue(oal_net_device_stru *netdev, oal_netbuf_stru *netbuf, hi_void *accel_priv,
184     select_queue_fallback_t fallback)
185 {
186     return oal_netbuf_select_queue(netbuf);
187 }
188 
189 #endif /* endif of _PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL */
190 
191 #ifdef __cplusplus
192 #if __cplusplus
193 }
194 #endif
195 #endif
196