mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 19:56:18 +00:00
f83ef8c0b5
This patch adds GSO support for IPv6 and TCPv6. This is based on a patch by Ananda Raju <Ananda.Raju@neterion.com>. His original description is: This patch enables TSO over IPv6. Currently Linux network stacks restricts TSO over IPv6 by clearing of the NETIF_F_TSO bit from "dev->features". This patch will remove this restriction. This patch will introduce a new flag NETIF_F_TSO6 which will be used to check whether device supports TSO over IPv6. If device support TSO over IPv6 then we don't clear of NETIF_F_TSO and which will make the TCP layer to create TSO packets. Any device supporting TSO over IPv6 will set NETIF_F_TSO6 flag in "dev->features" along with NETIF_F_TSO. In case when user disables TSO using ethtool, NETIF_F_TSO will get cleared from "dev->features". So even if we have NETIF_F_TSO6 we don't get TSO packets created by TCP layer. SKB_GSO_TCPV4 renamed to SKB_GSO_TCP to make it generic GSO packet. SKB_GSO_UDPV4 renamed to SKB_GSO_UDP as UFO is not a IPv4 feature. UFO is supported over IPv6 also The following table shows there is significant improvement in throughput with normal frames and CPU usage for both normal and jumbo. -------------------------------------------------- | | 1500 | 9600 | | ------------------|-------------------| | | thru CPU | thru CPU | -------------------------------------------------- | TSO OFF | 2.00 5.5% id | 5.66 20.0% id | -------------------------------------------------- | TSO ON | 2.63 78.0 id | 5.67 39.0% id | -------------------------------------------------- Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
127 lines
3.1 KiB
C
127 lines
3.1 KiB
C
#ifndef _NET_TCP_ECN_H_
|
|
#define _NET_TCP_ECN_H_ 1
|
|
|
|
#include <net/inet_ecn.h>
|
|
#include <net/request_sock.h>
|
|
|
|
#define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
|
|
|
|
#define TCP_ECN_OK 1
|
|
#define TCP_ECN_QUEUE_CWR 2
|
|
#define TCP_ECN_DEMAND_CWR 4
|
|
|
|
static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp)
|
|
{
|
|
if (tp->ecn_flags&TCP_ECN_OK)
|
|
tp->ecn_flags |= TCP_ECN_QUEUE_CWR;
|
|
}
|
|
|
|
|
|
/* Output functions */
|
|
|
|
static inline void TCP_ECN_send_synack(struct tcp_sock *tp,
|
|
struct sk_buff *skb)
|
|
{
|
|
TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
|
|
if (!(tp->ecn_flags&TCP_ECN_OK))
|
|
TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
|
|
}
|
|
|
|
static inline void TCP_ECN_send_syn(struct sock *sk, struct tcp_sock *tp,
|
|
struct sk_buff *skb)
|
|
{
|
|
tp->ecn_flags = 0;
|
|
if (sysctl_tcp_ecn) {
|
|
TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
|
|
tp->ecn_flags = TCP_ECN_OK;
|
|
}
|
|
}
|
|
|
|
static __inline__ void
|
|
TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th)
|
|
{
|
|
if (inet_rsk(req)->ecn_ok)
|
|
th->ece = 1;
|
|
}
|
|
|
|
static inline void TCP_ECN_send(struct sock *sk, struct tcp_sock *tp,
|
|
struct sk_buff *skb, int tcp_header_len)
|
|
{
|
|
if (tp->ecn_flags & TCP_ECN_OK) {
|
|
/* Not-retransmitted data segment: set ECT and inject CWR. */
|
|
if (skb->len != tcp_header_len &&
|
|
!before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
|
|
INET_ECN_xmit(sk);
|
|
if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
|
|
tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
|
|
skb->h.th->cwr = 1;
|
|
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
|
|
}
|
|
} else {
|
|
/* ACK or retransmitted segment: clear ECT|CE */
|
|
INET_ECN_dontxmit(sk);
|
|
}
|
|
if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
|
|
skb->h.th->ece = 1;
|
|
}
|
|
}
|
|
|
|
/* Input functions */
|
|
|
|
static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
|
|
{
|
|
if (skb->h.th->cwr)
|
|
tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
|
|
}
|
|
|
|
static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp)
|
|
{
|
|
tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
|
|
}
|
|
|
|
static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb)
|
|
{
|
|
if (tp->ecn_flags&TCP_ECN_OK) {
|
|
if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
|
|
tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
|
|
/* Funny extension: if ECT is not set on a segment,
|
|
* it is surely retransmit. It is not in ECN RFC,
|
|
* but Linux follows this rule. */
|
|
else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags)))
|
|
tcp_enter_quickack_mode((struct sock *)tp);
|
|
}
|
|
}
|
|
|
|
static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th)
|
|
{
|
|
if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr))
|
|
tp->ecn_flags &= ~TCP_ECN_OK;
|
|
}
|
|
|
|
static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th)
|
|
{
|
|
if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr))
|
|
tp->ecn_flags &= ~TCP_ECN_OK;
|
|
}
|
|
|
|
static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th)
|
|
{
|
|
if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK))
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
static inline void TCP_ECN_openreq_child(struct tcp_sock *tp,
|
|
struct request_sock *req)
|
|
{
|
|
tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0;
|
|
}
|
|
|
|
static __inline__ void
|
|
TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
|
|
{
|
|
if (sysctl_tcp_ecn && th->ece && th->cwr)
|
|
inet_rsk(req)->ecn_ok = 1;
|
|
}
|
|
|
|
#endif
|