/** *spu_sg_at_offset()-Findthescatterlistentryatagivendistancefromthe *startofascatterlist. *@sg:[in]Startofascatterlist *@skip:[in]Distancefromthestartofthescatterlist,inbytes *@sge:[out]Scatterlistentryatskipbytesfromstart *@sge_offset:[out]Numberofbytesfromstartofsgebuffertogetto *requesteddistance. * *Return:0ifentryfoundatrequesteddistance *<0otherwise
*/ int spu_sg_at_offset(struct scatterlist *sg, unsignedint skip, struct scatterlist **sge, unsignedint *sge_offset)
{ /* byte index from start of sg to the end of the previous entry */ unsignedint index = 0; /* byte index from start of sg to the end of the current entry */ unsignedint next_index;
next_index = sg->length; while (next_index <= skip) {
sg = sg_next(sg);
index = next_index; if (!sg) return -EINVAL;
next_index += sg->length;
}
*sge_offset = skip - index;
*sge = sg; return0;
}
/* Copy len bytes of sg data, starting at offset skip, to a dest buffer */ void sg_copy_part_to_buf(struct scatterlist *src, u8 *dest, unsignedint len, unsignedint skip)
{
size_t copied; unsignedint nents = sg_nents(src);
copied = sg_pcopy_to_buffer(src, nents, dest, len, skip); if (copied != len) {
flow_log("%s copied %u bytes of %u requested. ",
__func__, (u32)copied, len);
flow_log("sg with %u entries and skip %u\n", nents, skip);
}
}
/** *spu_msg_sg_add()-Copyscatterlistentriesfromonesgtoanother,uptoa *givenlength. *@to_sg:scatterlisttocopyto *@from_sg:scatterlisttocopyfrom *@from_skip:numberofbytestoskipinfrom_sg.Non-zerowhenprevious *requestincludedpartofthebufferinentryinfrom_sg. *Assumesfrom_skip<from_sg->length. *@from_nents:numberofentriesinfrom_sg *@length:numberofbytestocopy.mayreachthislimitbeforeexhausting *from_sg. * *Copiestheentriesthemselves,notthedataintheentries.Assumesto_sghas *enoughentries.Doesnotlimitthesizeofanindividualbufferinto_sg. * *to_sg,from_sg,skipareallupdatedtoendofcopy * *Return:Numberofbytescopied
*/
u32 spu_msg_sg_add(struct scatterlist **to_sg, struct scatterlist **from_sg, u32 *from_skip,
u8 from_nents, u32 length)
{ struct scatterlist *sg; /* an entry in from_sg */ struct scatterlist *to = *to_sg; struct scatterlist *from = *from_sg;
u32 skip = *from_skip;
u32 offset; int i;
u32 entry_len = 0;
u32 frag_len = 0; /* length of entry added to to_sg */
u32 copied = 0; /* number of bytes copied so far */
if (length == 0) return0;
for_each_sg(from, sg, from_nents, i) { /* number of bytes in this from entry not yet used */
entry_len = sg->length - skip;
frag_len = min(entry_len, length - copied);
offset = sg->offset + skip; if (frag_len)
sg_set_page(to++, sg_page(sg), frag_len, offset);
copied += frag_len; if (copied == entry_len) { /* used up all of from entry */
skip = 0; /* start at beginning of next entry */
} if (copied == length) break;
}
*to_sg = to;
*from_sg = sg; if (frag_len < entry_len)
*from_skip = skip + frag_len; else
*from_skip = 0;
*low_be = __cpu_to_be64(new_low); if (new_low < orig_low) /* there was a carry from the low 8 bytes */
*high_be = __cpu_to_be64(__be64_to_cpu(*high_be) + 1);
}
#ifdef DEBUG /* Dump len bytes of a scatterlist starting at skip bytes into the sg */ void __dump_sg(struct scatterlist *sg, unsignedint skip, unsignedint len)
{
u8 dbuf[16]; unsignedint idx = skip; unsignedint num_out = 0; /* number of bytes dumped so far */ unsignedint count;
/* Returns the name for a given cipher alg/mode */ char *spu_alg_name(enum spu_cipher_alg alg, enum spu_cipher_mode mode)
{ switch (alg) { case CIPHER_ALG_RC4: return"rc4"; case CIPHER_ALG_AES: switch (mode) { case CIPHER_MODE_CBC: return"cbc(aes)"; case CIPHER_MODE_ECB: return"ecb(aes)"; case CIPHER_MODE_OFB: return"ofb(aes)"; case CIPHER_MODE_CFB: return"cfb(aes)"; case CIPHER_MODE_CTR: return"ctr(aes)"; case CIPHER_MODE_XTS: return"xts(aes)"; case CIPHER_MODE_GCM: return"gcm(aes)"; default: return"aes";
} break; case CIPHER_ALG_DES: switch (mode) { case CIPHER_MODE_CBC: return"cbc(des)"; case CIPHER_MODE_ECB: return"ecb(des)"; case CIPHER_MODE_CTR: return"ctr(des)"; default: return"des";
} break; case CIPHER_ALG_3DES: switch (mode) { case CIPHER_MODE_CBC: return"cbc(des3_ede)"; case CIPHER_MODE_ECB: return"ecb(des3_ede)"; case CIPHER_MODE_CTR: return"ctr(des3_ede)"; default: return"3des";
} break; default: return"other";
}
}
/* First clear full output buffer */
memset(buf, 0, len);
/* Then, starting from right side, fill in with data */ for (i = 0; i < len; i++) {
buf[len - i - 1] = (val >> (8 * i)) & 0xff; if (i >= 3) break; /* Only handle up to 32 bits of 'val' */
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.