blob: 132ef29b58f6044582c4d05075e61d6a0b8ca516 [file] [log] [blame]
Nikhil Potadeb669b6b2019-03-13 10:52:21 -07001#pragma once
2
3#include <libmctp-smbus.h>
4#include <libmctp.h>
5
6#include <sensor.hpp>
7
8class NVMeSensor : public Sensor
9{
10 public:
11 NVMeSensor(sdbusplus::asio::object_server& objectServer,
12 boost::asio::io_service& io,
13 std::shared_ptr<sdbusplus::asio::connection>& conn,
14 const std::string& sensorName,
15 std::vector<thresholds::Threshold>&& _thresholds,
16 const std::string& sensorConfiguration, const int busNumber);
17 virtual ~NVMeSensor();
18
19 NVMeSensor& operator=(const NVMeSensor& other) = delete;
20
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070021 int bus;
22
23 private:
24 sdbusplus::asio::object_server& objServer;
25
26 void checkThresholds(void) override;
27};
28
29struct NVMeContext : std::enable_shared_from_this<NVMeContext>
30{
31 NVMeContext(boost::asio::io_service& io, int rootBus);
32
33 virtual ~NVMeContext();
34
35 void pollNVMeDevices();
36
37 boost::asio::deadline_timer scanTimer;
38 int rootBus; // Root bus for this drive
39 boost::asio::deadline_timer mctpResponseTimer;
40 boost::asio::ip::tcp::socket nvmeSlaveSocket;
41 std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue
42};
43
44using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>;
45
46int verifyIntegrity(uint8_t* msg, size_t len);
47
48namespace nvmeMCTP
49{
50void init(void);
51}
52
53NVMEMap& getNVMEMap(void);