blob: 5d2927ab668efd42b28bbd6978c6f0c0d940b22e [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();
James Feist375ade22020-07-16 16:32:10 -070036 void close();
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070037
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);