@@ -132,6 +132,23 @@ void DbInterface::probeMuxState(const std::string &portName)
132
132
)));
133
133
}
134
134
135
+ //
136
+ // ---> probeForwardingState(const std::string &portName)
137
+ //
138
+ // trigger tranceiver daemon to read Fowarding state using gRPC
139
+ //
140
+ void DbInterface::probeForwardingState (const std::string &portName)
141
+ {
142
+ MUXLOGDEBUG (portName);
143
+
144
+ boost::asio::io_service &ioService = mStrand .context ();
145
+ ioService.post (mStrand .wrap (boost::bind (
146
+ &DbInterface::handleProbeForwardingState,
147
+ this ,
148
+ portName
149
+ )));
150
+ }
151
+
135
152
//
136
153
// ---> setMuxLinkmgrState(const std::string &portName, link_manager::ActiveStandbyStateMachine::Label label);
137
154
//
@@ -251,11 +268,14 @@ void DbInterface::initialize()
251
268
mAppDbMuxTablePtr = std::make_shared<swss::ProducerStateTable> (
252
269
mAppDbPtr .get (), APP_MUX_CABLE_TABLE_NAME
253
270
);
271
+ mAppDbPeerMuxTablePtr = std::make_shared<swss::ProducerStateTable> (
272
+ mAppDbPtr .get (), APP_PEER_HW_FORWARDING_STATE_TABLE_NAME
273
+ );
254
274
mAppDbMuxCommandTablePtr = std::make_shared<swss::Table> (
255
275
mAppDbPtr .get (), APP_MUX_CABLE_COMMAND_TABLE_NAME
256
276
);
257
- mAppDbPeerMuxCommandTablePtr = std::make_shared<swss::Table> (
258
- mAppDbPtr .get (), PEER_FORWARDING_STATE_COMMAND_TABLE
277
+ mAppDbForwardingCommandTablePtr = std::make_shared<swss::Table> (
278
+ mAppDbPtr .get (), APP_FORWARDING_STATE_COMMAND_TABLE_NAME
259
279
);
260
280
mStateDbMuxLinkmgrTablePtr = std::make_shared<swss::Table> (
261
281
mStateDbPtr .get (), STATE_MUX_LINKMGR_TABLE_NAME
@@ -352,7 +372,7 @@ void DbInterface::handleSetPeerMuxState(const std::string portName, mux_state::M
352
372
std::vector<swss::FieldValueTuple> values = {
353
373
{" state" , mMuxState [label]},
354
374
};
355
- mAppDbPeerMuxCommandTablePtr ->set (portName, values);
375
+ mAppDbPeerMuxTablePtr ->set (portName, values);
356
376
}
357
377
}
358
378
@@ -368,6 +388,18 @@ void DbInterface::handleProbeMuxState(const std::string portName)
368
388
mAppDbMuxCommandTablePtr ->hset (portName, " command" , " probe" );
369
389
}
370
390
391
+ //
392
+ // ---> handleProbeForwardingState(const std::string portName)
393
+ //
394
+ // trigger xcvrd to read forwarding state using gRPC
395
+ //
396
+ void DbInterface::handleProbeForwardingState (const std::string portName)
397
+ {
398
+ MUXLOGDEBUG (portName);
399
+
400
+ mAppDbForwardingCommandTablePtr ->hset (portName, " command" , " probe" );
401
+ }
402
+
371
403
//
372
404
// ---> handleSetMuxLinkmgrState(const std::string portName, link_manager::ActiveStandbyStateMachine::Label label);
373
405
//
@@ -988,6 +1020,56 @@ void DbInterface::processMuxResponseNotifiction(std::deque<swss::KeyOpFieldsValu
988
1020
}
989
1021
}
990
1022
1023
+ //
1024
+ // ---> processForwardingResponseNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries);
1025
+ //
1026
+ // process forwarding response (from xcvrd probing) notification
1027
+ //
1028
+ void DbInterface::processForwardingResponseNotification (std::deque<swss::KeyOpFieldsValuesTuple> &entries)
1029
+ {
1030
+ for (auto &entry: entries) {
1031
+ std::string port = kfvKey (entry);
1032
+ std::string oprtation = kfvOp (entry);
1033
+ std::vector<swss::FieldValueTuple> fieldValues = kfvFieldsValues (entry);
1034
+
1035
+ std::vector<swss::FieldValueTuple>::const_iterator cit_self = std::find_if (
1036
+ fieldValues.cbegin (),
1037
+ fieldValues.cend (),
1038
+ [] (const swss::FieldValueTuple &fv) {return fvField (fv) == " response" ;}
1039
+ );
1040
+ if (cit_self != fieldValues.cend ()) {
1041
+ const std::string f = cit_self->first ;
1042
+ const std::string v = cit_self->second ;
1043
+
1044
+ MUXLOGDEBUG (boost::format (" port: %s, operation: %s, f: %s, v: %s" ) %
1045
+ port %
1046
+ oprtation %
1047
+ f %
1048
+ v
1049
+ );
1050
+ mMuxManagerPtr ->processProbeMuxState (port, v);
1051
+ }
1052
+
1053
+ std::vector<swss::FieldValueTuple>::const_iterator cit_peer = std::find_if (
1054
+ fieldValues.cbegin (),
1055
+ fieldValues.cend (),
1056
+ [] (const swss::FieldValueTuple &fv) {return fvField (fv) == " response_peer" ;}
1057
+ );
1058
+ if (cit_peer != fieldValues.cend ()) {
1059
+ const std::string f = cit_peer->first ;
1060
+ const std::string v = cit_peer->second ;
1061
+
1062
+ MUXLOGDEBUG (boost::format (" port: %s, operation: %s, f: %s, v: %s" ) %
1063
+ port %
1064
+ oprtation %
1065
+ f %
1066
+ v
1067
+ );
1068
+ mMuxManagerPtr ->processPeerMuxState (port, v);
1069
+ }
1070
+ }
1071
+ }
1072
+
991
1073
//
992
1074
// ---> handleMuxResponseNotifiction(swss::SubscriberStateTable &appdbPortTable);
993
1075
//
@@ -1001,12 +1083,26 @@ void DbInterface::handleMuxResponseNotifiction(swss::SubscriberStateTable &appdb
1001
1083
processMuxResponseNotifiction (entries);
1002
1084
}
1003
1085
1086
+ //
1087
+ // ---> handleForwardingResponseNotification(swss::SubscriberStateTable &appdbForwardingResponseTable)
1088
+ //
1089
+ // handle fowarding response (from xcvrd) notification
1090
+ //
1091
+ void DbInterface::handleForwardingResponseNotification (swss::SubscriberStateTable &appdbForwardingResponseTable)
1092
+ {
1093
+ std::deque<swss::KeyOpFieldsValuesTuple> entries;
1094
+
1095
+ appdbForwardingResponseTable.pops (entries);
1096
+ processForwardingResponseNotification (entries);
1097
+ }
1098
+
1099
+
1004
1100
//
1005
1101
// ---> processPeerMuxResponseNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries);
1006
1102
//
1007
- // process peer MUX response (from xcvrd) notification
1103
+ // process peer MUX state (from xcvrd) notification
1008
1104
//
1009
- void DbInterface::processPeerMuxResponseNotification (std::deque<swss::KeyOpFieldsValuesTuple> &entries)
1105
+ void DbInterface::processPeerMuxNotification (std::deque<swss::KeyOpFieldsValuesTuple> &entries)
1010
1106
{
1011
1107
for (auto &entry: entries) {
1012
1108
std::string port = kfvKey (entry);
@@ -1034,16 +1130,16 @@ void DbInterface::processPeerMuxResponseNotification(std::deque<swss::KeyOpField
1034
1130
}
1035
1131
1036
1132
//
1037
- // ---> handlePeerMuxResponseNotification (swss::SubscriberStateTable &stateDbPeerMuxResponseTable );
1133
+ // ---> handlePeerMuxStateNotification (swss::SubscriberStateTable &stateDbPeerMuxTable );
1038
1134
//
1039
- // handles peer MUX response (from xcvrd) notification
1135
+ // handles peer MUX notification (from xcvrd)
1040
1136
//
1041
- void DbInterface::handlePeerMuxResponseNotification (swss::SubscriberStateTable &stateDbPeerMuxResponseTable )
1137
+ void DbInterface::handlePeerMuxStateNotification (swss::SubscriberStateTable &stateDbPeerMuxTable )
1042
1138
{
1043
1139
std::deque<swss::KeyOpFieldsValuesTuple> entries;
1044
1140
1045
- stateDbPeerMuxResponseTable .pops (entries);
1046
- processPeerMuxResponseNotification (entries);
1141
+ stateDbPeerMuxTable .pops (entries);
1142
+ processPeerMuxNotification (entries);
1047
1143
}
1048
1144
1049
1145
//
@@ -1164,14 +1260,16 @@ void DbInterface::handleSwssNotification()
1164
1260
swss::SubscriberStateTable appDbPortTable (appDbPtr.get (), APP_PORT_TABLE_NAME);
1165
1261
// for command responses from the driver
1166
1262
swss::SubscriberStateTable appDbMuxResponseTable (appDbPtr.get (), APP_MUX_CABLE_RESPONSE_TABLE_NAME);
1263
+ // for command response of forwarding state probing from driver
1264
+ swss::SubscriberStateTable appDbForwardingResponseTable (appDbPtr.get (), APP_FORWARDING_STATE_RESPONSE_TABLE_NAME);
1167
1265
// for getting state db MUX state when orchagent updates it
1168
1266
swss::SubscriberStateTable stateDbPortTable (stateDbPtr.get (), STATE_MUX_CABLE_TABLE_NAME);
1169
1267
// for getting state db default route state
1170
1268
swss::SubscriberStateTable stateDbRouteTable (stateDbPtr.get (), STATE_ROUTE_TABLE_NAME);
1171
1269
// for getting peer's link status
1172
1270
swss::SubscriberStateTable stateDbMuxInfoTable (stateDbPtr.get (), MUX_CABLE_INFO_TABLE);
1173
1271
// for getting peer's admin forwarding state
1174
- swss::SubscriberStateTable stateDbPeerMuxResponseTable (stateDbPtr.get (), PEER_FORWARDING_STATE_RESPONSE_TABLE );
1272
+ swss::SubscriberStateTable stateDbPeerMuxTable (stateDbPtr.get (), STATE_PEER_HW_FORWARDING_STATE_TABLE_NAME );
1175
1273
1176
1274
getTorMacAddress (configDbPtr);
1177
1275
getLoopback2InterfaceInfo (configDbPtr);
@@ -1192,10 +1290,11 @@ void DbInterface::handleSwssNotification()
1192
1290
swssSelect.addSelectable (&configDbMuxTable);
1193
1291
swssSelect.addSelectable (&appDbPortTable);
1194
1292
swssSelect.addSelectable (&appDbMuxResponseTable);
1293
+ swssSelect.addSelectable (&appDbForwardingResponseTable);
1195
1294
swssSelect.addSelectable (&stateDbPortTable);
1196
1295
swssSelect.addSelectable (&stateDbRouteTable);
1197
1296
swssSelect.addSelectable (&stateDbMuxInfoTable);
1198
- swssSelect.addSelectable (&stateDbPeerMuxResponseTable );
1297
+ swssSelect.addSelectable (&stateDbPeerMuxTable );
1199
1298
swssSelect.addSelectable (&netlinkNeighbor);
1200
1299
1201
1300
while (mPollSwssNotifcation ) {
@@ -1220,14 +1319,16 @@ void DbInterface::handleSwssNotification()
1220
1319
handleLinkStateNotifiction (appDbPortTable);
1221
1320
} else if (selectable == static_cast <swss::Selectable *> (&appDbMuxResponseTable)) {
1222
1321
handleMuxResponseNotifiction (appDbMuxResponseTable);
1322
+ } else if (selectable == static_cast <swss::Selectable *> (&appDbForwardingResponseTable)) {
1323
+ handleForwardingResponseNotification (appDbForwardingResponseTable);
1223
1324
} else if (selectable == static_cast <swss::Selectable *> (&stateDbPortTable)) {
1224
1325
handleMuxStateNotifiction (stateDbPortTable);
1225
1326
} else if (selectable == static_cast <swss::Selectable *> (&stateDbRouteTable)) {
1226
1327
handleDefaultRouteStateNotification (stateDbRouteTable);
1227
1328
} else if (selectable == static_cast <swss::Selectable *> (&stateDbMuxInfoTable)) {
1228
1329
handlePeerLinkStateNotification (stateDbMuxInfoTable);
1229
- } else if (selectable == static_cast <swss::Selectable *> (&stateDbPeerMuxResponseTable )) {
1230
- handlePeerMuxResponseNotification (stateDbPeerMuxResponseTable );
1330
+ } else if (selectable == static_cast <swss::Selectable *> (&stateDbPeerMuxTable )) {
1331
+ handlePeerMuxStateNotification (stateDbPeerMuxTable );
1231
1332
} else if (selectable == static_cast <swss::Selectable *> (&netlinkNeighbor)) {
1232
1333
continue ;
1233
1334
} else {
0 commit comments