netkvm: add "binding" state machine to the miniport
This is regular state machine with a pointer inside.
The pointer is set with "Start" and cleared with "Stop".
Callers can reference/dereference the pointer with
Register/Unregister interface of state machine; the
registering prevents the pointer from being cleared
until dereferenced.
@@ -174,6 +174,39 @@ private:
DECLARE_CNDISLIST_ENTRY(CConfigFlowStateMachine);
};
+class CFlowStateMachineWithPointer : public CFlowStateMachine
+{
+public:
+ CFlowStateMachineWithPointer() : m_Value(NULL) { }
+ void Clear()
+ {
+ Stop();
+ m_Value = NULL;
+ }
+ void Set(PVOID Value)
+ {
+ m_Value = Value;
+ Start();
+ }
+ PVOID Reference()
+ {
+ if (!RegisterOutstandingItem())
+ return NULL;
+ if (!m_Value)
+ {
+ UnregisterOutstandingItem();
+ return NULL;
+ }
+ return m_Value;
+ }
+ void Dereference()
+ {
+ UnregisterOutstandingItem();
+ }
+private:
+ PVOID m_Value;
+};
+
class CMiniportStateMachine : public CPlacementAllocatable, public CObservee<SMNotifications>
{
public:
@@ -270,7 +303,28 @@ public:
void NotifyHalted()
{
- StopConfigFlows(NDIS_STATUS_PAUSED); }
+ StopConfigFlows(NDIS_STATUS_PAUSED);
+ }
+
+ void NotifyBindSriov(PVOID Value)
+ {
+ m_BindingToSriov.Set(Value);
+ }
+
+ void NotifyUnbindSriov()
+ {
+ m_BindingToSriov.Clear();
+ }
+
+ PVOID ReferenceSriovBinding()
+ {
+ return m_BindingToSriov.Reference();
+ }
+
+ void DereferenceSriovBinding()
+ {
+ m_BindingToSriov.Dereference();
+ }
CMiniportStateMachine() = default;
~CMiniportStateMachine() = default;
@@ -349,4 +403,5 @@ private:
MiniportState m_State = MiniportState::Halted;
CNdisList<CDataFlowStateMachine, CRawAccess, CNonCountingObject> m_DataFlows;
CNdisList<CConfigFlowStateMachine, CRawAccess, CNonCountingObject> m_ConfigFlows;
+ CFlowStateMachineWithPointer m_BindingToSriov;
};
