Commit 27a14b12 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[TCP]: Remove tcp_pcount_t

IMHO the TSO stuff has mostly settled down now.  As a result
tcp_pcount_t is now more of a liability in that it reduces the
readability of the code.

So here is a patch to remove it.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7875f697
......@@ -203,10 +203,6 @@ struct tcp_sack_block {
__u32 end_seq;
};
typedef struct tcp_pcount {
__u32 val;
} tcp_pcount_t;
enum tcp_congestion_algo {
TCP_RENO=0,
TCP_VEGAS,
......@@ -289,9 +285,9 @@ struct tcp_sock {
__u32 rtt_seq; /* sequence number to update rttvar */
__u32 rto; /* retransmit timeout */
tcp_pcount_t packets_out; /* Packets which are "in flight" */
tcp_pcount_t left_out; /* Packets which leaved network */
tcp_pcount_t retrans_out; /* Retransmitted packets out */
__u32 packets_out; /* Packets which are "in flight" */
__u32 left_out; /* Packets which leaved network */
__u32 retrans_out; /* Retransmitted packets out */
/*
......@@ -352,9 +348,9 @@ struct tcp_sock {
__u8 syn_retries; /* num of allowed syn retries */
__u8 ecn_flags; /* ECN status bits. */
__u16 prior_ssthresh; /* ssthresh saved at recovery start */
tcp_pcount_t lost_out; /* Lost packets */
tcp_pcount_t sacked_out;/* SACK'd packets */
tcp_pcount_t fackets_out;/* FACK'd packets */
__u32 lost_out; /* Lost packets */
__u32 sacked_out; /* SACK'd packets */
__u32 fackets_out; /* FACK'd packets */
__u32 high_seq; /* snd_nxt at onset of congestion */
__u32 retrans_stamp; /* Timestamp of the last retransmit,
......
......@@ -1176,55 +1176,23 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
return skb_shinfo(skb)->tso_size;
}
static inline void tcp_inc_pcount(tcp_pcount_t *count,
const struct sk_buff *skb)
{
count->val += tcp_skb_pcount(skb);
}
static inline void tcp_inc_pcount_explicit(tcp_pcount_t *count, int amt)
{
count->val += amt;
}
static inline void tcp_dec_pcount_explicit(tcp_pcount_t *count, int amt)
{
count->val -= amt;
}
static inline void tcp_dec_pcount(tcp_pcount_t *count,
const struct sk_buff *skb)
{
count->val -= tcp_skb_pcount(skb);
}
static inline void tcp_dec_pcount_approx(tcp_pcount_t *count,
static inline void tcp_dec_pcount_approx(__u32 *count,
const struct sk_buff *skb)
{
if (count->val) {
count->val -= tcp_skb_pcount(skb);
if ((int)count->val < 0)
count->val = 0;
if (*count) {
*count -= tcp_skb_pcount(skb);
if ((int)*count < 0)
*count = 0;
}
}
static inline __u32 tcp_get_pcount(const tcp_pcount_t *count)
{
return count->val;
}
static inline void tcp_set_pcount(tcp_pcount_t *count, __u32 val)
{
count->val = val;
}
static inline void tcp_packets_out_inc(struct sock *sk,
struct tcp_sock *tp,
const struct sk_buff *skb)
{
int orig = tcp_get_pcount(&tp->packets_out);
int orig = tp->packets_out;
tcp_inc_pcount(&tp->packets_out, skb);
tp->packets_out += tcp_skb_pcount(skb);
if (!orig)
tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto);
}
......@@ -1232,7 +1200,7 @@ static inline void tcp_packets_out_inc(struct sock *sk,
static inline void tcp_packets_out_dec(struct tcp_sock *tp,
const struct sk_buff *skb)
{
tcp_dec_pcount(&tp->packets_out, skb);
tp->packets_out -= tcp_skb_pcount(skb);
}
/* This determines how many packets are "in the network" to the best
......@@ -1251,9 +1219,7 @@ static inline void tcp_packets_out_dec(struct tcp_sock *tp,
*/
static __inline__ unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
{
return (tcp_get_pcount(&tp->packets_out) -
tcp_get_pcount(&tp->left_out) +
tcp_get_pcount(&tp->retrans_out));
return (tp->packets_out - tp->left_out + tp->retrans_out);
}
/*
......@@ -1357,14 +1323,9 @@ static inline __u32 tcp_current_ssthresh(struct tcp_sock *tp)
static inline void tcp_sync_left_out(struct tcp_sock *tp)
{
if (tp->sack_ok &&
(tcp_get_pcount(&tp->sacked_out) >=
tcp_get_pcount(&tp->packets_out) - tcp_get_pcount(&tp->lost_out)))
tcp_set_pcount(&tp->sacked_out,
(tcp_get_pcount(&tp->packets_out) -
tcp_get_pcount(&tp->lost_out)));
tcp_set_pcount(&tp->left_out,
(tcp_get_pcount(&tp->sacked_out) +
tcp_get_pcount(&tp->lost_out)));
(tp->sacked_out >= tp->packets_out - tp->lost_out))
tp->sacked_out = tp->packets_out - tp->lost_out;
tp->left_out = tp->sacked_out + tp->lost_out;
}
extern void tcp_cwnd_application_limited(struct sock *sk);
......@@ -1373,7 +1334,7 @@ extern void tcp_cwnd_application_limited(struct sock *sk);
static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
{
__u32 packets_out = tcp_get_pcount(&tp->packets_out);
__u32 packets_out = tp->packets_out;
if (packets_out >= tp->snd_cwnd) {
/* Network is feed fully. */
......@@ -1381,8 +1342,8 @@ static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
tp->snd_cwnd_stamp = tcp_time_stamp;
} else {
/* Network starves. */
if (tcp_get_pcount(&tp->packets_out) > tp->snd_cwnd_used)
tp->snd_cwnd_used = tcp_get_pcount(&tp->packets_out);
if (tp->packets_out > tp->snd_cwnd_used)
tp->snd_cwnd_used = tp->packets_out;
if ((s32)(tcp_time_stamp - tp->snd_cwnd_stamp) >= tp->rto)
tcp_cwnd_application_limited(sk);
......@@ -1450,7 +1411,7 @@ tcp_nagle_check(const struct tcp_sock *tp, const struct sk_buff *skb,
!(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
((nonagle&TCP_NAGLE_CORK) ||
(!nonagle &&
tcp_get_pcount(&tp->packets_out) &&
tp->packets_out &&
tcp_minshall_check(tp))));
}
......@@ -1503,7 +1464,7 @@ static __inline__ int tcp_snd_test(const struct tcp_sock *tp,
static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp)
{
if (!tcp_get_pcount(&tp->packets_out) && !tp->pending)
if (!tp->packets_out && !tp->pending)
tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, tp->rto);
}
......
......@@ -1822,7 +1822,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tp->backoff = 0;
tp->snd_cwnd = 2;
tp->probes_out = 0;
tcp_set_pcount(&tp->packets_out, 0);
tp->packets_out = 0;
tp->snd_ssthresh = 0x7fffffff;
tp->snd_cwnd_cnt = 0;
tcp_set_ca_state(tp, TCP_CA_Open);
......@@ -2137,11 +2137,11 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
info->tcpi_snd_mss = tp->mss_cache_std;
info->tcpi_rcv_mss = tp->ack.rcv_mss;
info->tcpi_unacked = tcp_get_pcount(&tp->packets_out);
info->tcpi_sacked = tcp_get_pcount(&tp->sacked_out);
info->tcpi_lost = tcp_get_pcount(&tp->lost_out);
info->tcpi_retrans = tcp_get_pcount(&tp->retrans_out);
info->tcpi_fackets = tcp_get_pcount(&tp->fackets_out);
info->tcpi_unacked = tp->packets_out;
info->tcpi_sacked = tp->sacked_out;
info->tcpi_lost = tp->lost_out;
info->tcpi_retrans = tp->retrans_out;
info->tcpi_fackets = tp->fackets_out;
info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
info->tcpi_last_data_recv = jiffies_to_msecs(now - tp->ack.lrcvtime);
......
This diff is collapsed.
......@@ -754,11 +754,11 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
newtp->mdev = TCP_TIMEOUT_INIT;
newtp->rto = TCP_TIMEOUT_INIT;
tcp_set_pcount(&newtp->packets_out, 0);
tcp_set_pcount(&newtp->left_out, 0);
tcp_set_pcount(&newtp->retrans_out, 0);
tcp_set_pcount(&newtp->sacked_out, 0);
tcp_set_pcount(&newtp->fackets_out, 0);
newtp->packets_out = 0;
newtp->left_out = 0;
newtp->retrans_out = 0;
newtp->sacked_out = 0;
newtp->fackets_out = 0;
newtp->snd_ssthresh = 0x7fffffff;
/* So many TCP implementations out there (incorrectly) count the
......
......@@ -129,8 +129,7 @@ static inline void tcp_event_data_sent(struct tcp_sock *tp,
{
u32 now = tcp_time_stamp;
if (!tcp_get_pcount(&tp->packets_out) &&
(s32)(now - tp->lsndtime) > tp->rto)
if (!tp->packets_out && (s32)(now - tp->lsndtime) > tp->rto)
tcp_cwnd_restart(tp, __sk_dst_get(sk));
tp->lsndtime = now;
......@@ -509,8 +508,8 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when;
if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
tcp_dec_pcount(&tp->lost_out, skb);
tcp_dec_pcount(&tp->left_out, skb);
tp->lost_out -= tcp_skb_pcount(skb);
tp->left_out -= tcp_skb_pcount(skb);
}
/* Fix up tso_factor for both original and new SKB. */
......@@ -518,13 +517,13 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
tcp_set_skb_tso_segs(buff, tp->mss_cache_std);
if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
tcp_inc_pcount(&tp->lost_out, skb);
tcp_inc_pcount(&tp->left_out, skb);
tp->lost_out += tcp_skb_pcount(skb);
tp->left_out += tcp_skb_pcount(skb);
}
if (TCP_SKB_CB(buff)->sacked&TCPCB_LOST) {
tcp_inc_pcount(&tp->lost_out, buff);
tcp_inc_pcount(&tp->left_out, buff);
tp->lost_out += tcp_skb_pcount(buff);
tp->left_out += tcp_skb_pcount(buff);
}
/* Link BUFF into the send queue. */
......@@ -773,7 +772,7 @@ int tcp_write_xmit(struct sock *sk, int nonagle)
return 0;
}
return !tcp_get_pcount(&tp->packets_out) && sk->sk_send_head;
return !tp->packets_out && sk->sk_send_head;
}
return 0;
}
......@@ -945,15 +944,15 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
*/
TCP_SKB_CB(skb)->sacked |= TCP_SKB_CB(next_skb)->sacked&(TCPCB_EVER_RETRANS|TCPCB_AT_TAIL);
if (TCP_SKB_CB(next_skb)->sacked&TCPCB_SACKED_RETRANS)
tcp_dec_pcount(&tp->retrans_out, next_skb);
tp->retrans_out -= tcp_skb_pcount(next_skb);
if (TCP_SKB_CB(next_skb)->sacked&TCPCB_LOST) {
tcp_dec_pcount(&tp->lost_out, next_skb);
tcp_dec_pcount(&tp->left_out, next_skb);
tp->lost_out -= tcp_skb_pcount(next_skb);
tp->left_out -= tcp_skb_pcount(next_skb);
}
/* Reno case is special. Sigh... */
if (!tp->sack_ok && tcp_get_pcount(&tp->sacked_out)) {
if (!tp->sack_ok && tp->sacked_out) {
tcp_dec_pcount_approx(&tp->sacked_out, next_skb);
tcp_dec_pcount(&tp->left_out, next_skb);
tp->left_out -= tcp_skb_pcount(next_skb);
}
/* Not quite right: it can be > snd.fack, but
......@@ -981,11 +980,11 @@ void tcp_simple_retransmit(struct sock *sk)
!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED)) {
if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) {
TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
tcp_dec_pcount(&tp->retrans_out, skb);
tp->retrans_out -= tcp_skb_pcount(skb);
}
if (!(TCP_SKB_CB(skb)->sacked&TCPCB_LOST)) {
TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
tcp_inc_pcount(&tp->lost_out, skb);
tp->lost_out += tcp_skb_pcount(skb);
lost = 1;
}
}
......@@ -1060,9 +1059,8 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
/* New SKB created, account for it. */
new_factor = tcp_skb_pcount(skb);
tcp_dec_pcount_explicit(&tp->packets_out,
old_factor - new_factor);
tcp_inc_pcount(&tp->packets_out, skb->next);
tp->packets_out -= old_factor - new_factor;
tp->packets_out += tcp_skb_pcount(skb->next);
}
/* Collapse two adjacent packets if worthwhile and we can. */
......@@ -1115,7 +1113,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
}
#endif
TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS;
tcp_inc_pcount(&tp->retrans_out, skb);
tp->retrans_out += tcp_skb_pcount(skb);
/* Save stamp of the first retransmit. */
if (!tp->retrans_stamp)
......@@ -1143,7 +1141,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
int packet_cnt = tcp_get_pcount(&tp->lost_out);
int packet_cnt = tp->lost_out;
/* First pass: retransmit lost packets. */
if (packet_cnt) {
......@@ -1210,7 +1208,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
* real MSS sized packet because tcp_retransmit_skb()
* will fragment it if necessary.
*/
if (++packet_cnt > tcp_get_pcount(&tp->fackets_out))
if (++packet_cnt > tp->fackets_out)
break;
if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)
......@@ -1496,7 +1494,7 @@ int tcp_connect(struct sock *sk)
tp->retrans_stamp = TCP_SKB_CB(buff)->when;
__skb_queue_tail(&sk->sk_write_queue, buff);
sk_charge_skb(sk, buff);
tcp_inc_pcount(&tp->packets_out, buff);
tp->packets_out += tcp_skb_pcount(buff);
tcp_transmit_skb(sk, skb_clone(buff, GFP_KERNEL));
TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
......@@ -1694,7 +1692,7 @@ void tcp_send_probe0(struct sock *sk)
err = tcp_write_wakeup(sk);
if (tcp_get_pcount(&tp->packets_out) || !sk->sk_send_head) {
if (tp->packets_out || !sk->sk_send_head) {
/* Cancel probe timer, if it is not required. */
tp->probes_out = 0;
tp->backoff = 0;
......
......@@ -123,7 +123,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset)
* 1. Last segment was sent recently. */
if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN ||
/* 2. Window is closed. */
(!tp->snd_wnd && !tcp_get_pcount(&tp->packets_out)))
(!tp->snd_wnd && !tp->packets_out))
do_reset = 1;
if (do_reset)
tcp_send_active_reset(sk, GFP_ATOMIC);
......@@ -271,7 +271,7 @@ static void tcp_probe_timer(struct sock *sk)
struct tcp_sock *tp = tcp_sk(sk);
int max_probes;
if (tcp_get_pcount(&tp->packets_out) || !sk->sk_send_head) {
if (tp->packets_out || !sk->sk_send_head) {
tp->probes_out = 0;
return;
}
......@@ -318,7 +318,7 @@ static void tcp_retransmit_timer(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
if (!tcp_get_pcount(&tp->packets_out))
if (!tp->packets_out)
goto out;
BUG_TRAP(!skb_queue_empty(&sk->sk_write_queue));
......@@ -608,7 +608,7 @@ static void tcp_keepalive_timer (unsigned long data)
elapsed = keepalive_time_when(tp);
/* It is alive without keepalive 8) */
if (tcp_get_pcount(&tp->packets_out) || sk->sk_send_head)
if (tp->packets_out || sk->sk_send_head)
goto resched;
elapsed = tcp_time_stamp - tp->rcv_tstamp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment