X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=extension%2Fopenflowplugin-extension-nicira%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fextension%2Fvendor%2Fnicira%2Fconvertor%2Faction%2FRegLoad2Convertor.java;h=cf1dd2485b3d71765e02942407d4e35c00e04d77;hb=refs%2Fchanges%2F45%2F101745%2F10;hp=ab9997f6cae549e332b847367d290584648cb1c3;hpb=c9fb5748beda27ab17867f687c252c149928edfc;p=openflowplugin.git diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2Convertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2Convertor.java index ab9997f6ca..cf1dd2485b 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2Convertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2Convertor.java @@ -26,12 +26,12 @@ import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.N import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.Nshc4Convertor; import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NsiConvertor; import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NspConvertor; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.experimenter.id.match.entry.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad2; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad2Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.aug.nx.action.ActionRegLoad2; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.aug.nx.action.ActionRegLoad2Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshFlags; @@ -43,16 +43,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsi; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.NxExpMatchEntryValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NshFlagsCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NshTtlCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NshcCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NsiCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NspCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.flags.grouping.NshFlagsValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.ttl.grouping.NshTtlValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValues; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionRegLoadGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshFlagsCase; @@ -90,8 +90,8 @@ public class RegLoad2Convertor implements ConvertorActionFromOFJava { @Override - public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(Action input, - ActionPath path) { + public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert( + final Action input, final ActionPath path) { NxActionRegLoad2 actionRegLoad2 = ((ActionRegLoad2) input.getActionChoice()).getNxActionRegLoad2(); MatchEntry matchEntry = actionRegLoad2.getMatchEntry().get(0); NxRegLoad nxRegLoad = resolveRegLoad(matchEntry); @@ -100,7 +100,7 @@ public class RegLoad2Convertor implements @Override public Action convert( - org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase) { Preconditions.checkArgument(actionCase instanceof NxActionRegLoadGrouping); NxActionRegLoadGrouping nxAction = (NxActionRegLoadGrouping) actionCase; @@ -112,7 +112,7 @@ public class RegLoad2Convertor implements return ActionUtil.createAction(actionRegLoad2); } - private static MatchEntry resolveMatchEntry(NxRegLoad nxRegLoad) { + private static MatchEntry resolveMatchEntry(final NxRegLoad nxRegLoad) { Dst dst = nxRegLoad.getDst(); Uint64 value = nxRegLoad.getValue(); Uint16 start = dst.getStart(); @@ -124,7 +124,7 @@ public class RegLoad2Convertor implements return resolveMatchEntry(dstChoice, value, mask); } - private static MatchEntry resolveMatchEntry(DstChoice dstChoice, Uint64 value, Uint64 mask) { + private static MatchEntry resolveMatchEntry(final DstChoice dstChoice, final Uint64 value, final Uint64 mask) { try { if (dstChoice instanceof DstNxNshFlagsCase) { return NshFlagsConvertor.buildMatchEntry(Uint8.valueOf(value), Uint8.valueOf(mask)); @@ -157,8 +157,8 @@ public class RegLoad2Convertor implements throw new CodecPreconditionException("Missing implementation of a case in dst-choice? " + dstChoice.getClass()); } - private static NxRegLoad resolveRegLoad(MatchEntry matchEntry) { - Class oxmMatchField = matchEntry.getOxmMatchField(); + private static NxRegLoad resolveRegLoad(final MatchEntry matchEntry) { + MatchField oxmMatchField = matchEntry.getOxmMatchField(); ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue(); OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class); NxExpMatchEntryValue nxExpMatchEntryValue = ofjAugNxExpMatch.getNxExpMatchEntryValue(); @@ -167,55 +167,48 @@ public class RegLoad2Convertor implements } private static NxRegLoad resolveRegLoad( - Class oxmMatchField, - NxExpMatchEntryValue value, - DstBuilder dstBuilder) { + final MatchField oxmMatchField, + final NxExpMatchEntryValue value, + final DstBuilder dstBuilder) { - if (NxmNxNshFlags.class.equals(oxmMatchField)) { + if (NxmNxNshFlags.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSH_FLAGS_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshFlagsCaseBuilder().setNxNshFlags(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshFlagsCaseBuilder().setNxNshFlags(Empty.value()).build()); NshFlagsValues nshFlagsValues = ((NshFlagsCaseValue) value).getNshFlagsValues(); return resolveRegLoad(nshFlagsValues.getNshFlags(), nshFlagsValues.getMask(), valueLength, dstBuilder); - } - if (NxmNxNsp.class.equals(oxmMatchField)) { + } else if (NxmNxNsp.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSP_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNspCaseBuilder().setNxNspDst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNspCaseBuilder().setNxNspDst(Empty.value()).build()); NspValues nspValues = ((NspCaseValue) value).getNspValues(); return resolveRegLoad(nspValues.getNsp(), nspValues.getMask(), valueLength, dstBuilder); - } - if (NxmNxNsi.class.equals(oxmMatchField)) { + } else if (NxmNxNsi.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSI_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNsiCaseBuilder().setNxNsiDst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNsiCaseBuilder().setNxNsiDst(Empty.value()).build()); NsiValues nsiValues = ((NsiCaseValue) value).getNsiValues(); return resolveRegLoad(nsiValues.getNsi(), nsiValues.getMask(), valueLength, dstBuilder); - } - if (NxmNxNshc1.class.equals(oxmMatchField)) { + } else if (NxmNxNshc1.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSC1_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshc1CaseBuilder().setNxNshc1Dst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshc1CaseBuilder().setNxNshc1Dst(Empty.value()).build()); NshcCaseValue nshcCaseValue = (NshcCaseValue) value; return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder); - } - if (NxmNxNshc2.class.equals(oxmMatchField)) { + } else if (NxmNxNshc2.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSC2_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshc2CaseBuilder().setNxNshc2Dst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshc2CaseBuilder().setNxNshc2Dst(Empty.value()).build()); NshcCaseValue nshcCaseValue = (NshcCaseValue) value; return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder); - } - if (NxmNxNshc3.class.equals(oxmMatchField)) { + } else if (NxmNxNshc3.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSC3_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshc3CaseBuilder().setNxNshc3Dst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshc3CaseBuilder().setNxNshc3Dst(Empty.value()).build()); NshcCaseValue nshcCaseValue = (NshcCaseValue) value; return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder); - } - if (NxmNxNshc4.class.equals(oxmMatchField)) { + } else if (NxmNxNshc4.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSC4_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshc4CaseBuilder().setNxNshc4Dst(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshc4CaseBuilder().setNxNshc4Dst(Empty.value()).build()); NshcCaseValue nshcCaseValue = (NshcCaseValue) value; return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder); - } - if (NxmNxNshTtl.class.equals(oxmMatchField)) { + } else if (NxmNxNshTtl.VALUE.equals(oxmMatchField)) { int valueLength = NiciraMatchCodecs.NSH_TTL_CODEC.getValueLength(); - dstBuilder.setDstChoice(new DstNxNshTtlCaseBuilder().setNxNshTtl(Empty.getInstance()).build()); + dstBuilder.setDstChoice(new DstNxNshTtlCaseBuilder().setNxNshTtl(Empty.value()).build()); NshTtlValues nshTtlValues = ((NshTtlCaseValue) value).getNshTtlValues(); return resolveRegLoad(nshTtlValues.getNshTtl(), nshTtlValues.getMask(), valueLength, dstBuilder); } @@ -223,29 +216,20 @@ public class RegLoad2Convertor implements throw new CodecPreconditionException("Missing codec for " + value.implementedInterface()); } - private static NxRegLoad resolveRegLoad(Uint8 value, @Nullable Uint8 mask, int valueLength, DstBuilder dstBuilder) { - return resolveRegLoad( - Uint64.valueOf(value), - mask == null ? null : Uint64.valueOf(mask), - valueLength, - dstBuilder); + private static NxRegLoad resolveRegLoad(final Uint8 value, final @Nullable Uint8 mask, final int valueLength, + final DstBuilder dstBuilder) { + return resolveRegLoad(value.toUint64(), mask == null ? null : mask.toUint64(), valueLength, dstBuilder); } - private static NxRegLoad resolveRegLoad(Uint32 value, @Nullable Uint32 mask, int valueLength, - DstBuilder dstBuilder) { - return resolveRegLoad( - Uint64.valueOf(value), - mask == null ? null : Uint64.valueOf(mask), - valueLength, - dstBuilder); + private static NxRegLoad resolveRegLoad(final Uint32 value, final @Nullable Uint32 mask, final int valueLength, + final DstBuilder dstBuilder) { + return resolveRegLoad(value.toUint64(), mask == null ? null : mask.toUint64(), valueLength, dstBuilder); } // Convert the value/mask pair of the openflowjava reg_load2 action to the // value/bit range pair of the openfloplugin reg_load action. - private static NxRegLoad resolveRegLoad(Uint64 value, - @Nullable Uint64 mask, - int length, - DstBuilder dstBuilder) { + private static NxRegLoad resolveRegLoad(Uint64 value, final @Nullable Uint64 mask, final int length, + final DstBuilder dstBuilder) { final int start; final int end; if (mask == null) { @@ -268,12 +252,10 @@ public class RegLoad2Convertor implements value = Uint64.fromLongBits(newValueBits); } - dstBuilder.setStart(start); - dstBuilder.setEnd(end - 1); - NxRegLoadBuilder nxRegLoadBuilder = new NxRegLoadBuilder(); - nxRegLoadBuilder.setDst(dstBuilder.build()); - nxRegLoadBuilder.setValue(value); - return nxRegLoadBuilder.build(); + return new NxRegLoadBuilder() + .setDst(dstBuilder.setStart(Uint16.valueOf(start)).setEnd(Uint16.valueOf(end - 1)).build()) + .setValue(value) + .build(); } private static int lowestSetBit(final long value) { @@ -286,7 +268,7 @@ public class RegLoad2Convertor implements // Convert value/bit range pair of the openfloplugin reg_load action to the // value/mask pair of the openflowjava reg_load2 action. - private static Uint64[] resolveValueMask(Uint64 value, Uint16 start, Uint16 end) { + private static Uint64[] resolveValueMask(final Uint64 value, final Uint16 start, final Uint16 end) { final int startInt = start.toJava(); final int bits = end.toJava() - startInt + 1; final long valueBits = value.longValue();