hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/******************************************************************************
 *
 * Copyright(c) 2019 Realtek Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 ******************************************************************************/
 
#include "hwamsdu.h"
 
#if MAC_AX_FW_REG_OFLD
u32 mac_enable_cut_hwamsdu(struct mac_ax_adapter *adapter,
              u8 enable,
              u8 low_th,
              u16 high_th,
              enum mac_ax_ex_shift aligned)
{
   u32 ret = 0;
   struct h2c_info h2c_info = {0};
   struct mac_ax_en_amsdu_cut *content;
 
   if (chk_patch_cut_amsdu_rls_ple_issue(adapter) == (u32)PATCH_ENABLE)
       return MACNOTSUP;
 
   h2c_info.agg_en = 0;
   h2c_info.content_len = sizeof(struct fwcmd_shcut_update);
   h2c_info.h2c_cat = FWCMD_H2C_CAT_MAC;
   h2c_info.h2c_class = FWCMD_H2C_CL_FW_OFLD;
   h2c_info.h2c_func = FWCMD_H2C_FUNC_AMSDU_CUT_REG;
   h2c_info.rec_ack = 0;
   h2c_info.done_ack = 1;
 
   content = (struct mac_ax_en_amsdu_cut *)PLTFM_MALLOC(h2c_info.content_len);
   if (!content)
       return MACBUFALLOC;
   content->enable = enable;
   content->low_th = low_th;
   content->high_th = high_th;
   content->aligned = aligned;
 
   ret = mac_h2c_common(adapter, &h2c_info, (u32 *)content);
 
   PLTFM_FREE(content, h2c_info.content_len);
 
   return ret;
}
 
u32 mac_enable_hwmasdu(struct mac_ax_adapter *adapter,
              u8 enable,
              enum mac_ax_amsdu_pkt_num max_num,
              u8 en_single_amsdu,
              u8 en_last_amsdu_padding)
 
{
   u32 ret = 0;
   struct h2c_info h2c_info = {0};
   struct mac_ax_en_hwamsdu *content;
 
   if (chk_patch_txamsdu_rls_wd_issue(adapter) == (u32)PATCH_ENABLE)
       return MACNOTSUP;
 
   h2c_info.agg_en = 0;
   h2c_info.content_len = sizeof(struct fwcmd_shcut_update);
   h2c_info.h2c_cat = FWCMD_H2C_CAT_MAC;
   h2c_info.h2c_class = FWCMD_H2C_CL_FW_OFLD;
   h2c_info.h2c_func = FWCMD_H2C_FUNC_HWAMSDU_REG;
   h2c_info.rec_ack = 0;
   h2c_info.done_ack = 1;
 
   content = (struct mac_ax_en_hwamsdu *)PLTFM_MALLOC(h2c_info.content_len);
   if (!content)
       return MACBUFALLOC;
   content->enable = enable;
   content->max_num = max_num;
   content->en_single_amsdu = en_single_amsdu;
   content->en_last_amsdu_padding = en_last_amsdu_padding;
 
   ret = mac_h2c_common(adapter, &h2c_info, (u32 *)content);
 
   PLTFM_FREE(content, h2c_info.content_len);
 
   return ret;
}
#else
 
u32 mac_enable_hwamsdu(struct mac_ax_adapter *adapter,
              u8 enable,
              enum mac_ax_amsdu_pkt_num max_num,
              u8 en_single_amsdu,
              u8 en_last_amsdu_padding)
{
   u32 val;
   struct mac_ax_intf_ops *ops = adapter_to_intf_ops(adapter);
 
   if (chk_patch_txamsdu_rls_wd_issue(adapter) == (u32)PATCH_ENABLE)
       return MACNOTSUP;
 
   if (max_num >= MAC_AX_AMSDU_AGG_NUM_MAX)
       return MACNOITEM;
 
   //HW AMSDU register
   val = MAC_REG_R32(R_AX_HWAMSDU_CTRL);
   val = (SET_CLR_WORD(val, max_num, B_AX_MAX_AMSDU_NUM) |
          B_AX_HWAMSDU_EN);
   if (!enable)
       val &= ~B_AX_HWAMSDU_EN;
   MAC_REG_W32(R_AX_HWAMSDU_CTRL, val);
 
   MAC_REG_W32(R_AX_HWAMSDU_CTRL, (MAC_REG_R32(R_AX_HWAMSDU_CTRL) &
           (~B_AX_SINGLE_AMSDU)) |
           (en_single_amsdu ? B_AX_SINGLE_AMSDU : 0));
 
   MAC_REG_W32(R_AX_DMAC_TABLE_CTRL, (MAC_REG_R32(R_AX_DMAC_TABLE_CTRL) &
           (~B_AX_HWAMSDU_PADDING_MODE)) |
           (en_last_amsdu_padding ? B_AX_HWAMSDU_PADDING_MODE : 0));
 
   return MACSUCCESS;
}
#endif
 
u32 mac_hwamsdu_fwd_search_en(struct mac_ax_adapter *adapter, u8 enable)
{
   u32 val;
   struct mac_ax_intf_ops *ops = adapter_to_intf_ops(adapter);
 
   if (is_chip_id(adapter, MAC_AX_CHIP_ID_8852C) ||
       is_chip_id(adapter, MAC_AX_CHIP_ID_8192XB) ||
       is_chip_id(adapter, MAC_AX_CHIP_ID_8851E) ||
       is_chip_id(adapter, MAC_AX_CHIP_ID_8852D)) {
       val = MAC_REG_R32(R_AX_HWAMSDU_CTRL);
       if (!enable)
           val &= ~B_AX_AMSDU_FS_ENABLE;
       else
           val |= B_AX_AMSDU_FS_ENABLE;
 
       MAC_REG_W32(R_AX_HWAMSDU_CTRL, val);
       return MACSUCCESS;
   } else {
       return MACNOTSUP;
   }
}
 
u32 mac_hwamsdu_macid_en(struct mac_ax_adapter *adapter, u8 macid, u8 enable)
{
   struct mac_ax_dctl_info info = {0};
   struct mac_ax_dctl_info mask = {0};
   struct mac_ax_ops *ops = adapter_to_mac_ops(adapter);
   u32 ret = 0;
 
   info.sta_amsdu_en = enable;
   mask.sta_amsdu_en = HW_AMSDU_MACID_ENABLE;
   ret = ops->upd_dctl_info(adapter, &info, &mask, macid, 1);
 
   return ret;
}
 
u8 mac_hwamsdu_get_macid_en(struct mac_ax_adapter *adapter, u8 macid)
{
   struct mac_ax_dctl_info info = {0};
   struct mac_ax_dctl_info mask = {0};
   struct mac_ax_ops *ops = adapter_to_mac_ops(adapter);
   u32 ret = 0;
 
   mask.sta_amsdu_en = HW_AMSDU_MACID_ENABLE;
   ret = ops->upd_dctl_info(adapter, &info, &mask, macid, 0);
 
   if (ret != MACSUCCESS)
       return 0;
   else
       return (u8)info.sta_amsdu_en;
}
 
u32 mac_hwamsdu_max_len(struct mac_ax_adapter *adapter, u8 macid, u8 amsdu_max_len)
{
   struct mac_ax_dctl_info info = {0};
   struct mac_ax_dctl_info mask = {0};
   struct mac_ax_ops *ops = adapter_to_mac_ops(adapter);
   u32 ret = 0;
 
   info.amsdu_max_length = amsdu_max_len;
   mask.amsdu_max_length = FWCMD_H2C_DCTRL_AMSDU_MAX_LEN_MSK;
   ret = ops->upd_dctl_info(adapter, &info, &mask, macid, 1);
 
   return ret;
}
 
u8 mac_hwamsdu_get_max_len(struct mac_ax_adapter *adapter, u8 macid)
{
   struct mac_ax_dctl_info info = {0};
   struct mac_ax_dctl_info mask = {0};
   struct mac_ax_ops *ops = adapter_to_mac_ops(adapter);
   u32 ret = 0;
 
   mask.amsdu_max_length = FWCMD_H2C_DCTRL_AMSDU_MAX_LEN_MSK;
   ret = ops->upd_dctl_info(adapter, &info, &mask, macid, 0);
 
   if (ret != MACSUCCESS)
       return 0;
   else
       return (u8)info.amsdu_max_length;
}