core: Define return value behaviours for binding Tx callbacks
Binding Tx callbacks must return 0 upon success or a negative error code
on failure. Some error codes invoke specific error handling behaviours.
If a binding Tx callback returns the following negative error codes:
1. EMSGSIZE: The packet whose transmission failed is dequeued from the
transmit queue and dropped, as it will never be successfully
transmitted
2. EBUSY: The packet whose transmission failed remains queued for a
subsequent attempt.
This prevents Tx queue stalls for bindings such as astlpc where
reinitialisation can renegotiate the Tx buffer size to a lower value
than the size of packets already in the Tx queue. Previously the
implementation in core failed to discard the packet from the binding Tx
queue if transmission of the head packet was not possible.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I7dde22bd7340f2c028adf5112d7d4ab78cac66a6
diff --git a/astlpc.c b/astlpc.c
index 0e7e9f8..455276d 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -821,9 +821,10 @@
__func__, len, hdr->src, hdr->dest, hdr->flags_seq_tag);
if (len > astlpc->proto->body_size(astlpc->layout.tx.size)) {
- astlpc_prwarn(astlpc, "invalid TX len %" PRIu32 ": %" PRIu32, len,
- astlpc->proto->body_size(astlpc->layout.tx.size));
- return -1;
+ astlpc_prwarn(astlpc, "invalid TX len %" PRIu32 ": %" PRIu32,
+ len,
+ astlpc->proto->body_size(astlpc->layout.tx.size));
+ return -EMSGSIZE;
}
mctp_binding_set_tx_enabled(b, false);