Documentation/translations/zh_CN/scsi/libsas.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/scsi/libsas.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/scsi/libsas.rst- Extension
.rst- Size
- 14775 bytes
- Lines
- 426
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct my_phystruct my_sas_hastruct sas_taskfunction register_sas_ha
Annotated Snippet
struct my_phy {
blah;
struct sas_phy sas_phy;
bleh;
}
随后,在主机适配器(HA)的结构体中,所有的 PHY 通常以 my_phy
数组的形式存在(如下文所示)。
在初始化各个 PHY 时,除了初始化驱动自定义的 PHY 结构体外,还
需要同时初始化其中的 sas_phy 结构体。
一般来说,PHY 的管理由 LLDD 负责,而端口(port)的管理由 SAS
层负责。因此,PHY 的初始化与更新由 LLDD 完成,而端口的初始化与
更新则由 SAS 层完成。系统设计中规定,某些字段可由 LLDD 进行读
写,而 SAS 层只能读取这些字段;反之亦然。其设计目的是为了避免不
必要的锁操作。
在该设计中,某些字段可由 LLDD 进行读写(RW),而 SAS 层仅可读
取这些字段;反之亦然。这样设计的目的在于避免不必要的锁操作。
enabled
- 必须设置(0/1)
id
- 必须设置[0,MAX_PHYS)]
class, proto, type, role, oob_mode, linkrate
- 必须设置。
oob_mode
- 当 OOB(带外信号)完成后,设置此字段,然后通知 SAS 层。
sas_addr
- 通常指向一个保存该 PHY 的 SAS 地址的数组,该数组可能位于
驱动自定义的 my_phy 结构体中。
attached_sas_addr
- 当 LLDD 接收到 IDENTIFY 帧或 FIS 帧时,应在通知 SAS 层
之前设置该字段。其设计意图在于:有时 LLDD 可能需要伪造或
提供一个与实际不同的 SAS 地址用于该 PHY/端口,而该机制允许
LLDD 这样做。理想情况下,应将 SAS 地址从 IDENTIFY 帧中
复制过来;对于直接连接的 SATA 设备,也可以由 LLDD 生成一
个 SAS 地址。后续的发现过程可能会修改此字段。
frame_rcvd
- 当接收到 IDENTIFY 或 FIS 帧时,将该帧复制到此处。正确的
操作流程是获取锁 → 复制数据 → 设置 frame_rcvd_size → 释
放锁 → 调用事件通知。该字段是一个指针,因为驱动无法精确确
定硬件帧的大小;因此,实际的帧数据数组应定义在驱动自定义的
PHY 结构体中,然后让此指针指向该数组。在持锁状态下,将帧从
DMA 可访问内存区域复制到该数组中。
sas_prim
- 用于存放接收到的原语(primitive)。参见 sas.h。操作流程同
样是:获取锁 → 设置 primitive → 释放锁 → 通知事件。
port
- 如果该 PHY 属于某个端口(port),此字段指向对应的 sas_port
结构体。LLDD 仅可读取此字段。它由 SAS 层设置,用于指向当前
PHY 所属的 sas_port。
ha
- 可以由 LLDD 设置;但无论是否设置,SAS 层都会再次对其进行赋值。
lldd_phy
- LLDD 应将此字段设置为指向自身定义的 PHY 结构体,这样当 SAS
层调用某个回调并传入 sas_phy 时,驱动可以快速定位自身的 PHY
结构体。如果 sas_phy 是嵌入式成员,也可以使用 container_of()
宏进行访问——两种方式均可。
Annotation
- Detected declarations: `struct my_phy`, `struct my_sas_ha`, `struct sas_task`, `function register_sas_ha`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.