Skip to contentSkip to conversation

net: ipa: pass checksum trailer with received packets

PATCH In review Alex Elder 1 participant 2 messages Feb 10, 2021 – Feb 11, 2021

Subsystems (3)
lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 net: ipa: pass checksum trailer with received packets

For a QMAP RX endpoint, received packets will be passed to the RMNet driver. If RX checksum offload is enabled, the RMNet driver expects to find a trailer following each packet that contains computed checksum information. Currently the IPA driver is passing the packet without the trailer.

Fix this bug.

Fixes 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")

---

David/Jakub,
I would like to have this back-ported as bug fix. At its core, the fix is simple, but even if it were reduced to a one-line change, the result won't cleanly apply to both net/master and net-next/master. How should this be handled? What can I do to make it easier?

Thanks.

-Alex

 drivers/net/ipa/ipa_endpoint.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/ipa/ipa_endpoint.c +10 -5
index 7209ee3c31244..5e3c2b3f38a95 100644
@@ -1232,6 +1232,11 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
 	void *data = page_address(page) + NET_SKB_PAD;
 	u32 unused = IPA_RX_BUFFER_SIZE - total_len;
 	u32 resid = total_len;
+	u32 trailer_len = 0;
+
+	/* If checksum offload is enabled, each packet includes a trailer */
+	if (endpoint->data->checksum)
+		trailer_len = sizeof(struct rmnet_map_dl_csum_trailer);
 
 	while (resid) {
 		const struct ipa_status *status = data;
@@ -1260,18 +1265,18 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
 		 */
 		align = endpoint->data->rx.pad_align ? : 1;
 		len = le16_to_cpu(status->pkt_len);
-		len = sizeof(*status) + ALIGN(len, align);
-		if (endpoint->data->checksum)
-			len += sizeof(struct rmnet_map_dl_csum_trailer);
+		len = sizeof(*status) + ALIGN(len, align) + trailer_len;
 
 		if (!ipa_endpoint_status_drop(endpoint, status)) {
 			void *data2;
 			u32 extra;
 			u32 len2;
 
-			/* Client receives only packet data (no status) */
+			/* Strip off the status element and pass only the
+			 * packet data (plus checksum trailer if enabled).
+			 */
 			data2 = data + sizeof(*status);
-			len2 = le16_to_cpu(status->pkt_len);
+			len2 = le16_to_cpu(status->pkt_len) + trailer_len;
 
 			/* Have the true size reflect the extra unused space in
 			 * the original receive buffer.  Distribute the "cost"
Signature · 1 line
2.20.1
author
#1 lore raw
Quoted 10 lines · Alex Elder

For a QMAP RX endpoint, received packets will be passed to the RMNet driver. If RX checksum offload is enabled, the RMNet driver expects to find a trailer following each packet that contains computed checksum information. Currently the IPA driver is passing the packet without the trailer.

Fix this bug.

Fixes 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")

I want to give this patch a little more thought.

In the end it's not that critical (this is not in the normal RX completion data path), and the way things are currently configured we won't have checksum offload enabled for the receiving endpoint anyway.

    --> So I WITHDRAW this patch. <--

I don't think the patch is wrong, but I'm going to avoid the backport hassle, and wait to address the issue until it really matters.

Thanks.

-Alex

Quoted 56 lines

---

David/Jakub,
I would like to have this back-ported as bug fix. At its core, the fix is simple, but even if it were reduced to a one-line change, the result won't cleanly apply to both net/master and net-next/master. How should this be handled? What can I do to make it easier?

Thanks.

-Alex

  drivers/net/ipa/ipa_endpoint.c | 15 ++++++++++-----
  1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/ipa/ipa_endpoint.c +10 -5
index 7209ee3c31244..5e3c2b3f38a95 100644
@@ -1232,6 +1232,11 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
  	void *data = page_address(page) + NET_SKB_PAD;
  	u32 unused = IPA_RX_BUFFER_SIZE - total_len;
  	u32 resid = total_len;
+	u32 trailer_len = 0;
+
+	/* If checksum offload is enabled, each packet includes a trailer */
+	if (endpoint->data->checksum)
+		trailer_len = sizeof(struct rmnet_map_dl_csum_trailer);
 
  	while (resid) {
  		const struct ipa_status *status = data;
@@ -1260,18 +1265,18 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
  		 */
  		align = endpoint->data->rx.pad_align ? : 1;
  		len = le16_to_cpu(status->pkt_len);
-		len = sizeof(*status) + ALIGN(len, align);
-		if (endpoint->data->checksum)
-			len += sizeof(struct rmnet_map_dl_csum_trailer);
+		len = sizeof(*status) + ALIGN(len, align) + trailer_len;
 
  		if (!ipa_endpoint_status_drop(endpoint, status)) {
  			void *data2;
  			u32 extra;
  			u32 len2;
 
-			/* Client receives only packet data (no status) */
+			/* Strip off the status element and pass only the
+			 * packet data (plus checksum trailer if enabled).
+			 */
  			data2 = data + sizeof(*status);
-			len2 = le16_to_cpu(status->pkt_len);
+			len2 = le16_to_cpu(status->pkt_len) + trailer_len;
 
  			/* Have the true size reflect the extra unused space in
  			 * the original receive buffer.  Distribute the "cost"