Skip to content

Commit aa2092a

Browse files
Venkateswara NaralasettyKalle Valo
authored andcommitted
ath11k: add raw mode and software crypto support
Adding raw mode tx/rx support. Also, adding support for software crypto which depends on raw mode. To enable raw mode tx/rx: insmod ath11k.ko frame_mode=0 To enable software crypto: insmod ath11k.ko crypto_mode=1 These modes could be helpful in debugging crypto related issues. Tested-on: IPQ8074 WLAN.HK.2.1.0.1-01228-QCAHKSWPL_SILICONZ-1 Signed-off-by: Manikanta Pubbisetty <[email protected]> Signed-off-by: Venkateswara Naralasetty <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/010101746c6a52d9-18302a2c-0d6d-4057-aa4b-95960c809646-000000@us-west-2.amazonses.com
1 parent b129699 commit aa2092a

File tree

7 files changed

+91
-22
lines changed

7 files changed

+91
-22
lines changed

drivers/net/wireless/ath/ath11k/core.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ EXPORT_SYMBOL(ath11k_debug_mask);
1818
module_param_named(debug_mask, ath11k_debug_mask, uint, 0644);
1919
MODULE_PARM_DESC(debug_mask, "Debugging mask");
2020

21+
static unsigned int ath11k_crypto_mode;
22+
module_param_named(crypto_mode, ath11k_crypto_mode, uint, 0644);
23+
MODULE_PARM_DESC(crypto_mode, "crypto mode: 0-hardware, 1-software");
24+
25+
/* frame mode values are mapped as per enum ath11k_hw_txrx_mode */
26+
unsigned int ath11k_frame_mode = ATH11K_HW_TXRX_NATIVE_WIFI;
27+
module_param_named(frame_mode, ath11k_frame_mode, uint, 0644);
28+
MODULE_PARM_DESC(frame_mode,
29+
"Datapath frame mode (0: raw, 1: native wifi (default), 2: ethernet)");
30+
2131
static const struct ath11k_hw_params ath11k_hw_params[] = {
2232
{
2333
.hw_rev = ATH11K_HW_IPQ8074,
@@ -617,6 +627,23 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
617627
return ret;
618628
}
619629

630+
switch (ath11k_crypto_mode) {
631+
case ATH11K_CRYPT_MODE_SW:
632+
set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
633+
set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
634+
break;
635+
case ATH11K_CRYPT_MODE_HW:
636+
clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
637+
clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
638+
break;
639+
default:
640+
ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode);
641+
return -EINVAL;
642+
}
643+
644+
if (ath11k_frame_mode == ATH11K_HW_TXRX_RAW)
645+
set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
646+
620647
mutex_lock(&ab->core_lock);
621648
ret = ath11k_core_start(ab, ATH11K_FIRMWARE_MODE_NORMAL);
622649
if (ret) {

drivers/net/wireless/ath/ath11k/core.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#define ATH11K_INVALID_HW_MAC_ID 0xFF
3737

38+
extern unsigned int ath11k_frame_mode;
39+
3840
enum ath11k_supported_bw {
3941
ATH11K_BW_20 = 0,
4042
ATH11K_BW_40 = 1,
@@ -54,6 +56,13 @@ enum wme_ac {
5456
#define ATH11K_VHT_MCS_MAX 9
5557
#define ATH11K_HE_MCS_MAX 11
5658

59+
enum ath11k_crypt_mode {
60+
/* Only use hardware crypto engine */
61+
ATH11K_CRYPT_MODE_HW,
62+
/* Only use software crypto */
63+
ATH11K_CRYPT_MODE_SW,
64+
};
65+
5766
static inline enum wme_ac ath11k_tid_to_ac(u32 tid)
5867
{
5968
return (((tid == 0) || (tid == 3)) ? WME_AC_BE :

drivers/net/wireless/ath/ath11k/debug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum ath11k_debug_mask {
2626
ATH11K_DBG_TESTMODE = 0x00000400,
2727
ATH11k_DBG_HAL = 0x00000800,
2828
ATH11K_DBG_PCI = 0x00001000,
29+
ATH11K_DBG_DP_TX = 0x00001000,
30+
ATH11K_DBG_DP_RX = 0x00002000,
2931
ATH11K_DBG_ANY = 0xffffffff,
3032
};
3133

drivers/net/wireless/ath/ath11k/dp_rx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,8 +2133,6 @@ static void ath11k_dp_rx_h_mpdu(struct ath11k *ar,
21332133
mcast = is_multicast_ether_addr(hdr->addr1);
21342134
fill_crypto_hdr = mcast;
21352135

2136-
is_decrypted = ath11k_dp_rx_h_attn_is_decrypted(rx_desc);
2137-
21382136
spin_lock_bh(&ar->ab->base_lock);
21392137
peer = ath11k_peer_find_by_addr(ar->ab, hdr->addr2);
21402138
if (peer) {
@@ -2148,6 +2146,8 @@ static void ath11k_dp_rx_h_mpdu(struct ath11k *ar,
21482146
spin_unlock_bh(&ar->ab->base_lock);
21492147

21502148
err_bitmap = ath11k_dp_rx_h_attn_mpdu_err(rx_desc);
2149+
if (enctype != HAL_ENCRYPT_TYPE_OPEN && !err_bitmap)
2150+
is_decrypted = ath11k_dp_rx_h_attn_is_decrypted(rx_desc);
21512151

21522152
/* Clear per-MPDU flags while leaving per-PPDU flags intact */
21532153
rx_status->flag &= ~(RX_FLAG_FAILED_FCS_CRC |
@@ -2350,6 +2350,9 @@ static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *nap
23502350
!!(status->flag & RX_FLAG_MMIC_ERROR),
23512351
!!(status->flag & RX_FLAG_AMSDU_MORE));
23522352

2353+
ath11k_dbg_dump(ar->ab, ATH11K_DBG_DP_RX, NULL, "dp rx msdu: ",
2354+
msdu->data, msdu->len);
2355+
23532356
/* TODO: trace rx packet */
23542357

23552358
ieee80211_rx_napi(ar->hw, NULL, msdu, napi);

drivers/net/wireless/ath/ath11k/dp_tx.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ static enum hal_tcl_encap_type
1313
ath11k_dp_tx_get_encap_type(struct ath11k_vif *arvif, struct sk_buff *skb)
1414
{
1515
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
16+
struct ath11k_base *ab = arvif->ar->ab;
17+
18+
if (test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags))
19+
return HAL_TCL_ENCAP_TYPE_RAW;
1620

1721
if (tx_info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP)
1822
return HAL_TCL_ENCAP_TYPE_ETHERNET;
@@ -79,6 +83,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
7983
struct ath11k_dp *dp = &ab->dp;
8084
struct hal_tx_info ti = {0};
8185
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
86+
struct ieee80211_key_conf *key = info->control.hw_key;
8287
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb);
8388
struct hal_srng *tcl_ring;
8489
struct ieee80211_hdr *hdr = (void *)skb->data;
@@ -142,11 +147,17 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
142147
ti.encap_type = ath11k_dp_tx_get_encap_type(arvif, skb);
143148
ti.meta_data_flags = arvif->tcl_metadata;
144149

145-
if (info->control.hw_key)
146-
ti.encrypt_type =
147-
ath11k_dp_tx_get_encrypt_type(info->control.hw_key->cipher);
148-
else
149-
ti.encrypt_type = HAL_ENCRYPT_TYPE_OPEN;
150+
if (ti.encap_type == HAL_TCL_ENCAP_TYPE_RAW) {
151+
if (key) {
152+
ti.encrypt_type =
153+
ath11k_dp_tx_get_encrypt_type(key->cipher);
154+
155+
if (ieee80211_has_protected(hdr->frame_control))
156+
skb_put(skb, IEEE80211_CCMP_MIC_LEN);
157+
} else {
158+
ti.encrypt_type = HAL_ENCRYPT_TYPE_OPEN;
159+
}
160+
}
150161

151162
ti.addr_search_flags = arvif->hal_addr_search_flags;
152163
ti.search_type = arvif->search_type;
@@ -156,7 +167,8 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
156167
ti.bss_ast_hash = arvif->ast_hash;
157168
ti.dscp_tid_tbl_idx = 0;
158169

159-
if (skb->ip_summed == CHECKSUM_PARTIAL) {
170+
if (skb->ip_summed == CHECKSUM_PARTIAL &&
171+
ti.encap_type != HAL_TCL_ENCAP_TYPE_RAW) {
160172
ti.flags0 |= FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_IP4_CKSUM_EN, 1) |
161173
FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_UDP4_CKSUM_EN, 1) |
162174
FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_UDP6_CKSUM_EN, 1) |
@@ -176,10 +188,11 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
176188
ath11k_dp_tx_encap_nwifi(skb);
177189
break;
178190
case HAL_TCL_ENCAP_TYPE_RAW:
179-
/* TODO: for CHECKSUM_PARTIAL case in raw mode, HW checksum offload
180-
* is not applicable, hence manual checksum calculation using
181-
* skb_checksum_help() is needed
182-
*/
191+
if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) {
192+
ret = -EINVAL;
193+
goto fail_remove_idr;
194+
}
195+
break;
183196
case HAL_TCL_ENCAP_TYPE_ETHERNET:
184197
/* no need to encap */
185198
break;
@@ -242,6 +255,9 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
242255

243256
spin_unlock_bh(&tcl_ring->lock);
244257

258+
ath11k_dbg_dump(ab, ATH11K_DBG_DP_TX, NULL, "dp tx msdu: ",
259+
skb->data, skb->len);
260+
245261
atomic_inc(&ar->dp.num_tx_pending);
246262

247263
return 0;
@@ -352,7 +368,6 @@ ath11k_dp_tx_process_htt_tx_complete(struct ath11k_base *ab,
352368

353369
wbm_status = FIELD_GET(HTT_TX_WBM_COMP_INFO0_STATUS,
354370
status_desc->info0);
355-
356371
switch (wbm_status) {
357372
case HAL_WBM_REL_HTT_TX_COMP_STATUS_OK:
358373
case HAL_WBM_REL_HTT_TX_COMP_STATUS_DROP:

drivers/net/wireless/ath/ath11k/mac.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@
4242
.max_power = 30, \
4343
}
4444

45-
/* frame mode values are mapped as per enum ath11k_hw_txrx_mode */
46-
static unsigned int ath11k_frame_mode = ATH11K_HW_TXRX_NATIVE_WIFI;
47-
module_param_named(frame_mode, ath11k_frame_mode, uint, 0644);
48-
MODULE_PARM_DESC(frame_mode,
49-
"Datapath frame mode (0: raw, 1: native wifi (default), 2: ethernet)");
50-
5145
static const struct ieee80211_channel ath11k_2ghz_channels[] = {
5246
CHAN2G(1, 2412, 0),
5347
CHAN2G(2, 2417, 0),
@@ -2405,6 +2399,9 @@ static int ath11k_install_key(struct ath11k_vif *arvif,
24052399

24062400
reinit_completion(&ar->install_key_done);
24072401

2402+
if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags))
2403+
return 0;
2404+
24082405
if (cmd == DISABLE_KEY) {
24092406
/* TODO: Check if FW expects value other than NONE for del */
24102407
/* arg.key_cipher = WMI_CIPHER_NONE; */
@@ -2436,8 +2433,13 @@ static int ath11k_install_key(struct ath11k_vif *arvif,
24362433
return -EOPNOTSUPP;
24372434
}
24382435

2436+
if (test_bit(ATH11K_FLAG_RAW_MODE, &ar->ab->dev_flags))
2437+
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV |
2438+
IEEE80211_KEY_FLAG_RESERVE_TAILROOM;
2439+
24392440
install:
24402441
ret = ath11k_wmi_vdev_install_key(arvif->ar, &arg);
2442+
24412443
if (ret)
24422444
return ret;
24432445

@@ -2509,6 +2511,9 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
25092511
key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
25102512
return 1;
25112513

2514+
if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags))
2515+
return 1;
2516+
25122517
if (key->keyidx > WMI_MAX_KEY_INDEX)
25132518
return -ENOSPC;
25142519

@@ -4461,6 +4466,8 @@ static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw,
44614466

44624467
if (ieee80211_set_hw_80211_encap(vif, hw_encap))
44634468
param_value = ATH11K_HW_TXRX_ETHERNET;
4469+
else if (test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags))
4470+
param_value = ATH11K_HW_TXRX_RAW;
44644471
else
44654472
param_value = ATH11K_HW_TXRX_NATIVE_WIFI;
44664473

@@ -6134,7 +6141,6 @@ static int __ath11k_mac_register(struct ath11k *ar)
61346141
ieee80211_hw_set(ar->hw, HAS_RATE_CONTROL);
61356142
ieee80211_hw_set(ar->hw, AP_LINK_PS);
61366143
ieee80211_hw_set(ar->hw, SPECTRUM_MGMT);
6137-
ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
61386144
ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
61396145
ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
61406146
ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
@@ -6201,8 +6207,11 @@ static int __ath11k_mac_register(struct ath11k *ar)
62016207

62026208
ath11k_reg_init(ar);
62036209

6204-
/* advertise HW checksum offload capabilities */
6205-
ar->hw->netdev_features = NETIF_F_HW_CSUM;
6210+
if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) {
6211+
ar->hw->netdev_features = NETIF_F_HW_CSUM;
6212+
ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL);
6213+
ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
6214+
}
62066215

62076216
ret = ieee80211_register_hw(ar->hw);
62086217
if (ret) {

drivers/net/wireless/ath/ath11k/wmi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,10 @@ int ath11k_wmi_cmd_init(struct ath11k_base *ab)
33663366
config.rx_timeout_pri[2] = TARGET_RX_TIMEOUT_LO_PRI;
33673367
config.rx_timeout_pri[3] = TARGET_RX_TIMEOUT_HI_PRI;
33683368
config.rx_decap_mode = TARGET_DECAP_MODE_NATIVE_WIFI;
3369+
3370+
if (test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags))
3371+
config.rx_decap_mode = TARGET_DECAP_MODE_RAW;
3372+
33693373
config.scan_max_pending_req = TARGET_SCAN_MAX_PENDING_REQS;
33703374
config.bmiss_offload_max_vdev = TARGET_BMISS_OFFLOAD_MAX_VDEV;
33713375
config.roam_offload_max_vdev = TARGET_ROAM_OFFLOAD_MAX_VDEV;

0 commit comments

Comments
 (0)