NVMeContext: Split out NVMeMCTPContext
The MCTP-oriented implementation of NVMeContext requires linking against
a libmctp build that provides an SMBus binding implementation. The SMBus
binding implementation isn't upstream, and neither are the kernel
interfaces it relies on.
Later, an NVMe MI Basic implementation will be introduced. NVMe MI Basic
only requires support for SMBus block reads rather than MCTP, though is
not as fully featured as the MCTP interface and is not required to be
supported by implementers of the NVMe specification.
For now, reduce NVMeContext to a base class that NVMeMCTPContext
extends and only use the NVMeMCTPContext type where explicitly
required. This opens up the opportunity to make MCTP support a
build-time configurable option.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I6920f79ca389481f3be43ee9a0d336bf8f72d55b
diff --git a/include/NVMeContext.hpp b/include/NVMeContext.hpp
index 7f24e17..f7216f1 100644
--- a/include/NVMeContext.hpp
+++ b/include/NVMeContext.hpp
@@ -4,38 +4,49 @@
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
-#include <boost/asio/ip/tcp.hpp>
#include <memory>
class NVMeContext : public std::enable_shared_from_this<NVMeContext>
{
public:
- NVMeContext(boost::asio::io_service& io, int rootBus);
+ NVMeContext(boost::asio::io_service& io, int rootBus) :
+ scanTimer(io), rootBus(rootBus)
+ {}
- virtual ~NVMeContext();
+ virtual ~NVMeContext()
+ {
+ close();
+ }
- void addSensor(std::shared_ptr<NVMeSensor> sensor);
- virtual void pollNVMeDevices();
- virtual void close();
- virtual void readAndProcessNVMeSensor();
- virtual void processResponse(void* msg, size_t len);
+ void addSensor(std::shared_ptr<NVMeSensor> sensor)
+ {
+ sensors.emplace_back(sensor);
+ }
- private:
+ virtual void pollNVMeDevices()
+ {}
+
+ virtual void close()
+ {
+ scanTimer.cancel();
+ }
+
+ virtual void readAndProcessNVMeSensor()
+ {}
+
+ virtual void processResponse(void* msg, size_t len)
+ {
+ (void)msg;
+ (void)len;
+ }
+
+ protected:
boost::asio::deadline_timer scanTimer;
- int rootBus; // Root bus for this drive
- boost::asio::deadline_timer mctpResponseTimer;
- boost::asio::ip::tcp::socket nvmeSlaveSocket;
+ int rootBus; // Root bus for this drive
std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue
-
- void readResponse();
};
using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>;
-namespace nvmeMCTP
-{
-void init(void);
-}
-
NVMEMap& getNVMEMap(void);