| @@ -1,4 +1,7 @@ | |||
| 1 | All notable changes to this project will be documented in this file. | 1 | All notable changes to this project will be documented in this file. |
| 2 | +## [1.80.50] - 2026-08-03 | ||
| 3 | +支持PSR中配置的serdes参数index下发给cpld | ||
| 4 | + | ||
| 2 | ## [1.80.49] - 2026-07-17 | 5 | ## [1.80.49] - 2026-07-17 |
| 3 | chassis组件裁剪命令字调整 | 6 | chassis组件裁剪命令字调整 |
| 4 | 7 | ||
| @@ -0,0 +1,336 @@ | |||
| 1 | +*openUBMC 支持PSR中配置的serdes参数index下发给cpld设计说明书* | ||
| 2 | +<table> | ||
| 3 | + <tr> | ||
| 4 | + <td>所属SIG组:</td> | ||
| 5 | + <td>hardware</td> | ||
| 6 | + </tr> | ||
| 7 | + <tr> | ||
| 8 | + <td>落入版本:</td> | ||
| 9 | + <td>26.09</td> | ||
| 10 | + </tr> | ||
| 11 | + <tr> | ||
| 12 | + <td>设计人员:</td> | ||
| 13 | + <td>zhaohongbang</td> | ||
| 14 | + </tr> | ||
| 15 | + <tr> | ||
| 16 | + <td>日期:</td> | ||
| 17 | + <td>2026/08/04</td> | ||
| 18 | + </tr> | ||
| 19 | +</table> | ||
| 20 | + | ||
| 21 | +**Copyright © 2026 openUBMC Community** | ||
| 22 | + | ||
| 23 | +您对"本文档"的复制,使用,修改及分发受木兰宽松许可证, 第2版协议(以下简称"MulanPSL2")的约束。 | ||
| 24 | +为了方便用户理解,您可以通过访问<https://license.coscl.org.cn/MulanPSL2>了解MulanPSL2的概要 (但不是替代)。 | ||
| 25 | +MulanPSL2的完整协议内容您可以访问如下网址获取:<https://license.coscl.org.cn/MulanPSL2>。 | ||
| 26 | + | ||
| 27 | +**改版记录** | ||
| 28 | + | ||
| 29 | +<table> | ||
| 30 | + <tr> | ||
| 31 | + <th>日期</th> | ||
| 32 | + <th>修订版本</th> | ||
| 33 | + <th>修订描述</th> | ||
| 34 | + <th>作者</th> | ||
| 35 | + <th>审核</th> | ||
| 36 | + </tr> | ||
| 37 | + <tr> | ||
| 38 | + <td>2026/08/04</td> | ||
| 39 | + <td>1.0</td> | ||
| 40 | + <td>支持PSR中配置的serdes参数index下发给cpld设计</td> | ||
| 41 | + <td>zhaohongbang</td> | ||
| 42 | + <td>/</td> | ||
| 43 | + </tr> | ||
| 44 | +</table> | ||
| 45 | + | ||
| 46 | +**List of abbreviations** **缩略语清单** : | ||
| 47 | + | ||
| 48 | +<table> | ||
| 49 | + <tr> | ||
| 50 | + <th>Abbreviations 缩略语</th> | ||
| 51 | + <th>Full spelling 英文全名</th> | ||
| 52 | + <th>Chinese explanation 中文解释</th> | ||
| 53 | + </tr> | ||
| 54 | + <tr> | ||
| 55 | + <td>BMC</td> | ||
| 56 | + <td>Baseboard Management Controller</td> | ||
| 57 | + <td>基板管理控制器</td> | ||
| 58 | + </tr> | ||
| 59 | + <tr> | ||
| 60 | + <td>PSR</td> | ||
| 61 | + <td>Product Self-Description Record</td> | ||
| 62 | + <td>产品自描述信息</td> | ||
| 63 | + </tr> | ||
| 64 | + <tr> | ||
| 65 | + <td>CPLD</td> | ||
| 66 | + <td>Complex Programmable Logic Device</td> | ||
| 67 | + <td>复杂可编程逻辑器件</td> | ||
| 68 | + </tr> | ||
| 69 | + <tr> | ||
| 70 | + <td>CSR</td> | ||
| 71 | + <td>Compoent Self-Description Record</td> | ||
| 72 | + <td>组件自描述信息</td> | ||
| 73 | + </tr> | ||
| 74 | + <tr> | ||
| 75 | + <td>UID</td> | ||
| 76 | + <td>User Identification</td> | ||
| 77 | + <td>用户识别灯</td> | ||
| 78 | + </tr> | ||
| 79 | + <tr> | ||
| 80 | + <td>hwproxy</td> | ||
| 81 | + <td>Hardware Proxy</td> | ||
| 82 | + <td>硬件代理服务</td> | ||
| 83 | + </tr> | ||
| 84 | + <tr> | ||
| 85 | + <td>SerDes</td> | ||
| 86 | + <td>Serializer/Deserializer</td> | ||
| 87 | + <td>即串行器/解串器</td> | ||
| 88 | + </tr> | ||
| 89 | +</table> | ||
| 90 | + | ||
| 91 | +[TOC] | ||
| 92 | + | ||
| 93 | +# 1.功能分析 | ||
| 94 | + | ||
| 95 | +## 1.1 功能背景 | ||
| 96 | + | ||
| 97 | +在设备整机每次AC上电时,BIOS会通过寄存器中特定地址,读取到UB Serdes参数index,以此通过查表来确定不同整机形态的UB Serdes参数配置。当前是通过在产品仓中写死逻辑,不同的产品分别向固定的寄存器地址中写入固定的index来实现这一目的。 | ||
| 98 | + | ||
| 99 | +如果没有该需求,当前不同产品会有重复的代码逻辑,且代码内强制写死逻辑参数,可维护性较差。另外一个产品需要适配多种整机形态时,需要做特别区分,建议将这部分逻辑提取为配置和公共逻辑。 | ||
| 100 | + | ||
| 101 | +## 1.2 功能描述 | ||
| 102 | + | ||
| 103 | +本需求在chassis主干代码中扩展支持PSR中配置的UB serdes参数index下发给cpld,主要实现以下功能: | ||
| 104 | +- 与涉及的产品的PSR配置中,新增UBConfiguration配置参数,用于存放UB参数的index和对应要写入的寄存器 | ||
| 105 | +- chassis仓内添加私有对象UBConfiguration对象的解析 | ||
| 106 | +- chassis在上电时,检查PSR中有无配置UBConfiguration参数,如果有,则将UBParam中的index写入UBParamReg所关联的寄存器中 | ||
| 107 | +- 如果PSR中没有配置相关参数,则不做处理 | ||
| 108 | +- 设置ub参数的动作需要在单板上电前完成,配置PSR内容时可将PSR自发先提前,或在后续添加上电锁来保证。当前版本已保证已适配产品的设置在单板上电之前。 | ||
| 109 | + | ||
| 110 | +方案实现策略:直接新增src/lualib/ub_configuration_service.lua,在model.json中新增UBConfiguration字段并生成解析逻辑。 | ||
| 111 | + | ||
| 112 | +## 1.3 功能场景 | ||
| 113 | + | ||
| 114 | +1) **场景触发条件及对象**:仅每次AC上电时或bmc重启时,由BMC将参数写入CPLD寄存器中,CPLD转发给BIOS供BIOS使用。 | ||
| 115 | + | ||
| 116 | +2) **使用时间及频度**:仅每次AC上电时或bmc重启时1次。 | ||
| 117 | + | ||
| 118 | +3) **主要场景**: | ||
| 119 | + | ||
| 120 | +| 子场景 | 触发条件 | 关键操作 | | ||
| 121 | +| ------ | -------- | -------- | | ||
| 122 | +| AC上电时 | AC上电时 | ub_configuration_service.lua 执行 set_ub_index 逻辑设置 ub参数 | | ||
| 123 | +| BMC重启时 | AC上电时 | ub_configuration_service.lua 执行 set_ub_index 逻辑设置 ub参数 | | ||
| 124 | + | ||
| 125 | +## 1.4 功能列表 | ||
| 126 | + | ||
| 127 | +| 功能编号 | 功能标题 | 功能描述 | | ||
| 128 | +| ------- | ------- | -------- | | ||
| 129 | +| 1 | set_ub_index | 从PSR中获取ub参数,写入对应寄存器中 | | ||
| 130 | + | ||
| 131 | +# 2.功能设计 | ||
| 132 | + | ||
| 133 | +## 2.1 总体方案分析 | ||
| 134 | + | ||
| 135 | +### 2.1.1 方案详细设计 | ||
| 136 | + | ||
| 137 | +#### 2.1.1.1 方案概述 | ||
| 138 | + | ||
| 139 | +**修改文件清单:** | ||
| 140 | + | ||
| 141 | +| 文件 | 改动类型 | 说明 | | ||
| 142 | +| --- | --- | --- | | ||
| 143 | +| src/lualib/chassis_app.lua | 修改 | 新增 UBConfiguration 对象的对应new和add_object逻辑,如果未发现UBConfiguration对象则不做处理 | | ||
| 144 | +| src/lualib/ub_configuration_service.lua| 新增 | 新增 set_ub_index 逻辑,获取对象中的UBParam中的index写入UBParamReg所关联的寄存器中,写入后校验,失败3次后报错。 | | ||
| 145 | + | ||
| 146 | +#### 2.1.1.2 开发视图 | ||
| 147 | + | ||
| 148 | +```mermaid | ||
| 149 | +graph TB | ||
| 150 | + subgraph chassis主干代码 | ||
| 151 | + ChassisApp[chassis_app.lua<br>on_add_object → c_ub_configuration_service:add_object<br>on_delete_object] | ||
| 152 | + UB_Configuration_Service[ub_configuration_service.lua<br>读取并写入UBParam set_ub_index] | ||
| 153 | + end | ||
| 154 | + | ||
| 155 | + subgraph PSR配置私有属性 | ||
| 156 | + UBConfiguration[UBParam<br>UBParamReg] | ||
| 157 | + end | ||
| 158 | + | ||
| 159 | + subgraph 硬件层 | ||
| 160 | + CPLD[CPLD内寄存器] | ||
| 161 | + end | ||
| 162 | + | ||
| 163 | + ChassisApp -->|add_object| UB_Configuration_Service | ||
| 164 | + ChassisApp -->|读取| UBConfiguration | ||
| 165 | + UB_Configuration_Service -->|写入| CPLD | ||
| 166 | +``` | ||
| 167 | + | ||
| 168 | +#### 2.1.1.3 运行视图 | ||
| 169 | + | ||
| 170 | +**BMC启动及ASU模组注册流程:** | ||
| 171 | + | ||
| 172 | +```mermaid | ||
| 173 | +sequenceDiagram | ||
| 174 | + participant BMC as BMC启动 | ||
| 175 | + participant App as chassis_app | ||
| 176 | + participant UB_Configuration_Service as UB_Configuration_Service | ||
| 177 | + participant PSR as PSR | ||
| 178 | + participant CPLD as CPLD | ||
| 179 | + | ||
| 180 | + BMC->>App: init() → ctor() | ||
| 181 | + App->>UB_Configuration_Service : c_ub_configuration_service.new(self.bus) | ||
| 182 | + App->>UB_Configuration_Service : c_ub_configuration_service.add_object(mds_obj, position) | ||
| 183 | + UB_Configuration_Service ->>PSR: 获取配置的UBParam和UBParamReg | ||
| 184 | + UB_Configuration_Service ->>CPLD: 将UBParam的值写入UBParamReg所关联的寄存器中 | ||
| 185 | +``` | ||
| 186 | +### 2.1.2 内部依赖分析 | ||
| 187 | + | ||
| 188 | +不涉及 | ||
| 189 | + | ||
| 190 | +### 2.1.3 外部依赖分析 | ||
| 191 | + | ||
| 192 | +| 依赖项 | 说明 | | ||
| 193 | +| ------ | ---- | | ||
| 194 | +| PSR | PSR中需要添加对应配置信息,如果没有配置则不处理 | | ||
| 195 | + | ||
| 196 | +### 2.1.4 北向接口分析 | ||
| 197 | + | ||
| 198 | +本需求为BMC内部自动控制逻辑,不新增北向接口。 | ||
| 199 | + | ||
| 200 | +| 特性 | SNMP | CLI | WEB | KVM_VMM | IPMI(RMCP/RMCP+) | HMM | Redfish | | ||
| 201 | +| ---- | ---- | ---- | --- | ------ | ---------------- | --- | ------- | | ||
| 202 | +| NA | NA | NA | NA | NA | NA | NA | NA | | ||
| 203 | + | ||
| 204 | +### 2.1.5 兼容性分析 | ||
| 205 | + | ||
| 206 | +| 影响点 | 影响说明 | 兼容方案 | | ||
| 207 | +| ------ | -------- | -------- | | ||
| 208 | +| PSR | 不受影响 | PSR中没有配置UBConfiguration时,不会走入add_object逻辑中 | | ||
| 209 | + | ||
| 210 | +### 2.1.6 定制化接口分析 | ||
| 211 | + | ||
| 212 | +本需求不涉及定制化接口变更。 | ||
| 213 | + | ||
| 214 | +### 2.1.7 导入导出分析 | ||
| 215 | + | ||
| 216 | +不涉及。本需求为BMC内部自动控制逻辑,不涉及导入导出配置。 | ||
| 217 | + | ||
| 218 | +### 2.1.8 传感器分析 | ||
| 219 | + | ||
| 220 | +不涉及。本需求不新增传感器。 | ||
| 221 | + | ||
| 222 | +### 2.1.9 精准告警事件分析 | ||
| 223 | + | ||
| 224 | +不涉及。本需求不新增告警事件。 | ||
| 225 | + | ||
| 226 | +### 2.1.10 系统锁定分析 | ||
| 227 | + | ||
| 228 | +不涉及。本需求为BMC内部自动控制逻辑,不涉及对外接口或命令。 | ||
| 229 | + | ||
| 230 | +### 2.1.11 用例场景分析 | ||
| 231 | + | ||
| 232 | +| 用例编号 | 用例名称 | 前置条件 | 操作步骤 | 预期结果 | | ||
| 233 | +| -------- | -------- | -------- | -------- | -------- | | ||
| 234 | +| 1 | PSR中配置对应属性 | PSR中配置对应属性 | 1. 重启bmc 2.收集日志 | 检查日志,有成功写入ubparam的日志 | | ||
| 235 | +| 2 | PSR中配置未对应属性 | PSR中配置未对应属性 | 1. 重启bmc 2.收集日志 | 检查日志,没有相关日志 | | ||
| 236 | +| 2 | PSR中配置无效寄存器地址 | PSR中配置无效寄存器地址 | 1. 重启bmc 2.收集日志 | 检查日志,重复写入3次失败后有报错日志 | | ||
| 237 | + | ||
| 238 | +### 2.1.12 装备能力差异分析 | ||
| 239 | + | ||
| 240 | +不涉及。本需求在装备版本和Release版本中能力一致。 | ||
| 241 | + | ||
| 242 | +### 2.1.13 持久化分析 | ||
| 243 | + | ||
| 244 | +不涉及新增持久化,属性配置在PSR中,仅启动时使用1次。 | ||
| 245 | + | ||
| 246 | +### 2.1.14 日志收集分析 | ||
| 247 | + | ||
| 248 | +不涉及。本需求不涉及日志收集。相关定位日志已添加 | ||
| 249 | + | ||
| 250 | +## 2.2 非功能质量属性设计 | ||
| 251 | +### 2.2.1 扩展性分析 | ||
| 252 | +<!-- 考虑后续新增类似功能可以很好地扩展 --> | ||
| 253 | +不涉及 | ||
| 254 | + | ||
| 255 | +### 2.2.2 重用性分析 | ||
| 256 | +<!-- 是否为通用处理方式、接口,如果是得考虑重用性 --> | ||
| 257 | +不涉及 | ||
| 258 | + | ||
| 259 | +### 2.2.3 可测试性分析 | ||
| 260 | +<!-- 此需求如何验证,是否可直接验证,or通过XXX功能覆盖验证,or需要单独怎加测试接口验证 --> | ||
| 261 | +- 可直接验证 | ||
| 262 | + | ||
| 263 | +### 2.2.4 资料分析 | ||
| 264 | +<!-- 是否涉及资料修改 --> | ||
| 265 | +- 已支持 | ||
| 266 | + | ||
| 267 | +### 2.2.5 资源使用分析 | ||
| 268 | +<!-- 新增线程、内存分配、模型属性名长度是否合理,CPU占用率是否会激增,Flash中新增文件是否合理(频繁读写Flash会大幅缩短emmc寿命);是否涉及消息队列,如果涉及请检查是否存在某些场景下消息队列会满导致消息丢失,例如大量消息发送到队列且处理消息需要耗费较长时间的场景。 --> | ||
| 269 | +不涉及 | ||
| 270 | + | ||
| 271 | +### 2.2.6 可靠性分析 | ||
| 272 | +| 编号 | 场景 | 问题描述 | 可靠性影响 | 问题级别 | 建议解决方案/需求 | 讨论结果 | 跟踪人 | 备注 | | ||
| 273 | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | | ||
| 274 | +| 1 | 写入ub参数错误 | 写入ub参数错误 | BIOS获取不到正确的index | 一般 | 记录错误日志,可能有其他硬件问题 | --- | --- | --- | | ||
| 275 | + | ||
| 276 | +### 2.2.7 安全性分析 | ||
| 277 | +| 安全合规项 | 是否涉及 | 现有的防护措施 | | ||
| 278 | +| --- | --- | --- | | ||
| 279 | +| 访问控制 | 否 | - | | ||
| 280 | +| 敏感数据 | 否 | - | | ||
| 281 | +| 日志 | 否 | - | | ||
| 282 | +| 文档 | 否 | - | | ||
| 283 | +| 加密及算法 | 否 | - | | ||
| 284 | +| 新增关键资源备份、恢复 | 否 | - | | ||
| 285 | +| 新增对外接口入参校验 | 是 | 按IPMI协议校验 | | ||
| 286 | +| 新增开源及三方软件引入 | 否 | - | | ||
| 287 | + | ||
| 288 | +# 3.功能实现 | ||
| 289 | +<!-- 通过表格、流程图、简明文字描述提供,力求容易看懂、容易实现,详细描述细节。 --> | ||
| 290 | +## 3.1【功能编号】支持Get Chassis Capabilities Command功能实现 | ||
| 291 | +### 3.1.1 功能实现设计 | ||
| 292 | +对应model.json新增属性配置: | ||
| 293 | + "UBConfiguration": { | ||
| 294 | + "properties": { | ||
| 295 | + "UBParam": { | ||
| 296 | + "usage": ["CSR"], | ||
| 297 | + "default": 255, | ||
| 298 | + "baseType": "U8", | ||
| 299 | + "description": "UB参数" | ||
| 300 | + }, | ||
| 301 | + "UBParamReg": { | ||
| 302 | + "usage": ["CSR"], | ||
| 303 | + "baseType": "U32", | ||
| 304 | + "description": "关联写入UB参数的寄存器" | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | +PSR配置示例: | ||
| 310 | + "UBConfiguration": { | ||
| 311 | + "UBParam": 1, | ||
| 312 | + "UBParamReg": "#/Accessor_UBParam.Value" | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | +### 3.1.2 功能详细设计 | ||
| 316 | +读取PSR配置中的UBParam参数,写入UBParamReg对应关联的寄存器中,失败则等待1s重试,失败三次则记录错误日志。 | ||
| 317 | + | ||
| 318 | +### 3.1.3 开发者测试 | ||
| 319 | +<!-- | ||
| 320 | +增加模块接口:以活动图/流程图等形式明确模块内处理流程,针对模块处理流程中的分支进行覆盖 | ||
| 321 | +修改模块接口处理流程:覆盖修改影响流程分支 | ||
| 322 | +--> | ||
| 323 | +#### 3.1.3.1 单元测试 | ||
| 324 | +<!-- UT,主要是功能单元测试,测试对象是功能单元接口。UT测试设计要从黑盒(功能)角度设计,从输入(I)、处理(B)、预期输出(O)的角度进行用例分析设计,测试覆盖率仅作为反馈,用于分析哪些功能场景没有覆盖到,从而指导测试设计优化并补充测试用例 --> | ||
| 325 | +- 针对set_ub_index处理函数构造入参,设计如下单元测试用例: | ||
| 326 | + | ||
| 327 | +| 组件名 | 用例类型 | 测试用例描述 | 用例名称 | 预置条件 | 操作步骤 | 预期结果 | | ||
| 328 | +| --- | --- | --- | --- | --- | --- | --- | | ||
| 329 | +| Chassis | DT | 测试test_set_ub_index_process流程 | test_set_ub_index_process | BMC正常运行 | 1.执行dt用例| 返回查询UBParamReg结果和预期一致 | | ||
| 330 | +| Chassis | DT | 测试test_set_ub_index流程 | test_set_ub_index | BMC正常运行 | 1.执行dt用例 | 几组构造case返回查询UBParamReg结果和预期一致 | | ||
| 331 | + | ||
| 332 | +#### 3.1.3.2 集成测试 | ||
| 333 | +<!-- IT,主要是组件/模块内的集成测试,测试对象是模块/组件接口。IT测试设计将模块/组件当作黑盒测试,IT测试用例中禁止对组件/模块内部代码打桩,如果确实有少量场景难以构造,可以考虑在测试框架中统一打桩并提供接口供测试用例调用构造场景。 | ||
| 334 | +说明:API测试属于IT,其测试对象是微服务接口。 | ||
| 335 | +PCST,是指PC上的服务集成测试,测试对象是功能需求。PCST测试设计,要覆盖正常功能、异常功能和交叉功能,采用灰盒 --> | ||
| 336 | +无 | ||
| @@ -22,6 +22,7 @@ local chassis_table_class_types = require 'class.types.ChassisTable' | |||
| 22 | local super_pod_label_class_types = require 'class.types.SuperPodLabel' | 22 | local super_pod_label_class_types = require 'class.types.SuperPodLabel' |
| 23 | local dft_button_test_class_types = require 'class.types.DftButtonTest' | 23 | local dft_button_test_class_types = require 'class.types.DftButtonTest' |
| 24 | local adc_voltage_config_class_types = require 'class.types.AdcVoltageConfig' | 24 | local adc_voltage_config_class_types = require 'class.types.AdcVoltageConfig' |
| 25 | +local ub_configuration_class_types = require 'class.types.UBConfiguration' | ||
| 25 | local policy_intf_types = require 'chassis.json_types.Policy' | 26 | local policy_intf_types = require 'chassis.json_types.Policy' |
| 26 | local system_health_intf_types = require 'chassis.json_types.SystemHealth' | 27 | local system_health_intf_types = require 'chassis.json_types.SystemHealth' |
| 27 | local properties_intf_types = require 'mdb.bmc.kepler.Object.PropertiesInterface' | 28 | local properties_intf_types = require 'mdb.bmc.kepler.Object.PropertiesInterface' |
| @@ -2021,6 +2022,23 @@ local AdcVoltageConfig = { | |||
| 2021 | } | 2022 | } |
| 2022 | } | 2023 | } |
| 2023 | 2024 | ||
| 2025 | +local UBConfiguration = { | ||
| 2026 | + ['prop_configs'] = { | ||
| 2027 | + ['UBParam'] = { | ||
| 2028 | + ['usage'] = {'CSR'}, | ||
| 2029 | + ['default'] = 255, | ||
| 2030 | + ['baseType'] = 'U8', | ||
| 2031 | + ['validator'] = ub_configuration_class_types.UBParam | ||
| 2032 | + }, | ||
| 2033 | + ['UBParamReg'] = { | ||
| 2034 | + ['usage'] = {'CSR'}, | ||
| 2035 | + ['baseType'] = 'U32', | ||
| 2036 | + ['validator'] = ub_configuration_class_types.UBParamReg | ||
| 2037 | + } | ||
| 2038 | + }, | ||
| 2039 | + ['default_props'] = {['UBParam'] = 255, ['UBParamReg'] = ub_configuration_class_types.UBParamReg.default[1]} | ||
| 2040 | +} | ||
| 2041 | + | ||
| 2024 | local M = {} | 2042 | local M = {} |
| 2025 | 2043 | ||
| 2026 | function M.init(bus) | 2044 | function M.init(bus) |
| @@ -2042,6 +2060,7 @@ function M.init(bus) | |||
| 2042 | class('DftButtonTest', DftButtonTest):set_bus(bus) | 2060 | class('DftButtonTest', DftButtonTest):set_bus(bus) |
| 2043 | class('Enclosure', Enclosure):set_bus(bus) | 2061 | class('Enclosure', Enclosure):set_bus(bus) |
| 2044 | class('AdcVoltageConfig', AdcVoltageConfig):set_bus(bus) | 2062 | class('AdcVoltageConfig', AdcVoltageConfig):set_bus(bus) |
| 2063 | + class('UBConfiguration', UBConfiguration):set_bus(bus) | ||
| 2045 | end | 2064 | end |
| 2046 | 2065 | ||
| 2047 | -- The callback needs to be registered during app initialization | 2066 | -- The callback needs to be registered during app initialization |
| @@ -0,0 +1,107 @@ | |||
| 1 | +-- Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 2 | +-- openUBMC is licensed under Mulan PSL v2. | ||
| 3 | +-- You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 4 | +-- You may obtain a copy of Mulan PSL v2 at: | ||
| 5 | +-- http://license.coscl.org.cn/MulanPSL2 | ||
| 6 | +-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 7 | +-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 8 | +-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 9 | +-- See the Mulan PSL v2 for more details. | ||
| 10 | +local validate = require 'mc.validate' | ||
| 11 | +local utils = require 'mc.utils' | ||
| 12 | + | ||
| 13 | +local MUBConfiguration = {} | ||
| 14 | + | ||
| 15 | +---@class MUBConfiguration.UBParamReg | ||
| 16 | +---@field UBParamReg integer | ||
| 17 | +local TUBParamReg = {} | ||
| 18 | +TUBParamReg.__index = TUBParamReg | ||
| 19 | +TUBParamReg.group = {} | ||
| 20 | + | ||
| 21 | +local function TUBParamReg_from_obj(obj) | ||
| 22 | + return setmetatable(obj, TUBParamReg) | ||
| 23 | +end | ||
| 24 | + | ||
| 25 | +function TUBParamReg.new(UBParamReg) | ||
| 26 | + return TUBParamReg_from_obj({UBParamReg = UBParamReg}) | ||
| 27 | +end | ||
| 28 | +---@param obj MUBConfiguration.UBParamReg | ||
| 29 | +function TUBParamReg:init_from_obj(obj) | ||
| 30 | + self.UBParamReg = obj.UBParamReg | ||
| 31 | +end | ||
| 32 | + | ||
| 33 | +function TUBParamReg:remove_error_props(errs, obj) | ||
| 34 | + utils.remove_obj_error_property(obj, errs, TUBParamReg.group) | ||
| 35 | +end | ||
| 36 | + | ||
| 37 | +TUBParamReg.from_obj = TUBParamReg_from_obj | ||
| 38 | + | ||
| 39 | +TUBParamReg.proto_property = {'UBParamReg'} | ||
| 40 | + | ||
| 41 | +TUBParamReg.default = {0} | ||
| 42 | + | ||
| 43 | +TUBParamReg.struct = {{name = 'UBParamReg', is_array = false, struct = nil}} | ||
| 44 | + | ||
| 45 | +function TUBParamReg:validate(prefix, errs, need_convert) | ||
| 46 | + prefix = prefix or '' | ||
| 47 | + | ||
| 48 | + validate.Optional(prefix .. 'UBParamReg', self.UBParamReg, 'uint32', false, errs, need_convert) | ||
| 49 | + | ||
| 50 | + TUBParamReg:remove_error_props(errs, self) | ||
| 51 | + validate.CheckUnknowProperty(self, TUBParamReg.proto_property, errs, need_convert) | ||
| 52 | + return self | ||
| 53 | +end | ||
| 54 | + | ||
| 55 | +function TUBParamReg:unpack(_) | ||
| 56 | + return self.UBParamReg | ||
| 57 | +end | ||
| 58 | + | ||
| 59 | +MUBConfiguration.UBParamReg = TUBParamReg | ||
| 60 | + | ||
| 61 | +---@class MUBConfiguration.UBParam | ||
| 62 | +---@field UBParam integer | ||
| 63 | +local TUBParam = {} | ||
| 64 | +TUBParam.__index = TUBParam | ||
| 65 | +TUBParam.group = {} | ||
| 66 | + | ||
| 67 | +local function TUBParam_from_obj(obj) | ||
| 68 | + return setmetatable(obj, TUBParam) | ||
| 69 | +end | ||
| 70 | + | ||
| 71 | +function TUBParam.new(UBParam) | ||
| 72 | + return TUBParam_from_obj({UBParam = UBParam or 255}) | ||
| 73 | +end | ||
| 74 | +---@param obj MUBConfiguration.UBParam | ||
| 75 | +function TUBParam:init_from_obj(obj) | ||
| 76 | + self.UBParam = obj.UBParam or 255 | ||
| 77 | +end | ||
| 78 | + | ||
| 79 | +function TUBParam:remove_error_props(errs, obj) | ||
| 80 | + utils.remove_obj_error_property(obj, errs, TUBParam.group) | ||
| 81 | +end | ||
| 82 | + | ||
| 83 | +TUBParam.from_obj = TUBParam_from_obj | ||
| 84 | + | ||
| 85 | +TUBParam.proto_property = {'UBParam'} | ||
| 86 | + | ||
| 87 | +TUBParam.default = {255} | ||
| 88 | + | ||
| 89 | +TUBParam.struct = {{name = 'UBParam', is_array = false, struct = nil}} | ||
| 90 | + | ||
| 91 | +function TUBParam:validate(prefix, errs, need_convert) | ||
| 92 | + prefix = prefix or '' | ||
| 93 | + | ||
| 94 | + validate.Optional(prefix .. 'UBParam', self.UBParam, 'uint8', false, errs, need_convert) | ||
| 95 | + | ||
| 96 | + TUBParam:remove_error_props(errs, self) | ||
| 97 | + validate.CheckUnknowProperty(self, TUBParam.proto_property, errs, need_convert) | ||
| 98 | + return self | ||
| 99 | +end | ||
| 100 | + | ||
| 101 | +function TUBParam:unpack(_) | ||
| 102 | + return self.UBParam | ||
| 103 | +end | ||
| 104 | + | ||
| 105 | +MUBConfiguration.UBParam = TUBParam | ||
| 106 | + | ||
| 107 | +return MUBConfiguration | ||
| @@ -968,5 +968,20 @@ | |||
| 968 | "description": "ADC电压转换成节点id的配置" | 968 | "description": "ADC电压转换成节点id的配置" |
| 969 | } | 969 | } |
| 970 | } | 970 | } |
| 971 | + }, | ||
| 972 | + "UBConfiguration": { | ||
| 973 | + "properties": { | ||
| 974 | + "UBParam": { | ||
| 975 | + "usage": ["CSR"], | ||
| 976 | + "default": 255, | ||
| 977 | + "baseType": "U8", | ||
| 978 | + "description": "UB参数" | ||
| 979 | + }, | ||
| 980 | + "UBParamReg": { | ||
| 981 | + "usage": ["CSR"], | ||
| 982 | + "baseType": "U32", | ||
| 983 | + "description": "关联写入UB参数的寄存器" | ||
| 984 | + } | ||
| 985 | + } | ||
| 971 | } | 986 | } |
| 972 | } | 987 | } |
| @@ -1815,6 +1815,27 @@ | |||
| 1815 | "type": "object", | 1815 | "type": "object", |
| 1816 | "interfaces": {}, | 1816 | "interfaces": {}, |
| 1817 | "additionalProperties": false | 1817 | "additionalProperties": false |
| 1818 | + }, | ||
| 1819 | + "UBConfiguration": { | ||
| 1820 | + "properties": { | ||
| 1821 | + "UBParam": { | ||
| 1822 | + "allOf": [ | ||
| 1823 | + { | ||
| 1824 | + "$ref": "base.json#/U8" | ||
| 1825 | + } | ||
| 1826 | + ] | ||
| 1827 | + }, | ||
| 1828 | + "UBParamReg": { | ||
| 1829 | + "allOf": [ | ||
| 1830 | + { | ||
| 1831 | + "$ref": "base.json#/U32" | ||
| 1832 | + } | ||
| 1833 | + ] | ||
| 1834 | + } | ||
| 1835 | + }, | ||
| 1836 | + "type": "object", | ||
| 1837 | + "interfaces": {}, | ||
| 1838 | + "additionalProperties": false | ||
| 1818 | } | 1839 | } |
| 1819 | }, | 1840 | }, |
| 1820 | "id": "bmc", | 1841 | "id": "bmc", |
| @@ -1867,6 +1888,9 @@ | |||
| 1867 | }, | 1888 | }, |
| 1868 | "^AdcVoltageConfig_": { | 1889 | "^AdcVoltageConfig_": { |
| 1869 | "$ref": "#/defs/AdcVoltageConfig" | 1890 | "$ref": "#/defs/AdcVoltageConfig" |
| 1891 | + }, | ||
| 1892 | + "^UBConfiguration_": { | ||
| 1893 | + "$ref": "#/defs/UBConfiguration" | ||
| 1870 | } | 1894 | } |
| 1871 | }, | 1895 | }, |
| 1872 | "$schema": "https://json-schema.org/draft/2019-09/schema#", | 1896 | "$schema": "https://json-schema.org/draft/2019-09/schema#", |
| @@ -2,7 +2,7 @@ | |||
| 2 | "name": "chassis", | 2 | "name": "chassis", |
| 3 | "type": "application", | 3 | "type": "application", |
| 4 | "deployConfig": "hardware.service", | 4 | "deployConfig": "hardware.service", |
| 5 | - "version": "1.80.49", | 5 | + "version": "1.80.50", |
| 6 | "author": "Huawei", | 6 | "author": "Huawei", |
| 7 | "license": "Mulan PSL v2", | 7 | "license": "Mulan PSL v2", |
| 8 | "description": "chassis management component", | 8 | "description": "chassis management component", |
| @@ -27,6 +27,7 @@ local c_chassis_service = require('chassis.service') | |||
| 27 | local ipmi_req = require('chassis.ipmi.ipmi') | 27 | local ipmi_req = require('chassis.ipmi.ipmi') |
| 28 | local led_i2c_service = require('led_i2c_service') | 28 | local led_i2c_service = require('led_i2c_service') |
| 29 | local c_tasks = require('mc.orm.tasks') | 29 | local c_tasks = require('mc.orm.tasks') |
| 30 | +local c_ub_configuration_service = require('ub_configuration_service') | ||
| 30 | local base_msg = require('messages.base') | 31 | local base_msg = require('messages.base') |
| 31 | 32 | ||
| 32 | local enclosure_service_ok, enclosure_service = pcall(require, 'enclosure_service') | 33 | local enclosure_service_ok, enclosure_service = pcall(require, 'enclosure_service') |
| @@ -74,6 +75,9 @@ function chassis_app:on_add_object(class_name, object, position) | |||
| 74 | self.node_id_identify:add_object(object, position) | 75 | self.node_id_identify:add_object(object, position) |
| 75 | end | 76 | end |
| 76 | end, | 77 | end, |
| 78 | + ['UBConfiguration'] = function() | ||
| 79 | + self.c_ub_configuration_service:add_object(object, position) | ||
| 80 | + end, | ||
| 77 | } | 81 | } |
| 78 | if switch[class_name] then | 82 | if switch[class_name] then |
| 79 | switch[class_name]() | 83 | switch[class_name]() |
| @@ -114,6 +118,7 @@ function chassis_app:ctor() | |||
| 114 | if c_node_id_identify_ok then | 118 | if c_node_id_identify_ok then |
| 115 | self.node_id_identify = c_node_id_identify.new(self.bus) | 119 | self.node_id_identify = c_node_id_identify.new(self.bus) |
| 116 | end | 120 | end |
| 121 | + self.c_ub_configuration_service = c_ub_configuration_service.new() | ||
| 117 | self.dft_obj_list = {} | 122 | self.dft_obj_list = {} |
| 118 | factory:register('chassis_service', self.chassis_service) | 123 | factory:register('chassis_service', self.chassis_service) |
| 119 | factory:register('led_service', self.led_service) | 124 | factory:register('led_service', self.led_service) |
| @@ -0,0 +1,60 @@ | |||
| 1 | +-- Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 2 | +-- openUBMC is licensed under Mulan PSL v2. | ||
| 3 | +-- You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 4 | +-- You may obtain a copy of Mulan PSL v2 at: | ||
| 5 | +-- http://license.coscl.org.cn/MulanPSL2 | ||
| 6 | +-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 7 | +-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 8 | +-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 9 | +-- See the Mulan PSL v2 for more details. | ||
| 10 | + | ||
| 11 | +-- Description: ub_configuration_service, 支持PSR中配置的serdes参数index下发给cpld | ||
| 12 | +local class = require('mc.class') | ||
| 13 | +local skynet = require('skynet') | ||
| 14 | +local log = require('mc.logging') | ||
| 15 | + | ||
| 16 | +local c_ub_configuration_service = class() | ||
| 17 | + | ||
| 18 | +function c_ub_configuration_service:add_object(mds_obj, position) | ||
| 19 | + log:notice('set_ub_index start') | ||
| 20 | + skynet.fork(function() | ||
| 21 | + self:set_ub_index(mds_obj) | ||
| 22 | + end) | ||
| 23 | +end | ||
| 24 | + | ||
| 25 | +function c_ub_configuration_service:set_ub_index(mds_obj) | ||
| 26 | + local ok, ub_param | ||
| 27 | + ok, ub_param = pcall(function() | ||
| 28 | + return (mds_obj.UBParam == 255) and 0 or mds_obj.UBParam | ||
| 29 | + end) | ||
| 30 | + if not ok then | ||
| 31 | + log:error('read UBParam fail ub_param:%s', ub_param) | ||
| 32 | + return | ||
| 33 | + end | ||
| 34 | + log:notice('set_ub_index UBParam:%s', ub_param) | ||
| 35 | + local read_ub_param, err | ||
| 36 | + for i = 1, 3 do | ||
| 37 | + ok, err = pcall(function() -- write 环节 | ||
| 38 | + mds_obj.UBParamReg = ub_param | ||
| 39 | + skynet.sleep(10) | ||
| 40 | + read_ub_param = mds_obj.UBParamReg | ||
| 41 | + if read_ub_param ~= ub_param then | ||
| 42 | + error(string.format('set_ub_index failed, read UBParam: %s', read_ub_param)) | ||
| 43 | + end | ||
| 44 | + end) | ||
| 45 | + if ok then | ||
| 46 | + log:notice('set_ub_index success, write time %s', i) | ||
| 47 | + break | ||
| 48 | + end | ||
| 49 | + skynet.sleep(100) | ||
| 50 | + end | ||
| 51 | + if not ok then | ||
| 52 | + error(string.format('set_ub_index failed after 3 times, err:%s', err)) | ||
| 53 | + end | ||
| 54 | +end | ||
| 55 | + | ||
| 56 | +function c_ub_configuration_service:init() end | ||
| 57 | + | ||
| 58 | +function c_ub_configuration_service:ctor() end | ||
| 59 | + | ||
| 60 | +return c_ub_configuration_service | ||
| @@ -31,5 +31,6 @@ require('test_super_pod_label') | |||
| 31 | require('test_led_i2c') | 31 | require('test_led_i2c') |
| 32 | require('test_led_tube_service') | 32 | require('test_led_tube_service') |
| 33 | require('test_chassis_app') | 33 | require('test_chassis_app') |
| 34 | +require('test_ub_configuration_service') | ||
| 34 | 35 | ||
| 35 | os.exit(lu.LuaUnit.run()) | 36 | os.exit(lu.LuaUnit.run()) |
| @@ -0,0 +1,95 @@ | |||
| 1 | +-- Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 2 | +-- openUBMC is licensed under Mulan PSL v2. | ||
| 3 | +-- You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 4 | +-- You may obtain a copy of Mulan PSL v2 at: | ||
| 5 | +-- http://license.coscl.org.cn/MulanPSL2 | ||
| 6 | +-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 7 | +-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 8 | +-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 9 | +-- See the Mulan PSL v2 for more details. | ||
| 10 | + | ||
| 11 | +local lu = require('luaunit') | ||
| 12 | +local c_ub_configuration_service = require('ub_configuration_service') | ||
| 13 | + | ||
| 14 | +TestUbConfigurationService = {} | ||
| 15 | + | ||
| 16 | +function TestUbConfigurationService:test_set_ub_index() | ||
| 17 | + local test_cases = { | ||
| 18 | + { | ||
| 19 | + name = 'case 1', | ||
| 20 | + mds_obj = { | ||
| 21 | + UBParam = nil, | ||
| 22 | + UBParamReg = 0, | ||
| 23 | + expect_ret = nil, | ||
| 24 | + }, | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + name = 'case 2', | ||
| 28 | + mds_obj = { | ||
| 29 | + UBParam = 255, | ||
| 30 | + UBParamReg = 0, | ||
| 31 | + expect_ret = 0, | ||
| 32 | + }, | ||
| 33 | + }, | ||
| 34 | + { | ||
| 35 | + name = 'case 3', | ||
| 36 | + mds_obj = { | ||
| 37 | + UBParam = 1, | ||
| 38 | + UBParamReg = 0, | ||
| 39 | + expect_ret = 1, | ||
| 40 | + }, | ||
| 41 | + }, | ||
| 42 | + } | ||
| 43 | + for _, case in ipairs(test_cases) do | ||
| 44 | + c_ub_configuration_service.set_ub_index(case, case.mds_obj) | ||
| 45 | + lu.assertEquals(case.mds_obj.UBParamReg, case.mds_obj.expect_ret, string.format('%s fail', case.name)) | ||
| 46 | + end | ||
| 47 | +end | ||
| 48 | + | ||
| 49 | +function TestUbConfigurationService:test_set_ub_index_error() | ||
| 50 | + local test_cases = { | ||
| 51 | + { | ||
| 52 | + name = 'case 1', | ||
| 53 | + expect_ret = 0, | ||
| 54 | + setup = function() | ||
| 55 | + local mock = { | ||
| 56 | + UBParamReg = 0, | ||
| 57 | + } | ||
| 58 | + setmetatable(mock, { | ||
| 59 | + __index = function(t, key) | ||
| 60 | + if key == 'UBParam' then | ||
| 61 | + return 0 | ||
| 62 | + end | ||
| 63 | + end, | ||
| 64 | + }) | ||
| 65 | + return mock | ||
| 66 | + end, | ||
| 67 | + }, | ||
| 68 | + } | ||
| 69 | + for _, case in ipairs(test_cases) do | ||
| 70 | + local mds_obj = case.setup() | ||
| 71 | + c_ub_configuration_service.set_ub_index(case, case.mds_obj) | ||
| 72 | + lu.assertEquals(mds_obj.UBParamReg, case.expect_ret, string.format('%s fail', case.name)) | ||
| 73 | + end | ||
| 74 | +end | ||
| 75 | + | ||
| 76 | +function TestUbConfigurationService:test_set_ub_index_process() | ||
| 77 | + local test_cases = { | ||
| 78 | + { | ||
| 79 | + name = 'case 1', | ||
| 80 | + mds_obj = { | ||
| 81 | + UBParam = 255, | ||
| 82 | + UBParamReg = 0, | ||
| 83 | + expect_ret = 0, | ||
| 84 | + }, | ||
| 85 | + set_ub_index = c_ub_configuration_service.set_ub_index, | ||
| 86 | + }, | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + for _, case in ipairs(test_cases) do | ||
| 90 | + c_ub_configuration_service.init(case) | ||
| 91 | + c_ub_configuration_service.ctor(case, 0) | ||
| 92 | + c_ub_configuration_service.add_object(case, case.mds_obj, 0) | ||
| 93 | + lu.assertEquals(case.mds_obj.UBParamReg, case.mds_obj.expect_ret, string.format('%s fail', case.name)) | ||
🟡 Medium Priority 变更行: 问题链:
失败模式:当 建议:在测试中 mock skynet.fork 使其同步执行回调(参考 test_uid_led.lua 的做法),或改为直接调用 set_ub_index 验证核心逻辑。如果必须测试 add_object 流程,应在调用 add_object 前覆盖 skynet.fork: ![]() ![]() Incorrect? | |||
| 94 | + end | ||
🟡 Medium Priority 在 但
失败模式:当 建议:修复方案:不应将纯 table 作为 ![]() ![]() Incorrect? | |||
| 95 | +end | ||


🔵 Low Priority
在
src/lualib/ub_configuration_service.lua的set_ub_index函数中,写寄存器操作使用了pcall包裹(第 35 行),但未捕获pcall的第二个返回值(错误消息):ok = pcall(function() -- write 环节 ... end)
当 pcall 失败时,
ok为false,但实际的错误原因(pcall的第二个返回值)被丢弃。重试 3 次全部失败后,第 51 行仅输出set_ub_index failed after 3 times,但没有记录具体的失败原因。失败模式:在生产环境中,如果写入寄存器操作连续 3 次失败(如硬件异常、总线错误),日志中没有任何关于为何失败的信息,极大增加问题定位难度。
建议:建议捕获 pcall 的第二返回值并在最终失败时输出,以便定位问题根因。例如将
ok = pcall(...)改为ok, pcall_err = pcall(...),在if not ok then分支中记录pcall_err。