Documentation/translations/zh_CN/infiniband/user_mad.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/infiniband/user_mad.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/infiniband/user_mad.rst- Extension
.rst- Size
- 5368 bytes
- Lines
- 165
- 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
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. include:: ../disclaimer-zh_CN.rst
:Original: Documentation/infiniband/user_mad.rst
:翻译:
司延腾 Yanteng Si <siyanteng@loongson.cn>
:校译:
王普宇 Puyu Wang <realpuyuwang@gmail.com>
时奎亮 Alex Shi <alexs@kernel.org>
.. _cn_infiniband_user_mad:
===============
用户空间MAD访问
===============
设备文件
========
每个InfiniBand设备的每个端口都有一个“umad”设备和一个“issm”设备连接。
例如,一个双端口的HCA将有两个umad设备和两个issm设备,而一个交换机将
有每个类型的一个设备(对于交换机端口0)。
创建MAD代理
===========
一个MAD代理可以通过填写一个结构体ib_user_mad_reg_req来创建,然后在
适当的设备文件的文件描述符上调用IB_USER_MAD_REGISTER_AGENT ioctl。
如果注册请求成功,结构体中会返回一个32位的ID。比如说::
struct ib_user_mad_reg_req req = { /* ... */ };
ret = ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (char *) &req);
if (!ret)
my_agent = req.id;
else
perror("agent register");
代理可以通过IB_USER_MAD_UNREGISTER_AGENT ioctl取消注册。另外,所有
通过文件描述符注册的代理在描述符关闭时将被取消注册。
2014
现在提供了一个新的注册IOctl,允许在注册时提供额外的字段。这个注册
调用的用户隐含了对pkey_index的使用(见下文)。现在提供了一个新的
注册IOctl,允许在注册时提供额外的字段。这个注册调用的用户隐含了对
pkey_index的使用(见下文)。
接收MADs
========
使用read()接收MAD。现在接收端支持RMPP。传给read()的缓冲区必须至少是
一个struct ib_user_mad + 256字节。比如说:
如果传递的缓冲区不足以容纳收到的MAD(RMPP),errno被设置为ENOSPC,需
要的缓冲区长度被设置在mad.length中。
正常MAD(非RMPP)的读取示例::
struct ib_user_mad *mad;
mad = malloc(sizeof *mad + 256);
ret = read(fd, mad, sizeof *mad + 256);
if (ret != sizeof mad + 256) {
perror("read");
free(mad);
}
RMPP读取示例::
Annotation
- 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.