Megaraid 通用管理模块¶
概述¶
LSI Logic 的不同类别的控制器以类似的方式接受和响应用户应用程序。它们理解相同的固件控制命令。此外,应用程序还可以统一地对待不同类别的控制器。因此,拥有一个模块,在一侧与应用程序接口,在另一侧与所有低级驱动程序接口是合乎逻辑的。
这些优点虽然很明显,但为了完整起见,在此列出:
避免低级驱动程序中的重复代码。
减轻低级驱动程序导出字符节点设备和相关处理的负担。
在一个地方实现任何策略机制。
应用程序只需与一个模块接口,而不是多个低级驱动程序。
目前,此模块(称为通用管理模块)仅用于发出 ioctl 命令。但是,此模块预计将处理所有用户空间级别的交互。因此,任何“proc”、“sysfs”实现都将在此通用模块中本地化。
致谢¶
"Shared code in a third module, a "library module", is an acceptable
solution. modprobe automatically loads dependent modules, so users
running "modprobe driver1" or "modprobe driver2" would automatically
load the shared library module."
Jeff Garzik (jgarzik@pobox.com), 02.25.2004 LKML
"As Jeff hinted, if your userspace<->driver API is consistent between
your new MPT-based RAID controllers and your existing megaraid driver,
then perhaps you need a single small helper module (lsiioctl or some
better name), loaded by both mptraid and megaraid automatically, which
handles registering the /dev/megaraid node dynamically. In this case,
both mptraid and megaraid would register with lsiioctl for each
adapter discovered, and lsiioctl would essentially be a switch,
redirecting userspace tool ioctls to the appropriate driver."
Matt Domsch, (Matt_Domsch@dell.com), 02.25.2004 LKML
设计¶
通用管理模块在 megaraid_mm.[ch] 文件中实现。此模块充当低级 hba 驱动程序的注册表。低级驱动程序(目前只有 megaraid)向通用模块注册每个控制器。
应用程序通过模块导出的字符设备节点与通用模块接口。
较低级别的驱动程序现在只理解一种新的改进的 ioctl 数据包,称为 uioc_t。管理模块将旧应用程序的旧 ioctl 数据包转换为 uioc_t。在驱动程序处理 uioc_t 后,通用模块会在返回应用程序之前将其转换回旧格式。
随着新应用程序的出现并取代旧应用程序,旧的数据包格式将被弃用。
通用模块为每个注册的控制器分配一个 uioc_t 数据包。这很容易超过一个。但由于 megaraid 是今天唯一的低级驱动程序,并且它只能处理一个 ioctl,因此没有理由拥有更多。但是,随着新的控制器类别的添加,这将得到适当的调整。