Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 1a595394b241504ff370a8d12ebfcea7 > files > 3390

kernel-doc-3.11.10-100.fc18.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
	"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>

<book id="Reed-Solomon-Library-Guide">
 <bookinfo>
  <title>Reed-Solomon Library Programming Interface</title>
  
  <authorgroup>
   <author>
    <firstname>Thomas</firstname>
    <surname>Gleixner</surname>
    <affiliation>
     <address>
      <email>tglx@linutronix.de</email>
     </address>
    </affiliation>
   </author>
  </authorgroup>

  <copyright>
   <year>2004</year>
   <holder>Thomas Gleixner</holder>
  </copyright>

  <legalnotice>
   <para>
     This documentation is free software; you can redistribute
     it and/or modify it under the terms of the GNU General Public
     License version 2 as published by the Free Software Foundation.
   </para>
      
   <para>
     This program is distributed in the hope that it will be
     useful, but WITHOUT ANY WARRANTY; without even the implied
     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     See the GNU General Public License for more details.
   </para>
      
   <para>
     You should have received a copy of the GNU General Public
     License along with this program; if not, write to the Free
     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     MA 02111-1307 USA
   </para>
      
   <para>
     For more details see the file COPYING in the source
     distribution of Linux.
   </para>
  </legalnotice>
 </bookinfo>

<toc></toc>

  <chapter id="intro">
      <title>Introduction</title>
  <para>
  	The generic Reed-Solomon Library provides encoding, decoding
	and error correction functions.
  </para>
  <para>
  	Reed-Solomon codes are used in communication and storage
	applications to ensure data integrity. 
  </para>
  <para>
  	This documentation is provided for developers who want to utilize
	the functions provided by the library.
  </para>
  </chapter>
  
  <chapter id="bugs">
     <title>Known Bugs And Assumptions</title>
  <para>
	None.	
  </para>
  </chapter>

  <chapter id="usage">
     	<title>Usage</title>
	<para>
		This chapter provides examples of how to use the library.
	</para>
	<sect1>
		<title>Initializing</title>
		<para>
			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.
		</para>
		<programlisting>
/* 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);
		</programlisting>
	</sect1>
	<sect1>
		<title>Encoding</title>
		<para>
			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.
		</para>
		<para>
			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.
		</para>
		<para>
			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.
		</para>
		<programlisting>
/* Parity buffer. Size = number of roots */
uint16_t par[6];
/* Initialize the parity buffer */
memset(par, 0, sizeof(par));
/* Encode 512 byte in data8. Store parity in buffer par */
encode_rs8 (rs_decoder, data8, 512, par, 0);
		</programlisting>
	</sect1>
	<sect1>
		<title>Decoding</title>
		<para>
			The decoder calculates the syndrome over
			the given data length and the received parity symbols
			and corrects errors in the data.
		</para>
		<para>
			If a syndrome is available from a hardware decoder
			then the syndrome calculation is skipped.
		</para>
		<para>
			The correction of the data buffer can be suppressed
			by providing a correction pattern buffer and an error
			location buffer to the decoder. The decoder stores the
			calculated error location and the correction bitmask
			in the given buffers. This is useful for hardware
			decoders which use a weird bit ordering scheme.
		</para>
		<para>
			The databytes are expanded to the given symbol size
			on the fly. There is no support for decoding continuous
			bitstreams with a symbolsize != 8 at the moment. If
			it is necessary it should be not a big deal to implement
			such functionality.
		</para>
		
		<sect2>
		<title>
			Decoding with syndrome calculation, direct data correction
		</title>
		<programlisting>
/* Parity buffer. Size = number of roots */
uint16_t par[6];
uint8_t  data[512];
int numerr;
/* Receive data */
.....
/* Receive parity */
.....
/* Decode 512 byte in data8.*/
numerr = decode_rs8 (rs_decoder, data8, par, 512, NULL, 0, NULL, 0, NULL);
		</programlisting>
		</sect2>

		<sect2>
		<title>
			Decoding with syndrome given by hardware decoder, direct data correction
		</title>
		<programlisting>
/* Parity buffer. Size = number of roots */
uint16_t par[6], syn[6];
uint8_t  data[512];
int numerr;
/* Receive data */
.....
/* Receive parity */
.....
/* Get syndrome from hardware decoder */
.....
/* Decode 512 byte in data8.*/
numerr = decode_rs8 (rs_decoder, data8, par, 512, syn, 0, NULL, 0, NULL);
		</programlisting>
		</sect2>

		<sect2>
		<title>
			Decoding with syndrome given by hardware decoder, no direct data correction.
		</title>
		<para>
			Note: It's not necessary to give data and received parity to the decoder.
		</para>
		<programlisting>
/* Parity buffer. Size = number of roots */
uint16_t par[6], syn[6], corr[8];
uint8_t  data[512];
int numerr, errpos[8];
/* Receive data */
.....
/* Receive parity */
.....
/* Get syndrome from hardware decoder */
.....
/* Decode 512 byte in data8.*/
numerr = decode_rs8 (rs_decoder, NULL, NULL, 512, syn, 0, errpos, 0, corr);
for (i = 0; i &lt; numerr; i++) {
	do_error_correction_in_your_buffer(errpos[i], corr[i]);
}
		</programlisting>
		</sect2>
	</sect1>
	<sect1>
		<title>Cleanup</title>
		<para>
			The function free_rs frees the allocated resources,
			if the caller is the last user of the decoder.
		</para>
		<programlisting>
/* Release resources */
free_rs(rs_decoder);
		</programlisting>
	</sect1>

  </chapter>
	
  <chapter id="structs">
     <title>Structures</title>
     <para>
     This chapter contains the autogenerated documentation of the structures which are
     used in the Reed-Solomon Library and are relevant for a developer.
     </para>
<!-- include/linux/rslib.h -->
<refentry id="API-struct-rs-control">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>struct rs_control</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>struct rs_control</refname>
 <refpurpose>
  rs control structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <programlisting>
struct rs_control {
  int mm;
  int nn;
  uint16_t * alpha_to;
  uint16_t * index_of;
  uint16_t * genpoly;
  int nroots;
  int fcr;
  int prim;
  int iprim;
  int gfpoly;
  int (* gffunc) (int);
  int users;
  struct list_head list;
};  </programlisting>
</refsynopsisdiv>
 <refsect1>
  <title>Members</title>
  <variablelist>
    <varlistentry>      <term>mm</term>
      <listitem><para>
Bits per symbol
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>nn</term>
      <listitem><para>
Symbols per block (= (1&lt;&lt;mm)-1)
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>alpha_to</term>
      <listitem><para>
log lookup table
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>index_of</term>
      <listitem><para>
Antilog lookup table
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>genpoly</term>
      <listitem><para>
Generator polynomial
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>nroots</term>
      <listitem><para>
Number of generator roots = number of parity symbols
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>fcr</term>
      <listitem><para>
First consecutive root, index form
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>prim</term>
      <listitem><para>
Primitive element, index form
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>iprim</term>
      <listitem><para>
prim-th root of 1, index form
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>gfpoly</term>
      <listitem><para>
The primitive generator polynominal
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>gffunc</term>
      <listitem><para>
Function to generate the field, if non-canonical representation
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>users</term>
      <listitem><para>
Users of this structure
      </para></listitem>
    </varlistentry>
    <varlistentry>      <term>list</term>
      <listitem><para>
List entry for the rs control list
      </para></listitem>
    </varlistentry>
  </variablelist>
 </refsect1>
</refentry>

  </chapter>

  <chapter id="pubfunctions">
     <title>Public Functions Provided</title>
     <para>
     This chapter contains the autogenerated documentation of the Reed-Solomon functions
     which are exported.
     </para>
<!-- lib/reed_solomon/reed_solomon.c -->
<refentry id="API-free-rs">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>free_rs</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>free_rs</refname>
 <refpurpose>
  Free the rs control structure, if it is no longer used
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>free_rs </function></funcdef>
   <paramdef>struct rs_control * <parameter>rs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>rs</parameter></term>
   <listitem>
    <para>
     the control structure which is not longer used by the
     caller
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-init-rs">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>init_rs</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>init_rs</refname>
 <refpurpose>
     Find a matching or allocate a new rs control structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct rs_control * <function>init_rs </function></funcdef>
   <paramdef>int <parameter>symsize</parameter></paramdef>
   <paramdef>int <parameter>gfpoly</parameter></paramdef>
   <paramdef>int <parameter>fcr</parameter></paramdef>
   <paramdef>int <parameter>prim</parameter></paramdef>
   <paramdef>int <parameter>nroots</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>symsize</parameter></term>
   <listitem>
    <para>
     the symbol size (number of bits)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfpoly</parameter></term>
   <listitem>
    <para>
     the extended Galois field generator polynomial coefficients,
     with the 0th coefficient in the low order bit. The polynomial
     must be primitive;
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fcr</parameter></term>
   <listitem>
    <para>
     the first consecutive root of the rs code generator polynomial
     in index form
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>prim</parameter></term>
   <listitem>
    <para>
     primitive element to generate polynomial roots
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nroots</parameter></term>
   <listitem>
    <para>
     RS code generator polynomial degree (number of roots)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-init-rs-non-canonical">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>init_rs_non_canonical</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>init_rs_non_canonical</refname>
 <refpurpose>
     Find a matching or allocate a new rs control structure, for fields with non-canonical representation
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct rs_control * <function>init_rs_non_canonical </function></funcdef>
   <paramdef>int <parameter>symsize</parameter></paramdef>
   <paramdef>int (*<parameter>gffunc</parameter>)
     <funcparams>int</funcparams></paramdef>
   <paramdef>int <parameter>fcr</parameter></paramdef>
   <paramdef>int <parameter>prim</parameter></paramdef>
   <paramdef>int <parameter>nroots</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>symsize</parameter></term>
   <listitem>
    <para>
     the symbol size (number of bits)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gffunc</parameter></term>
   <listitem>
    <para>
     pointer to function to generate the next field element,
     or the multiplicative identity element if given 0.  Used
     instead of gfpoly if gfpoly is 0
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fcr</parameter></term>
   <listitem>
    <para>
     the first consecutive root of the rs code generator polynomial
     in index form
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>prim</parameter></term>
   <listitem>
    <para>
     primitive element to generate polynomial roots
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nroots</parameter></term>
   <listitem>
    <para>
     RS code generator polynomial degree (number of roots)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-encode-rs8">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>encode_rs8</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>encode_rs8</refname>
 <refpurpose>
     Calculate the parity for data values (8bit data width)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>encode_rs8 </function></funcdef>
   <paramdef>struct rs_control * <parameter>rs</parameter></paramdef>
   <paramdef>uint8_t * <parameter>data</parameter></paramdef>
   <paramdef>int <parameter>len</parameter></paramdef>
   <paramdef>uint16_t * <parameter>par</parameter></paramdef>
   <paramdef>uint16_t <parameter>invmsk</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>rs</parameter></term>
   <listitem>
    <para>
     the rs control structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     data field of a given type
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     data length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>par</parameter></term>
   <listitem>
    <para>
     parity data, must be initialized by caller (usually all 0)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>invmsk</parameter></term>
   <listitem>
    <para>
     invert data mask (will be xored on data)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The parity uses a uint16_t data type to enable
   symbol size &gt; 8. The calling code must take care of encoding of the
   syndrome result for storage itself.
</para>
</refsect1>
</refentry>

<refentry id="API-decode-rs8">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>decode_rs8</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>decode_rs8</refname>
 <refpurpose>
     Decode codeword (8bit data width)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>decode_rs8 </function></funcdef>
   <paramdef>struct rs_control * <parameter>rs</parameter></paramdef>
   <paramdef>uint8_t * <parameter>data</parameter></paramdef>
   <paramdef>uint16_t * <parameter>par</parameter></paramdef>
   <paramdef>int <parameter>len</parameter></paramdef>
   <paramdef>uint16_t * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>no_eras</parameter></paramdef>
   <paramdef>int * <parameter>eras_pos</parameter></paramdef>
   <paramdef>uint16_t <parameter>invmsk</parameter></paramdef>
   <paramdef>uint16_t * <parameter>corr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>rs</parameter></term>
   <listitem>
    <para>
     the rs control structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     data field of a given type
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>par</parameter></term>
   <listitem>
    <para>
     received parity data field
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     data length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     syndrome data field (if NULL, syndrome is calculated)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>no_eras</parameter></term>
   <listitem>
    <para>
     number of erasures
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>eras_pos</parameter></term>
   <listitem>
    <para>
     position of erasures, can be NULL
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>invmsk</parameter></term>
   <listitem>
    <para>
     invert data mask (will be xored on data, not on parity!)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>corr</parameter></term>
   <listitem>
    <para>
     buffer to store correction bitmask on eras_pos
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The syndrome and parity uses a uint16_t data type to enable
   symbol size &gt; 8. The calling code must take care of decoding of the
   syndrome result and the received parity before calling this code.
   Returns the number of corrected bits or -EBADMSG for uncorrectable errors.
</para>
</refsect1>
</refentry>

<refentry id="API-encode-rs16">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>encode_rs16</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>encode_rs16</refname>
 <refpurpose>
     Calculate the parity for data values (16bit data width)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>encode_rs16 </function></funcdef>
   <paramdef>struct rs_control * <parameter>rs</parameter></paramdef>
   <paramdef>uint16_t * <parameter>data</parameter></paramdef>
   <paramdef>int <parameter>len</parameter></paramdef>
   <paramdef>uint16_t * <parameter>par</parameter></paramdef>
   <paramdef>uint16_t <parameter>invmsk</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>rs</parameter></term>
   <listitem>
    <para>
     the rs control structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     data field of a given type
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     data length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>par</parameter></term>
   <listitem>
    <para>
     parity data, must be initialized by caller (usually all 0)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>invmsk</parameter></term>
   <listitem>
    <para>
     invert data mask (will be xored on data, not on parity!)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Each field in the data array contains up to symbol size bits of valid data.
</para>
</refsect1>
</refentry>

<refentry id="API-decode-rs16">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>December 2013</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>decode_rs16</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">3.11.10</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>decode_rs16</refname>
 <refpurpose>
     Decode codeword (16bit data width)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>decode_rs16 </function></funcdef>
   <paramdef>struct rs_control * <parameter>rs</parameter></paramdef>
   <paramdef>uint16_t * <parameter>data</parameter></paramdef>
   <paramdef>uint16_t * <parameter>par</parameter></paramdef>
   <paramdef>int <parameter>len</parameter></paramdef>
   <paramdef>uint16_t * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>no_eras</parameter></paramdef>
   <paramdef>int * <parameter>eras_pos</parameter></paramdef>
   <paramdef>uint16_t <parameter>invmsk</parameter></paramdef>
   <paramdef>uint16_t * <parameter>corr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>rs</parameter></term>
   <listitem>
    <para>
     the rs control structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     data field of a given type
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>par</parameter></term>
   <listitem>
    <para>
     received parity data field
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     data length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     syndrome data field (if NULL, syndrome is calculated)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>no_eras</parameter></term>
   <listitem>
    <para>
     number of erasures
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>eras_pos</parameter></term>
   <listitem>
    <para>
     position of erasures, can be NULL
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>invmsk</parameter></term>
   <listitem>
    <para>
     invert data mask (will be xored on data, not on parity!)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>corr</parameter></term>
   <listitem>
    <para>
     buffer to store correction bitmask on eras_pos
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Each field in the data array contains up to symbol size bits of valid data.
   Returns the number of corrected bits or -EBADMSG for uncorrectable errors.
</para>
</refsect1>
</refentry>

  </chapter>
  
  <chapter id="credits">
     <title>Credits</title>
	<para>
		The library code for encoding and decoding was written by Phil Karn.
	</para>
	<programlisting>
		Copyright 2002, Phil Karn, KA9Q
 		May be used under the terms of the GNU General Public License (GPL)
	</programlisting>
	<para>
		The wrapper functions and interfaces are written by Thomas Gleixner.
	</para>
	<para>
		Many users have provided bugfixes, improvements and helping hands for testing.
		Thanks a lot.
	</para>
	<para>
		The following people have contributed to this document:
	</para>
	<para>
		Thomas Gleixner<email>tglx@linutronix.de</email>
	</para>
  </chapter>
</book>