[PATCH] nvmet-tcp: fix data digest calculation for multiple H2CData PDUs

Varun Prakash varun at chelsio.com
Tue Aug 1 01:26:21 PDT 2023


>Maybe instead of (re)coding crypto_ahash_digest, maybe we can do a
>little hack to pass the request sg from cmd->sg_idx which is already
>set when we build the pdu?
>
>Something like:
>--
>+static void nvmet_tcp_calc_recv_ddgst(struct ahash_request *hash,
>+               struct nvmet_tcp_cmd *cmd)
>+{
>+       struct scatterlist *sg;
>+       u32 sg_offset;
>+
>+       sg = &cmd->req.sg[cmd->sg_idx];
>+
>+       /*
>+        * adjust the offset for the first sg element if the received bytes
>+        * is not aligned to page size (and adjust back after the ddgst
>+        * calculation). A bit hacky but we don't need to do the hash digest
>+        * update per sg entry this way.
>+        */
>+       sg_offset = cmd->rbytes_done % PAGE_SIZE;
>+       sg->offset -= sg_offset;
>+       __nvmet_tcp_calc_ddgst(hash, sg, (void *)&cmd->exp_ddgst, 
>cmd->pdu_len);
>+       sg->offset += sg_offset;
> }
>--

In case of offset instead of updating sg->offset can we calculate digest
for first sg separately by using local sg variable?


More information about the Linux-nvme mailing list