Skip to contentSkip to conversation

eHEA: Receive SKB Aggregation

PATCH Applied Jan-Bernd Themann 2 participants 4 messages Jul 5, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 eHEA: Receive SKB Aggregation

This patch enables the receive side processing to aggregate TCP packets within the HEA device driver. It analyses the packets already received after an interrupt arrived and forwards these as chains of SKBs for the same TCP connection with modified header field. We have seen a lower CPU load and improved throughput for small numbers of parallel TCP connections. As this feature is considered as experimental it is switched off by default and can be activated via a module parameter.

---
 drivers/net/ehea/ehea.h      |   30 ++++
 drivers/net/ehea/ehea_main.c |  324 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 348 insertions(+), 6 deletions(-)
drivers/net/ehea/ehea.h +30 -0
index f03f070..65e6c8e 100644
@@ -55,6 +55,7 @@
 #define EHEA_MAX_ENTRIES_RQ3 16383
 #define EHEA_MAX_ENTRIES_SQ  32767
 #define EHEA_MIN_ENTRIES_QP  127
+#define EHEA_LRO_MAX_PKTS 60
 
 #define EHEA_SMALL_QUEUES
 #define EHEA_NUM_TX_QP 1
@@ -84,6 +85,8 @@
 #define EHEA_RQ2_PKT_SIZE       1522
 #define EHEA_L_PKT_SIZE         256	/* low latency */
 
+#define MAX_LRO_DESCRIPTORS 8
+
 /* Send completion signaling */
 
 /* Protection Domain Identifier */
@@ -340,6 +343,29 @@ struct ehea_q_skb_arr {
 };
 
 /*
+ * Large Receive Offload (LRO) descriptor for a tcp session
+ */
+struct ehea_lro {
+	struct sk_buff *parent;
+	struct sk_buff *last_skb;
+	struct iphdr *iph;
+	struct tcphdr *tcph;
+
+	u32 tcp_rcv_tsecr;
+	u32 tcp_rcv_tsval;
+	u32 tcp_ack;
+	u32 tcp_next_seq;
+	u32 skb_tot_frags_len;
+	u16 ip_tot_len;
+	u16 tcp_saw_tstamp; 		/* timestamps enabled */
+	u16 tcp_window;
+	u16 vlan_tag;
+	int skb_sg_cnt;			/* counts aggregated skbs */
+	int vlan_packet;
+	int active;
+};
+
+/*
  * Port resources
  */
 struct ehea_port_res {
@@ -368,6 +394,9 @@ struct ehea_port_res {
 	u64 tx_packets;
 	u64 rx_packets;
 	u32 poll_counter;
+	struct ehea_lro lro[MAX_LRO_DESCRIPTORS];
+	u64 lro_desc;
+	struct port_stats p_state;
 };
 
 
@@ -417,6 +446,7 @@ struct ehea_port {
 	u32 msg_enable;
 	u32 sig_comp_iv;
 	u32 state;
+	u32 lro_max_aggr;
 	u8 full_duplex;
 	u8 autoneg;
 	u8 num_def_qps;
drivers/net/ehea/ehea_main.c +318 -6

393 lines not on this page · raw message

Signature · 1 line
1.5.2
#1 lore raw

Hi Jan-Bernd.

[ Dropped spambot/i.e. unrelated mail lists ]

Quoted 7 lines · Jan-Bernd Themann

This patch enables the receive side processing to aggregate TCP packets within the HEA device driver. It analyses the packets already received after an interrupt arrived and forwards these as chains of SKBs for the same TCP connection with modified header field. We have seen a lower CPU load and improved throughput for small numbers of parallel TCP connections. As this feature is considered as experimental it is switched off by default and can be activated via a module parameter.

I've couple of comments on the driver, but mainly the fact of decreased CPU usage itself - what was the magnitude of the win with this driver, it looks like because of per-packet receive code path invocation is the place of the latency...
Your implementation looks generic enough to be used by any driver, don't you want to push it separately from eHEA driver?

Quoted 22 lines
drivers/net/ehea/ehea_main.c +22 -0
+static int lro_tcp_check(struct iphdr *iph, struct tcphdr *tcph,
+			 int tcp_data_len, struct ehea_lro *lro)
+{
+	if (tcp_data_len == 0)
+		return -1;
+
+	if (iph->ihl != IPH_LEN_WO_OPTIONS)
+		return -1;
+
+	if (tcph->cwr || tcph->ece || tcph->urg || !tcph->ack || tcph->psh
+	    || tcph->rst || tcph->syn || tcph->fin)
+		return -1;
+
+	if (INET_ECN_is_ce(ipv4_get_dsfield(iph)))
+		return -1;
+
+	if (tcph->doff != TCPH_LEN_WO_OPTIONS
+	    && tcph->doff != TCPH_LEN_W_TIMESTAMP)
+		return -1;
+
+	/* check tcp options (only timestamp allowed) */
+	if (tcph->doff == TCPH_LEN_W_TIMESTAMP) {

drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, · line 467

Quoted 10 lines
drivers/net/ehea/ehea_main.c +10 -0
+		u32 *topt = (u32 *)(tcph + 1);
+
+		if (*topt != htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
+				   | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP))
+			return -1;
+
+		/* timestamp should be in right order */
+		topt++;
+		if (lro && (ntohl(lro->tcp_rcv_tsval) > ntohl(*topt)))
+			return -1;

This should use before/after technique like PAWS in TCP code or there will be a problem with wrapper timestamps.

Quoted 30 lines
drivers/net/ehea/ehea_main.c +30 -0
+
+		/* timestamp reply should not be zero */
+		topt++;
+		if (*topt == 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static void update_tcp_ip_header(struct ehea_lro *lro)
+{
+	struct iphdr *iph = lro->iph;
+	struct tcphdr *tcph = lro->tcph;
+	u32 *p;
+
+	tcph->ack_seq = lro->tcp_ack;
+	tcph->window = lro->tcp_window;
+
+	if (lro->tcp_saw_tstamp) {
+		p = (u32 *)(tcph + 1);
+		*(p+2) = lro->tcp_rcv_tsecr;
+	}
+
+	iph->tot_len = htons(lro->ip_tot_len);
+	iph->check = 0;
+	iph->check = ip_fast_csum((u8 *)lro->iph, iph->ihl);
+}
+
+static void init_lro_desc(struct ehea_lro *lro, struct ehea_cqe *cqe,

drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, · line 507

Quoted 10 lines
drivers/net/ehea/ehea_main.c +10 -0
+			  struct sk_buff *skb, struct iphdr *iph,
+			  struct tcphdr *tcph, u32 tcp_data_len)
+{
+	u32 *ptr;
+
+	lro->parent = skb;
+	lro->iph = iph;
+	lro->tcph = tcph;
+	lro->tcp_next_seq = ntohl(tcph->seq) + tcp_data_len;
+	lro->tcp_ack = ntohl(tcph->ack_seq);

How do you handle misordering or duplicate acks or resends?

Quoted 17 lines
drivers/net/ehea/ehea_main.c +17 -0
+	lro->skb_sg_cnt = 1;
+	lro->ip_tot_len = ntohs(iph->tot_len);
+
+	if (tcph->doff == 8) {
+		ptr = (u32 *)(tcph+1);
+		lro->tcp_saw_tstamp = 1;
+		lro->tcp_rcv_tsval = *(ptr+1);
+		lro->tcp_rcv_tsecr = *(ptr+2);
+	}
+
+	if (cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) {
+		lro->vlan_packet = 1;
+		lro->vlan_tag = cqe->vlan_tag;
+	}
+
+	lro->active = 1;
+}
Signature · 1 line
	Evgeniy Polyakov
#2 lore raw

Re: [PATCH 2/2] eHEA: Receive SKB Aggregation, generic LRO helper functions

Hi,

thanks for your comment.

Jan-Bernd

Quoted 13 lines · you

Hi Jan-Bernd.

[ Dropped spambot/i.e. unrelated mail lists ]

Quoted 7 lines · Jan-Bernd Themann

This patch enables the receive side processing to aggregate TCP packets within the HEA device driver. It analyses the packets already received after an interrupt arrived and forwards these as chains of SKBs for the same TCP connection with modified header field. We have seen a lower CPU load and improved throughput for small numbers of parallel TCP connections. As this feature is considered as experimental it is switched off by default and can be activated via a module parameter.

Quoted 7 lines

I've couple of comments on the driver, but mainly the fact of decreased CPU usage itself - what was the magnitude of the win with this driver, it looks like because of per-packet receive code path invocation is the place of the latency...
Your implementation looks generic enough to be used by any driver, don't you want to push it separately from eHEA driver?

We can try to come up with a generic file with these helperfunctions. What do you think about putting them into /net/ipv4/inet_lro.c and /include/linux/inet_lro.h ?

Latency: We didn't measure it so far, but it leads to a significant improvement concerning the throughput. Our LRO algorithm only handles X packets a time (depends on MTU and budget), so the upper bound delay is X*processing a single packet from driver perspective.

Quoted 28 lines
Quoted 28 lines
drivers/net/ehea/ehea_main.c +27 -0
+static int lro_tcp_check(struct iphdr *iph, struct tcphdr *tcph,
+			 int tcp_data_len, struct ehea_lro *lro)
+{
+	if (tcp_data_len == 0)
+		return -1;
+
+	if (iph->ihl != IPH_LEN_WO_OPTIONS)
+		return -1;
+
+	if (tcph->cwr || tcph->ece || tcph->urg || !tcph->ack || tcph->psh
+	    || tcph->rst || tcph->syn || tcph->fin)
+		return -1;
+
+	if (INET_ECN_is_ce(ipv4_get_dsfield(iph)))
+		return -1;
+
+	if (tcph->doff != TCPH_LEN_WO_OPTIONS
+	    && tcph->doff != TCPH_LEN_W_TIMESTAMP)
+		return -1;
+
+	/* check tcp options (only timestamp allowed) */
+	if (tcph->doff == TCPH_LEN_W_TIMESTAMP) {
+		u32 *topt = (u32 *)(tcph + 1);
+
+		if (*topt != htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
+				   | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP))
+			return -1;
Quoted 9 lines

drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, · line 467

Quoted 5 lines
drivers/net/ehea/ehea_main.c +5 -0
+
+		/* timestamp should be in right order */
+		topt++;
+		if (lro && (ntohl(lro->tcp_rcv_tsval) > ntohl(*topt)))
+			return -1;

This should use before/after technique like PAWS in TCP code or there will be a problem with wrapper timestamps.

good point, will look into this

Quoted 34 lines
Quoted 34 lines
drivers/net/ehea/ehea_main.c +34 -0
+
+		/* timestamp reply should not be zero */
+		topt++;
+		if (*topt == 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static void update_tcp_ip_header(struct ehea_lro *lro)
+{
+	struct iphdr *iph = lro->iph;
+	struct tcphdr *tcph = lro->tcph;
+	u32 *p;
+
+	tcph->ack_seq = lro->tcp_ack;
+	tcph->window = lro->tcp_window;
+
+	if (lro->tcp_saw_tstamp) {
+		p = (u32 *)(tcph + 1);
+		*(p+2) = lro->tcp_rcv_tsecr;
+	}
+
+	iph->tot_len = htons(lro->ip_tot_len);
+	iph->check = 0;
+	iph->check = ip_fast_csum((u8 *)lro->iph, iph->ihl);
+}
+
+static void init_lro_desc(struct ehea_lro *lro, struct ehea_cqe *cqe,
+			  struct sk_buff *skb, struct iphdr *iph,
+			  struct tcphdr *tcph, u32 tcp_data_len)
+{
+	u32 *ptr;
Quoted 9 lines

drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, · line 507

Quoted 6 lines
drivers/net/ehea/ehea_main.c +6 -0
+
+	lro->parent = skb;
+	lro->iph = iph;
+	lro->tcph = tcph;
+	lro->tcp_next_seq = ntohl(tcph->seq) + tcp_data_len;
+	lro->tcp_ack = ntohl(tcph->ack_seq);

How do you handle misordering or duplicate acks or resends?

we just forward these packets and leave it to the network stack to handle them. As soon as we get a packet which does not match we just flush the LRO session and the current packet (forward to stack as separate SKBs)

Quoted 18 lines
Quoted 17 lines
drivers/net/ehea/ehea_main.c +17 -0
+	lro->skb_sg_cnt = 1;
+	lro->ip_tot_len = ntohs(iph->tot_len);
+
+	if (tcph->doff == 8) {
+		ptr = (u32 *)(tcph+1);
+		lro->tcp_saw_tstamp = 1;
+		lro->tcp_rcv_tsval = *(ptr+1);
+		lro->tcp_rcv_tsecr = *(ptr+2);
+	}
+
+	if (cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) {
+		lro->vlan_packet = 1;
+		lro->vlan_tag = cqe->vlan_tag;
+	}
+
+	lro->active = 1;
+}
#3 lore raw

Re: [PATCH 2/2] eHEA: Receive SKB Aggregation, generic LRO helper functions

Quoted 11 lines · Jan-Bernd Themann
Quoted 7 lines

I've couple of comments on the driver, but mainly the fact of decreased CPU usage itself - what was the magnitude of the win with this driver, it looks like because of per-packet receive code path invocation is the place of the latency...
Your implementation looks generic enough to be used by any driver, don't you want to push it separately from eHEA driver?

We can try to come up with a generic file with these helperfunctions. What do you think about putting them into /net/ipv4/inet_lro.c and /include/linux/inet_lro.h ?

The more I think, the more it looks as appropriate to be used by all hardware drivers with proper API. As far as I recall this is third implementation in the linux drivers :)

Signature · 1 line
	Evgeniy Polyakov