MINOR: proxy: factorize send rate measurement

Implement a new dedicated function increment_send_rate() which can be
call anywhere new bytes must be accounted for global total sent.
diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h
index 547c671..39a4637 100644
--- a/include/haproxy/proxy.h
+++ b/include/haproxy/proxy.h
@@ -30,6 +30,7 @@
 #include <haproxy/proxy-t.h>
 #include <haproxy/server-t.h>
 #include <haproxy/ticks.h>
+#include <haproxy/thread.h>
 
 extern struct proxy *proxies_list;
 extern struct eb_root used_proxy_id;	/* list of proxy IDs in use */
@@ -235,6 +236,22 @@
 	return 0;
 }
 
+/* Add <bytes> to the global total bytes sent and adjust the send rate. Set
+ * <splice> if this was sent usigin splicing.
+ */
+static inline void increment_send_rate(uint64_t bytes, int splice)
+{
+	/* We count the total bytes sent, and the send rate for 32-byte blocks.
+	 * The reason for the latter is that freq_ctr are limited to 4GB and
+	 * that it's not enough per second.
+	 */
+
+	if (splice)
+		_HA_ATOMIC_ADD(&th_ctx->spliced_out_bytes, bytes);
+	_HA_ATOMIC_ADD(&th_ctx->out_bytes, bytes);
+	update_freq_ctr(&th_ctx->out_32bps, (bytes + 16) / 32);
+}
+
 #endif /* _HAPROXY_PROXY_H */
 
 /*
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 44a8d27..82d2076 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -5,7 +5,6 @@
 #include <haproxy/api.h>
 #include <haproxy/connection.h>
 #include <haproxy/dynbuf.h>
-#include <haproxy/freq_ctr.h>
 #include <haproxy/h3.h>
 #include <haproxy/list.h>
 #include <haproxy/ncbuf.h>
@@ -20,7 +19,6 @@
 #include <haproxy/quic_tp-t.h>
 #include <haproxy/ssl_sock-t.h>
 #include <haproxy/stconn.h>
-#include <haproxy/thread.h>
 #include <haproxy/trace.h>
 
 DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc));
@@ -1648,13 +1646,8 @@
 
 		/* Add measurement for send rate. This is done at the MUX layer
 		 * to account only for STREAM frames without retransmission.
-		 *
-		 * we count the total bytes sent, and the send rate for 32-byte blocks.
-		 * The reason for the latter is that freq_ctr are limited to 4GB and
-		 * that it's not enough per second.
 		 */
-		_HA_ATOMIC_ADD(&th_ctx->out_bytes, ret);
-		update_freq_ctr(&th_ctx->out_32bps, (ret + 16) / 32);
+		increment_send_rate(diff, 0);
 	}
 
 	if (qcs->tx.offset == qcs->tx.sent_offset && !b_data(&qcs->tx.buf)) {
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 9901f9b..31ca970 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -26,9 +26,9 @@
 #include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/fd.h>
-#include <haproxy/freq_ctr.h>
 #include <haproxy/global.h>
 #include <haproxy/pipe.h>
+#include <haproxy/proxy.h>
 #include <haproxy/tools.h>
 
 
@@ -147,15 +147,9 @@
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 
  leave:
-	if (retval > 0) {
-		/* we count the total bytes sent, and the send rate for 32-byte
-		 * blocks. The reason for the latter is that freq_ctr are
-		 * limited to 4GB and that it's not enough per second.
-		 */
-		_HA_ATOMIC_ADD(&th_ctx->out_bytes, retval);
-		_HA_ATOMIC_ADD(&th_ctx->spliced_out_bytes, retval);
-		update_freq_ctr(&th_ctx->out_32bps, (retval + 16) / 32);
-	}
+	if (retval > 0)
+		increment_send_rate(retval, 1);
+
 	return retval;
 
  out_read0:
@@ -416,14 +410,9 @@
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 	}
 
-	if (done > 0) {
-		/* we count the total bytes sent, and the send rate for 32-byte
-		 * blocks. The reason for the latter is that freq_ctr are
-		 * limited to 4GB and that it's not enough per second.
-		 */
-		_HA_ATOMIC_ADD(&th_ctx->out_bytes, done);
-		update_freq_ctr(&th_ctx->out_32bps, (done + 16) / 32);
-	}
+	if (done > 0)
+		increment_send_rate(done, 0);
+
 	return done;
 }