tcp_dctcp.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _TCP_DCTCP_H
  2. #define _TCP_DCTCP_H
  3. static inline void dctcp_ece_ack_cwr(struct sock *sk, u32 ce_state)
  4. {
  5. struct tcp_sock *tp = tcp_sk(sk);
  6. if (ce_state == 1)
  7. tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
  8. else
  9. tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
  10. }
  11. /* Minimal DCTP CE state machine:
  12. *
  13. * S: 0 <- last pkt was non-CE
  14. * 1 <- last pkt was CE
  15. */
  16. static inline void dctcp_ece_ack_update(struct sock *sk, enum tcp_ca_event evt,
  17. u32 *prior_rcv_nxt, u32 *ce_state)
  18. {
  19. u32 new_ce_state = (evt == CA_EVENT_ECN_IS_CE) ? 1 : 0;
  20. if (*ce_state != new_ce_state) {
  21. /* CE state has changed, force an immediate ACK to
  22. * reflect the new CE state. If an ACK was delayed,
  23. * send that first to reflect the prior CE state.
  24. */
  25. if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER) {
  26. dctcp_ece_ack_cwr(sk, *ce_state);
  27. __tcp_send_ack(sk, *prior_rcv_nxt);
  28. }
  29. inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW;
  30. }
  31. *prior_rcv_nxt = tcp_sk(sk)->rcv_nxt;
  32. *ce_state = new_ce_state;
  33. dctcp_ece_ack_cwr(sk, new_ce_state);
  34. }
  35. #endif