Merged
feat(drivers): 新增 WestDigi NVMe PCIe4 驱动适配 #1456
byosoft_renqixingAdd on 13 days ago
feat(drivers): 新增 WestDigi NVMe PCIe4 驱动适配 #1456
Merged
Total: 8 files changed+574-0
| @@ -2,3 +2,4 @@ subdir('huawei') | |||
| 2 | subdir('samsung') | 2 | subdir('samsung') |
| 3 | subdir('dera') | 3 | subdir('dera') |
| 4 | subdir('dapustor') | 4 | subdir('dapustor') |
| 5 | +subdir('westdigi') | ||
| @@ -0,0 +1,28 @@ | |||
| 1 | +{ | ||
| 2 | + "Schema": "dds-v1", | ||
| 3 | + "Type": "Component", | ||
| 4 | + "DeviceCategory": "PCIeNVMe", | ||
| 5 | + "ID": "N/A", | ||
| 6 | + "Objects": { | ||
| 7 | + "PCIeNVMe": { | ||
| 8 | + "Path": "/bmc/dev/Systems/:SystemId/PCIeNVMe/:Id", | ||
| 9 | + "Interfaces": [ | ||
| 10 | + "bmc.dev.PCIeDevice", | ||
| 11 | + "bmc.dev.PCIeDevice.PCIeFunction", | ||
| 12 | + "bmc.dev.PCIeDevice.Oem", | ||
| 13 | + "bmc.dev.PCIeDevice.Status", | ||
| 14 | + "bmc.dev.NVMe", | ||
| 15 | + "bmc.dev.NVMe.Management", | ||
| 16 | + "bmc.dev.NVMe.ProductInfo", | ||
| 17 | + "bmc.dev.NVMe.MultiRecord", | ||
| 18 | + "bmc.dev.NVMe.Status", | ||
| 19 | + "bmc.dev.Cooling", | ||
| 20 | + "bmc.dev.NVMe.BasicManagement", | ||
| 21 | + "bmc.dev.NVMe.NVMeMI", | ||
| 22 | + "bmc.dev.NVMe.LogCollection", | ||
| 23 | + "bmc.dev.NVMe.Smart", | ||
| 24 | + "bmc.dev.NVMe.Oem" | ||
| 25 | + ] | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} | ||
| @@ -0,0 +1,335 @@ | |||
| 1 | +{ | ||
| 2 | + "FormatVersion": "5.00", | ||
| 3 | + "DataVersion": "5.00", | ||
| 4 | + "Unit": { | ||
| 5 | + "Type": "PCIeNVMe", | ||
| 6 | + "Name": "PCIeNVMe_1", | ||
| 7 | + "Compatible": [ | ||
| 8 | + "westdigi_nvme_pcie4" | ||
| 9 | + ] | ||
| 10 | + }, | ||
| 11 | + "ManagementTopology": { | ||
| 12 | + "Anchor": { | ||
| 13 | + "Buses": [ | ||
| 14 | + "I2cMux_SMC" | ||
| 15 | + ] | ||
| 16 | + }, | ||
| 17 | + "I2cMux_SMC": { | ||
| 18 | + "Chips": [ | ||
| 19 | + "Chip_Temp", | ||
| 20 | + "Chip_Virtual_SSD", | ||
| 21 | + "Chip_SSD" | ||
| 22 | + ] | ||
| 23 | + } | ||
| 24 | + }, | ||
| 25 | + "Objects": { | ||
| 26 | + "Component_PCIeCard": { | ||
| 27 | + "FruId": 255, | ||
| 28 | + "Name": "Disk${Slot}", | ||
| 29 | + "Instance": 255, | ||
| 30 | + "BoardId": 65535, | ||
| 31 | + "Type": 2, | ||
| 32 | + "Presence": 1, | ||
| 33 | + "Health": 0, | ||
| 34 | + "PowerState": 1, | ||
| 35 | + "UniqueId": "N/A", | ||
| 36 | + "Manufacturer": "", | ||
| 37 | + "ReplaceFlag": 0, | ||
| 38 | + "PreviousSN": "", | ||
| 39 | + "SerialNumber": "<=/PCIeNVMe_1[bmc.dev.NVMe.ProductInfo].SerialNumber", | ||
| 40 | + "GroupId": 1 | ||
| 41 | + }, | ||
| 42 | + "Entity_SSD": { | ||
| 43 | + "Id": 4, | ||
| 44 | + "Instance": 101, | ||
| 45 | + "Name": "Disk${Slot}", | ||
| 46 | + "PowerState": 1, | ||
| 47 | + "Presence": 1 | ||
| 48 | + }, | ||
| 49 | + "MctpBinding_1": { | ||
| 50 | + "BmcSMBusEid": 8, | ||
| 51 | + "BmcSMBusPhyAddr": 16 | ||
| 52 | + }, | ||
| 53 | + "Endpoint_1": { | ||
| 54 | + "TargetEid": "${Slot} |> expr($1 + 8)", | ||
| 55 | + "TargetPhyAddr": 29, | ||
| 56 | + "MessageType": 4, | ||
| 57 | + "MediumType": 129, | ||
| 58 | + "RefChip": "#/Chip_SSD" | ||
| 59 | + }, | ||
| 60 | + "Event_DiskLinkSpeed": { | ||
| 61 | + "EventKeyId": "Disk.DiskLinkSpeedReduced", | ||
| 62 | + "Condition": 1, | ||
| 63 | + "Reading": "<=/PCIeNVMe_1.LinkSpeedReduced", | ||
| 64 | + "OperatorId": 5, | ||
| 65 | + "Enabled": true, | ||
| 66 | + "DescArg2": "${Slot}", | ||
| 67 | + "Component": "#/Component_PCIeCard" | ||
| 68 | + }, | ||
| 69 | + "Event_DiskUncorrectableErr": { | ||
| 70 | + "EventKeyId": "Disk.DiskUncorrectableErr", | ||
| 71 | + "Condition": 1, | ||
| 72 | + "Reading": "<=/PCIeNVMe_1.DiagnosticFault", | ||
| 73 | + "OperatorId": 5, | ||
| 74 | + "Enabled": true, | ||
| 75 | + "DescArg2": "#/Component_PCIeCard.Name", | ||
| 76 | + "DescArg3": "NA", | ||
| 77 | + "Component": "#/Component_PCIeCard" | ||
| 78 | + }, | ||
| 79 | + "Event_DiskCEHardFailure": { | ||
| 80 | + "EventKeyId": "Disk.DiskCEHardFailure", | ||
| 81 | + "Condition": 1, | ||
| 82 | + "Reading": "<=/PCIeNVMe_1.PredictiveFault", | ||
| 83 | + "OperatorId": 5, | ||
| 84 | + "Enabled": true, | ||
| 85 | + "AdditionalInfo": "2", | ||
| 86 | + "DescArg2": "#/Component_PCIeCard.Name", | ||
| 87 | + "Component": "#/Component_PCIeCard" | ||
| 88 | + }, | ||
| 89 | + "Event_NVMeBandWidth": { | ||
| 90 | + "EventKeyId": "Disk.DiskBandWidthReduced", | ||
| 91 | + "Condition": 1, | ||
| 92 | + "Reading": "<=/PCIeNVMe_1.BandwidthReduced", | ||
| 93 | + "OperatorId": 5, | ||
| 94 | + "Enabled": true, | ||
| 95 | + "AdditionalInfo": "2", | ||
| 96 | + "DescArg2": "${Slot}", | ||
| 97 | + "Component": "#/Component_PCIeCard" | ||
| 98 | + }, | ||
| 99 | + "PCIeNVMe_1": { | ||
| 100 | + "bmc.dev.PCIeDevice": { | ||
| 101 | + "DeviceName": "Disk${Slot}" | ||
| 102 | + }, | ||
| 103 | + "bmc.dev.PCIeDevice.PCIeFunction": { | ||
| 104 | + "VendorId": "0x1b96" | ||
| 105 | + }, | ||
| 106 | + "bmc.dev.PCIeDevice.Oem" : { | ||
| 107 | + "FunctionClass": 4, | ||
| 108 | + "ComponentType": 2, | ||
| 109 | + "Container": "${Container}", | ||
| 110 | + "GroupPosition": "PCIeDevice_${GroupPosition}" | ||
| 111 | + }, | ||
| 112 | + "bmc.dev.PCIeDevice.Status": {}, | ||
| 113 | + "bmc.dev.NVMe": { | ||
| 114 | + "Slot": "${Slot}", | ||
| 115 | + "MediaType": 1, | ||
| 116 | + "Protocol": 6, | ||
| 117 | + "NegotiatedSpeedGbs": 255, | ||
| 118 | + "PredictedMediaLifeLeftPercent": 255, | ||
| 119 | + "SpareBlockPercentage": 255 | ||
| 120 | + }, | ||
| 121 | + "bmc.dev.NVMe.Management": { | ||
| 122 | + "NvmeProtocol": 0, | ||
| 123 | + "SupportedMctpOverPcie": 0, | ||
| 124 | + "SupportedVendorSpecificSmart": 0, | ||
| 125 | + "VPDChip": "#/Chip_Virtual_SSD", | ||
| 126 | + "SSDChip": "#/Chip_SSD", | ||
| 127 | + "RefComponent": "#/Component_PCIeCard" | ||
| 128 | + }, | ||
| 129 | + "bmc.dev.NVMe.ProductInfo": { | ||
| 130 | + "Model": "N/A", | ||
| 131 | + "SerialNumber": "N/A", | ||
| 132 | + "Manufacturer": "N/A", | ||
| 133 | + "ManufacturerId": "4294967295" | ||
| 134 | + }, | ||
| 135 | + "bmc.dev.NVMe.MultiRecord": { | ||
| 136 | + "Revision": "N/A", | ||
| 137 | + "CapacityMiB": 4294967295, | ||
| 138 | + "CapableSpeedGbs": 255 | ||
| 139 | + }, | ||
| 140 | + "bmc.dev.NVMe.Status": { | ||
| 141 | + "Failure": 255, | ||
| 142 | + "PredictiveFailure": 255, | ||
| 143 | + "MediaErrorCount": 4294967295 | ||
| 144 | + }, | ||
| 145 | + "bmc.dev.Cooling": { | ||
| 146 | + "TemperatureCelsius": 128, | ||
| 147 | + "TemperatureStatus": 4, | ||
| 148 | + "TargetTemperatureCelsius": 68, | ||
| 149 | + "MaxTemperatureCelsius": 75 | ||
| 150 | + }, | ||
| 151 | + "bmc.dev.NVMe.BasicManagement": { | ||
| 152 | + "Port0PCIeLinkActive": 255, | ||
| 153 | + "Port1PCIeLinkActive": 255, | ||
| 154 | + "ResetNotRequired": 255, | ||
| 155 | + "DriveFunctional": 255, | ||
| 156 | + "DriveNotReady": 255, | ||
| 157 | + "SMARTWarnings": 255, | ||
| 158 | + "PercentageDriveLifeUsed": 255, | ||
| 159 | + "LinkFault": 255 | ||
| 160 | + }, | ||
| 161 | + "bmc.dev.NVMe.NVMeMI": {}, | ||
| 162 | + "bmc.dev.NVMe.LogCollection": {}, | ||
| 163 | + "bmc.dev.NVMe.Smart": { | ||
| 164 | + "AvailableSpare": 255, | ||
| 165 | + "CriticalWarning": 255, | ||
| 166 | + "UsedPercentage": 255, | ||
| 167 | + "PowerOnHours": 4294967295, | ||
| 168 | + "Status": 255, | ||
| 169 | + "TLCSpareBlockPercentage": 255 | ||
| 170 | + }, | ||
| 171 | + "bmc.dev.Upgrade": {}, | ||
| 172 | + "bmc.dev.NVMe.Oem": { | ||
| 173 | + "OSPowerState": 0 | ||
| 174 | + } | ||
| 175 | + }, | ||
| 176 | + "Chip_Virtual_SSD": { | ||
| 177 | + "Address": 166, | ||
| 178 | + "AddrWidth": 1, | ||
| 179 | + "OffsetWidth": 1, | ||
| 180 | + "WriteTmout": 100, | ||
| 181 | + "ReadTmout": 100, | ||
| 182 | + "HealthStatus": 0 | ||
| 183 | + }, | ||
| 184 | + "Chip_SSD": { | ||
| 185 | + "Address": 212, | ||
| 186 | + "AddrWidth": 1, | ||
| 187 | + "OffsetWidth": 1, | ||
| 188 | + "WriteTmout": 100, | ||
| 189 | + "ReadTmout": 100, | ||
| 190 | + "HealthStatus": 0 | ||
| 191 | + }, | ||
| 192 | + "Scanner_Remtime": { | ||
| 193 | + "Chip": "#/Chip_SSD", | ||
| 194 | + "Offset": 4, | ||
| 195 | + "Size": 1, | ||
| 196 | + "Mask": 255, | ||
| 197 | + "Type": 0, | ||
| 198 | + "Period": 2000, | ||
| 199 | + "Debounce": "None", | ||
| 200 | + "NominalValue": 0, | ||
| 201 | + "ScanEnabled": "<=/PCIeNVMe_1.OSPowerState", | ||
| 202 | + "Value": 0 | ||
| 203 | + }, | ||
| 204 | + "Chip_Temp": { | ||
| 205 | + "Address": 213, | ||
| 206 | + "AddrWidth": 1, | ||
| 207 | + "OffsetWidth": 1, | ||
| 208 | + "WriteTmout": 100, | ||
| 209 | + "ReadTmout": 100, | ||
| 210 | + "HealthStatus": 0 | ||
| 211 | + }, | ||
| 212 | + "Scanner_Temp": { | ||
| 213 | + "Chip": "#/Chip_Temp", | ||
| 214 | + "Offset": 3, | ||
| 215 | + "Size": 1, | ||
| 216 | + "Mask": 255, | ||
| 217 | + "Type": 0, | ||
| 218 | + "Period": 2000, | ||
| 219 | + "Debounce": "#/Average_DiskTemp", | ||
| 220 | + "NominalValue": 20, | ||
| 221 | + "ScanEnabled": "<=/PCIeNVMe_1.OSPowerState", | ||
| 222 | + "Value": 20 | ||
| 223 | + }, | ||
| 224 | + "ThresholdSensor_NvmeTemp": { | ||
| 225 | + "AssertMask": 29312, | ||
| 226 | + "DeassertMask": 29312, | ||
| 227 | + "ReadingMask": 6168, | ||
| 228 | + "Linearization": 0, | ||
| 229 | + "M": 100, | ||
| 230 | + "RBExp": 224, | ||
| 231 | + "UpperCritical": 85, | ||
| 232 | + "UpperNoncritical": 84, | ||
| 233 | + "PositiveHysteresis": 2, | ||
| 234 | + "NegativeHysteresis": 2, | ||
| 235 | + "OwnerId": 32, | ||
| 236 | + "OwnerLun": 0, | ||
| 237 | + "EntityId": "<=/Entity_SSD.Id", | ||
| 238 | + "EntityInstance": "<=/Entity_SSD.Instance", | ||
| 239 | + "Initialization": 127, | ||
| 240 | + "Capabilities": 104, | ||
| 241 | + "SensorType": 1, | ||
| 242 | + "ReadingType": 1, | ||
| 243 | + "SensorName": "SSD Disk${Slot} Temp", | ||
| 244 | + "Unit": 128, | ||
| 245 | + "BaseUnit": 1, | ||
| 246 | + "ModifierUnit": 0, | ||
| 247 | + "Analog": 1, | ||
| 248 | + "NominalReading": 25, | ||
| 249 | + "NormalMaximum": 0, | ||
| 250 | + "NormalMinimum": 0, | ||
| 251 | + "MaximumReading": 127, | ||
| 252 | + "MinimumReading": 128, | ||
| 253 | + "Reading": "<=/PCIeNVMe_1.TemperatureCelsius", | ||
| 254 | + "ReadingStatus": "<=/Scanner_Temp.Status; <=/PCIeNVMe_1.TemperatureCelsius |> expr((($1 == 0) && ($2 == 129 || $2 == 128 || ($2 >= 130 && $2 <= 195))) ? 2 : $1)" | ||
| 255 | + }, | ||
| 256 | + "Event_NVMeTempHighMinor": { | ||
| 257 | + "EventKeyId": "PCIeCard.DiskOverTempMinor", | ||
| 258 | + "Condition": "<=/ThresholdSensor_NvmeTemp.UpperNoncritical", | ||
| 259 | + "Hysteresis": "<=/ThresholdSensor_NvmeTemp.PositiveHysteresis", | ||
| 260 | + "Reading": "<=/PCIeNVMe_1.TemperatureCelsius; <=/ThresholdSensor_NvmeTemp.UpperNoncritical; <=/ThresholdSensor_NvmeTemp.UpperCritical |> expr(($1 >= $2 && $1 < $3) ? $1 : 20)", | ||
| 261 | + "@Default": { | ||
| 262 | + "Condition": 84 | ||
| 263 | + }, | ||
| 264 | + "OperatorId": 4, | ||
| 265 | + "Enabled": true, | ||
| 266 | + "Component": "#/Component_PCIeCard", | ||
| 267 | + "DescArg2": "#/Component_PCIeCard.Name", | ||
| 268 | + "DescArg3": "#/Event_NVMeTempHighMinor.Reading", | ||
| 269 | + "DescArg4": "#/ThresholdSensor_NvmeTemp.UpperNoncritical" | ||
| 270 | + }, | ||
| 271 | + "Event_NVMeTempHighMajor": { | ||
| 272 | + "EventKeyId": "Disk.DiskMaxTempMajorInfo", | ||
| 273 | + "Condition": "<=/ThresholdSensor_NvmeTemp.UpperCritical", | ||
| 274 | + "Hysteresis": "<=/ThresholdSensor_NvmeTemp.PositiveHysteresis", | ||
| 275 | + "Reading": "<=/PCIeNVMe_1.TemperatureCelsius; <=/ThresholdSensor_NvmeTemp.UpperCritical |> expr(($1 >= $2 && $1 <= 127) ? $1 : 20)", | ||
| 276 | + "@Default": { | ||
| 277 | + "Condition": 85 | ||
| 278 | + }, | ||
| 279 | + "OperatorId": 4, | ||
| 280 | + "Enabled": true, | ||
| 281 | + "Component": "#/Component_PCIeCard", | ||
| 282 | + "DescArg2": "#/Component_PCIeCard.Name", | ||
| 283 | + "DescArg3": "#/Event_NVMeTempHighMajor.Reading", | ||
| 284 | + "DescArg4": "#/ThresholdSensor_NvmeTemp.UpperCritical" | ||
| 285 | + }, | ||
| 286 | + "Event_NVMeTempFail": { | ||
| 287 | + "EventKeyId": "Disk.DiskAccessTempFailure", | ||
| 288 | + "Condition": 1, | ||
| 289 | + "Reading": "<=/Scanner_Temp.Status; <=/PCIeNVMe_1.TemperatureCelsius |> expr((($1 == 1) || ($2 == 129)) ? 1 : 0)", | ||
| 290 | + "OperatorId": 5, | ||
| 291 | + "Enabled": true, | ||
| 292 | + "Component": "#/Component_PCIeCard", | ||
| 293 | + "DescArg2": "#/Component_PCIeCard.Name" | ||
| 294 | + }, | ||
| 295 | + "Scanner_SSD_Fault": { | ||
| 296 | + "Chip": "#/Chip_SSD", | ||
| 297 | + "Offset": 1, | ||
| 298 | + "Size": 1, | ||
| 299 | + "Mask": 255, | ||
| 300 | + "Type": 0, | ||
| 301 | + "Period": 2000, | ||
| 302 | + "Debounce": "None", | ||
| 303 | + "NominalValue": 0, | ||
| 304 | + "ScanEnabled": "<=/PCIeNVMe_1.OSPowerState", | ||
| 305 | + "Value": 0 | ||
| 306 | + }, | ||
| 307 | + "Scanner_SSD_Pre_Fault": { | ||
| 308 | + "Chip": "#/Chip_SSD", | ||
| 309 | + "Offset": 2, | ||
| 310 | + "Size": 1, | ||
| 311 | + "Mask": 255, | ||
| 312 | + "Type": 0, | ||
| 313 | + "Period": 2000, | ||
| 314 | + "Debounce": "None", | ||
| 315 | + "NominalValue": 0, | ||
| 316 | + "ScanEnabled": "<=/PCIeNVMe_1.OSPowerState", | ||
| 317 | + "Value": 0 | ||
| 318 | + }, | ||
| 319 | + "Average_DiskTemp": { | ||
| 320 | + "WindowSize": 3, | ||
| 321 | + "DefaultValue": 20 | ||
| 322 | + }, | ||
| 323 | + "CoolingRequirement_1_60": { | ||
| 324 | + "RequirementId": "${Slot} |> expr((60 << 8) | $1)", | ||
| 325 | + "MonitoringStatus": "<=/Scanner_Temp.Status; <=/Scanner_Temp.Value |> expr(($1 == 1 || $2 >= 255) ? 1 : 0)", | ||
| 326 | + "MonitoringValue": "<=/Scanner_Temp.Value", | ||
| 327 | + "FailedValue": 80, | ||
| 328 | + "TargetTemperatureCelsius": 68, | ||
| 329 | + "MaxAllowedTemperatureCelsius": 75, | ||
| 330 | + "TargetTemperatureRangeCelsius": [], | ||
| 331 | + "ThresholdValue": [], | ||
| 332 | + "AlarmSpeed": [] | ||
| 333 | + } | ||
| 334 | + } | ||
| 335 | +} | ||
| @@ -0,0 +1,3 @@ | |||
| 1 | +# westdigi 目录的 meson.build 文件 | ||
| 2 | + | ||
| 3 | +subdir('westdigi_nvme_pcie4') | ||
| @@ -0,0 +1,55 @@ | |||
| 1 | +# westdigi_nvme_pcie4 目录的 meson.build 文件 | ||
| 2 | + | ||
| 3 | +message('开始构建 westdigi_nvme_pcie4 驱动库') | ||
| 4 | + | ||
| 5 | +westdigi_nvme_pcie4_sources = files( | ||
| 6 | + 'westdigi_nvme_pcie4.cpp', | ||
| 7 | + 'westdigi_nvme_pcie4_abi.cpp', | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +include_dirs += include_directories('../../../chip') | ||
| 11 | +include_dirs += include_directories('../../../internal') | ||
| 12 | + | ||
| 13 | +libwestdigi_nvme_pcie4_static = static_library( | ||
| 14 | + 'westdigi_nvme_pcie4', | ||
| 15 | + westdigi_nvme_pcie4_sources, | ||
| 16 | + include_directories: include_dirs + pcie_nvme_common_inc, | ||
| 17 | + dependencies: [dev_deps, libnvme_dep], | ||
| 18 | + install: false, | ||
| 19 | + override_options: ['unity_size=15'], | ||
| 20 | +) | ||
| 21 | + | ||
| 22 | +libwestdigi_nvme_pcie4 = shared_library( | ||
| 23 | + 'westdigi_nvme_pcie4', | ||
| 24 | + include_directories: include_dirs + pcie_nvme_common_inc, | ||
| 25 | + name_prefix: 'lib', | ||
| 26 | + name_suffix: 'so', | ||
| 27 | + install: true, | ||
| 28 | + install_dir: drivers_install_dir, | ||
| 29 | + link_whole: [libwestdigi_nvme_pcie4_static, libpcie_nvme_common_static], | ||
| 30 | + dependencies: [dev_deps, libnvme_dep], | ||
| 31 | +) | ||
| 32 | + | ||
| 33 | +if build_tests | ||
| 34 | + westdigi_nvme_pcie4_dep = declare_dependency( | ||
| 35 | + include_directories: include_dirs + pcie_nvme_common_inc, | ||
| 36 | + link_with: [libwestdigi_nvme_pcie4_static, libpcie_nvme_common_static], | ||
| 37 | + dependencies: [ | ||
| 38 | + libmcpp_deps, | ||
| 39 | + libnvme_dep, | ||
| 40 | + libmctp_dep, | ||
| 41 | + ], | ||
| 42 | + ) | ||
| 43 | +endif | ||
| 44 | + | ||
| 45 | +if build_tests and meson_build | ||
| 46 | + all_copy_targets += custom_target( | ||
| 47 | + 'copy_libwestdigi_nvme_pcie4', | ||
| 48 | + output: 'copy_libwestdigi_nvme_pcie4', | ||
| 49 | + command: ['sh', '-c', 'cp --remove-destination $1 $2 && touch $3', '--', libwestdigi_nvme_pcie4.full_path(), drivers_install_dir, '@OUTPUT@'], | ||
| 50 | + depends: libwestdigi_nvme_pcie4, | ||
| 51 | + build_by_default: true, | ||
| 52 | + ) | ||
| 53 | +endif | ||
| 54 | + | ||
| 55 | +message('westdigi_nvme_pcie4 驱动库构建完成') | ||
| @@ -0,0 +1,14 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * openUBMC is licensed under Mulan PSL v2. | ||
| 4 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 5 | + * You may obtain a copy of Mulan PSL v2 at: 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 | + | ||
| 12 | +#include "westdigi_nvme_pcie4.h" | ||
| 13 | + | ||
| 14 | +NVME_PCIE4_REFLECT(dev::westdigi_nvme_pcie4) | ||
| @@ -0,0 +1,29 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * openUBMC is licensed under Mulan PSL v2. | ||
| 4 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 5 | + * You may obtain a copy of Mulan PSL v2 at: 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 | + | ||
| 12 | +#ifndef WESTDIGI_NVME_PCIE4_H | ||
| 13 | +#define WESTDIGI_NVME_PCIE4_H | ||
| 14 | + | ||
| 15 | +#include "../../common/nvme_pcie4_driver.h" | ||
| 16 | +#include "../../common/nvme_pcie4_object_macros.h" | ||
| 17 | + | ||
| 18 | +namespace dev { | ||
| 19 | + | ||
| 20 | +class westdigi_nvme_pcie4 : public nvme_pcie4_driver<westdigi_nvme_pcie4> { | ||
| 21 | +public: | ||
| 22 | + static constexpr const char* vendor_key = "westdigi"; | ||
| 23 | + | ||
| 24 | + NVME_PCIE4_OBJECT(westdigi_nvme_pcie4) | ||
| 25 | +}; | ||
| 26 | + | ||
| 27 | +} // namespace dev | ||
| 28 | + | ||
| 29 | +#endif // WESTDIGI_NVME_PCIE4_H | ||
| @@ -0,0 +1,109 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * openUBMC is licensed under Mulan PSL v2. | ||
| 4 | + * You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
| 5 | + * You may obtain a copy of Mulan PSL v2 at: | ||
| 6 | + * http://license.coscl.org.cn/MulanPSL2 | ||
| 7 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
| 8 | + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
| 9 | + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
| 10 | + * See the Mulan PSL v2 for more details. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +#include <devmon/driver_abi.h> | ||
| 14 | +#include <mc/log.h> | ||
| 15 | + | ||
| 16 | +#include "westdigi_nvme_pcie4.h" | ||
| 17 | + | ||
| 18 | +#ifndef DEVICE_DRIVER_NAME | ||
| 19 | +#define DEVICE_DRIVER_NAME "westdigi_nvme_pcie4" | ||
| 20 | +#endif | ||
| 21 | + | ||
| 22 | +using namespace dev; | ||
| 23 | + | ||
| 24 | +// 导出信息实现 | ||
| 25 | +extern "C" { | ||
| 26 | + | ||
| 27 | +driver_handle_t create_westdigi_nvme_pcie4(void* service, const char* name) | ||
| 28 | +{ | ||
| 29 | + try { | ||
| 30 | + if (service == nullptr || name == nullptr) { | ||
| 31 | + elog("Error creating westdigi_nvme_pcie4 NVMe: service or name is null"); | ||
| 32 | + return nullptr; | ||
| 33 | + } | ||
| 34 | + westdigi_nvme_pcie4* device = new westdigi_nvme_pcie4(); | ||
| 35 | + device->set_service(static_cast<mc::engine::service*>(service)); | ||
| 36 | + device->set_object_name(name); | ||
| 37 | + return (void*)device; | ||
| 38 | + } catch (const std::exception& e) { | ||
| 39 | + elog("Error creating westdigi_nvme_pcie4 NVMe: ${error}", ("error", e.what())); | ||
| 40 | + return nullptr; | ||
| 41 | + } | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +status_t init_westdigi_nvme_pcie4(driver_handle_t device, void* csr_object, void* connector) | ||
| 45 | +{ | ||
| 46 | + if (device == nullptr || csr_object == nullptr || connector == nullptr) { | ||
| 47 | + elog("Error initializing westdigi_nvme_pcie4 NVMe: device is null"); | ||
| 48 | + return STATUS_ERROR; | ||
| 49 | + } | ||
| 50 | + westdigi_nvme_pcie4* device_object = static_cast<westdigi_nvme_pcie4*>(device); | ||
| 51 | + mc::mutable_dict* csr_object_ptr = static_cast<mc::mutable_dict*>(csr_object); | ||
| 52 | + mc::dict* connector_ptr = static_cast<mc::dict*>(connector); | ||
| 53 | + | ||
| 54 | + bool ret = device_object->init(*csr_object_ptr, *connector_ptr); | ||
| 55 | + if (!ret) { | ||
| 56 | + elog("Error initializing westdigi_nvme_pcie4 NVMe: init failed"); | ||
| 57 | + return STATUS_ERROR; | ||
| 58 | + } | ||
| 59 | + return STATUS_OK; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +status_t start_westdigi_nvme_pcie4(driver_handle_t device) | ||
| 63 | +{ | ||
| 64 | + if (device == nullptr) { | ||
| 65 | + elog("Error starting westdigi_nvme_pcie4 NVMe: device is null"); | ||
| 66 | + return STATUS_ERROR; | ||
| 67 | + } | ||
| 68 | + westdigi_nvme_pcie4* device_object = static_cast<westdigi_nvme_pcie4*>(device); | ||
| 69 | + bool ret = device_object->start(); | ||
| 70 | + if (!ret) { | ||
| 71 | + elog("Error starting westdigi_nvme_pcie4 NVMe: start failed"); | ||
| 72 | + return STATUS_ERROR; | ||
| 73 | + } | ||
| 74 | + return STATUS_OK; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +status_t stop_westdigi_nvme_pcie4(driver_handle_t device) | ||
| 78 | +{ | ||
| 79 | + if (device == nullptr) { | ||
| 80 | + elog("Error stopping westdigi_nvme_pcie4 NVMe: device is null"); | ||
| 81 | + return STATUS_ERROR; | ||
| 82 | + } | ||
| 83 | + westdigi_nvme_pcie4* device_object = static_cast<westdigi_nvme_pcie4*>(device); | ||
| 84 | + bool ret = device_object->stop(); | ||
| 85 | + if (!ret) { | ||
| 86 | + elog("Error stopping westdigi_nvme_pcie4 NVMe: stop failed"); | ||
| 87 | + return STATUS_ERROR; | ||
| 88 | + } | ||
| 89 | + return STATUS_OK; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +// PCIeNVMe设备类信息 | ||
| 93 | +device_driver_t westdigi_nvme_pcie4_device_driver = {.device_name = "PCIeNVMe", | ||
| 94 | + .ctor = create_westdigi_nvme_pcie4, | ||
| 95 | + .init = init_westdigi_nvme_pcie4, | ||
| 96 | + .start = start_westdigi_nvme_pcie4, | ||
| 97 | + .stop = stop_westdigi_nvme_pcie4}; | ||
| 98 | + | ||
| 99 | +// 导出设备类信息 | ||
| 100 | +device_driver_t westdigi_nvme_pcie4_device_driver_array[] = {westdigi_nvme_pcie4_device_driver}; | ||
| 101 | + | ||
| 102 | +status_t register_device_driver(device_driver_t** device_driver, uint8_t* count) | ||
| 103 | +{ | ||
| 104 | + *device_driver = westdigi_nvme_pcie4_device_driver_array; | ||
| 105 | + *count = sizeof(westdigi_nvme_pcie4_device_driver_array) / sizeof(westdigi_nvme_pcie4_device_driver_array[0]); | ||
| 106 | + return STATUS_OK; | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +} // extern "C" | ||