core: Reuse buffers for tx, allow message pools
Use new m_msg_alloc/m_msg_free operations for whole-message
MCTP buffers. m_realloc is no longer used, instead the maximum
sized buffer is allocated for each reassembly.
This allows applications to keep a pool of MCTP message buffers.
Don't create a queue of packets to transmit, instead reuse a single
binding-provided tx_storage buffer for each transmitted packet, which
can be static for bindings that have a known maximum packet size.
Asynchronous users/bindings can no longer rely on the core for queueing
TX packets, instead they should test mctp_is_tx_ready() prior to calling
mctp_message_tx(). The stack will return -EBUSY from mctp_message_tx()
if there is already a message pending to send.
Bindings must be updated to add the tx_storage member, and the core will
no longer free packets passed to mctp_bus_rx().
Change-Id: I2598bb91026ccef01b268c52b06c0f8e20bebb1e
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/tests/test_bridge.c b/tests/test_bridge.c
index 35625ca..73705ba 100644
--- a/tests/test_bridge.c
+++ b/tests/test_bridge.c
@@ -19,6 +19,7 @@
int rx_count;
int tx_count;
uint8_t last_pkt_data;
+ uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)];
};
struct test_ctx {
@@ -61,6 +62,7 @@
binding->rx_count++;
mctp_bus_rx(&binding->binding, pkt);
+ mctp_pktbuf_free(pkt);
}
static struct mctp_binding_bridge *mctp_binding_bridge_init(char *name)
@@ -75,6 +77,7 @@
binding->binding.pkt_size = MCTP_PACKET_SIZE(MCTP_BTU);
binding->binding.pkt_header = 0;
binding->binding.pkt_trailer = 0;
+ binding->binding.tx_storage = binding->tx_storage;
return binding;
}