BUG:6997 supporting OXM_OF_MPLS_LABEL in nicira extensiona 62/47662/8
authorepgoraj <p.govinda.rajulu@ericsson.com>
Thu, 27 Oct 2016 11:22:18 +0000 (16:52 +0530)
committerPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
Tue, 22 Nov 2016 09:49:21 +0000 (15:19 +0530)
        Description : currently under nicira-extension, MPLS support is not
        present in nicira Move action. Mainly in ECMP use-case we need to use
        mpls_label under nicira_move_action type. The mpls_label will be using as
        example ( move:NXM_NX_REG1[0..19]->OXM_OF_MPLS_LABEL[] )

Change-Id: Ia497b963f30bf9ffcd09430db8ed85661a64859f
Signed-off-by: epgoraj <p.govinda.rajulu@ericsson.com>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/MplsLabelCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/yang/nicira-match.yang
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertor.java
extension/openflowplugin-extension-nicira/src/main/yang/openflowplugin-extension-nicira-action.yang

index 0d2de7a41e6b26b39382f64cfd7321a3839a05a1..f182d8f5039ec2ca14c85792412435bdc1ea92cc 100644 (file)
@@ -57,6 +57,7 @@ import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.UdpDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.UdpSrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.InPortCodec;
+import org.opendaylight.openflowjava.nx.codec.match.MplsLabelCodec;
 
 import com.google.common.base.Preconditions;
 
@@ -125,6 +126,8 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.registerMatchEntryDeserializer(ArpTpaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_TPA_CODEC);
         registrator.registerMatchEntrySerializer(InPortCodec.SERIALIZER_KEY, NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC);
         registrator.registerMatchEntryDeserializer(InPortCodec.DESERIALIZER_KEY, NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC);
+        registrator.registerMatchEntrySerializer(MplsLabelCodec.SERIALIZER_KEY, NiciraMatchCodecs.OXM_OF_MPLS_LABEL);
+        registrator.registerMatchEntryDeserializer(MplsLabelCodec.DESERIALIZER_KEY, NiciraMatchCodecs.OXM_OF_MPLS_LABEL);
         registrator.registerMatchEntrySerializer(EthDstCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC);
         registrator.registerMatchEntryDeserializer(EthDstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC);
         registrator.registerMatchEntrySerializer(EthSrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_SRC_CODEC);
@@ -224,6 +227,8 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.unregisterMatchEntryDeserializer(ArpTpaCodec.DESERIALIZER_KEY);
         registrator.unregisterMatchEntrySerializer(InPortCodec.SERIALIZER_KEY);
         registrator.unregisterMatchEntryDeserializer(InPortCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(MplsLabelCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(MplsLabelCodec.DESERIALIZER_KEY);
         registrator.unregisterMatchEntrySerializer(EthDstCodec.SERIALIZER_KEY);
         registrator.unregisterMatchEntryDeserializer(EthDstCodec.DESERIALIZER_KEY);
         registrator.unregisterMatchEntrySerializer(EthSrcCodec.SERIALIZER_KEY);
index 198ecd7d278825c5dbc510243715ef5b612b258b..27cd24f47f1d1d55d319aff0b4a5ee2c8cdd90bc 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.openflowjava.nx.codec.match.IcmpTypeCodec;
 import org.opendaylight.openflowjava.nx.codec.match.IpSrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.IpDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.InPortCodec;
+import org.opendaylight.openflowjava.nx.codec.match.MplsLabelCodec;
 import org.opendaylight.openflowjava.nx.codec.match.Nshc1Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Nshc2Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Nshc3Codec;
@@ -71,6 +72,7 @@ public class NiciraMatchCodecs {
     public static final ArpThaCodec ARP_THA_CODEC = new ArpThaCodec();
     public static final ArpTpaCodec ARP_TPA_CODEC = new ArpTpaCodec();
     public static final InPortCodec NXM_OF_IN_PORT_CODEC = new InPortCodec();
+    public static final MplsLabelCodec OXM_OF_MPLS_LABEL = new MplsLabelCodec();
     public static final EthDstCodec ETH_DST_CODEC = new EthDstCodec();
     public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec();
     public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec();
diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/MplsLabelCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/MplsLabelCodec.java
new file mode 100644 (file)
index 0000000..72f3b9f
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Ericsson, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfMplsLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.oxm.of.mpls.label.grouping.MplsLabelValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValueBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class MplsLabelCodec extends AbstractMatchCodec {
+
+  private static final int VALUE_LENGTH = 4;
+  private static final int NXM_FIELD_CODE = 34;
+
+  public static final MatchEntrySerializerKey<Nxm0Class, NxmOfMplsLabel> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+      EncodeConstants.OF13_VERSION_ID, Nxm0Class.class,
+      NxmOfMplsLabel.class);
+
+  public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+      EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS,
+      NXM_FIELD_CODE);
+
+  @Override
+  public void serialize(MatchEntry input, ByteBuf outBuffer) {
+    serializeHeader(input, outBuffer);
+    OfMplsLabelCaseValue value = (OfMplsLabelCaseValue) input.getMatchEntryValue();
+    outBuffer.writeInt(value.getMplsLabelValues().getMplsLabel().intValue());
+  }
+
+  @Override
+  public MatchEntry deserialize(ByteBuf message) {
+    MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
+    OfMplsLabelCaseValueBuilder caseBuilder = new OfMplsLabelCaseValueBuilder();
+    MplsLabelValuesBuilder valuesBuilder = new MplsLabelValuesBuilder();
+    valuesBuilder.setMplsLabel(message.readLong()).build();
+    caseBuilder.setMplsLabelValues(valuesBuilder.build());
+    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+    return matchEntryBuilder.build();
+  }
+
+  @Override
+  public int getNxmFieldCode() {
+    return NXM_FIELD_CODE;
+  }
+
+  @Override
+  public int getOxmClassCode() {
+    return OxmMatchConstants.NXM_0_CLASS;
+  }
+
+  @Override
+  public int getValueLength() {
+    return VALUE_LENGTH;
+  }
+
+  @Override
+  public Class<? extends MatchField> getNxmField() {
+    return NxmOfMplsLabel.class;
+  }
+
+  @Override
+  public Class<? extends OxmClassBase> getOxmClass() {
+    return Nxm0Class.class;
+  }
+}
index 4ea7dd700709ec7a44cda15b0a0706d5f6d244ef..ab902d6e29322ad7387ec9cd5adebbae8e2f7e94 100644 (file)
@@ -144,6 +144,9 @@ module nicira-match {
     identity nxm-nx-tun-gpe-np {
         base ofoxm:match-field;
     }
+    identity nxm-of-mpls-label {
+        base ofoxm:match-field;
+    }
 
 
     grouping ofj-nxm-nx-match-reg-grouping {
@@ -153,6 +156,14 @@ module nicira-match {
             }
         }
     }
+    grouping ofj-oxm-of-mpls-label-grouping {
+        container mpls-label-values {
+             leaf mpls-label {
+                 type uint32;
+             }
+        }
+    }
+
     grouping ofj-nxm-nx-match-tun-id-grouping {
         container tun-id-values {
             leaf value {
@@ -436,6 +447,9 @@ module nicira-match {
         case eth-src-case-value {
             uses ofj-nxm-of-match-eth-src-grouping;
         }
+        case of-mpls-label-case-value {
+            uses ofj-oxm-of-mpls-label-grouping;
+        }
         case eth-dst-case-value {
             uses ofj-nxm-of-match-eth-dst-grouping;
         }
index ddbeb3f076ae2434038d472023170ddafd4914e8..2dd71c98296f8f70e1420b75e6be70ddcf4320ef 100644 (file)
@@ -81,6 +81,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfMplsLabelCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfMplsLabelCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionRegMoveNotifGroupDescStatsUpdatedCaseBuilder;
@@ -116,6 +118,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshMdtypeCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxOfMplsLabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCase;
@@ -198,6 +201,9 @@ public class RegMoveConvertor implements
         if (dstValue == NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong()) {
             return new DstNxOfInPortCaseBuilder().setOfInPort(true).build();
         }
+        if (dstValue == NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong()) {
+            return new DstOfMplsLabelCaseBuilder().setOfMplsLabel(true).build();
+        }
         if (dstValue == NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
             return new DstOfEthDstCaseBuilder().setOfEthDst(true).build();
         }
@@ -428,6 +434,9 @@ public class RegMoveConvertor implements
         if (dstChoice instanceof DstNxOfInPortCase) {
             return NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong();
         }
+        if (dstChoice instanceof DstOfMplsLabelCase) {
+            return NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong();
+        }
         if (dstChoice instanceof DstNxTunIpv4DstCase) {
             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
         }
@@ -518,6 +527,9 @@ public class RegMoveConvertor implements
         if (srcChoice instanceof SrcNxOfInPortCase) {
             return NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong();
         }
+        if (srcChoice instanceof SrcNxOfMplsLabelCase) {
+            return NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong();
+        }
         if (srcChoice instanceof SrcNxTunIpv4DstCase) {
             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
         }
index 3bb70190461f5cd6c6b10554ee87ef92071afafc..3966262105b1194a24af6e2240440f0f68196a38 100644 (file)
@@ -53,6 +53,11 @@ module openflowplugin-extension-nicira-action {
             type empty;
         }
     }
+    grouping oxm-of-mpls-label-grouping {
+        leaf of-mpls-label {
+            type empty;
+        }
+    }
     grouping nxm-of-arp-op-grouping {
         leaf of-arp-op {
             type empty;
@@ -177,6 +182,9 @@ module openflowplugin-extension-nicira-action {
             case dst-nx-tun-id-case {
                 uses nxm-nx-tun-id-grouping;
             }
+            case dst-of-mpls-label-case {
+                 uses oxm-of-mpls-label-grouping;
+            }
             case dst-nx-arp-sha-case {
                 uses nxm-nx-arp-sha-grouping;
             }
@@ -260,6 +268,9 @@ module openflowplugin-extension-nicira-action {
             case src-nx-tun-id-case {
                 uses nxm-nx-tun-id-grouping;
             }
+            case src-nx-of-mpls-label-case {
+                uses oxm-of-mpls-label-grouping;
+            }
             case src-nx-arp-sha-case {
                 uses nxm-nx-arp-sha-grouping;
             }