blob: ec0bfd119950648bfc00334ef52772a7943d7d9e [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
21 size_t errorCount;
22 int bus;
23
24 private:
25 sdbusplus::asio::object_server& objServer;
26
27 void checkThresholds(void) override;
28};
29
30struct NVMeContext : std::enable_shared_from_this<NVMeContext>
31{
32 NVMeContext(boost::asio::io_service& io, int rootBus);
33
34 virtual ~NVMeContext();
35
36 void pollNVMeDevices();
37
38 boost::asio::deadline_timer scanTimer;
39 int rootBus; // Root bus for this drive
40 boost::asio::deadline_timer mctpResponseTimer;
41 boost::asio::ip::tcp::socket nvmeSlaveSocket;
42 std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue
43};
44
45using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>;
46
47int verifyIntegrity(uint8_t* msg, size_t len);
48
49namespace nvmeMCTP
50{
51void init(void);
52}
53
54NVMEMap& getNVMEMap(void);