Skip to content

Commit f330fda

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: header pad field only valid for AP->modem endpoint
Only QMAP endpoints should be configured to find a pad size field within packet headers. They are found in the first byte of the QMAP header (and the hardware fills only the 6 bits in that byte that constitute the pad_len field). The RMNet driver assumes the pad_len field is valid for received packets, so we want to ensure the pad_len field is filled in that case. That driver also assumes the length in the QMAP header includes the pad bytes. The RMNet driver does *not* pad the packets it sends, so the pad_len field can be ignored. Fix ipa_endpoint_init_hdr_ext() so it only marks the pad field offset valid for QMAP RX endpoints, and in that case indicates that the length field in the header includes the pad bytes. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 636edea commit f330fda

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

drivers/net/ipa/ipa_endpoint.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint)
467467
header_size += sizeof(struct rmnet_map_ul_csum_header);
468468
val |= u32_encode_bits(header_size, HDR_LEN_FMASK);
469469

470-
/* Define how to fill mux_id in a received QMAP header */
470+
/* Define how to fill fields in a received QMAP header */
471471
if (!endpoint->toward_ipa) {
472472
u32 off; /* Field offset within header */
473473

@@ -499,10 +499,21 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint)
499499
u32 val = 0;
500500

501501
val |= HDR_ENDIANNESS_FMASK; /* big endian */
502-
val |= HDR_TOTAL_LEN_OR_PAD_VALID_FMASK;
503-
/* HDR_TOTAL_LEN_OR_PAD is 0 (pad, not total_len) */
502+
503+
/* A QMAP header contains a 6 bit pad field at offset 0. The RMNet
504+
* driver assumes this field is meaningful in packets it receives,
505+
* and assumes the header's payload length includes that padding.
506+
* The RMNet driver does *not* pad packets it sends, however, so
507+
* the pad field (although 0) should be ignored.
508+
*/
509+
if (endpoint->data->qmap && !endpoint->toward_ipa) {
510+
val |= HDR_TOTAL_LEN_OR_PAD_VALID_FMASK;
511+
/* HDR_TOTAL_LEN_OR_PAD is 0 (pad, not total_len) */
512+
val |= HDR_PAYLOAD_LEN_INC_PADDING_FMASK;
513+
/* HDR_TOTAL_LEN_OR_PAD_OFFSET is 0 */
514+
}
515+
504516
/* HDR_PAYLOAD_LEN_INC_PADDING is 0 */
505-
/* HDR_TOTAL_LEN_OR_PAD_OFFSET is 0 */
506517
if (!endpoint->toward_ipa)
507518
val |= u32_encode_bits(pad_align, HDR_PAD_TO_ALIGNMENT_FMASK);
508519

0 commit comments

Comments
 (0)