summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-13 23:20:13 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-12 20:55:19 -0700
commita24a60232204702fe245c312edb0c2c8041b17a8 (patch)
tree01cc4a46cad37087aa419b2b13c9aa27c568eea2 /lib9p/include
parent1793bda7f3e445c5ad81cf108589f8b1edcda4eb (diff)
lib9p: Rewrite the marshalers to support zero-copy for data
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.generated.h16
-rw-r--r--lib9p/include/lib9p/9p.h4
2 files changed, 17 insertions, 3 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index 881d2e3..d34a0f6 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -6,6 +6,8 @@
#include <stdint.h> /* for uint{n}_t types */
+#include <libhw/generic/net.h> /* for struct iovec */
+
/* config *********************************************************************/
#include "config.h"
@@ -1071,7 +1073,7 @@ struct lib9p_msg_Twstat {
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-/* sizes **********************************************************************/
+/* containers *****************************************************************/
#define _LIB9P_MAX(a, b) ((a) > (b)) ? (a) : (b)
@@ -1114,3 +1116,15 @@ struct lib9p_msg_Twstat {
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
#define LIB9P_RMSG_MAX_COPY 217
#endif
+
+struct lib9p_Tmsg_send_buf {
+ size_t iov_cnt;
+ struct iovec iov[LIB9P_TMSG_MAX_IOV];
+ uint8_t copied[LIB9P_TMSG_MAX_COPY];
+};
+
+struct lib9p_Rmsg_send_buf {
+ size_t iov_cnt;
+ struct iovec iov[LIB9P_RMSG_MAX_IOV];
+ uint8_t copied[LIB9P_RMSG_MAX_COPY];
+};
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index d4764a2..68e007f 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -118,7 +118,7 @@ void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
* @errno LINUX_ERANGE: reply does not fit in ctx->max_msg_size
*/
bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- uint8_t *ret_bytes);
+ struct lib9p_Tmsg_send_buf *ret);
/* main R-message functions ***************************************************/
@@ -128,7 +128,7 @@ ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, void *ret_body);
bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- uint8_t *ret_bytes);
+ struct lib9p_Rmsg_send_buf *ret);
/* `struct lib9p_stat` helpers ************************************************/