MINOR: quic: Allocate listener RX buffers

At this time we allocate an RX buffer by thread.
Also take the opportunity offered by this patch to rename TX related variable
names to distinguish them from the RX part.
diff --git a/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h
index 3e1ff81..f7412df 100644
--- a/include/haproxy/receiver-t.h
+++ b/include/haproxy/receiver-t.h
@@ -68,8 +68,10 @@
 	struct eb_root odcids;           /* QUIC original destination connection IDs. */
 	struct eb_root cids;             /* QUIC connection IDs. */
 	__decl_thread(HA_RWLOCK_T cids_lock); /* RW lock for connection IDs tree accesses */
-	struct qring *qrings;            /* Array of rings (one by thread) */
-	struct mt_list tx_qrings;        /* The same as ->qrings but arranged in a list */
+	struct qring *tx_qrings;         /* Array of rings (one by thread) */
+	struct mt_list tx_qring_list;    /* The same as ->qrings but arranged in a list */
+	struct rxbuf *rxbufs;            /* Array of buffers for RX (one by thread) */
+	struct mt_list rxbuf_list;       /* The same as ->rxbufs but arranged in a list */
 #endif
 	/* warning: this struct is huge, keep it at the bottom */
 	struct sockaddr_storage addr;    /* the address the socket is bound to */
diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h
index 07ccf23..f7975cf 100644
--- a/include/haproxy/xprt_quic-t.h
+++ b/include/haproxy/xprt_quic-t.h
@@ -232,9 +232,12 @@
 
 /* Size of the internal buffer of QUIC TX ring buffers (must be a power of 2) */
 #define QUIC_TX_RING_BUFSZ  (1UL << 12)
+/* Size of the internal buffer of QUIC RX buffer. */
+#define QUIC_RX_BUFSZ  (1UL << 18)
 
 extern struct trace_source trace_quic;
 extern struct pool_head *pool_head_quic_tx_ring;
+extern struct pool_head *pool_head_quic_rxbuf;
 extern struct pool_head *pool_head_quic_rx_packet;
 extern struct pool_head *pool_head_quic_tx_packet;
 extern struct pool_head *pool_head_quic_frame;
@@ -587,6 +590,12 @@
 	struct mt_list mt_list;
 };
 
+/* QUIC RX buffer */
+struct rxbuf {
+	struct buffer buf;
+	struct mt_list mt_list;
+};
+
 /* The number of buffers for outgoing packets (must be a power of two). */
 #define QUIC_CONN_TX_BUFS_NB 8
 #define QUIC_CONN_TX_BUF_SZ  QUIC_PACKET_MAXLEN
diff --git a/src/proto_quic.c b/src/proto_quic.c
index 1aa3e69..9c2bbd6 100644
--- a/src/proto_quic.c
+++ b/src/proto_quic.c
@@ -528,19 +528,19 @@
 /* Allocate the TX ring buffers for <l> listener.
  * Return 1 if succeeded, 0 if not.
  */
-static int quic_alloc_rings_listener(struct listener *l)
+static int quic_alloc_tx_rings_listener(struct listener *l)
 {
 	struct qring *qr;
 	int i;
 
-	l->rx.qrings = calloc(global.nbthread, sizeof *l->rx.qrings);
-	if (!l->rx.qrings)
+	l->rx.tx_qrings = calloc(global.nbthread, sizeof *l->rx.tx_qrings);
+	if (!l->rx.tx_qrings)
 		return 0;
 
-	MT_LIST_INIT(&l->rx.tx_qrings);
+	MT_LIST_INIT(&l->rx.tx_qring_list);
 	for (i = 0; i < global.nbthread; i++) {
 		unsigned char *buf;
-		struct qring *qr = &l->rx.qrings[i];
+		struct qring *qr = &l->rx.tx_qrings[i];
 
 		buf = pool_alloc(pool_head_quic_tx_ring);
 		if (!buf)
@@ -552,20 +552,54 @@
 			goto err;
 		}
 
-		MT_LIST_APPEND(&l->rx.tx_qrings, &qr->mt_list);
+		MT_LIST_APPEND(&l->rx.tx_qring_list, &qr->mt_list);
 	}
 
 	return 1;
 
  err:
-	while ((qr = MT_LIST_POP(&l->rx.tx_qrings, typeof(qr), mt_list))) {
+	while ((qr = MT_LIST_POP(&l->rx.tx_qring_list, typeof(qr), mt_list))) {
 		pool_free(pool_head_quic_tx_ring, qr->cbuf->buf);
 		cbuf_free(qr->cbuf);
 	}
-	free(l->rx.qrings);
+	free(l->rx.tx_qrings);
 	return 0;
 }
 
+/* Allocate the RX buffers for <l> listener.
+ * Return 1 if succeeded, 0 if not.
+ */
+static int quic_alloc_rxbufs_listener(struct listener *l)
+{
+	int i;
+	struct rxbuf *rxbuf;
+
+	l->rx.rxbufs = calloc(global.nbthread, sizeof *l->rx.rxbufs);
+	if (!l->rx.rxbufs)
+		return 0;
+
+	MT_LIST_INIT(&l->rx.rxbuf_list);
+	for (i = 0; i < global.nbthread; i++) {
+		char *buf;
+
+		rxbuf = &l->rx.rxbufs[i];
+		buf = pool_alloc(pool_head_quic_rxbuf);
+		if (!buf)
+			goto err;
+
+		rxbuf->buf = b_make(buf, QUIC_RX_BUFSZ, 0, 0);
+		MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->mt_list);
+	}
+
+	return 1;
+
+ err:
+	while ((rxbuf = MT_LIST_POP(&l->rx.rxbuf_list, typeof(rxbuf), mt_list)))
+		pool_free(pool_head_quic_rxbuf, rxbuf->buf.area);
+	free(l->rx.rxbufs);
+	return 0;
+}
+
 /* This function tries to bind a QUIC4/6 listener. It may return a warning or
  * an error message in <errmsg> if the message is at most <errlen> bytes long
  * (including '\0'). Note that <errmsg> may be NULL if <errlen> is also zero.
@@ -596,8 +630,9 @@
 		goto udp_return;
 	}
 
-	if (!quic_alloc_rings_listener(listener)) {
-		msg = "could not initialize tx rings";
+	if (!quic_alloc_tx_rings_listener(listener) ||
+	    !quic_alloc_rxbufs_listener(listener)) {
+		msg = "could not initialize tx/rx rings";
 		err |= ERR_WARN;
 		goto udp_return;
 	}
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index 49165c3..9de8a03 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -139,6 +139,7 @@
 static BIO_METHOD *ha_quic_meth;
 
 DECLARE_POOL(pool_head_quic_tx_ring, "quic_tx_ring_pool", QUIC_TX_RING_BUFSZ);
+DECLARE_POOL(pool_head_quic_rxbuf, "quic_rxbuf_pool", QUIC_RX_BUFSZ);
 DECLARE_STATIC_POOL(pool_head_quic_conn_ctx,
                     "quic_conn_ctx_pool", sizeof(struct ssl_sock_ctx));
 DECLARE_STATIC_POOL(pool_head_quic_conn, "quic_conn", sizeof(struct quic_conn));
@@ -3016,7 +3017,7 @@
 		if (scid_len)
 			memcpy(qc->dcid.data, scid, scid_len);
 		qc->dcid.len = scid_len;
-		qc->tx.qring_list = &l->rx.tx_qrings;
+		qc->tx.qring_list = &l->rx.tx_qring_list;
 		qc->li = l;
 	}
 	/* QUIC Client (outgoing connection to servers) */