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 <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250515081008.583578-12-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
Jamin Lin 2025-05-15 16:09:43 +08:00 committed by Cédric Le Goater
parent 973fab3b30
commit 7b4e588000

View file

@ -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) {