Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\842\842_compress.c Create Date:2022-07-28 06:57:25
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:sw842_compress* Compress the uncompressed buffer of length @ilen at @in to the output buffer*@out, using no more than @olen bytes, using the 842 compression format

Proto:int sw842_compress(const u8 *in, unsigned int ilen, u8 *out, unsigned int *olen, void *wmem)

Type:int

Parameter:

TypeParameterName
const u8 *in
unsigned intilen
u8 *out
unsigned int *olen
void *wmem
480  p = wmem
483  repeat_count = 0
486  BUILD_BUG_ON - break compile if a condition is true( size of p > SW842_MEM_COMPRESS)
488  init_hashtable_nodes(p, 8)
489  init_hashtable_nodes(p, 4)
490  init_hashtable_nodes(p, 2)
492  in = in
493  instart = in
494  ilen = ilen
495  out = out
496  olen = olen
497  bit = 0
499  total = olen
501  olen = 0
504  If By default, we allow compressing input buffers of any length, but we must* use the non-standard "short data" template so the decompressor can correctly* reproduce the uncompressed data buffer at the right length && ilen % 8 Then
505  pr_err("Using strict mode, can't compress len %d\n", ilen)
506  Return -EINVAL
510  If Value for the false possibility is greater at compile time(ilen < 8) Then Go to skip_comp
514  last = ~get value from possibly mis-aligned location((u64 * )in)
516  When ilen > 7 cycle
517  next = get value from possibly mis-aligned location((u64 * )in)
522  get_next_data(p)
528  If next == last Then
530  If ++repeat_count <= REPEAT_BITS_MAX Then Go to repeat
533  If repeat_count Then
535  repeat_count = 0
536  If next == last Then Go to repeat
540  If next == 0 Then ret = add_zeros_template(p)
542  Else ret = d the next template to use, and add it* the p->dataN fields must already be set for the current 8 byte block
545  If ret Then Return ret
548  repeat :
549  last = next
550  pdate the hashtable entries.* only call this after finding/adding the current template* the dataN fields for the current 8 byte block must be already updated
551  in += 8
552  ilen -= 8
555  If repeat_count Then
556  ret = add_repeat_template(p, repeat_count)
557  If ret Then Return ret
561  skip_comp :
562  If ilen > 0 Then
563  ret = add_short_data_template(p, ilen)
564  If ret Then Return ret
567  in += ilen
568  ilen = 0
571  ret = add_end_template(p)
572  If ret Then Return ret
582  crc = crc32_be(0, in, ilen)
583  ret = add_bits(p, crc, CRC_BITS)
584  If ret Then Return ret
587  If bit Then
588  out++
589  olen--
590  bit = 0
594  pad = (8 - (total - olen) % 8 ) % 8
595  If pad Then
596  If pad > olen Then Return -ENOSPC
598  memset(out, 0, pad)
599  out += pad
600  olen -= pad
603  If Value for the false possibility is greater at compile time((total - olen) > UINT_MAX) Then Return -ENOSPC
606  olen = total - olen
608  Return 0