Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "NVMeSensor.hpp" |
| 4 | |
| 5 | #include <boost/asio/deadline_timer.hpp> |
| 6 | #include <boost/asio/io_service.hpp> |
| 7 | #include <boost/asio/ip/tcp.hpp> |
| 8 | |
| 9 | #include <memory> |
| 10 | |
Andrew Jeffery | fa500ae | 2021-05-21 16:46:36 +0930 | [diff] [blame^] | 11 | class NVMeContext : public std::enable_shared_from_this<NVMeContext> |
Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 12 | { |
Andrew Jeffery | fa500ae | 2021-05-21 16:46:36 +0930 | [diff] [blame^] | 13 | public: |
Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 14 | NVMeContext(boost::asio::io_service& io, int rootBus); |
| 15 | |
| 16 | virtual ~NVMeContext(); |
| 17 | |
Andrew Jeffery | fa500ae | 2021-05-21 16:46:36 +0930 | [diff] [blame^] | 18 | void addSensor(std::shared_ptr<NVMeSensor> sensor); |
| 19 | virtual void pollNVMeDevices(); |
| 20 | virtual void close(); |
| 21 | virtual void readAndProcessNVMeSensor(); |
| 22 | virtual void processResponse(void* msg, size_t len); |
Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 23 | |
Andrew Jeffery | fa500ae | 2021-05-21 16:46:36 +0930 | [diff] [blame^] | 24 | private: |
Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 25 | boost::asio::deadline_timer scanTimer; |
| 26 | int rootBus; // Root bus for this drive |
| 27 | boost::asio::deadline_timer mctpResponseTimer; |
| 28 | boost::asio::ip::tcp::socket nvmeSlaveSocket; |
| 29 | std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue |
Andrew Jeffery | fa500ae | 2021-05-21 16:46:36 +0930 | [diff] [blame^] | 30 | |
| 31 | void readResponse(); |
Andrew Jeffery | dae6e18 | 2021-05-21 16:23:07 +0930 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>; |
| 35 | |
| 36 | namespace nvmeMCTP |
| 37 | { |
| 38 | void init(void); |
| 39 | } |
| 40 | |
| 41 | NVMEMap& getNVMEMap(void); |