From: Jamin Lin Date: Thu, 15 May 2025 08:09:43 +0000 (+0800) Subject: hw/misc/aspeed_hace: Support accumulative mode for direct access mode X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b4e588000699701f5906746d1b5b845391705e6;p=thirdparty%2Fqemu.git hw/misc/aspeed_hace: Support accumulative mode for direct access mode Enable accumulative mode for direct access mode operations. In direct access mode, only a single source buffer is used, so the "iovec" count is set to 1. If "acc_mode" is enabled: 1. Accumulate "total_req_len" with the current request length ("plen"). 2. Check for padding and determine whether this is the final request. Signed-off-by: Jamin Lin Reviewed-by: Cédric Le Goater Link: https://lore.kernel.org/qemu-devel/20250515081008.583578-12-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater --- diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index 62649b5b27..049f732f99 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -151,8 +151,11 @@ static uint64_t hash_get_source_addr(AspeedHACEState *s) return src_addr; } -static int hash_prepare_direct_iov(AspeedHACEState *s, struct iovec *iov) +static int hash_prepare_direct_iov(AspeedHACEState *s, struct iovec *iov, + bool acc_mode, bool *acc_final_request) { + uint32_t total_msg_len; + uint32_t pad_offset; uint64_t src; void *haddr; hwaddr plen; @@ -171,9 +174,23 @@ static int hash_prepare_direct_iov(AspeedHACEState *s, struct iovec *iov) } iov[0].iov_base = haddr; - iov[0].iov_len = plen; iov_idx = 1; + if (acc_mode) { + s->total_req_len += plen; + + if (has_padding(s, &iov[0], plen, &total_msg_len, + &pad_offset)) { + /* Padding being present indicates the final request */ + *acc_final_request = true; + iov[0].iov_len = pad_offset; + } else { + iov[0].iov_len = plen; + } + } else { + iov[0].iov_len = plen; + } + return iov_idx; } @@ -345,7 +362,8 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode, if (sg_mode) { iov_idx = hash_prepare_sg_iov(s, iov, acc_mode, &acc_final_request); } else { - iov_idx = hash_prepare_direct_iov(s, iov); + iov_idx = hash_prepare_direct_iov(s, iov, acc_mode, + &acc_final_request); } if (iov_idx <= 0) {