ehea: Receive SKB Aggregation
Subsystems (2)
PATCH 2/2 ehea: Receive SKB Aggregation
After there were no technical concerns about this patch I'm resending it with all whitespace issues fixed which were mentioned by Stephen Rothwell.
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.
We added a disabled module parameter to prevent disruption of normal driver operation.
We currently consider this as "experimental" until further review and tests have been passed.
---
drivers/net/ehea/ehea.h +32 -1
@@ -39,7 +39,7 @@#include <asm/io.h> #define DRV_NAME "ehea" -#define DRV_VERSION "EHEA_0062" +#define DRV_VERSION "EHEA_0063"#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -49,6 +49,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
@@ -78,6 +79,9 @@#define EHEA_RQ2_PKT_SIZE 1522#define EHEA_L_PKT_SIZE 256/* low latency */ +#define MAX_LRO_DESCRIPTORS 8 +#define LRO_DESC_MASK 0xFFFFFFFF +/* Send completion signaling */ /* Protection Domain Identifier */
@@ -334,6 +338,29 @@ struct ehea_q_skb_arr { };/* +* Large Receive Offload (LRO) descriptor for a tcp seesion +*/ +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 {
@@ -362,6 +389,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; };
@@ -411,6 +441,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 +301 -5
375 lines not on this page · raw message
I'm still very unhappy with having all this in various drivers. There's a lot of code that can be turned into generic library functions, and even more code that could be made generic with some amount of refactoring.
Quoted 4 lines
drivers/net/ehea/ehea_main.c +1
-0+static int try_get_ip_tcp_hdr(struct ehea_cqe *cqe, struct sk_buff *skb,
drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct · line 401
Quoted 10 lines
drivers/net/ehea/ehea_main.c +10
-0+ struct iphdr **iph, struct tcphdr **tcph) +{ + int ip_len; + +/* non tcp/udp packets */ +if (!cqe->header_length) +return -1 ; + +/* non tcp packet */ + *iph = (struct iphdr *)(skb->data);
Why the indirection, copying of headers..
drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct · line 411
Quoted 11 lines
drivers/net/ehea/ehea_main.c +10
-0+if ((*iph)->protocol !=IPPROTO_TCP ) +return -1 ; + + ip_len = (u8)((*iph)->ihl); + ip_len <<=2 ; + *tcph = (struct tcphdr *)(((u64)*iph) + ip_len); + +return 0 ; +} +
This code seems to be duplicating a lot (but not all) of the TCP/IP input path validation checks. This is a security problem if nothing else...
Also, how do you prevent DoS attacks from hostile TCP senders that send huge number of back to back frames?
Signature · 1 line
Stephen Hemminger <[email protected]>
Stephen Hemminger wrote on 31.05.2007 18:37:03:
Quoted 4 lines
Quoted 4 lines
+static int try_get_ip_tcp_hdr(struct
ehea_cqe*cqe, structsk_buff
*skb,
Quoted 4 lines
Quoted 4 lines
drivers/net/ehea/ehea_main.c +4
-0+ struct iphdr **iph, struct tcphdr **tcph) +{ + int ip_len; +
Quoted 8 lines
drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct · line 401
Quoted 6 lines
drivers/net/ehea/ehea_main.c +6
-0+/* non tcp/udp packets */ +if (!cqe->header_length) +return -1 ; + +/* non tcp packet */ + *iph = (struct iphdr *)(skb->data);Why the indirection, copying of headers..
This interacts with the header split function in the hardware.
Quoted 15 lines
drivers/net/ehea/ehea_main.c static int ehea_treat_poll_error(struct · line 411
Quoted 12 lines
drivers/net/ehea/ehea_main.c +10
-0+if ((*iph)->protocol !=IPPROTO_TCP ) +return -1 ; + + ip_len = (u8)((*iph)->ihl); + ip_len <<=2 ; + *tcph = (struct tcphdr *)(((u64)*iph) + ip_len); + +return 0 ; +} +This code seems to be duplicating a lot (but not all) of the TCP/IP input path validation checks. This is a security problem if nothing
else...
Quoted 1 line
We should only do aggregation in the driver if this really is a TCP header, otherwise things will get worse.
You're right, we should at least check that tcph is within the received frame.
Quoted 2 lines
Also, how do you prevent DoS attacks from hostile TCP senders that send huge number of back to back frames?
Actually a huge number of back to back frames is what we would want to receive
at 10 gbit ;-)
How is it possible to figure out if this is what you want or just DoS? It doesn't change anything compared to a non LRO driver, we process a certain
maximum amount of frames before waiting for the next interrupt, the packet filters/DoS should still see all traffic (which is above the driver).
Any suggestions how to handle this better/different?
Quoted 3 lines
--
Stephen Hemminger
Gruss / Regards
Christoph Raisch
Christoph Hellwig wrote on 31.05.2007 15:41:18:
Quoted 3 lines
I'm still very unhappy with having all this in various drivers. There's a lot of code that can be turned into generic library functions, and even more code that could be made generic with some amount of refactoring.
Yes, we'd also prefer to use a generic function, but we first would want to get
some "real world" experience how our driver behaves with LRO to be even able to
define requirements for such a generic function. A lot of this is tied into pathlengths,
caching, and why does that help compared to a different TCP receive side processing?
In a perfect world we shouldn't see a diffference if this is enabled or not,
but measurements indicate something completely different at 10gbit.
Gruss / Regards
Christoph Raisch