import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.mdsalutil.AbstractDataChangeListener;
import org.opendaylight.genius.mdsalutil.ActionInfo;
-import org.opendaylight.genius.mdsalutil.ActionType;
import org.opendaylight.genius.mdsalutil.FlowEntity;
import org.opendaylight.genius.mdsalutil.InstructionInfo;
import org.opendaylight.genius.mdsalutil.InstructionType;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.NxMatchFieldType;
import org.opendaylight.genius.mdsalutil.NxMatchInfo;
+import org.opendaylight.genius.mdsalutil.actions.ActionLearn;
+import org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit;
+import org.opendaylight.genius.mdsalutil.actions.ActionPuntToController;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
public class ElanNodeListener extends AbstractDataChangeListener<Node> implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ElanNodeListener.class);
- private static final String LEARN_MATCH_REG4_VALUE = "1";
+ private static final int LEARN_MATCH_REG4_VALUE = 1;
private final DataBroker broker;
private final IMdsalApiManager mdsalManager;
private void setupTableMissSmacFlow(BigInteger dpId) {
List<ActionInfo> actionsInfos = new ArrayList<>();
- actionsInfos.add(new ActionInfo(ActionType.punt_to_controller, new String[] {}));
-
- String[][] learnActionMatches = new String[2][];
- learnActionMatches[0] = new String[] { NwConstants.LearnFlowModsType.MATCH_FROM_FIELD.name(),
- NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getHexType(),
- NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getHexType(),
- NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getFlowModHeaderLen() };
- learnActionMatches[1] = new String[] {
- NwConstants.LearnFlowModsType.COPY_FROM_VALUE.name(), LEARN_MATCH_REG4_VALUE,
- NwConstants.NxmOfFieldType.NXM_NX_REG4.getHexType(), "8" };
-
- String[] header = new String[] {
- String.valueOf(0),
- String.valueOf(tempSmacLearnTimeout),
- BigInteger.ZERO.toString(),
- ElanConstants.COOKIE_ELAN_LEARNED_SMAC.toString(),
- "0",
- Short.toString(NwConstants.ELAN_SMAC_LEARNED_TABLE),
- String.valueOf(0),
- String.valueOf(0)
- };
- actionsInfos.add(new ActionInfo(ActionType.learn, header, learnActionMatches));
+ actionsInfos.add(new ActionPuntToController());
+ actionsInfos.add(new ActionLearn(0, tempSmacLearnTimeout, 0, ElanConstants.COOKIE_ELAN_LEARNED_SMAC, 0,
+ NwConstants.ELAN_SMAC_LEARNED_TABLE, 0, 0, Arrays.asList(
+ new ActionLearn.MatchFromField(NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getType(),
+ NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getType(),
+ NwConstants.NxmOfFieldType.NXM_OF_ETH_SRC.getFlowModHeaderLenInt()),
+ new ActionLearn.CopyFromValue(LEARN_MATCH_REG4_VALUE,
+ NwConstants.NxmOfFieldType.NXM_NX_REG4.getType(), 8))));
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionInfo(InstructionType.apply_actions, actionsInfos));
private void addSmacBaseTableFlow(BigInteger dpId) {
//T48 - resubmit to T49 & T50
List<ActionInfo> actionsInfo = new ArrayList<>();
- actionsInfo.add(new ActionInfo(ActionType.nx_resubmit,
- new String[] {Short.toString(NwConstants.ELAN_SMAC_LEARNED_TABLE) }));
- actionsInfo.add(new ActionInfo(ActionType.nx_resubmit,
- new String[] {Short.toString(NwConstants.ELAN_SMAC_TABLE) }));
+ actionsInfo.add(new ActionNxResubmit(NwConstants.ELAN_SMAC_LEARNED_TABLE));
+ actionsInfo.add(new ActionNxResubmit(NwConstants.ELAN_SMAC_TABLE));
List<InstructionInfo> mkInstruct = new ArrayList<>();
mkInstruct.add(new InstructionInfo(InstructionType.apply_actions, actionsInfo));
List<MatchInfo> mkMatch = new ArrayList<>();
.append(LEARN_MATCH_REG4_VALUE).toString();
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_SMAC_TABLE, flowRef,
10, "ELAN sMac Table Reg4 Flow", 0, 0,
- ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(new BigInteger(LEARN_MATCH_REG4_VALUE)),
+ ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(LEARN_MATCH_REG4_VALUE)),
mkMatches, mkInstructions);
mdsalManager.installFlow(flowEntity);
}