libmctp: Split padding in pktbuf into header and trailer
The astlpc binding will shortly make use of a medium-specific trailer to
implement a CRC-32 integrity check over packet data. Allow for
medium-specific trailer data in the pktbuf in order to remove the need
for a bounce-buffer. The binding will trim the pktbuf to the payload
length before passing the instance up the stack.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ib215a552ff218b007f7f119c5235fbc75d9ca6cb
diff --git a/astlpc.c b/astlpc.c
index 93e5271..95d8701 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -1049,7 +1049,8 @@
astlpc->binding.version = 1;
astlpc->binding.pkt_size =
MCTP_PACKET_SIZE(mtu > MCTP_BTU ? mtu : MCTP_BTU);
- astlpc->binding.pkt_pad = 0;
+ astlpc->binding.pkt_header = 0;
+ astlpc->binding.pkt_trailer = 0;
astlpc->binding.tx = mctp_binding_astlpc_tx;
if (mode == MCTP_BINDING_ASTLPC_MODE_BMC)
astlpc->binding.start = mctp_binding_astlpc_start_bmc;
diff --git a/core.c b/core.c
index 7b1d072..19202e8 100644
--- a/core.c
+++ b/core.c
@@ -90,13 +90,13 @@
struct mctp_pktbuf *buf;
size_t size;
- size = binding->pkt_size + binding->pkt_pad;
+ size = binding->pkt_size + binding->pkt_header + binding->pkt_trailer;
/* todo: pools */
buf = __mctp_alloc(sizeof(*buf) + size);
buf->size = size;
- buf->start = binding->pkt_pad;
+ buf->start = binding->pkt_header;
buf->end = buf->start + len;
buf->mctp_hdr_off = buf->start;
buf->next = NULL;
diff --git a/libmctp.h b/libmctp.h
index 7aa24a2..36e1483 100644
--- a/libmctp.h
+++ b/libmctp.h
@@ -103,7 +103,8 @@
struct mctp_bus *bus;
struct mctp *mctp;
size_t pkt_size;
- size_t pkt_pad;
+ size_t pkt_header;
+ size_t pkt_trailer;
int (*start)(struct mctp_binding *binding);
int (*tx)(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
mctp_rx_fn control_rx;
diff --git a/serial.c b/serial.c
index 007a377..ac91eb4 100644
--- a/serial.c
+++ b/serial.c
@@ -344,7 +344,8 @@
serial->binding.name = "serial";
serial->binding.version = 1;
serial->binding.pkt_size = MCTP_PACKET_SIZE(MCTP_BTU);
- serial->binding.pkt_pad = 0;
+ serial->binding.pkt_header = 0;
+ serial->binding.pkt_header = 0;
serial->binding.start = mctp_serial_core_start;
serial->binding.tx = mctp_binding_serial_tx;
diff --git a/tests/test-utils.c b/tests/test-utils.c
index c9defe2..d1a306c 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -30,7 +30,8 @@
test->binding.version = 1;
test->binding.tx = mctp_binding_test_tx;
test->binding.pkt_size = MCTP_PACKET_SIZE(MCTP_BTU);
- test->binding.pkt_pad = 0;
+ test->binding.pkt_header = 0;
+ test->binding.pkt_trailer = 0;
return test;
}
diff --git a/tests/test_bridge.c b/tests/test_bridge.c
index 1a2fc38..923ee82 100644
--- a/tests/test_bridge.c
+++ b/tests/test_bridge.c
@@ -70,7 +70,8 @@
binding->binding.version = 1;
binding->binding.tx = mctp_binding_bridge_tx;
binding->binding.pkt_size = MCTP_PACKET_SIZE(MCTP_BTU);
- binding->binding.pkt_pad = 0;
+ binding->binding.pkt_header = 0;
+ binding->binding.pkt_trailer = 0;
return binding;
}
diff --git a/tests/test_cmds.c b/tests/test_cmds.c
index 1772734..057a755 100644
--- a/tests/test_cmds.c
+++ b/tests/test_cmds.c
@@ -63,7 +63,8 @@
test_binding->version = 1;
test_binding->tx = NULL;
test_binding->pkt_size = MCTP_PACKET_SIZE(MCTP_BTU);
- test_binding->pkt_pad = 0;
+ test_binding->pkt_header = 0;
+ test_binding->pkt_trailer = 0;
test_binding->control_rx = control_message_transport_callback;
test_binding->control_rx_data = callback_ctx;