From ea9f43c0975b7bcbf6d16377a7ccea989d16d44b Mon Sep 17 00:00:00 2001
From: Aastha Mehta <aasthakm@mpi-sws.org>
Date: Tue, 11 Sep 2018 20:35:16 +0000
Subject: [PATCH] interception to update tail in currently active profile on
 conn

---
 .../net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.c    |  7 +++++++
 .../net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.h    |  1 +
 .../ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.c   | 13 +++++++++++++
 .../ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.h   |  4 +++-
 net/ipv4/tcp_output.c                               |  4 ++++
 5 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.c b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.c
index b5c22f0f1..9b9796829 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.c
@@ -47,6 +47,7 @@ struct ptcp_hook_heads ptcp_hook_heads = {
   .tx_adjust_seq = LIST_HEAD_INIT(ptcp_hook_heads.tx_adjust_seq),
   .rxtx_sync_shared_seq = LIST_HEAD_INIT(ptcp_hook_heads.rxtx_sync_shared_seq),
   .tx_adjust_urg = LIST_HEAD_INIT(ptcp_hook_heads.tx_adjust_urg),
+  .tx_incr_tail = LIST_HEAD_INIT(ptcp_hook_heads.tx_incr_tail),
   .is_paced_flow = LIST_HEAD_INIT(ptcp_hook_heads.is_paced_flow),
   .get_retransmit_skb = LIST_HEAD_INIT(ptcp_hook_heads.get_retransmit_skb),
 };
@@ -130,6 +131,12 @@ int ptcp_tx_adjust_urg(struct sock *sk, struct sk_buff *skb)
 }
 EXPORT_SYMBOL(ptcp_tx_adjust_urg);
 
+int ptcp_tx_incr_tail(struct sock *sk, struct sk_buff *skb)
+{
+  return call_ptcp_int_hook(tx_incr_tail, -1, sk, skb);
+}
+EXPORT_SYMBOL(ptcp_tx_incr_tail);
+
 int ptcp_is_paced_flow(struct sock *sk)
 {
   return call_ptcp_int_hook(is_paced_flow, -1, sk);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.h b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.h
index 32ba157f3..6b0b153ca 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks.h
@@ -32,6 +32,7 @@ int ptcp_tx_add_dummy(struct sock *sk, u32 old_write_seq, u32 new_write_seq);
 int ptcp_tx_adjust_seq(struct sock *sk, struct sk_buff *skb, int copy, int copied);
 int ptcp_rxtx_sync_shared_seq(struct sock *sk, struct sk_buff *skb, int write);
 int ptcp_tx_adjust_urg(struct sock *sk, struct sk_buff *skb);
+int ptcp_tx_incr_tail(struct sock *sk, struct sk_buff *skb);
 int ptcp_is_paced_flow(struct sock *sk);
 int ptcp_get_retransmit_skb(struct sock *sk, struct sk_buff **skb_p);
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.c b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.c
index 39d150913..a9002a077 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.c
@@ -166,6 +166,18 @@ ptcp_impl_tx_adjust_urg(struct sock *sk, struct sk_buff *skb)
   return -1;
 }
 
+int (*lnk_tx_incr_tail) (struct sock *sk, struct sk_buff *skb) = 0;
+EXPORT_SYMBOL(lnk_tx_incr_tail);
+static int
+ptcp_impl_tx_incr_tail(struct sock *sk, struct sk_buff *skb)
+{
+  if (lnk_tx_incr_tail) {
+    return lnk_tx_incr_tail(sk, skb);
+  }
+
+  return -1;
+}
+
 int (*lnk_is_paced_flow) (struct sock *sk) = 0;
 EXPORT_SYMBOL(lnk_is_paced_flow);
 static int
@@ -203,6 +215,7 @@ struct ptcp_hook_list ptcp_hooks[NUM_PTCP_HOOKS] = {
   PTCP_HOOK_INIT(tx_adjust_seq, ptcp_impl_tx_adjust_seq),
   PTCP_HOOK_INIT(rxtx_sync_shared_seq, ptcp_impl_rxtx_sync_shared_seq),
   PTCP_HOOK_INIT(tx_adjust_urg, ptcp_impl_tx_adjust_urg),
+  PTCP_HOOK_INIT(tx_incr_tail, ptcp_impl_tx_incr_tail),
   PTCP_HOOK_INIT(is_paced_flow, ptcp_impl_is_paced_flow),
   PTCP_HOOK_INIT(get_retransmit_skb, ptcp_impl_get_retransmit_skb),
 };
diff --git a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.h b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.h
index 0817116da..c9b50b9eb 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/sme/ptcp_hooks_impl.h
@@ -40,6 +40,7 @@ union ptcp_list_options {
   int (*tx_adjust_seq) (struct sock *sk, struct sk_buff *skb, int copy, int copied);
   int (*rxtx_sync_shared_seq) (struct sock *sk, struct sk_buff *skb, int write);
   int (*tx_adjust_urg) (struct sock *sk, struct sk_buff *skb);
+  int (*tx_incr_tail) (struct sock *sk, struct sk_buff *skb);
   int (*is_paced_flow) (struct sock *sk);
   int (*get_retransmit_skb) (struct sock *sk, struct sk_buff **skb_p);
 };
@@ -57,6 +58,7 @@ struct ptcp_hook_heads {
   struct list_head tx_adjust_seq;
   struct list_head rxtx_sync_shared_seq;
   struct list_head tx_adjust_urg;
+  struct list_head tx_incr_tail;
   struct list_head is_paced_flow;
   struct list_head get_retransmit_skb;
 };
@@ -71,7 +73,7 @@ struct ptcp_hook_list {
 { .head = &ptcp_hook_heads.HEAD, .hook = { . HEAD = HOOK } }
 
 // increment this every time a new hook is added
-#define NUM_PTCP_HOOKS  14
+#define NUM_PTCP_HOOKS  15
 
 extern struct ptcp_hook_heads ptcp_hook_heads;
 extern struct ptcp_hook_list ptcp_hooks[NUM_PTCP_HOOKS];
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a4e03e016..633e8f68c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1103,6 +1103,10 @@ skip_orig_urg:
 			      tcp_skb_pcount(skb));
 
 	tp->segs_out += tcp_skb_pcount(skb);
+#ifdef CONFIG_PACER_TCP
+  ptcp_tx_incr_tail(sk, skb);
+#endif
+
 	/* OK, its time to fill skb_shinfo(skb)->gso_{segs|size} */
 	skb_shinfo(skb)->gso_segs = tcp_skb_pcount(skb);
 	skb_shinfo(skb)->gso_size = tcp_skb_mss(skb);
-- 
GitLab