Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions src/link_manager/LinkManagerStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ void LinkManagerStateMachine::handleStateChange(MuxStateEvent &event, mux_state:
if (ms(mCompositeState) != mux_state::MuxState::Wait) {
// Verify if state db MUX state matches the driver/current MUX state
mMuxPortPtr->getMuxState();

// Handle pening mux mode config change
if (mPendingMuxModeChange) {
handleMuxConfigNotification(mTargetMuxMode);
mPendingMuxModeChange = false;
}
}

if (ms(mCompositeState) != mux_state::MuxState::Unknown) {
Expand Down Expand Up @@ -706,28 +712,41 @@ void LinkManagerStateMachine::handleSwssLinkStateNotification(const link_state::
//
void LinkManagerStateMachine::handleMuxConfigNotification(const common::MuxPortConfig::Mode mode)
{
if (mComponentInitState.all()) {
if (mode == common::MuxPortConfig::Mode::Active &&
ms(mCompositeState) != mux_state::MuxState::Label::Active &&
ms(mCompositeState) != mux_state::MuxState::Label::Wait) {
CompositeState nextState = mCompositeState;
enterLinkProberState(nextState, link_prober::LinkProberState::Wait);
switchMuxState(nextState, mux_state::MuxState::Label::Active);
LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState);
mCompositeState = nextState;
} else if(mode == common::MuxPortConfig::Mode::Standby &&
ms(mCompositeState) != mux_state::MuxState::Label::Standby &&
ms(mCompositeState) != mux_state::MuxState::Label::Wait) {
mSendPeerSwitchCommandFnPtr();
} else {
mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::DriverUpdate);
mMuxPortPtr->probeMuxState();
if (mComponentInitState.test(MuxStateComponent) &&
mode != common::MuxPortConfig::Mode::Auto &&
mode != common::MuxPortConfig::Mode::Manual &&
ms(mCompositeState) == mux_state::MuxState::Wait) {

MUXLOGWARNING(boost::format("%s: Mux mode: %s , mux mode config change is pending. ") %
mMuxPortConfig.getPortName() %
mMuxStateName[ms(mCompositeState)]
);

mPendingMuxModeChange = true;
mTargetMuxMode = mode;
} else {
if (mComponentInitState.all()) {
if (mode == common::MuxPortConfig::Mode::Active &&
ms(mCompositeState) != mux_state::MuxState::Label::Active) {
CompositeState nextState = mCompositeState;
enterLinkProberState(nextState, link_prober::LinkProberState::Wait);
switchMuxState(nextState, mux_state::MuxState::Label::Active);
LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState);
mCompositeState = nextState;
} else if(mode == common::MuxPortConfig::Mode::Standby &&
ms(mCompositeState) != mux_state::MuxState::Label::Standby) {
mSendPeerSwitchCommandFnPtr();
} else {
mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::DriverUpdate);
mMuxPortPtr->probeMuxState();
}

updateMuxLinkmgrState();
}

updateMuxLinkmgrState();
}
mMuxPortConfig.setMode(mode);

mMuxPortConfig.setMode(mode);
}
}

//
Expand Down
3 changes: 3 additions & 0 deletions src/link_manager/LinkManagerStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ class LinkManagerStateMachine: public common::StateMachine,
uint32_t mWaitActiveUpCount = 0;
uint32_t mMuxUnknownBackoffFactor = 1;

bool mPendingMuxModeChange = false;
common::MuxPortConfig::Mode mTargetMuxMode = common::MuxPortConfig::Mode::Auto;

std::bitset<ComponentCount> mComponentInitState = {0};
Label mLabel = Label::Uninitialized;
};
Expand Down