Documentation/core-api/librs.rst

Source file repositories/reference/linux-study-clean/Documentation/core-api/librs.rst

File Facts

System
Linux kernel
Corpus path
Documentation/core-api/librs.rst
Extension
.rst
Size
6026 bytes
Lines
213
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

==========================================
Reed-Solomon Library Programming Interface
==========================================

:Author: Thomas Gleixner

Introduction
============

The generic Reed-Solomon Library provides encoding, decoding and error
correction functions.

Reed-Solomon codes are used in communication and storage applications to
ensure data integrity.

This documentation is provided for developers who want to utilize the
functions provided by the library.

Known Bugs And Assumptions
==========================

None.

Usage
=====

This chapter provides examples of how to use the library.

Initializing
------------

The init function init_rs returns a pointer to an rs decoder structure,
which holds the necessary information for encoding, decoding and error
correction with the given polynomial. It either uses an existing
matching decoder or creates a new one. On creation all the lookup tables
for fast en/decoding are created. The function may take a while, so make
sure not to call it in critical code paths.

::

    /* the Reed Solomon control structure */
    static struct rs_control *rs_decoder;

    /* Symbolsize is 10 (bits)
     * Primitive polynomial is x^10+x^3+1
     * first consecutive root is 0
     * primitive element to generate roots = 1
     * generator polynomial degree (number of roots) = 6
     */
    rs_decoder = init_rs (10, 0x409, 0, 1, 6);


Encoding
--------

The encoder calculates the Reed-Solomon code over the given data length
and stores the result in the parity buffer. Note that the parity buffer
must be initialized before calling the encoder.

The expanded data can be inverted on the fly by providing a non-zero
inversion mask. The expanded data is XOR'ed with the mask. This is used
e.g. for FLASH ECC, where the all 0xFF is inverted to an all 0x00. The
Reed-Solomon code for all 0x00 is all 0x00. The code is inverted before
storing to FLASH so it is 0xFF too. This prevents that reading from an
erased FLASH results in ECC errors.

The databytes are expanded to the given symbol size on the fly. There is
no support for encoding continuous bitstreams with a symbol size != 8 at
the moment. If it is necessary it should be not a big deal to implement
such functionality.

Annotation

Implementation Notes