ath11k_dp_rx_h_csum_offload() marks every received MSDU CHECKSUM_UNNECESSARY unless the attention TLV reports an IP or TCP/UDP checksum failure. Those bits report a checksum the hardware computed and found wrong, so both are also clear for a frame whose transport checksum it never computed: any protocol other than TCP and UDP, such as ICMP, ICMPv6 or GRE, and a TCP or UDP frame whose headers it did not parse within the first 256 bytes. An IP fragment carries only part of the datagram its checksum covers. The descriptor also describes only the MSDU the hardware received. A frame that ath11k_dp_rx_h_defrag() reassembles from 802.11 fragments keeps the descriptor of its first fragment, of which only the MSDU length is rewritten, so the flags say nothing about the payload of the later fragments. With raw decap (frame_mode=0 or crypto_mode=1) an A-MSDU reaches mac80211 as one MPDU; when it spans several RX buffers and ath11k_dp_rx_msdu_coalesce() moves it into a larger buffer, ieee80211_amsdu_to_8023s() hands that skb, ip_summed included, to the last subframe. The stack then skips the checks it would make: icmp_rcv() takes the checksum as verified, and reassembly keeps CHECKSUM_UNNECESSARY when every fragment carries it, so a UDP datagram that arrives in IP fragments is never checked. By the code this holds for every ath11k chip and frame mode and for any frame an associated peer sends. The MSDU start TLV carries the flags that say what the hardware parsed: TCP, UDP, IP fragment, and whether the fixed IP header and the TCP/UDP header were parsed. Mark a frame CHECKSUM_UNNECESSARY only when it is TCP or UDP, not a fragment, and both headers were parsed, and never for a reassembled 802.11 frame or a raw A-MSDU; ath10k_htt_rx_get_csum_state() already leaves a frame that is neither TCP nor UDP to the stack. The flags sit in a different descriptor layout on each chip family, so add a hw_ops accessor for the MSDU start word that holds them. Found by an LLM review (Claude) of the code. Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Julius Bairaktaris --- v2: also leave a frame reassembled from 802.11 fragments and a raw A-MSDU to the stack (Sashiko); discovery line reworded. drivers/net/wireless/ath/ath11k/dp_rx.c | 61 ++++++++++++++++++++++++- drivers/net/wireless/ath/ath11k/hw.c | 22 +++++++++ drivers/net/wireless/ath/ath11k/hw.h | 1 + 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 6d95f7b343a5..a2c359cc8e92 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -1860,18 +1860,75 @@ static struct sk_buff *ath11k_dp_rx_get_msdu_last_buf(struct sk_buff_head *msdu_ return NULL; } +static bool ath11k_dp_rx_h_is_raw_amsdu(struct ath11k_base *ab, + struct sk_buff *msdu) +{ + struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; + + if (ath11k_dp_rx_h_msdu_start_decap_type(ab, rxcb->rx_desc) != + DP_RX_DECAP_TYPE_RAW) + return false; + + /* + * Neither an MPDU the hardware delivered as several MSDUs nor a frame + * too short to tell is taken as a single MSDU. + */ + if (!rxcb->is_first_msdu || !rxcb->is_last_msdu) + return true; + + if (msdu->len < sizeof(hdr->frame_control)) + return true; + + if (!ieee80211_is_data_qos(hdr->frame_control)) + return false; + + if (msdu->len < ieee80211_hdrlen(hdr->frame_control)) + return true; + + return *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_A_MSDU_PRESENT; +} + static void ath11k_dp_rx_h_csum_offload(struct ath11k *ar, struct sk_buff *msdu) { struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); struct rx_attention *rx_attention; bool ip_csum_fail, l4_csum_fail; + u32 info2; rx_attention = ath11k_dp_rx_get_attention(ar->ab, rxcb->rx_desc); ip_csum_fail = ath11k_dp_rx_h_attn_ip_cksum_fail(rx_attention); l4_csum_fail = ath11k_dp_rx_h_attn_l4_cksum_fail(rx_attention); + info2 = ar->ab->hw_params.hw_ops->rx_desc_get_msdu_start_info2(rxcb->rx_desc); + + msdu->ip_summed = CHECKSUM_NONE; + + /* + * The descriptor describes one MSDU as the hardware received it. A + * frame reassembled from 802.11 fragments keeps the descriptor of its + * first fragment, and mac80211 splits a raw A-MSDU into subframes the + * descriptor does not describe one by one. + */ + if (rxcb->is_frag || ath11k_dp_rx_h_is_raw_amsdu(ar->ab, msdu)) + return; + + if (ip_csum_fail || l4_csum_fail) + return; + + /* + * The failure bits only report a checksum the hardware computed, so + * they are also clear for a frame it did not check. It checks the + * TCP or UDP checksum of a frame whose IP and TCP/UDP headers it + * parsed; an IP fragment does not carry the whole datagram the + * checksum covers. + */ + if (!(info2 & (RX_MSDU_START_INFO2_TCP | RX_MSDU_START_INFO2_UDP)) || + (info2 & RX_MSDU_START_INFO2_IP_FRAG) || + !(info2 & RX_MSDU_START_INFO2_IP_FIXED_HDR_VALID) || + !(info2 & RX_MSDU_START_INFO2_IP_TCP_UDP_HDR_VALID)) + return; - msdu->ip_summed = (ip_csum_fail || l4_csum_fail) ? - CHECKSUM_NONE : CHECKSUM_UNNECESSARY; + msdu->ip_summed = CHECKSUM_UNNECESSARY; } int ath11k_dp_rx_crypto_mic_len(struct ath11k *ar, enum hal_encrypt_type enctype) diff --git a/drivers/net/wireless/ath/ath11k/hw.c b/drivers/net/wireless/ath/ath11k/hw.c index 93f9a03c48dc..096366b85849 100644 --- a/drivers/net/wireless/ath/ath11k/hw.c +++ b/drivers/net/wireless/ath/ath11k/hw.c @@ -272,6 +272,11 @@ static u8 ath11k_hw_ipq8074_rx_desc_get_decap_type(struct hal_rx_desc *desc) __le32_to_cpu(desc->u.ipq8074.msdu_start.info2)); } +static u32 ath11k_hw_ipq8074_rx_desc_get_msdu_start_info2(struct hal_rx_desc *desc) +{ + return __le32_to_cpu(desc->u.ipq8074.msdu_start.info2); +} + static u8 ath11k_hw_ipq8074_rx_desc_get_mesh_ctl(struct hal_rx_desc *desc) { return FIELD_GET(RX_MSDU_START_INFO2_MESH_CTRL_PRESENT, @@ -449,6 +454,11 @@ static u8 ath11k_hw_qcn9074_rx_desc_get_decap_type(struct hal_rx_desc *desc) __le32_to_cpu(desc->u.qcn9074.msdu_start.info2)); } +static u32 ath11k_hw_qcn9074_rx_desc_get_msdu_start_info2(struct hal_rx_desc *desc) +{ + return __le32_to_cpu(desc->u.qcn9074.msdu_start.info2); +} + static u8 ath11k_hw_qcn9074_rx_desc_get_mesh_ctl(struct hal_rx_desc *desc) { return FIELD_GET(RX_MSDU_START_INFO2_MESH_CTRL_PRESENT, @@ -626,6 +636,11 @@ static u8 ath11k_hw_wcn6855_rx_desc_get_decap_type(struct hal_rx_desc *desc) __le32_to_cpu(desc->u.wcn6855.msdu_start.info2)); } +static u32 ath11k_hw_wcn6855_rx_desc_get_msdu_start_info2(struct hal_rx_desc *desc) +{ + return __le32_to_cpu(desc->u.wcn6855.msdu_start.info2); +} + static u8 ath11k_hw_wcn6855_rx_desc_get_mesh_ctl(struct hal_rx_desc *desc) { return FIELD_GET(RX_MSDU_START_INFO2_MESH_CTRL_PRESENT, @@ -914,6 +929,7 @@ const struct ath11k_hw_ops ipq8074_ops = { .rx_desc_get_encrypt_type = ath11k_hw_ipq8074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_ipq8074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_ipq8074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_ipq8074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_ipq8074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_ipq8074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_ipq8074_rx_desc_get_mpdu_fc_valid, @@ -954,6 +970,7 @@ const struct ath11k_hw_ops ipq6018_ops = { .rx_desc_get_encrypt_type = ath11k_hw_ipq8074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_ipq8074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_ipq8074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_ipq8074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_ipq8074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_ipq8074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_ipq8074_rx_desc_get_mpdu_fc_valid, @@ -994,6 +1011,7 @@ const struct ath11k_hw_ops qca6390_ops = { .rx_desc_get_encrypt_type = ath11k_hw_ipq8074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_ipq8074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_ipq8074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_ipq8074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_ipq8074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_ipq8074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_ipq8074_rx_desc_get_mpdu_fc_valid, @@ -1034,6 +1052,7 @@ const struct ath11k_hw_ops qcn9074_ops = { .rx_desc_get_encrypt_type = ath11k_hw_qcn9074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_qcn9074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_qcn9074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_qcn9074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_qcn9074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_qcn9074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_qcn9074_rx_desc_get_mpdu_fc_valid, @@ -1074,6 +1093,7 @@ const struct ath11k_hw_ops wcn6855_ops = { .rx_desc_get_encrypt_type = ath11k_hw_wcn6855_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_wcn6855_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_wcn6855_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_wcn6855_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_wcn6855_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_wcn6855_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_wcn6855_rx_desc_get_mpdu_fc_valid, @@ -1114,6 +1134,7 @@ const struct ath11k_hw_ops wcn6750_ops = { .rx_desc_get_encrypt_type = ath11k_hw_qcn9074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_qcn9074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_qcn9074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_qcn9074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_qcn9074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_qcn9074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_qcn9074_rx_desc_get_mpdu_fc_valid, @@ -1155,6 +1176,7 @@ const struct ath11k_hw_ops ipq5018_ops = { .rx_desc_get_encrypt_type = ath11k_hw_qcn9074_rx_desc_get_encrypt_type, .rx_desc_get_decap_type = ath11k_hw_qcn9074_rx_desc_get_decap_type, .rx_desc_get_mesh_ctl = ath11k_hw_qcn9074_rx_desc_get_mesh_ctl, + .rx_desc_get_msdu_start_info2 = ath11k_hw_qcn9074_rx_desc_get_msdu_start_info2, .rx_desc_get_ldpc_support = ath11k_hw_qcn9074_rx_desc_get_ldpc_support, .rx_desc_get_mpdu_seq_ctl_vld = ath11k_hw_qcn9074_rx_desc_get_mpdu_seq_ctl_vld, .rx_desc_get_mpdu_fc_valid = ath11k_hw_qcn9074_rx_desc_get_mpdu_fc_valid, diff --git a/drivers/net/wireless/ath/ath11k/hw.h b/drivers/net/wireless/ath/ath11k/hw.h index 4996536fbd14..8725e119707b 100644 --- a/drivers/net/wireless/ath/ath11k/hw.h +++ b/drivers/net/wireless/ath/ath11k/hw.h @@ -249,6 +249,7 @@ struct ath11k_hw_ops { u32 (*rx_desc_get_encrypt_type)(struct hal_rx_desc *desc); u8 (*rx_desc_get_decap_type)(struct hal_rx_desc *desc); u8 (*rx_desc_get_mesh_ctl)(struct hal_rx_desc *desc); + u32 (*rx_desc_get_msdu_start_info2)(struct hal_rx_desc *desc); bool (*rx_desc_get_ldpc_support)(struct hal_rx_desc *desc); bool (*rx_desc_get_mpdu_seq_ctl_vld)(struct hal_rx_desc *desc); bool (*rx_desc_get_mpdu_fc_valid)(struct hal_rx_desc *desc); -- 2.53.0