Skip to contentSkip to conversation

net: qualcomm: rmnet: Enable csum offloads

PATCH Superseded Subash Abhinov Kasiviswanathan 2 participants 15 messages Jan 3, 2018 – Jan 4, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover net: qualcomm: rmnet: Enable csum offloads

This series introduces the MAPv4 packet format for checksum offload plus some other minor changes.

Patches 1-3 are cleanups.

Patch 4 renames the ingress format to data format so that all data formats can be configured using this going forward.

Patch 5 uses the pacing helper to improve TCP transmit performance.

Patch 6-9 defines the the MAPv4 for checksum offload for RX and TX. A new header and trailer format are used as part of MAPv4. For RX checksum offload, only the 1's complement of the IP payload portion is computed by hardware. The meta data from RX header is used to verify the checksum field in the packet. Note that the IP packet and its field itself is not modified by hardware. This gives metadata to help with the RX checksum. For TX, the required metadata is filled up so hardware can compute the checksum.

Patch 10 enables GSO on rmnet devices

v1->v2: Fix sparse errors reported by kbuild test robot

Subash Abhinov Kasiviswanathan (10):
net: qualcomm: rmnet: Remove redundant check when stamping map header
net: qualcomm: rmnet: Remove invalid condition while stamping mux id
net: qualcomm: rmnet: Remove unused function declaration
net: qualcomm: rmnet: Rename ingress data format to data format
net: qualcomm: rmnet: Set pacing rate
net: qualcomm: rmnet: Define the MAPv4 packet formats
net: qualcomm: rmnet: Add support for RX checksum offload
net: qualcomm: rmnet: Handle command packets with checksum trailer
net: qualcomm: rmnet: Add support for TX checksum offload
net: qualcomm: rmnet: Add support for GSO

 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c |  10 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h |   2 +-
 .../net/ethernet/qualcomm/rmnet/rmnet_handlers.c   |  36 ++-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h    |  23 +-
 .../ethernet/qualcomm/rmnet/rmnet_map_command.c    |  17 +-
 .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c   | 309 ++++++++++++++++++++-
 .../net/ethernet/qualcomm/rmnet/rmnet_private.h    |   2 +
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c    |   4 +
 8 files changed, 378 insertions(+), 25 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/10 net: qualcomm: rmnet: Remove redundant check when stamping map header

We already check the headroom once in rmnet_map_egress_handler(), so this is not needed.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +0 -3
index 86b8c75..978ce26 100644
@@ -32,9 +32,6 @@ struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
 	u32 padding, map_datalen;
 	u8 *padbytes;
 
-	if (skb_headroom(skb) < sizeof(struct rmnet_map_header))
-		return NULL;
-
 	map_datalen = skb->len - hdrlen;
 	map_header = (struct rmnet_map_header *)
 			skb_push(skb, sizeof(struct rmnet_map_header));
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/10 net: qualcomm: rmnet: Remove invalid condition while stamping mux id

In reply to Subash Abhinov Kasiviswanathan

rmnet devices cannot have a mux id of 255. This is validated when assigning the mux id to the rmnet devices. As a result, checking for mux id 255 does not apply in egress path.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -4
index 0553932..b2d317e3 100644
@@ -143,10 +143,7 @@ static int rmnet_map_egress_handler(struct sk_buff *skb,
 	if (!map_header)
 		goto fail;
 
-	if (mux_id == 0xff)
-		map_header->mux_id = 0;
-	else
-		map_header->mux_id = mux_id;
+	map_header->mux_id = mux_id;
 
 	skb->protocol = htons(ETH_P_MAP);
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/10 net: qualcomm: rmnet: Remove unused function declaration

In reply to Subash Abhinov Kasiviswanathan

rmnet_map_demultiplex() is only declared but not defined anywhere, so remove it.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +0 -1
index 4df359d..ef0eff2 100644
@@ -67,7 +67,6 @@ struct rmnet_map_header {
 #define RMNET_MAP_NO_PAD_BYTES        0
 #define RMNET_MAP_ADD_PAD_BYTES       1
 
-u8 rmnet_map_demultiplex(struct sk_buff *skb);
 struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb);
 struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
 						  int hdrlen, int pad);
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/10 net: qualcomm: rmnet: Rename ingress data format to data format

In reply to Subash Abhinov Kasiviswanathan

This is done so that we can use this field for both ingress and egress flags.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c   | 10 +++++-----
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h   |  2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c |  5 ++---
 3 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +5 -5
index cedacdd..7e7704d 100644
@@ -143,7 +143,7 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
 			 struct nlattr *tb[], struct nlattr *data[],
 			 struct netlink_ext_ack *extack)
 {
-	int ingress_format = RMNET_INGRESS_FORMAT_DEAGGREGATION;
+	u32 data_format = RMNET_INGRESS_FORMAT_DEAGGREGATION;
 	struct net_device *real_dev;
 	int mode = RMNET_EPMODE_VND;
 	struct rmnet_endpoint *ep;
@@ -185,11 +185,11 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
 		struct ifla_vlan_flags *flags;
 
 		flags = nla_data(data[IFLA_VLAN_FLAGS]);
-		ingress_format = flags->flags & flags->mask;
+		data_format = flags->flags & flags->mask;
 	}
 
-	netdev_dbg(dev, "data format [ingress 0x%08X]\n", ingress_format);
-	port->ingress_data_format = ingress_format;
+	netdev_dbg(dev, "data format [0x%08X]\n", data_format);
+	port->data_format = data_format;
 
 	return 0;
 
@@ -353,7 +353,7 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
 		struct ifla_vlan_flags *flags;
 
 		flags = nla_data(data[IFLA_VLAN_FLAGS]);
-		port->ingress_data_format = flags->flags & flags->mask;
+		port->data_format = flags->flags & flags->mask;
 	}
 
 	return 0;
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +1 -1
index 2ea9fe3..00e4634 100644
@@ -32,7 +32,7 @@ struct rmnet_endpoint {
  */
 struct rmnet_port {
 	struct net_device *dev;
-	u32 ingress_data_format;
+	u32 data_format;
 	u8 nr_rmnet_devs;
 	u8 rmnet_mode;
 	struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +2 -3
index b2d317e3..8e1f43a 100644
@@ -69,8 +69,7 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 	u16 len;
 
 	if (RMNET_MAP_GET_CD_BIT(skb)) {
-		if (port->ingress_data_format
-		    & RMNET_INGRESS_FORMAT_MAP_COMMANDS)
+		if (port->data_format & RMNET_INGRESS_FORMAT_MAP_COMMANDS)
 			return rmnet_map_command(skb, port);
 
 		goto free_skb;
@@ -114,7 +113,7 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 		skb_push(skb, ETH_HLEN);
 	}
 
-	if (port->ingress_data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
+	if (port->data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
 		while ((skbn = rmnet_map_deaggregate(skb)) != NULL)
 			__rmnet_map_ingress_handler(skbn, port);
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 5/10 net: qualcomm: rmnet: Set pacing rate

In reply to Subash Abhinov Kasiviswanathan

With a default pacing rate of 10, the uplink data rate for a single TCP stream is around 10Mbps. Setting it to 8 increases it to 146Mbps which is the maximum supported transmit rate.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +3 -0
index 8e1f43a..8f8c4f2 100644
@@ -16,6 +16,7 @@
 #include <linux/netdevice.h>
 #include <linux/netdev_features.h>
 #include <linux/if_arp.h>
+#include <net/sock.h>
 #include "rmnet_private.h"
 #include "rmnet_config.h"
 #include "rmnet_vnd.h"
@@ -204,6 +205,8 @@ void rmnet_egress_handler(struct sk_buff *skb)
 	struct rmnet_priv *priv;
 	u8 mux_id;
 
+	sk_pacing_shift_update(skb->sk, 8);
+
 	orig_dev = skb->dev;
 	priv = netdev_priv(orig_dev);
 	skb->dev = priv->real_dev;
Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH net-next v2 05/10] net: qualcomm: rmnet: Set pacing rate

Quoted 22 lines · Subash Abhinov Kasiviswanathan

With a default pacing rate of 10, the uplink data rate for a single TCP stream is around 10Mbps. Setting it to 8 increases it to 146Mbps which is the maximum supported transmit rate.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -0
index 8e1f43a..8f8c4f2 100644
@@ -16,6 +16,7 @@
 #include <linux/netdevice.h>
 #include <linux/netdev_features.h>
 #include <linux/if_arp.h>
+#include <net/sock.h>
 #include "rmnet_private.h"
 #include "rmnet_config.h"
 #include "rmnet_vnd.h"

drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c void rmnet_egress_handler(struct sk_buff *skb) · line 208

Quoted 4 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -0
@@ -204,6 +205,8 @@ void rmnet_egress_handler(struct sk_buff *skb)
 	struct rmnet_priv *priv;
 	u8 mux_id;
 
+	sk_pacing_shift_update(skb->sk, 8);

Well... Please tell us why this is needed in this driver.

This interface is meant for wifi aggregation, not to work around some strange ethernet drivers designs.

#7 lore raw

Re: [PATCH net-next v2 05/10] net: qualcomm: rmnet: Set pacing rate

Quoted 6 lines

drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c void rmnet_egress_handler(struct sk_buff *skb) · line 208

Quoted 1 line
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -0
+	sk_pacing_shift_update(skb->sk, 8);

Well... Please tell us why this is needed in this driver.

This interface is meant for wifi aggregation, not to work around some strange ethernet drivers designs.

Hi Eric

The real device over which the rmnet devices are installed also aggregate multiple IP packets and sends them as a single large aggregate frame to the hardware.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#8 lore raw

Re: [PATCH net-next v2 05/10] net: qualcomm: rmnet: Set pacing rate

Quoted 4 lines · Subash Abhinov Kasiviswanathan
Quoted 4 lines

drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c void rmnet_egress_handler(struct sk_buff *skb) · line 208

Quoted 1 line
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -0
+	sk_pacing_shift_update(skb->sk, 8);

Well... Please tell us why this is needed in this driver.

Quoted 8 lines
Quoted 2 lines

This interface is meant for wifi aggregation, not to work around some strange ethernet drivers designs.

Hi Eric

The real device over which the rmnet devices are installed also aggregate multiple IP packets and sends them as a single large aggregate frame to the hardware.

It would be nice to give some details about this in the changelog.

Also what results you get with different values for the shift (10, 9,
8)

My fear is that people might be tempted to blindly use the sk_pacing_shift_update() just because a single TCP flow gets 'better' results.

bufferbloat is a serious issue, we do not want to allow a single TCP flow to fill a fifo.

Otherwise, we could remove TCP Small queues overhead from the kernel and be happy.

Thanks.

#9 lore raw

Re: [PATCH net-next v2 05/10] net: qualcomm: rmnet: Set pacing rate

Quoted 13 lines
Quoted 3 lines

The real device over which the rmnet devices are installed also aggregate multiple IP packets and sends them as a single large aggregate frame to the hardware.

It would be nice to give some details about this in the changelog.

Also what results you get with different values for the shift (10, 9,
8)

My fear is that people might be tempted to blindly use the sk_pacing_shift_update() just because a single TCP flow gets 'better' results.

Quoted 7 lines

bufferbloat is a serious issue, we do not want to allow a single TCP flow to fill a fifo.

Otherwise, we could remove TCP Small queues overhead from the kernel and be happy.

Thanks.

The test was run with iperf single stream TCP TX for a duration of 30s.

Pacing shift | Observed data rate (Mbps)
          10 | 9
          9  | 140
          8  | 146

I will update all of this in the commit text in v3.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#10 lore raw

PATCH v2 6/10 net: qualcomm: rmnet: Define the MAPv4 packet formats

In reply to Subash Abhinov Kasiviswanathan

The MAPv4 packet format adds support for RX / TX checksum offload. For a bi-directional UDP stream at a rate of 570 / 146 Mbps, roughly 10% CPU cycles are saved.

For receive path, there is a checksum trailer appended to the end of the MAP packet. The valid field indicates if hardware has computed the checksum. csum_start_offset indicates the offset from the start of the IP header from which hardware has computed checksum. csum_length is the number of bytes over which the checksum was computed and the resulting value is csum_value.

In the transmit path, a header is appended between the end of the MAP header and the start of the IP packet. csum_start_offset is the offset in bytes from which hardware will compute the checksum if the csum_enabled bit is set. udp_ip4_ind indicates if the checksum value of 0 is valid or not. csum_insert_offset is the offset from the csum_start_offset where hardware will insert the computed checksum.

The use of this additional packet format for checksum offload is explained in subsequent patches.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h     | 16 ++++++++++++++++
 drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h |  2 ++
 2 files changed, 18 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +16 -0
index ef0eff2..50c50cd 100644
@@ -47,6 +47,22 @@ struct rmnet_map_header {
 	u16 pkt_len;
 }  __aligned(1);
 
+struct rmnet_map_dl_csum_trailer {
+	u8  reserved1;
+	u8  valid:1;
+	u8  reserved2:7;
+	u16 csum_start_offset;
+	u16 csum_length;
+	__be16 csum_value;
+} __aligned(1);
+
+struct rmnet_map_ul_csum_header {
+	__be16 csum_start_offset;
+	u16 csum_insert_offset:14;
+	u16 udp_ip4_ind:1;
+	u16 csum_enabled:1;
+} __aligned(1);
+
 #define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \
 				 (Y)->data)->mux_id)
 #define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \
drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h +2 -0
index d214280..de0143e 100644
@@ -21,6 +21,8 @@
 /* Constants */
 #define RMNET_INGRESS_FORMAT_DEAGGREGATION      BIT(0)
 #define RMNET_INGRESS_FORMAT_MAP_COMMANDS       BIT(1)
+#define RMNET_INGRESS_FORMAT_MAP_CKSUMV4        BIT(2)
+#define RMNET_EGRESS_FORMAT_MAP_CKSUMV4         BIT(3)
 
 /* Replace skb->dev to a virtual rmnet device and pass up the stack */
 #define RMNET_EPMODE_VND (1)
Signature · 1 line
1.9.1
#11 lore raw

PATCH v2 7/10 net: qualcomm: rmnet: Add support for RX checksum offload

In reply to Subash Abhinov Kasiviswanathan

When using the MAPv4 packet format, receive checksum offload can be enabled in hardware. The checksum computation over pseudo header is not offloaded but the rest of the checksum computation over the payload is offloaded. This applies only for TCP / UDP packets which are not fragmented.

rmnet validates the TCP/UDP checksum for the packet using the checksum from the checksum trailer added to the packet by hardware. The validation performed is as following -

1. Perform 1's complement over the checksum value from the trailer
2. Compute 1's complement checksum over IPv4 / IPv6 header and subtracts it from the value from step 1
3. Computes 1's complement checksum over IPv4 / IPv6 pseudo header and adds it to the value from step 2
4. Subtracts the checksum value from the TCP / UDP header from the value from step 3.
5. Compares the value from step 4 to the checksum value from the TCP / UDP header.
6. If the comparison in step 5 succeeds, CHECKSUM_UNNECESSARY is set and the packet is passed on to network stack. If there is a failure, then the packet is passed on as such without modifying the ip_summed field.

The checksum field is also checked for UDP checksum 0 as per RFC 768 and for unexpected TCP checksum of 0.

If checksum offload is disabled when using MAPv4 packet format in receive path, the packet is queued as is to network stack without the validations above.

---
 .../net/ethernet/qualcomm/rmnet/rmnet_handlers.c   |  15 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h    |   4 +-
 .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c   | 186 ++++++++++++++++++++-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c    |   2 +
 4 files changed, 201 insertions(+), 6 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +11 -4
index 8f8c4f2..3409458 100644
@@ -66,8 +66,8 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 			    struct rmnet_port *port)
 {
 	struct rmnet_endpoint *ep;
+	u16 len, pad;
 	u8 mux_id;
-	u16 len;
 
 	if (RMNET_MAP_GET_CD_BIT(skb)) {
 		if (port->data_format & RMNET_INGRESS_FORMAT_MAP_COMMANDS)
@@ -77,7 +77,8 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 	}
 
 	mux_id = RMNET_MAP_GET_MUX_ID(skb);
-	len = RMNET_MAP_GET_LENGTH(skb) - RMNET_MAP_GET_PAD(skb);
+	pad = RMNET_MAP_GET_PAD(skb);
+	len = RMNET_MAP_GET_LENGTH(skb) - pad;
 
 	if (mux_id >= RMNET_MAX_LOGICAL_EP)
 		goto free_skb;
@@ -90,8 +91,14 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 
 	/* Subtract MAP header */
 	skb_pull(skb, sizeof(struct rmnet_map_header));
-	skb_trim(skb, len);
 	rmnet_set_skb_proto(skb);
+
+	if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) {
+		if (!rmnet_map_checksum_downlink_packet(skb, len + pad))
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
+	}
+
+	skb_trim(skb, len);
 	rmnet_deliver_skb(skb);
 	return;
 
@@ -115,7 +122,7 @@ static void rmnet_set_skb_proto(struct sk_buff *skb)
 	}
 
 	if (port->data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
-		while ((skbn = rmnet_map_deaggregate(skb)) != NULL)
+		while ((skbn = rmnet_map_deaggregate(skb, port)) != NULL)
 			__rmnet_map_ingress_handler(skbn, port);
 
 		consume_skb(skb);
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +3 -1
index 50c50cd..ca9f473 100644
@@ -83,9 +83,11 @@ struct rmnet_map_ul_csum_header {
 #define RMNET_MAP_NO_PAD_BYTES        0
 #define RMNET_MAP_ADD_PAD_BYTES       1
 
-struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb);
+struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
+				      struct rmnet_port *port);
 struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
 						  int hdrlen, int pad);
 void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port);
+int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len);
 
 #endif /* _RMNET_MAP_H_ */
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +185 -1

213 lines not on this page · raw message

drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +2 -0
index 5bb29f4..879a2e0 100644
@@ -188,6 +188,8 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
 	if (rmnet_get_endpoint(port, id))
 		return -EBUSY;
 
+	rmnet_dev->hw_features = NETIF_F_RXCSUM;
+
 	rc = register_netdevice(rmnet_dev);
 	if (!rc) {
 		ep->egress_dev = rmnet_dev;
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 8/10 net: qualcomm: rmnet: Handle command packets with checksum trailer

In reply to Subash Abhinov Kasiviswanathan

When using the MAPv4 packet format in conjunction with MAP commands, a dummy DL checksum trailer will be appended to the packet. Before this packet is sent out as an ACK, the DL checksum trailer needs to be removed.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +15 -2
index 51e6049..6bc328f 100644
@@ -58,11 +58,24 @@ static u8 rmnet_map_do_flow_control(struct sk_buff *skb,
 }
 
 static void rmnet_map_send_ack(struct sk_buff *skb,
-			       unsigned char type)
+			       unsigned char type,
+			       struct rmnet_port *port)
 {
 	struct rmnet_map_control_command *cmd;
 	int xmit_status;
 
+	if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) {
+		if (skb->len < sizeof(struct rmnet_map_header) +
+		    RMNET_MAP_GET_LENGTH(skb) +
+		    sizeof(struct rmnet_map_dl_csum_trailer)) {
+			kfree_skb(skb);
+			return;
+		}
+
+		skb_trim(skb, skb->len -
+			 sizeof(struct rmnet_map_dl_csum_trailer));
+	}
+
 	skb->protocol = htons(ETH_P_MAP);
 
 	cmd = RMNET_MAP_GET_CMD_START(skb);
@@ -100,5 +113,5 @@ void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port)
 		break;
 	}
 	if (rc == RMNET_MAP_COMMAND_ACK)
-		rmnet_map_send_ack(skb, rc);
+		rmnet_map_send_ack(skb, rc, port);
 }
Signature · 1 line
1.9.1
#13 lore raw

PATCH v2 9/10 net: qualcomm: rmnet: Add support for TX checksum offload

In reply to Subash Abhinov Kasiviswanathan

TX checksum offload applies to TCP / UDP packets which are not fragmented using the MAPv4 checksum trailer. The following needs to be done to have checksum computed in hardware -

1. Set the checksum start offset and inset offset.
2. Set the csum_enabled bit
3. Compute and set 1's complement of partial checksum field in transport header.

---
 .../net/ethernet/qualcomm/rmnet/rmnet_handlers.c   |   8 ++
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h    |   2 +
 .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c   | 120 +++++++++++++++++++++
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c    |   1 +
 4 files changed, 131 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +8 -0
index 3409458..601edec 100644
@@ -141,11 +141,19 @@ static int rmnet_map_egress_handler(struct sk_buff *skb,
 	additional_header_len = 0;
 	required_headroom = sizeof(struct rmnet_map_header);
 
+	if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4) {
+		additional_header_len = sizeof(struct rmnet_map_ul_csum_header);
+		required_headroom += additional_header_len;
+	}
+
 	if (skb_headroom(skb) < required_headroom) {
 		if (pskb_expand_head(skb, required_headroom, 0, GFP_KERNEL))
 			goto fail;
 	}
 
+	if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4)
+		rmnet_map_checksum_uplink_packet(skb, orig_dev);
+
 	map_header = rmnet_map_add_map_header(skb, additional_header_len, 0);
 	if (!map_header)
 		goto fail;
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +2 -0
index ca9f473..6ce31e2 100644
@@ -89,5 +89,7 @@ struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
 						  int hdrlen, int pad);
 void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port);
 int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len);
+void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
+				      struct net_device *orig_dev);
 
 #endif /* _RMNET_MAP_H_ */
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +120 -0

129 lines not on this page · raw message

drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +1 -0
index 879a2e0..f7f57ce 100644
@@ -189,6 +189,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
 		return -EBUSY;
 
 	rmnet_dev->hw_features = NETIF_F_RXCSUM;
+	rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 
 	rc = register_netdevice(rmnet_dev);
 	if (!rc) {
Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 10/10 net: qualcomm: rmnet: Add support for GSO

In reply to Subash Abhinov Kasiviswanathan

Real devices may support scatter gather(SG), so enable SG on rmnet devices to use GSO. GSO reduces CPU cycles by 20% for a rate of 146Mpbs for a single stream TCP connection.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +1 -0
index f7f57ce..570a227 100644
@@ -190,6 +190,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
 
 	rmnet_dev->hw_features = NETIF_F_RXCSUM;
 	rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+	rmnet_dev->hw_features |= NETIF_F_SG;
 
 	rc = register_netdevice(rmnet_dev);
 	if (!rc) {
Signature · 1 line
1.9.1