-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

local comm_defs = {}

comm_defs.MACA_SERVICE = 'bmc.kepler.maca'
comm_defs.MDB_PATH = '/bmc/kepler/MdbService'
comm_defs.MDB_INTERFACE = 'bmc.kepler.Mdb'

comm_defs.CARD_DEVICE_PATH_PATTERN = '/bmc/dev/Systems/1/PCIeNicCard'
comm_defs.FWINVENTORY_PATH_PREFIX = '/bmc/kepler/UpdateService/FirmwareInventory/'

-- 网卡可升级对象接口
comm_defs.FIRMWARE_INFO_INTERFACE = 'bmc.kepler.UpdateService.FirmwareInfo'

-- 网卡相关设备树接口
comm_defs.PCIE_DEVICE_INTERFACE = 'bmc.dev.PCIeDevice'
comm_defs.PCIE_CARD_DEVICE_INTERFACE = 'bmc.dev.PCIeCard'
comm_defs.PCIE_DEVICE_HOT_SWAP_INTERFACE = 'bmc.dev.PCIeDevice.HotSwap'
comm_defs.PCIE_DEVICE_BANDWIDTH_INTERFACE = 'bmc.dev.PCIeDevice.Bandwidth'
comm_defs.BOARD_DEVICE_INTERFACE = 'bmc.dev.Board'
comm_defs.NETWORK_ADAPTER_DEVICE_INTERFACE = 'bmc.dev.NetworkAdapter'
comm_defs.DEVICE_COOLING_INTERFACE = 'bmc.dev.Cooling'
comm_defs.NETWORK_ADAPTER_DEVICE_FAULT_STATUS_INTERFACE = 'bmc.dev.NetworkAdapter.FaultStatus'
comm_defs.NETWORK_ADAPTER_DEVICE_LOG_COLLECTION_INTERFACE = 'bmc.dev.NetworkAdapter.LogCollection'
comm_defs.NETWORK_ADAPTER_OEM_INTERFACE = 'bmc.dev.NetworkAdapter.Oem'
comm_defs.PCIE_DEVICE_OEM_INTERFACE = 'bmc.dev.PCIeDevice.Oem'
comm_defs.PCIE_DEVICE_STATUS_INTERFACE = 'bmc.dev.PCIeDevice.Status'
comm_defs.PCIE_DEVICE_PCIEFUNCTION_INTERFACE = 'bmc.dev.PCIeDevice.PCIeFunction'
comm_defs.PCIE_CARD_DEVICE_OEM_INTERFACE = 'bmc.dev.PCIeCard.Oem'

-- 网口相关设备树接口
comm_defs.NETWORK_PORT_DEVICE_INTERFACE = 'bmc.dev.NetworkPort'
comm_defs.NETWORK_PORT_DATA_CENTER_BRIDGING_INTERFACE = 'bmc.dev.NetworkPort.DataCenterBridging'
comm_defs.NETWORK_PORT_LLDP_RECEIVE_INTERFACE = 'bmc.dev.NetworkPort.LLDPReceive'
comm_defs.NETWORK_PORT_LINK_INFO_INTERFACE = 'bmc.dev.NetworkPort.LinkInfo'
comm_defs.NETWORK_PORT_METRICS_INTERFACE = 'bmc.dev.NetworkPort.Metrics'
comm_defs.NETWORK_PORT_FIBRE_CHANNEL_INTERFACE = 'bmc.dev.NetworkPort.FibreChannel'
comm_defs.NETWORK_PORT_OEM_INTERFACE = 'bmc.dev.NetworkPort.Oem'

-- 光模块相关设备树接口
comm_defs.OPTICAL_MODULE_DEVICE_INTERFACE = 'bmc.dev.OpticalModule'
comm_defs.OPTICAL_MODULE_STATUS_INTERFACE = 'bmc.dev.OpticalModule.Status'
comm_defs.OPTICAL_MODULE_TEMPERATURE_CELSIUS_INTERFACE = 'bmc.dev.OpticalModule.TemperatureCelsius'
comm_defs.OPTICAL_MODULE_POWER_INTERFACE = 'bmc.dev.OpticalModule.Power'
comm_defs.OPTICAL_MODULE_DIAGNOSE_INTERFACE = 'bmc.dev.OpticalModule.Diagnose'
comm_defs.OPTICAL_MODULE_VOLTAGE_INTERFACE = 'bmc.dev.OpticalModule.Voltage'
comm_defs.OPTICAL_MODULE_CURRENT_INTERFACE = 'bmc.dev.OpticalModule.Current'
comm_defs.OPTICAL_MODULE_CHANNEL_INTERFACE = 'bmc.dev.OpticalModule.Channel'
comm_defs.OPTICAL_MODULE_OEM_INTERFACE = 'bmc.dev.OpticalModule.Oem'

comm_defs.COMMON_PROPERTIES_INTERFACE = 'bmc.kepler.Object.Properties'
comm_defs.ORG_PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties'

-- 新增「同步到设备树」的逻辑时，勿漏此项（键名与设备树接口 property 名一致）。
comm_defs.INTERFACE_REGISTER_TABLE = {
    [comm_defs.NETWORK_ADAPTER_OEM_INTERFACE] = {
        OSPowerState = {'y', nil, false, nil, false},
        SmBiosStatus = {'y', nil, false, nil, false},
        IsPortCountMatched = {'y', nil, false, nil, false}
    },
    [comm_defs.PCIE_CARD_DEVICE_INTERFACE] = {
        Health = {'y', nil, false, nil, false}
    },
    [comm_defs.PCIE_DEVICE_INTERFACE] = {
        DeviceName = {'s', nil, true, nil, false}
    },
    [comm_defs.NETWORK_ADAPTER_DEVICE_INTERFACE] = {
        FirmwareVersion = {'s', nil, false, nil, false}
    },
    [comm_defs.NETWORK_PORT_DEVICE_INTERFACE] = {
        BDF = {'s', nil, false, nil, false}
    },
    [comm_defs.NETWORK_PORT_LINK_INFO_INTERFACE] = {
        LinkStatus = {'y', nil, false, nil, false},
        SpeedMbps = {'u', nil, false, nil, false},
        FullDuplex = {'y', nil, false, nil, false},
        AutoSpeedNegotiationEnabled = {'y', nil, false, nil, false}
    },
    [comm_defs.NETWORK_PORT_METRICS_INTERFACE] = {
        BandwidthPercent = {'d', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_DEVICE_INTERFACE] = {
        Presence = {'y', nil, false, nil, false},
        Manufacturer = {'s', nil, false, nil, false},
        PartNumber = {'s', nil, false, nil, false},
        SerialNumber = {'s', nil, false, nil, false},
        ProductionDate = {'s', nil, false, nil, false},
        WaveLengthNanometer = {'s', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_TEMPERATURE_CELSIUS_INTERFACE] = {
        TemperatureCelsius = {'d', nil, false, nil, false},
        TemperatureUpperThresholdCritical = {'d', nil, false, nil, false},
        TemperatureLowerThresholdCritical = {'d', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_STATUS_INTERFACE] = {
        TypeMatch = {'b', nil, false, nil, false},
        SpeedMatch = {'b', nil, false, nil, false},
        FaultState = {'u', nil, false, nil, false},
        PowerState = {'y', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_VOLTAGE_INTERFACE] = {
        SupplyVoltage = {'d', nil, false, nil, false},
        VoltageLowerThresholdCritical = {'d', nil, false, nil, false},
        VoltageUpperThresholdCritical = {'d', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_POWER_INTERFACE] = {
        RXInputPowerMilliWatts = {'ad', nil, false, nil, false},
        TXOutputPowerMilliWatts = {'ad', nil, false, nil, false},
        RXPowerUpperThresholdCritical = {'d', nil, false, nil, false},
        RXPowerLowerThresholdCritical = {'d', nil, false, nil, false},
        TXPowerUpperThresholdCritical = {'d', nil, false, nil, false},
        TXPowerLowerThresholdCritical = {'d', nil, false, nil, false}
    },
    [comm_defs.OPTICAL_MODULE_CURRENT_INTERFACE] = {
        TXBiasCurrentMilliAmps = {'ad', nil, false, nil, false},
        TXBiasCurrentLowerThresholdCritical = {'d', nil, false, nil, false},
        TXBiasCurrentUpperThresholdCritical = {'d', nil, false, nil, false}
    },
    [comm_defs.PCIE_DEVICE_HOT_SWAP_INTERFACE] = {
        ReadyToRemove = {'y', nil, false, nil, false}
    }
}

comm_defs.LOG_DUMP_BUSY = 1 -- 1表示正在收集
comm_defs.LOG_DUMP_IDLE = 0 -- 0 表示空闲

comm_defs.UPGRADABLE_FIRMWARE_OBJ = "NetworkAdapterFirmware"

return comm_defs
