* [PATCH net-next 0/2] net: ipa: IPA v4.5 inline checksum offload @ 2020-12-01 0:41 Alex Elder 2020-12-01 0:41 ` [PATCH net-next 1/2] if_rmnet.h: define struct rmnet_map_v5_csum_header Alex Elder 2020-12-01 0:41 ` [PATCH net-next 2/2] net: ipa: add support for inline checksum offload Alex Elder 0 siblings, 2 replies; 5+ messages in thread From: Alex Elder @ 2020-12-01 0:41 UTC (permalink / raw) To: davem, kuba, subashab Cc: evgreen, cpratapa, bjorn.andersson, netdev, linux-kernel This series includes one changed destined for a central header file and a second (dependent on the first) that applies to the IPA driver. If these should be posted a different way, please let me know. The first patch introduces a new data structure defining the format of a header that's used for "inline" checksum offload. Changes to the RMNet driver are required to fully support this feature, and those will be provided separately. The second patch implements changes to the IPA driver required to support inline checksum offload for IPA version 4.5. It uses only the *size* of the new data structure. -Alex Alex Elder (2): if_rmnet.h: define struct rmnet_map_v5_csum_header net: ipa: add support for inline checksum offload drivers/net/ipa/ipa_endpoint.c | 50 ++++++++++++++++++++++++++-------- drivers/net/ipa/ipa_reg.h | 1 + include/linux/if_rmnet.h | 30 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 11 deletions(-) -- 2.20.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/2] if_rmnet.h: define struct rmnet_map_v5_csum_header 2020-12-01 0:41 [PATCH net-next 0/2] net: ipa: IPA v4.5 inline checksum offload Alex Elder @ 2020-12-01 0:41 ` Alex Elder 2020-12-01 0:41 ` [PATCH net-next 2/2] net: ipa: add support for inline checksum offload Alex Elder 1 sibling, 0 replies; 5+ messages in thread From: Alex Elder @ 2020-12-01 0:41 UTC (permalink / raw) To: davem, kuba, subashab Cc: evgreen, cpratapa, bjorn.andersson, netdev, linux-kernel Define a new rmnet_map_v5_csum_header structure type. It will be used for inline checksum offload, supported with version 5 of the QMAP protocol. Signed-off-by: Alex Elder <elder@linaro.org> --- include/linux/if_rmnet.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index 9661416a9bb47..0fdda0e6e9963 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -52,4 +52,34 @@ struct rmnet_map_ul_csum_header { #endif } __aligned(1); + +/* Values for the header_type field of struct rmnet_map_v5_csum_header */ +enum rmnet_map_v5_header_type { + RMNET_MAP_HEADER_TYPE_UNKNOWN = 0x0, + RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, + RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, +}; + +/* QMAP v5 checksum offload header */ +struct rmnet_map_v5_csum_header { +#if defined(__LITTLE_ENDIAN_BITFIELD) + u8 next_hdr:1; + u8 header_type:7; + + u8 hw_reserved:5; + u8 priority:1; + u8 hw_reserved_bit:1; + u8 csum_valid_required:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + u8 header_type:7; + u8 next_hdr:1; + + u8 csum_valid_required:1; + u8 hw_reserved_bit:1; + u8 priority:1; + u8 hw_reserved:5; +#endif + __be16 reserved; +}; + #endif /* !(_LINUX_IF_RMNET_H_) */ -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] net: ipa: add support for inline checksum offload 2020-12-01 0:41 [PATCH net-next 0/2] net: ipa: IPA v4.5 inline checksum offload Alex Elder 2020-12-01 0:41 ` [PATCH net-next 1/2] if_rmnet.h: define struct rmnet_map_v5_csum_header Alex Elder @ 2020-12-01 0:41 ` Alex Elder 2020-12-02 2:13 ` Jakub Kicinski 1 sibling, 1 reply; 5+ messages in thread From: Alex Elder @ 2020-12-01 0:41 UTC (permalink / raw) To: davem, kuba Cc: evgreen, cpratapa, bjorn.andersson, subashab, netdev, linux-kernel Starting with IPA v4.5, IP payload checksum offload is implemented differently. Prior to v4.5, the IPA hardware appends an rmnet_map_dl_csum_trailer structure to each packet if checksum offload is enabled in the download direction (modem->AP). In the upload direction (AP->modem) a rmnet_map_ul_csum_header structure is prepended before each sent packet. Starting with IPA v4.5, checksum offload is implemented using a single new rmnet_map_v5_csum_header structure which sits between the QMAP header and the packet data. The same header structure is used in both directions. The new header contains a header type (CSUM_OFFLOAD); a checksum flag; and a flag indicating whether any other headers follow this one. The checksum flag indicates whether the hardware should compute (and insert) the checksum on a sent packet. On a received packet the checksum flag indicates whether the hardware confirms the checksum value in the payload is correct. To function, the rmnet driver must also add support for this new "inline" checksum offload. The changes implementing this will be submitted soon. Signed-off-by: Alex Elder <elder@linaro.org> --- drivers/net/ipa/ipa_endpoint.c | 50 ++++++++++++++++++++++++++-------- drivers/net/ipa/ipa_reg.h | 1 + 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 27f543b6780b1..1a4749f7f03e6 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -434,33 +434,63 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint) { u32 offset = IPA_REG_ENDP_INIT_CFG_N_OFFSET(endpoint->endpoint_id); + enum ipa_cs_offload_en enabled; u32 val = 0; /* FRAG_OFFLOAD_EN is 0 */ if (endpoint->data->checksum) { + enum ipa_version version = endpoint->ipa->version; + if (endpoint->toward_ipa) { u32 checksum_offset; - val |= u32_encode_bits(IPA_CS_OFFLOAD_UL, - CS_OFFLOAD_EN_FMASK); /* Checksum header offset is in 4-byte units */ checksum_offset = sizeof(struct rmnet_map_header); checksum_offset /= sizeof(u32); val |= u32_encode_bits(checksum_offset, CS_METADATA_HDR_OFFSET_FMASK); + + enabled = version < IPA_VERSION_4_5 + ? IPA_CS_OFFLOAD_UL + : IPA_CS_OFFLOAD_INLINE; } else { - val |= u32_encode_bits(IPA_CS_OFFLOAD_DL, - CS_OFFLOAD_EN_FMASK); + enabled = version < IPA_VERSION_4_5 + ? IPA_CS_OFFLOAD_DL + : IPA_CS_OFFLOAD_INLINE; } } else { - val |= u32_encode_bits(IPA_CS_OFFLOAD_NONE, - CS_OFFLOAD_EN_FMASK); + enabled = IPA_CS_OFFLOAD_NONE; } + val |= u32_encode_bits(enabled, CS_OFFLOAD_EN_FMASK); /* CS_GEN_QMB_MASTER_SEL is 0 */ iowrite32(val, endpoint->ipa->reg_virt + offset); } +static u32 +ipa_qmap_header_size(enum ipa_version version, struct ipa_endpoint *endpoint) +{ + u32 header_size = sizeof(struct rmnet_map_header); + + /* ipa_assert(endpoint->data->qmap); */ + + /* We might supply a checksum header after the QMAP header */ + if (endpoint->data->checksum) { + if (version < IPA_VERSION_4_5) { + size_t size = sizeof(struct rmnet_map_ul_csum_header); + + /* Checksum header inserted for AP TX endpoints */ + if (endpoint->toward_ipa) + header_size += size; + } else { + /* Checksum header is used in both directions */ + header_size += sizeof(struct rmnet_map_v5_csum_header); + } + } + + return header_size; +} + /** * ipa_endpoint_init_hdr() - Initialize HDR endpoint configuration register * @endpoint: Endpoint pointer @@ -489,13 +519,11 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) u32 val = 0; if (endpoint->data->qmap) { - size_t header_size = sizeof(struct rmnet_map_header); enum ipa_version version = ipa->version; + size_t header_size; - /* We might supply a checksum header after the QMAP header */ - if (endpoint->toward_ipa && endpoint->data->checksum) - header_size += sizeof(struct rmnet_map_ul_csum_header); - val |= ipa_header_size_encoded(version, header_size); + header_size = ipa_qmap_header_size(version, endpoint); + val = ipa_header_size_encoded(version, header_size); /* Define how to fill fields in a received QMAP header */ if (!endpoint->toward_ipa) { diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index 3fabafd7e32c6..6738cafe979ce 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -356,6 +356,7 @@ enum ipa_cs_offload_en { IPA_CS_OFFLOAD_NONE = 0x0, IPA_CS_OFFLOAD_UL = 0x1, IPA_CS_OFFLOAD_DL = 0x2, + IPA_CS_OFFLOAD_INLINE = 0x1, /* IPA v4.5 */ }; #define IPA_REG_ENDP_INIT_HDR_N_OFFSET(ep) \ -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net: ipa: add support for inline checksum offload 2020-12-01 0:41 ` [PATCH net-next 2/2] net: ipa: add support for inline checksum offload Alex Elder @ 2020-12-02 2:13 ` Jakub Kicinski 2020-12-02 13:24 ` Alex Elder 0 siblings, 1 reply; 5+ messages in thread From: Jakub Kicinski @ 2020-12-02 2:13 UTC (permalink / raw) To: Alex Elder Cc: davem, evgreen, cpratapa, bjorn.andersson, subashab, netdev, linux-kernel On Mon, 30 Nov 2020 18:41:43 -0600 Alex Elder wrote: > Starting with IPA v4.5, IP payload checksum offload is implemented > differently. > > Prior to v4.5, the IPA hardware appends an rmnet_map_dl_csum_trailer > structure to each packet if checksum offload is enabled in the > download direction (modem->AP). In the upload direction (AP->modem) > a rmnet_map_ul_csum_header structure is prepended before each sent > packet. > > Starting with IPA v4.5, checksum offload is implemented using a > single new rmnet_map_v5_csum_header structure which sits between > the QMAP header and the packet data. The same header structure > is used in both directions. > > The new header contains a header type (CSUM_OFFLOAD); a checksum > flag; and a flag indicating whether any other headers follow this > one. The checksum flag indicates whether the hardware should > compute (and insert) the checksum on a sent packet. On a received > packet the checksum flag indicates whether the hardware confirms the > checksum value in the payload is correct. > > To function, the rmnet driver must also add support for this new > "inline" checksum offload. The changes implementing this will be > submitted soon. We don't usually merge half of a feature. Why not wait until all support is in place? Do I understand right that it's rmnet that will push the csum header? This change seems to only reserve space for it and request the feature at init.. > diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c > index 27f543b6780b1..1a4749f7f03e6 100644 > --- a/drivers/net/ipa/ipa_endpoint.c > +++ b/drivers/net/ipa/ipa_endpoint.c > @@ -434,33 +434,63 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) > static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint) > { > u32 offset = IPA_REG_ENDP_INIT_CFG_N_OFFSET(endpoint->endpoint_id); > + enum ipa_cs_offload_en enabled; > u32 val = 0; > > /* FRAG_OFFLOAD_EN is 0 */ > if (endpoint->data->checksum) { > + enum ipa_version version = endpoint->ipa->version; > + > if (endpoint->toward_ipa) { > u32 checksum_offset; > > - val |= u32_encode_bits(IPA_CS_OFFLOAD_UL, > - CS_OFFLOAD_EN_FMASK); > /* Checksum header offset is in 4-byte units */ > checksum_offset = sizeof(struct rmnet_map_header); > checksum_offset /= sizeof(u32); > val |= u32_encode_bits(checksum_offset, > CS_METADATA_HDR_OFFSET_FMASK); > + > + enabled = version < IPA_VERSION_4_5 > + ? IPA_CS_OFFLOAD_UL > + : IPA_CS_OFFLOAD_INLINE; > } else { > - val |= u32_encode_bits(IPA_CS_OFFLOAD_DL, > - CS_OFFLOAD_EN_FMASK); > + enabled = version < IPA_VERSION_4_5 > + ? IPA_CS_OFFLOAD_DL > + : IPA_CS_OFFLOAD_INLINE; > } > } else { > - val |= u32_encode_bits(IPA_CS_OFFLOAD_NONE, > - CS_OFFLOAD_EN_FMASK); > + enabled = IPA_CS_OFFLOAD_NONE; > } > + val |= u32_encode_bits(enabled, CS_OFFLOAD_EN_FMASK); > /* CS_GEN_QMB_MASTER_SEL is 0 */ > > iowrite32(val, endpoint->ipa->reg_virt + offset); > } > > +static u32 > +ipa_qmap_header_size(enum ipa_version version, struct ipa_endpoint *endpoint) > +{ > + u32 header_size = sizeof(struct rmnet_map_header); > + > + /* ipa_assert(endpoint->data->qmap); */ > + > + /* We might supply a checksum header after the QMAP header */ > + if (endpoint->data->checksum) { > + if (version < IPA_VERSION_4_5) { > + size_t size = sizeof(struct rmnet_map_ul_csum_header); > + > + /* Checksum header inserted for AP TX endpoints */ > + if (endpoint->toward_ipa) > + header_size += size; > + } else { > + /* Checksum header is used in both directions */ > + header_size += sizeof(struct rmnet_map_v5_csum_header); > + } > + } > + > + return header_size; > +} ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net: ipa: add support for inline checksum offload 2020-12-02 2:13 ` Jakub Kicinski @ 2020-12-02 13:24 ` Alex Elder 0 siblings, 0 replies; 5+ messages in thread From: Alex Elder @ 2020-12-02 13:24 UTC (permalink / raw) To: Jakub Kicinski Cc: davem, evgreen, cpratapa, bjorn.andersson, subashab, netdev, linux-kernel On 12/1/20 8:13 PM, Jakub Kicinski wrote: >> To function, the rmnet driver must also add support for this new >> "inline" checksum offload. The changes implementing this will be >> submitted soon. > We don't usually merge half of a feature. Why not wait until all > support is in place? > > Do I understand right that it's rmnet that will push the csum header? > This change seems to only reserve space for it and request the feature > at init.. You are correct. The IPA hardware needs to be programmed to perform the computation and verify that the checksum in the header matches what it computes (for AP RX offload), or insert it into the header (for AP TX offload). That's what this patch handles. The RMNet driver is responsible for stripping the offload header off on RX, and acting on what it says (i.e., whether hardware is able to state the checksum is good). And on TX it inserts an offload header that says what to checksum and where to put it in the packet. It's totally fine not to merge this until we have the whole package ready, I understand. I'll see what I can do to get that done quickly. Thanks Jakub. -Alex ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-02 13:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-01 0:41 [PATCH net-next 0/2] net: ipa: IPA v4.5 inline checksum offload Alex Elder 2020-12-01 0:41 ` [PATCH net-next 1/2] if_rmnet.h: define struct rmnet_map_v5_csum_header Alex Elder 2020-12-01 0:41 ` [PATCH net-next 2/2] net: ipa: add support for inline checksum offload Alex Elder 2020-12-02 2:13 ` Jakub Kicinski 2020-12-02 13:24 ` Alex Elder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).