<!DOCTYPE html>
<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Using Linux CAIF — The Linux Kernel documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/alabaster.css?v=3918102e" />
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Netlink interface for ethtool" href="../ethtool-netlink.html" />
<link rel="prev" title="Linux CAIF" href="linux_caif.html" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/logo.svg" alt="Logo of The Linux Kernel"/>
</a></p>
<h1 class="logo"><a href="../../index.html">The Linux Kernel</a></h1>
<p class="blurb">6.18.50</p>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>
<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/index.html">All development-process docs</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../subsystem-apis.html">Subsystems</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../subsystem-apis.html#core-subsystems">Core subsystems</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../subsystem-apis.html#human-interfaces">Human interfaces</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../subsystem-apis.html#networking-interfaces">Networking interfaces</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../index.html">Networking</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../netlabel/index.html">NetLabel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../infiniband/index.html">InfiniBand</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../isdn/index.html">ISDN</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../mhi/index.html">MHI</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../subsystem-apis.html#storage-interfaces">Storage interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../subsystem-apis.html#other-subsystems">Other subsystems</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../arch/index.html">CPU architectures</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../translations/index.html">Translations</a></li>
</ul>
</div>
<script type="text/javascript"> <!--
var sbar = document.getElementsByClassName("sphinxsidebar")[0];
let currents = document.getElementsByClassName("current")
if (currents.length) {
sbar.scrollTop = currents[currents.length - 1].offsetTop;
}
--> </script>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/networking/caif/caif.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="using-linux-caif">
<h1>Using Linux CAIF<a class="headerlink" href="#using-linux-caif" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Copyright<span class="colon">:</span></dt>
<dd class="field-odd"><p>© ST-Ericsson AB 2010</p>
</dd>
<dt class="field-even">Author<span class="colon">:</span></dt>
<dd class="field-even"><p>Sjur Brendeland/ <a class="reference external" href="mailto:sjur.brandeland%40stericsson.com">sjur<span>.</span>brandeland<span>@</span>stericsson<span>.</span>com</a></p>
</dd>
</dl>
<section id="start">
<h2>Start<a class="headerlink" href="#start" title="Link to this heading">¶</a></h2>
<p>If you have compiled CAIF for modules do:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$modprobe crc_ccitt
$modprobe caif
$modprobe caif_socket
$modprobe chnl_net
</pre></div>
</div>
</section>
<section id="preparing-the-setup-with-a-ste-modem">
<h2>Preparing the setup with a STE modem<a class="headerlink" href="#preparing-the-setup-with-a-ste-modem" title="Link to this heading">¶</a></h2>
<p>If you are working on integration of CAIF you should make sure
that the kernel is built with module support.</p>
<p>There are some things that need to be tweaked to get the host TTY correctly
set up to talk to the modem.
Since the CAIF stack is running in the kernel and we want to use the existing
TTY, we are installing our physical serial driver as a line discipline above
the TTY device.</p>
<p>To achieve this we need to install the N_CAIF ldisc from user space.
The benefit is that we can hook up to any TTY.</p>
<p>The use of Start-of-frame-extension (STX) must also be set as
module parameter “ser_use_stx”.</p>
<p>Normally Frame Checksum is always used on UART, but this is also provided as a
module parameter “ser_use_fcs”.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ modprobe caif_serial ser_ttyname=/dev/ttyS0 ser_use_stx=yes
$ ifconfig caif_ttyS0 up
</pre></div>
</div>
<dl class="simple">
<dt>PLEASE NOTE:</dt><dd><p>There is a limitation in Android shell.
It only accepts one argument to insmod/modprobe!</p>
</dd>
</dl>
</section>
<section id="trouble-shooting">
<h2>Trouble shooting<a class="headerlink" href="#trouble-shooting" title="Link to this heading">¶</a></h2>
<p>There are debugfs parameters provided for serial communication.
/sys/kernel/debug/caif_serial/<tty-name>/</p>
<ul>
<li><p>ser_state: Prints the bit-mask status where</p>
<ul class="simple">
<li><p>0x02 means SENDING, this is a transient state.</p></li>
<li><p>0x10 means FLOW_OFF_SENT, i.e. the previous frame has not been sent
and is blocking further send operation. Flow OFF has been propagated
to all CAIF Channels using this TTY.</p></li>
</ul>
</li>
<li><p>tty_status: Prints the bit-mask tty status information</p>
<ul class="simple">
<li><p>0x01 - tty->warned is on.</p></li>
<li><p>0x04 - tty->packed is on.</p></li>
<li><p>0x08 - tty->flow.tco_stopped is on.</p></li>
<li><p>0x10 - tty->hw_stopped is on.</p></li>
<li><p>0x20 - tty->flow.stopped is on.</p></li>
</ul>
</li>
<li><p>last_tx_msg: Binary blob Prints the last transmitted frame.</p>
<p>This can be printed with:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$od --format=x1 /sys/kernel/debug/caif_serial/<tty>/last_rx_msg.
</pre></div>
</div>
<p>The first two tx messages sent look like this. Note: The initial
byte 02 is start of frame extension (STX) used for re-syncing
upon errors.</p>
<ul>
<li><p>Enumeration:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>0000000 02 05 00 00 03 01 d2 02
| | | | | |
STX(1) | | | |
Length(2)| | |
Control Channel(1)
Command:Enumeration(1)
Link-ID(1)
Checksum(2)
</pre></div>
</div>
</li>
<li><p>Channel Setup:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>0000000 02 07 00 00 00 21 a1 00 48 df
| | | | | | | |
STX(1) | | | | | |
Length(2)| | | | |
Control Channel(1)
Command:Channel Setup(1)
Channel Type(1)
Priority and Link-ID(1)
Endpoint(1)
Checksum(2)
</pre></div>
</div>
</li>
</ul>
</li>
<li><p>last_rx_msg: Prints the last transmitted frame.</p>
<p>The RX messages for LinkSetup look almost identical but they have the
bit 0x20 set in the command bit, and Channel Setup has added one byte
before Checksum containing Channel ID.</p>
<dl class="simple">
<dt>NOTE:</dt><dd><p>Several CAIF Messages might be concatenated. The maximum debug
buffer size is 128 bytes.</p>
</dd>
</dl>
</li>
</ul>
</section>
<section id="error-scenarios">
<h2>Error Scenarios<a class="headerlink" href="#error-scenarios" title="Link to this heading">¶</a></h2>
<ul>
<li><p>last_tx_msg contains channel setup message and last_rx_msg is empty ->
The host seems to be able to send over the UART, at least the CAIF ldisc get
notified that sending is completed.</p></li>
<li><p>last_tx_msg contains enumeration message and last_rx_msg is empty ->
The host is not able to send the message from UART, the tty has not been
able to complete the transmit operation.</p></li>
<li><p>if /sys/kernel/debug/caif_serial/<tty>/tty_status is non-zero there
might be problems transmitting over UART.</p>
<p>E.g. host and modem wiring is not correct you will typically see
tty_status = 0x10 (hw_stopped) and ser_state = 0x10 (FLOW_OFF_SENT).</p>
<p>You will probably see the enumeration message in last_tx_message
and empty last_rx_message.</p>
</li>
</ul>
</section>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©The kernel development community.
|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
|
<a href="../../_sources/networking/caif/caif.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>