<!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>SAS Layer — 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="LPFC Driver Release Notes" href="lpfc.html" />
<link rel="prev" title="Highpoint RocketRAID 3xxx/4xxx Adapter Driver (hptiop)" href="hptiop.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"><a class="reference internal" href="../subsystem-apis.html#networking-interfaces">Networking interfaces</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../subsystem-apis.html#storage-interfaces">Storage interfaces</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../filesystems/index.html">Filesystems in the Linux kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../block/index.html">Block</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cdrom/index.html">CD-ROM</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="index.html">SCSI Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../target/index.html">TCM Virtual Device</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nvme/index.html">NVMe Subsystem</a></li>
</ul>
</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/scsi/libsas.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="sas-layer">
<h1>SAS Layer<a class="headerlink" href="#sas-layer" title="Link to this heading">¶</a></h1>
<p>The SAS Layer is a management infrastructure which manages
SAS LLDDs. It sits between SCSI Core and SAS LLDDs. The
layout is as follows: while SCSI Core is concerned with
SAM/SPC issues, and a SAS LLDD+sequencer is concerned with
phy/OOB/link management, the SAS layer is concerned with:</p>
<blockquote>
<div><ul class="simple">
<li><p>SAS Phy/Port/HA event management (LLDD generates,
SAS Layer processes),</p></li>
<li><p>SAS Port management (creation/destruction),</p></li>
<li><p>SAS Domain discovery and revalidation,</p></li>
<li><p>SAS Domain device management,</p></li>
<li><p>SCSI Host registration/unregistration,</p></li>
<li><p>Device registration with SCSI Core (SAS) or libata
(SATA), and</p></li>
<li><p>Expander management and exporting expander control
to user space.</p></li>
</ul>
</div></blockquote>
<p>A SAS LLDD is a PCI device driver. It is concerned with
phy/OOB management, and vendor specific tasks and generates
events to the SAS layer.</p>
<p>The SAS Layer does most SAS tasks as outlined in the SAS 1.1
spec.</p>
<p>The sas_ha_struct describes the SAS LLDD to the SAS layer.
Most of it is used by the SAS Layer but a few fields need to
be initialized by the LLDDs.</p>
<p>After initializing your hardware, from the <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">probe()</span></code> function
you call <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">sas_register_ha()</span></code>. It will register your LLDD with
the SCSI subsystem, creating a SCSI host and it will
register your SAS driver with the sysfs SAS tree it creates.
It will then return. Then you enable your phys to actually
start OOB (at which point your driver will start calling the
notify_* event callbacks).</p>
<section id="structure-descriptions">
<h2>Structure descriptions<a class="headerlink" href="#structure-descriptions" title="Link to this heading">¶</a></h2>
<section id="struct-sas-phy">
<h3><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">sas_phy</span></code><a class="headerlink" href="#struct-sas-phy" title="Link to this heading">¶</a></h3>
<p>Normally this is statically embedded to your driver’s
phy structure:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct my_phy {
blah;
struct sas_phy sas_phy;
bleh;
};
</pre></div>
</div>
<p>And then all the phys are an array of my_phy in your HA
struct (shown below).</p>
<p>Then as you go along and initialize your phys you also
initialize the sas_phy struct, along with your own
phy structure.</p>
<p>In general, the phys are managed by the LLDD and the ports
are managed by the SAS layer. So the phys are initialized
and updated by the LLDD and the ports are initialized and
updated by the SAS layer.</p>
<p>There is a scheme where the LLDD can RW certain fields,
and the SAS layer can only read such ones, and vice versa.
The idea is to avoid unnecessary locking.</p>
<dl class="simple">
<dt>enabled</dt><dd><ul class="simple">
<li><p>must be set (0/1)</p></li>
</ul>
</dd>
<dt>id</dt><dd><ul class="simple">
<li><p>must be set [0,MAX_PHYS)]</p></li>
</ul>
</dd>
<dt>class, proto, type, role, oob_mode, linkrate</dt><dd><ul class="simple">
<li><p>must be set</p></li>
</ul>
</dd>
<dt>oob_mode</dt><dd><ul class="simple">
<li><p>you set this when OOB has finished and then notify
the SAS Layer.</p></li>
</ul>
</dd>
<dt>sas_addr</dt><dd><ul class="simple">
<li><p>this normally points to an array holding the sas
address of the phy, possibly somewhere in your my_phy
struct.</p></li>
</ul>
</dd>
<dt>attached_sas_addr</dt><dd><ul class="simple">
<li><p>set this when you (LLDD) receive an
IDENTIFY frame or a FIS frame, _before_ notifying the SAS
layer. The idea is that sometimes the LLDD may want to fake
or provide a different SAS address on that phy/port and this
allows it to do this. At best you should copy the sas
address from the IDENTIFY frame or maybe generate a SAS
address for SATA directly attached devices. The Discover
process may later change this.</p></li>
</ul>
</dd>
<dt>frame_rcvd</dt><dd><ul class="simple">
<li><p>this is where you copy the IDENTIFY/FIS frame
when you get it; you lock, copy, set frame_rcvd_size and
unlock the lock, and then call the event. It is a pointer
since there’s no way to know your hw frame size _exactly_,
so you define the actual array in your phy <code class="xref c c-struct broken_xref docutils literal notranslate"><span class="pre">struct</span> <span class="pre">and</span></code> let
this pointer point to it. You copy the frame from your
DMAable memory to that area holding the lock.</p></li>
</ul>
</dd>
<dt>sas_prim</dt><dd><ul class="simple">
<li><p>this is where primitives go when they’re
received. See sas.h. Grab the lock, set the primitive,
release the lock, notify.</p></li>
</ul>
</dd>
<dt>port</dt><dd><ul class="simple">
<li><p>this points to the sas_port if the phy belongs
to a port -- the LLDD only reads this. It points to the
sas_port this phy is part of. Set by the SAS Layer.</p></li>
</ul>
</dd>
<dt>ha</dt><dd><ul class="simple">
<li><p>may be set; the SAS layer sets it anyway.</p></li>
</ul>
</dd>
<dt>lldd_phy</dt><dd><ul class="simple">
<li><p>you should set this to point to your phy so you
can find your way around faster when the SAS layer calls one
of your callbacks and passes you a phy. If the sas_phy is
embedded you can also use container_of -- whatever you
prefer.</p></li>
</ul>
</dd>
</dl>
</section>
<section id="struct-sas-port">
<h3><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">sas_port</span></code><a class="headerlink" href="#struct-sas-port" title="Link to this heading">¶</a></h3>
<p>The LLDD doesn’t set any fields of this struct -- it only
reads them. They should be self explanatory.</p>
<p>phy_mask is 32 bit, this should be enough for now, as I
haven’t heard of a HA having more than 8 phys.</p>
<dl class="simple">
<dt>lldd_port</dt><dd><ul class="simple">
<li><p>I haven’t found use for that -- maybe other
LLDD who wish to have internal port representation can make
use of this.</p></li>
</ul>
</dd>
</dl>
</section>
<section id="struct-sas-ha-struct">
<h3><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">sas_ha_struct</span></code><a class="headerlink" href="#struct-sas-ha-struct" title="Link to this heading">¶</a></h3>
<p>It normally is statically declared in your own LLDD
structure describing your adapter:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct my_sas_ha {
blah;
struct sas_ha_struct sas_ha;
struct my_phy phys[MAX_PHYS];
struct sas_port sas_ports[MAX_PHYS]; /* (1) */
bleh;
};
(1) If your LLDD doesn't have its own port representation.
</pre></div>
</div>
<p>What needs to be initialized (sample function given below).</p>
<section id="pcidev">
<h4>pcidev<a class="headerlink" href="#pcidev" title="Link to this heading">¶</a></h4>
<dl class="simple">
<dt>sas_addr</dt><dd><ul class="simple">
<li><p>since the SAS layer doesn’t want to mess with
memory allocation, etc, this points to statically
allocated array somewhere (say in your host adapter
structure) and holds the SAS address of the host
adapter as given by you or the manufacturer, etc.</p></li>
</ul>
</dd>
</dl>
</section>
<section id="sas-port">
<h4>sas_port<a class="headerlink" href="#sas-port" title="Link to this heading">¶</a></h4>
<dl class="simple">
<dt>sas_phy</dt><dd><ul class="simple">
<li><p>an array of pointers to structures. (see
note above on sas_addr).
These must be set. See more notes below.</p></li>
</ul>
</dd>
<dt>num_phys</dt><dd><ul class="simple">
<li><p>the number of phys present in the sas_phy array,
and the number of ports present in the sas_port
array. There can be a maximum num_phys ports (one per
port) so we drop the num_ports, and only use
num_phys.</p></li>
</ul>
</dd>
</dl>
<p>The event interface:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* LLDD calls these to notify the class of an event. */
void sas_notify_port_event(struct sas_phy *, enum port_event, gfp_t);
void sas_notify_phy_event(struct sas_phy *, enum phy_event, gfp_t);
</pre></div>
</div>
<p>The port notification:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* The class calls these to notify the LLDD of an event. */
void (*lldd_port_formed)(struct sas_phy *);
void (*lldd_port_deformed)(struct sas_phy *);
</pre></div>
</div>
<p>If the LLDD wants notification when a port has been formed
or deformed it sets those to a function satisfying the type.</p>
<p>A SAS LLDD should also implement at least one of the Task
Management Functions (TMFs) described in SAM:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* Task Management Functions. Must be called from process context. */
int (*lldd_abort_task)(struct sas_task *);
int (*lldd_abort_task_set)(struct domain_device *, u8 *lun);
int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
int (*lldd_I_T_nexus_reset)(struct domain_device *);
int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
int (*lldd_query_task)(struct sas_task *);
</pre></div>
</div>
<p>For more information please read SAM from T10.org.</p>
<p>Port and Adapter management:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* Port and Adapter management */
int (*lldd_clear_nexus_port)(struct sas_port *);
int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);
</pre></div>
</div>
<p>A SAS LLDD should implement at least one of those.</p>
<p>Phy management:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* Phy management */
int (*lldd_control_phy)(struct sas_phy *, enum phy_func);
</pre></div>
</div>
<dl class="simple">
<dt>lldd_ha</dt><dd><ul class="simple">
<li><p>set this to point to your HA struct. You can also
use container_of if you embedded it as shown above.</p></li>
</ul>
</dd>
</dl>
<p>A sample initialization and registration function
can look like this (called last thing from <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">probe()</span></code>)
<em>but</em> before you enable the phys to do OOB:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>static int register_sas_ha(struct my_sas_ha *my_ha)
{
int i;
static struct sas_phy *sas_phys[MAX_PHYS];
static struct sas_port *sas_ports[MAX_PHYS];
my_ha->sas_ha.sas_addr = &my_ha->sas_addr[0];
for (i = 0; i < MAX_PHYS; i++) {
sas_phys[i] = &my_ha->phys[i].sas_phy;
sas_ports[i] = &my_ha->sas_ports[i];
}
my_ha->sas_ha.sas_phy = sas_phys;
my_ha->sas_ha.sas_port = sas_ports;
my_ha->sas_ha.num_phys = MAX_PHYS;
my_ha->sas_ha.lldd_port_formed = my_port_formed;
my_ha->sas_ha.lldd_dev_found = my_dev_found;
my_ha->sas_ha.lldd_dev_gone = my_dev_gone;
my_ha->sas_ha.lldd_execute_task = my_execute_task;
my_ha->sas_ha.lldd_abort_task = my_abort_task;
my_ha->sas_ha.lldd_abort_task_set = my_abort_task_set;
my_ha->sas_ha.lldd_clear_task_set = my_clear_task_set;
my_ha->sas_ha.lldd_I_T_nexus_reset= NULL; (2)
my_ha->sas_ha.lldd_lu_reset = my_lu_reset;
my_ha->sas_ha.lldd_query_task = my_query_task;
my_ha->sas_ha.lldd_clear_nexus_port = my_clear_nexus_port;
my_ha->sas_ha.lldd_clear_nexus_ha = my_clear_nexus_ha;
my_ha->sas_ha.lldd_control_phy = my_control_phy;
return sas_register_ha(&my_ha->sas_ha);
}
</pre></div>
</div>
<ol class="arabic simple" start="2">
<li><p>SAS 1.1 does not define I_T Nexus Reset TMF.</p></li>
</ol>
</section>
</section>
</section>
<section id="events">
<h2>Events<a class="headerlink" href="#events" title="Link to this heading">¶</a></h2>
<p>Events are <strong>the only way</strong> a SAS LLDD notifies the SAS layer
of anything. There is no other method or way a LLDD to tell
the SAS layer of anything happening internally or in the SAS
domain.</p>
<p>Phy events:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PHYE_LOSS_OF_SIGNAL, (C)
PHYE_OOB_DONE,
PHYE_OOB_ERROR, (C)
PHYE_SPINUP_HOLD.
</pre></div>
</div>
<p>Port events, passed on a _phy_:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PORTE_BYTES_DMAED, (M)
PORTE_BROADCAST_RCVD, (E)
PORTE_LINK_RESET_ERR, (C)
PORTE_TIMER_EVENT, (C)
PORTE_HARD_RESET.
</pre></div>
</div>
<dl class="simple">
<dt>Host Adapter event:</dt><dd><p>HAE_RESET</p>
</dd>
</dl>
<p>A SAS LLDD should be able to generate</p>
<blockquote>
<div><ul class="simple">
<li><p>at least one event from group C (choice),</p></li>
<li><p>events marked M (mandatory) are mandatory (only one),</p></li>
<li><p>events marked E (expander) if it wants the SAS layer
to handle domain revalidation (only one such).</p></li>
<li><p>Unmarked events are optional.</p></li>
</ul>
</div></blockquote>
<p>Meaning:</p>
<dl class="simple">
<dt>HAE_RESET</dt><dd><ul class="simple">
<li><p>when your HA got internal error and was reset.</p></li>
</ul>
</dd>
<dt>PORTE_BYTES_DMAED</dt><dd><ul class="simple">
<li><p>on receiving an IDENTIFY/FIS frame</p></li>
</ul>
</dd>
<dt>PORTE_BROADCAST_RCVD</dt><dd><ul class="simple">
<li><p>on receiving a primitive</p></li>
</ul>
</dd>
<dt>PORTE_LINK_RESET_ERR</dt><dd><ul class="simple">
<li><p>timer expired, loss of signal, loss of DWS, etc. <a class="footnote-reference brackets" href="#id5" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
</ul>
</dd>
<dt>PORTE_TIMER_EVENT</dt><dd><ul class="simple">
<li><p>DWS reset timeout timer expired <a class="footnote-reference brackets" href="#id5" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
</ul>
</dd>
<dt>PORTE_HARD_RESET</dt><dd><ul class="simple">
<li><p>Hard Reset primitive received.</p></li>
</ul>
</dd>
<dt>PHYE_LOSS_OF_SIGNAL</dt><dd><ul class="simple">
<li><p>the device is gone <a class="footnote-reference brackets" href="#id5" id="id3" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
</ul>
</dd>
<dt>PHYE_OOB_DONE</dt><dd><ul class="simple">
<li><p>OOB went fine and oob_mode is valid</p></li>
</ul>
</dd>
<dt>PHYE_OOB_ERROR</dt><dd><ul class="simple">
<li><p>Error while doing OOB, the device probably
got disconnected. <a class="footnote-reference brackets" href="#id5" id="id4" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
</ul>
</dd>
<dt>PHYE_SPINUP_HOLD</dt><dd><ul class="simple">
<li><p>SATA is present, COMWAKE not sent.</p></li>
</ul>
</dd>
</dl>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id5" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id1">1</a>,<a role="doc-backlink" href="#id2">2</a>,<a role="doc-backlink" href="#id3">3</a>,<a role="doc-backlink" href="#id4">4</a>)</span>
<p>should set/clear the appropriate fields in the phy,
or alternatively call the inlined <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">sas_phy_disconnected()</span></code>
which is just a helper, from their tasklet.</p>
</aside>
</aside>
<p>The Execute Command SCSI RPC:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags);
</pre></div>
</div>
<p>Used to queue a task to the SAS LLDD. @task is the task to be executed.
@gfp_mask is the gfp_mask defining the context of the caller.</p>
<p>This function should implement the Execute Command SCSI RPC,</p>
<p>That is, when <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">lldd_execute_task()</span></code> is called, the command
go out on the transport <em>immediately</em>. There is <em>no</em>
queuing of any sort and at any level in a SAS LLDD.</p>
<p>Returns:</p>
<blockquote>
<div><ul class="simple">
<li><p>-SAS_QUEUE_FULL, -ENOMEM, nothing was queued;</p></li>
<li><p>0, the task(s) were queued.</p></li>
</ul>
</div></blockquote>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct sas_task {
dev -- the device this task is destined to
task_proto -- _one_ of enum sas_proto
scatter -- pointer to scatter gather list array
num_scatter -- number of elements in scatter
total_xfer_len -- total number of bytes expected to be transferred
data_dir -- PCI_DMA_...
task_done -- callback when the task has finished execution
};
</pre></div>
</div>
</section>
<section id="discovery">
<h2>Discovery<a class="headerlink" href="#discovery" title="Link to this heading">¶</a></h2>
<p>The sysfs tree has the following purposes:</p>
<blockquote>
<div><ol class="loweralpha simple">
<li><p>It shows you the physical layout of the SAS domain at
the current time, i.e. how the domain looks in the
physical world right now.</p></li>
<li><p>Shows some device parameters _at_discovery_time_.</p></li>
</ol>
</div></blockquote>
<p>This is a link to the tree(1) program, very useful in
viewing the SAS domain:
<a class="reference external" href="ftp://mama.indstate.edu/linux/tree/">ftp://mama.indstate.edu/linux/tree/</a></p>
<p>I expect user space applications to actually create a
graphical interface of this.</p>
<p>That is, the sysfs domain tree doesn’t show or keep state if
you e.g., change the meaning of the READY LED MEANING
setting, but it does show you the current connection status
of the domain device.</p>
<p>Keeping internal device state changes is responsibility of
upper layers (Command set drivers) and user space.</p>
<p>When a device or devices are unplugged from the domain, this
is reflected in the sysfs tree immediately, and the device(s)
removed from the system.</p>
<p>The structure domain_device describes any device in the SAS
domain. It is completely managed by the SAS layer. A task
points to a domain device, this is how the SAS LLDD knows
where to send the task(s) to. A SAS LLDD only reads the
contents of the domain_device structure, but it never creates
or destroys one.</p>
</section>
<section id="expander-management-from-user-space">
<h2>Expander management from User Space<a class="headerlink" href="#expander-management-from-user-space" title="Link to this heading">¶</a></h2>
<p>In each expander directory in sysfs, there is a file called
“smp_portal”. It is a binary sysfs attribute file, which
implements an SMP portal (Note: this is <em>NOT</em> an SMP port),
to which user space applications can send SMP requests and
receive SMP responses.</p>
<p>Functionality is deceptively simple:</p>
<ol class="arabic simple">
<li><p>Build the SMP frame you want to send. The format and layout
is described in the SAS spec. Leave the CRC field equal 0.</p></li>
</ol>
<p>open(2)</p>
<ol class="arabic simple" start="2">
<li><p>Open the expander’s SMP portal sysfs file in RW mode.</p></li>
</ol>
<p>write(2)</p>
<ol class="arabic simple" start="3">
<li><p>Write the frame you built in 1.</p></li>
</ol>
<p>read(2)</p>
<ol class="arabic simple" start="4">
<li><p>Read the amount of data you expect to receive for the frame you built.
If you receive different amount of data you expected to receive,
then there was some kind of error.</p></li>
</ol>
<p>close(2)</p>
<p>All this process is shown in detail in the function <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">do_smp_func()</span></code>
and its callers, in the file “expander_conf.c”.</p>
<p>The kernel functionality is implemented in the file
“sas_expander.c”.</p>
<p>The program “expander_conf.c” implements this. It takes one
argument, the sysfs file name of the SMP portal to the
expander, and gives expander information, including routing
tables.</p>
<p>The SMP portal gives you complete control of the expander,
so please be careful.</p>
</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/scsi/libsas.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>