[PATCH v1 06/22] hw/misc/aspeed_hace: Support accumulative mode for direct access mode

Jamin Lin via posted 22 patches 10 months, 3 weeks ago
There is a newer version of this series
[PATCH v1 06/22] hw/misc/aspeed_hace: Support accumulative mode for direct access mode
Posted by Jamin Lin via 10 months, 3 weeks ago
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>
---
 hw/misc/aspeed_hace.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
index 8cf3f194a5..d06158dffd 100644
--- a/hw/misc/aspeed_hace.c
+++ b/hw/misc/aspeed_hace.c
@@ -223,8 +223,21 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
             return;
         }
         iov[0].iov_base = haddr;
-        iov[0].iov_len = plen;
         i = 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 */
+                sg_acc_mode_final_request = true;
+                iov[0].iov_len = pad_offset;
+            } else {
+                iov[0].iov_len = plen;
+            }
+        } else {
+            iov[0].iov_len = plen;
+        }
     }
 
     if (acc_mode) {
-- 
2.43.0
Re: [PATCH v1 06/22] hw/misc/aspeed_hace: Support accumulative mode for direct access mode
Posted by Cédric Le Goater 10 months, 1 week ago
On 3/21/25 10:26, Jamin Lin wrote:
> 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>
> ---
>   hw/misc/aspeed_hace.c | 15 ++++++++++++++-
>   1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
> index 8cf3f194a5..d06158dffd 100644
> --- a/hw/misc/aspeed_hace.c
> +++ b/hw/misc/aspeed_hace.c
> @@ -223,8 +223,21 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
>               return;
>           }
>           iov[0].iov_base = haddr;
> -        iov[0].iov_len = plen;
>           i = 1;
> +        if (acc_mode) {

hmm, more complexity is being added to do_hash_operation(). I would introduce
a sub routine do_hash_operation_acc() to handle accumulative mode.

Thanks,

C.



> +            s->total_req_len += plen;
> +
> +            if (has_padding(s, &iov[0], plen, &total_msg_len,
> +                            &pad_offset)) {
> +                /* Padding being present indicates the final request */
> +                sg_acc_mode_final_request = true;
> +                iov[0].iov_len = pad_offset;
> +            } else {
> +                iov[0].iov_len = plen;
> +            }
> +        } else {
> +            iov[0].iov_len = plen;
> +        }
>       }
>   
>       if (acc_mode) {