tcp_scalable.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Tom Kelly's Scalable TCP
  3. *
  4. * See http://www.deneholme.net/tom/scalable/
  5. *
  6. * John Heffner <jheffner@sc.edu>
  7. */
  8. #include <linux/module.h>
  9. #include <net/tcp.h>
  10. /* These factors derived from the recommended values in the aer:
  11. * .01 and 7/8.
  12. */
  13. #define TCP_SCALABLE_AI_CNT 100U
  14. #define TCP_SCALABLE_MD_SCALE 3
  15. static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
  16. {
  17. struct tcp_sock *tp = tcp_sk(sk);
  18. if (!tcp_is_cwnd_limited(sk))
  19. return;
  20. if (tcp_in_slow_start(tp)) {
  21. acked = tcp_slow_start(tp, acked);
  22. if (!acked)
  23. return;
  24. }
  25. tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
  26. acked);
  27. }
  28. static u32 tcp_scalable_ssthresh(struct sock *sk)
  29. {
  30. const struct tcp_sock *tp = tcp_sk(sk);
  31. return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
  32. }
  33. static struct tcp_congestion_ops tcp_scalable __read_mostly = {
  34. .ssthresh = tcp_scalable_ssthresh,
  35. .undo_cwnd = tcp_reno_undo_cwnd,
  36. .cong_avoid = tcp_scalable_cong_avoid,
  37. .owner = THIS_MODULE,
  38. .name = "scalable",
  39. };
  40. static int __init tcp_scalable_register(void)
  41. {
  42. return tcp_register_congestion_control(&tcp_scalable);
  43. }
  44. static void __exit tcp_scalable_unregister(void)
  45. {
  46. tcp_unregister_congestion_control(&tcp_scalable);
  47. }
  48. module_init(tcp_scalable_register);
  49. module_exit(tcp_scalable_unregister);
  50. MODULE_AUTHOR("John Heffner");
  51. MODULE_LICENSE("GPL");
  52. MODULE_DESCRIPTION("Scalable TCP");