// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>
#include <ipmid/api-types.hpp>
#include <map>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>

namespace google
{
namespace ipmi
{

using Resp = ::ipmi::RspType<std::uint8_t, std::vector<uint8_t>>;

using VersionTuple =
    std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;

class HandlerInterface
{
  public:
    virtual ~HandlerInterface() = default;

    /**
     * Return ethernet details (hard-coded).
     *
     * @return tuple of ethernet details (channel, if name).
     */
    virtual std::tuple<std::uint8_t, std::string>
        getEthDetails(std::string intf) const = 0;

    /**
     * Return the value of rx_packets, given a if_name.
     *
     * @param[in] name, the interface name.
     * @return the number of packets received.
     * @throw IpmiException on failure.
     */
    virtual std::int64_t getRxPackets(const std::string& name) const = 0;

    /**
     * Return the values from a cpld version file.
     *
     * @param[in] id - the cpld id number.
     * @return the quad of numbers as a tuple (maj,min,pt,subpt)
     * @throw IpmiException on failure.
     */
    virtual VersionTuple getCpldVersion(unsigned int id) const = 0;

    /**
     * Set the PSU Reset delay.
     *
     * @param[in] delay - delay in seconds.
     * @throw IpmiException on failure.
     */
    virtual void psuResetDelay(std::uint32_t delay) const = 0;

    /**
     * Arm for PSU reset on host shutdown.
     *
     * @throw IpmiException on failure.
     */
    virtual void psuResetOnShutdown() const = 0;

    /**
     * Return the entity name.
     * On the first call to this method it'll build the list of entities.
     * @todo Consider moving the list building to construction time (and ignore
     * failures).
     *
     * @param[in] id - the entity id value
     * @param[in] instance - the entity instance
     * @return the entity's name
     * @throw IpmiException on failure.
     */
    virtual std::string getEntityName(std::uint8_t id,
                                      std::uint8_t instance) = 0;

    /**
     * Return the flash size of bmc chip.
     *
     * @return the flash size of bmc chip
     * @throw IpmiException on failure.
     */
    virtual uint32_t getFlashSize() = 0;

    /**
     * Return the name of the machine, parsed from release information.
     *
     * @return the machine name
     * @throw IpmiException on failure.
     */
    virtual std::string getMachineName() = 0;

    /**
     * Populate the i2c-pcie mapping vector.
     */
    virtual void buildI2cPcieMapping() = 0;

    /**
     * Return the size of the i2c-pcie mapping vector.
     *
     * @return the size of the vector holding the i2c-pcie mapping tuples.
     */
    virtual size_t getI2cPcieMappingSize() const = 0;

    /**
     * Return a copy of the entry in the vector.
     *
     * @param[in] entry - the index into the vector.
     * @return the tuple at that index.
     */
    virtual std::tuple<std::uint32_t, std::string>
        getI2cEntry(unsigned int entry) const = 0;

    /**
     * Set the Host Power Off delay.
     *
     * @param[in] delay - delay in seconds.
     * @throw IpmiException on failure.
     */
    virtual void hostPowerOffDelay(std::uint32_t delay) const = 0;

    /**
     * Return the number of devices from the CustomAccel service.
     *
     * @return the number of devices.
     * @throw IpmiException on failure.
     */
    virtual uint32_t accelOobDeviceCount() const = 0;

    /**
     * Return the name of a single device from the CustomAccel service.
     *
     * Valid indexes start at 0 and go up to (but don't include) the number of
     * devices. The number of devices can be queried with accelOobDeviceCount.
     *
     * @param[in] index - the index of the device, starting at 0.
     * @return the name of the device.
     * @throw IpmiException on failure.
     */
    virtual std::string accelOobDeviceName(size_t index) const = 0;

    /**
     * Read from a single CustomAccel service device.
     *
     * Valid device names can be queried with accelOobDeviceName.
     * If num_bytes < 8, all unused MSBs are padded with 0s.
     *
     * @param[in] name - the name of the device (from DeviceName).
     * @param[in] address - the address to read from.
     * @param[in] num_bytes - the size of the read, in bytes.
     * @return the data read, with 0s padding any unused MSBs.
     * @throw IpmiException on failure.
     */
    virtual uint64_t accelOobRead(std::string_view name, uint64_t address,
                                  uint8_t num_bytes) const = 0;

    /**
     * Write to a single CustomAccel service device.
     *
     * Valid device names can be queried with accelOobDeviceName.
     * If num_bytes < 8, all unused MSBs are ignored.
     *
     * @param[in] name - the name of the device (from DeviceName).
     * @param[in] address - the address to read from.
     * @param[in] num_bytes - the size of the read, in bytes.
     * @param[in] data - the data to write.
     * @throw IpmiException on failure.
     */
    virtual void accelOobWrite(std::string_view name, uint64_t address,
                               uint8_t num_bytes, uint64_t data) const = 0;
};

} // namespace ipmi
} // namespace google
