Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Reed Solomon FAQ
@ 2010-06-21 15:04 Thomas Gleixner
  2010-06-25  6:35 ` Ghorai, Sukumar
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Gleixner @ 2010-06-21 15:04 UTC (permalink / raw)
  To: linux-mtd; +Cc: Ghorai, Sukumar

I got repeatedly questions like the following about Reed Solomon
codes:

> Say we have allocated 8bytes in spare area to store the ECC for 512
> bytes data. And we have to correct upto 4-bit in 512-byte data. And
> would you please let me know how to configure the rs-lib for the
> same? Say we are using the 8-bit data(symbol).

It's impossible to use 8bit symbol width for 512 byte data.

      m = number of bits per symbol
      n = code length in symbols up to 2^(m-1)
      k = original data length in symbols
      r = n - k = number of redundant symbols
      t = 1/2 (n-k) = error correction capability (number of symbols)

So for this use case we get for the kernel rs lib:

   k = 512

So for 512 byte data we need a symbol width of 10. The rs lib in the
kernel handles this in the encode/decode_rs8 functions by expanding
the 8 bit FLASH data to 10 bits internally.

   m = 10

If we can store 8 byte == 64bit of redundant symbols in the spare
area, so the number of redundant symbols is:

   r = 64/10 = 6

And the resulting code lenght is:

   n = k + r = 518

So the max. number of correctable symbols is:

   t = 1/2 * 6 = 3

That might be up to 24 bit of corrected data, when the errors are not
scattered over more than 3 bytes on FLASH.

If errors happen on 4 or more different FLASH bytes, they are
uncorrectable.

The 518/512 (10 bit symbol width) code is the optimum which can be
achieved for 512 byte FLASH read/write chunks with 8 byte of spare
area usage.

To correct 4 symbols in a 512 byte data chunk we need at least 8
redundant symbols, which means 80 bit == 10 bytes storage size in the
spare area.

> Is it possible to correct 4-symbols, by max 9-byte parity?

Yes, but that requires that the 512 byte data is converted into a
serialized bitstream w/o symbol width expansion so 9 bit symbol width
can be used.

    m = 9
    k = 456 [ 512 * 8 / 9 rounded up ]
    r = 8 [ 72 / 9 ]
    t = 4

Such modes are only useful when both the encoding and the decoding are
done in hardware, as serializing / deserializing for the software
en/decoder is making the already slow software RS even more horribly
slow.

As a side note: software RS encoding/decoding is performancewise a bad
idea in general.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Reed Solomon FAQ
  2010-06-21 15:04 Reed Solomon FAQ Thomas Gleixner
@ 2010-06-25  6:35 ` Ghorai, Sukumar
  0 siblings, 0 replies; 2+ messages in thread
From: Ghorai, Sukumar @ 2010-06-25  6:35 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-mtd@lists.infradead.org

> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Monday, June 21, 2010 8:35 PM
> To: linux-mtd@lists.infradead.org
> Cc: Ghorai, Sukumar
> Subject: Reed Solomon FAQ
> 
> I got repeatedly questions like the following about Reed Solomon
> codes:
> 
> > Say we have allocated 8bytes in spare area to store the ECC for 512
> > bytes data. And we have to correct upto 4-bit in 512-byte data. And
> > would you please let me know how to configure the rs-lib for the
> > same? Say we are using the 8-bit data(symbol).
> 
> It's impossible to use 8bit symbol width for 512 byte data.
> 
>       m = number of bits per symbol
>       n = code length in symbols up to 2^(m-1)
>       k = original data length in symbols
>       r = n - k = number of redundant symbols
>       t = 1/2 (n-k) = error correction capability (number of symbols)
> 
> So for this use case we get for the kernel rs lib:
> 
>    k = 512
> 
> So for 512 byte data we need a symbol width of 10. The rs lib in the
> kernel handles this in the encode/decode_rs8 functions by expanding
> the 8 bit FLASH data to 10 bits internally.
> 
>    m = 10
> 
> If we can store 8 byte == 64bit of redundant symbols in the spare
> area, so the number of redundant symbols is:
> 
>    r = 64/10 = 6
> 
> And the resulting code lenght is:
> 
>    n = k + r = 518
> 
> So the max. number of correctable symbols is:
> 
>    t = 1/2 * 6 = 3
> 
> That might be up to 24 bit of corrected data, when the errors are not
> scattered over more than 3 bytes on FLASH.
> 
> If errors happen on 4 or more different FLASH bytes, they are
> uncorrectable.
> 
> The 518/512 (10 bit symbol width) code is the optimum which can be
> achieved for 512 byte FLASH read/write chunks with 8 byte of spare
> area usage.
> 
> To correct 4 symbols in a 512 byte data chunk we need at least 8
> redundant symbols, which means 80 bit == 10 bytes storage size in the
> spare area.
> 
> > Is it possible to correct 4-symbols, by max 9-byte parity?
> 
> Yes, but that requires that the 512 byte data is converted into a
> serialized bitstream w/o symbol width expansion so 9 bit symbol width
> can be used.
> 
>     m = 9
>     k = 456 [ 512 * 8 / 9 rounded up ]
>     r = 8 [ 72 / 9 ]
>     t = 4
> 
> Such modes are only useful when both the encoding and the decoding are
> done in hardware, as serializing / deserializing for the software
> en/decoder is making the already slow software RS even more horribly
> slow.
> 
> As a side note: software RS encoding/decoding is performancewise a bad
> idea in general.
> 
> Thanks,
> 
> 	tglx
[Ghorai] Thanks Gleixner,
It's a very informative email for me.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-25  6:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-21 15:04 Reed Solomon FAQ Thomas Gleixner
2010-06-25  6:35 ` Ghorai, Sukumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox