Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:de_bch - calculate BCH ecc parity of data*@bch: BCH control structure*@data: data to encode*@len: data length in bytes*@ecc: ecc parity data, must be initialized by caller* The @ecc parity array is used both as input and output parameter, in order to

Proto:void encode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, uint8_t *ecc)

Type:void

Parameter:

TypeParameterName
struct bch_control *bch
const uint8_t *data
unsigned intlen
uint8_t *ecc
193  l = BCH_ECC_WORDS(bch) - 1
197  r_bytes = BCH_ECC_WORDS(bch) * size of r
198  tab0 = mod8_tab
199  tab1 = tab0 + 256 * (l + 1)
200  tab2 = tab1 + 256 * (l + 1)
201  tab3 = tab2 + 256 * (l + 1)
204  If WARN_ON(r_bytes > size of r ) Then Return
207  If ecc Then
209  vert ecc bytes to aligned, zero-padded 32-bit ecc words
210  Else
211  memset(ecc_buf, 0, r_bytes)
215  m = data & 3
216  If m Then
217  mlen = If len < 4 - m Then len Else 4 - m
218  same as encode_bch(), but process input data one byte at a time
219  data += mlen
220  len -= mlen
224  pdata = data
225  mlen = len / 4
226  data += 4 * mlen
227  len -= 4 * mlen
228  No 3D Now!(r, ecc_buf, r_bytes)
241  When mlen-- cycle
243  w = r[0] ^ cpu_to_be32( * pdata++)
244  p0 = tab0 + (l + 1) * ( w >> 0 & 0xff)
245  p1 = tab1 + (l + 1) * ( w >> 8 & 0xff)
246  p2 = tab2 + (l + 1) * ( w >> 16 & 0xff)
247  p3 = tab3 + (l + 1) * ( w >> 24 & 0xff)
249  When i < l cycle r[i] = r[i + 1] ^ p0[i] ^ p1[i] ^ p2[i] ^ p3[i]
252  r[l] = p0[l] ^ p1[l] ^ p2[l] ^ p3[l]
254  No 3D Now!(ecc_buf, r, r_bytes)
257  If len Then same as encode_bch(), but process input data one byte at a time
261  If ecc Then vert 32-bit ecc words to ecc bytes
Caller
NameDescribe
decode_bchdecode_bch - decode received codeword and find bit error locations*@bch: BCH control structure*@data: received data, ignored if @calc_ecc is provided*@len: data length in bytes, must always be provided*@recv_ecc: received ecc, if NULL then assume it was