Add arbitrary mask for nxm-reg 24/53424/1
authorTomas Slusny <tomas.slusny@pantheon.tech>
Tue, 14 Mar 2017 09:27:48 +0000 (10:27 +0100)
committerKoby Aizer <koby.aizer@hpe.com>
Thu, 16 Mar 2017 20:03:41 +0000 (20:03 +0000)
According to specification, nxm-reg should be fully maskable
using arbitrary mask.

Resolves: bug 7897

Change-Id: I912017e6bd33813ac65ed5799c8bfa7ebf217889
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
(cherry picked from commit 113fc0c316f814452a535a66f0da085076d282b5)

extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java
extension/openflowjava-extension-nicira/src/main/yang/nicira-match.yang
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/RegConvertor.java
extension/openflowplugin-extension-nicira/src/main/yang/openflowplugin-extension-nicira-match.yang

index 7ff2cc806a17dfec19e090c3c34382d4b504fccb..c186af39b7fd7b4f0032ea70dca41d0b5b126325 100644 (file)
@@ -25,19 +25,30 @@ public abstract class AbstractRegCodec extends AbstractMatchCodec {
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
-        RegCaseValueBuilder caseBuilder = new RegCaseValueBuilder();
-        caseBuilder.setRegValues(new RegValuesBuilder().setValue(message.readUnsignedInt()).build());
-        matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntriesBuilder.build();
+        final MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
+        final RegValuesBuilder regValuesBuilder = new RegValuesBuilder();
+        regValuesBuilder.setValue(message.readUnsignedInt());
+
+        if (matchEntriesBuilder.isHasMask()) {
+            regValuesBuilder.setMask(message.readUnsignedInt());
+        }
+
+        return matchEntriesBuilder
+            .setMatchEntryValue(new RegCaseValueBuilder()
+                .setRegValues(regValuesBuilder.build())
+                .build())
+            .build();
     }
 
     @Override
     public void serialize(MatchEntry input, ByteBuf outBuffer) {
         serializeHeader(input, outBuffer);
-        RegCaseValue regCase = ((RegCaseValue) input.getMatchEntryValue());
-        Long value = regCase.getRegValues().getValue();
-        outBuffer.writeInt(value.intValue());
+        final RegCaseValue regCase = ((RegCaseValue) input.getMatchEntryValue());
+        outBuffer.writeInt(regCase.getRegValues().getValue().intValue());
+
+        if (input.isHasMask()) {
+            outBuffer.writeInt(regCase.getRegValues().getMask().intValue());
+        }
     }
 
     @Override
index ab902d6e29322ad7387ec9cd5adebbae8e2f7e94..e7faa80678c03ec2323a1778bc6f658e00e4dc46 100644 (file)
@@ -148,14 +148,17 @@ module nicira-match {
         base ofoxm:match-field;
     }
 
-
     grouping ofj-nxm-nx-match-reg-grouping {
         container reg-values {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
+
     grouping ofj-oxm-of-mpls-label-grouping {
         container mpls-label-values {
              leaf mpls-label {
@@ -171,6 +174,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-arp-sha-grouping {
         container arp-sha-values {
             leaf mac-address {
@@ -178,6 +182,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-arp-tha-grouping {
         container arp-tha-values {
             leaf mac-address {
@@ -185,6 +190,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-arp-op-grouping {
         container arp-op-values {
             leaf value {
@@ -192,6 +198,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-arp-spa-grouping {
         container arp-spa-values {
             leaf value {
@@ -199,6 +206,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-arp-tpa-grouping {
         container arp-tpa-values {
             leaf value {
@@ -206,6 +214,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-in-port-type-grouping {
         container nxm-of-in-port-values {
             leaf value {
@@ -213,6 +222,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-tun-ipv4-dst-grouping {
         container tun-ipv4-dst-values {
             leaf value {
@@ -220,6 +230,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-tun-ipv4-src-grouping {
         container tun-ipv4-src-values {
             leaf value {
@@ -227,6 +238,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-eth-src-grouping {
         container eth-src-values {
             leaf mac-address {
@@ -234,6 +246,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-eth-dst-grouping {
         container eth-dst-values {
             leaf mac-address {
@@ -241,6 +254,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-eth-type-grouping {
         container eth-type-values {
             leaf value {
@@ -276,21 +290,25 @@ module nicira-match {
             uses ofj-nxm-nx-match-nshc-grouping;
         }
     }
+
     grouping ofj-nxm-nx-match-nshc-2-grouping {
         container nshc-2-values {
             uses ofj-nxm-nx-match-nshc-grouping;
         }
     }
+
     grouping ofj-nxm-nx-match-nshc-3-grouping {
         container nshc-3-values {
             uses ofj-nxm-nx-match-nshc-grouping;
         }
     }
+
     grouping ofj-nxm-nx-match-nshc-4-grouping {
         container nshc-4-values {
             uses ofj-nxm-nx-match-nshc-grouping;
         }
     }
+
     grouping ofj-nxm-of-match-tcp-src-grouping {
         container tcp-src-values {
             leaf port {
@@ -301,6 +319,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-tcp-dst-grouping {
         container tcp-dst-values {
             leaf port {
@@ -311,7 +330,8 @@ module nicira-match {
             }
         }
     }
-     grouping ofj-nxm-of-match-udp-src-grouping {
+
+    grouping ofj-nxm-of-match-udp-src-grouping {
         container udp-src-values {
             leaf port {
                type inet:port-number;
@@ -321,6 +341,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-udp-dst-grouping {
         container udp-dst-values {
             leaf port {
@@ -331,6 +352,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-ct-state-grouping{
          container ct-state-values {
             leaf ct-state {
@@ -341,6 +363,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-ct-zone-grouping{
          container ct-zone-values {
             leaf ct-zone {
@@ -348,6 +371,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-ip-dst-grouping {
         container ip-dst-values {
             leaf value {
@@ -355,6 +379,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-ip-src-grouping {
         container ip-src-values {
             leaf value {
@@ -362,6 +387,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-of-match-icmp-type-grouping {
         container icmp-type-values {
             leaf value {
@@ -369,6 +395,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-encap-eth-type-grouping {
         container encap-eth-type-values {
             leaf encap-eth-type {
@@ -376,6 +403,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-encap-eth-src-grouping {
         container encap-eth-src-values {
             leaf mac-address {
@@ -383,6 +411,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-encap-eth-dst-grouping {
         container encap-eth-dst-values {
             leaf mac-address {
@@ -390,6 +419,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-nsh-mdtype-grouping {
         container nsh-mdtype-values {
             leaf value {
@@ -397,6 +427,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-nsh-np-grouping {
         container nsh-np-values {
             leaf value {
@@ -404,6 +435,7 @@ module nicira-match {
             }
         }
     }
+
     grouping ofj-nxm-nx-match-tun-gpe-np-grouping {
         container tun-gpe-np-values {
             leaf value {
@@ -471,7 +503,6 @@ module nicira-match {
         case tun-gpe-np-case-value {
             uses ofj-nxm-nx-match-tun-gpe-np-grouping;
         }
-
         case eth-type-case-value {
             uses ofj-nxm-of-match-eth-type-grouping;
         }
@@ -520,7 +551,6 @@ module nicira-match {
         case icmp-type-case-value {
             uses ofj-nxm-of-match-icmp-type-grouping;
         }
-
     }
 
 }
index 1ba11162dbced0c3022b87e7de9cf0549b2947e6..579def71dd84801efe24708cd93ec80a58b95cd5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import java.util.Objects;
 import org.opendaylight.openflowjava.nx.NiciraMatchCodecs;
 import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
@@ -54,7 +55,7 @@ public class RegConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see
      * org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava#convert
      * (org.opendaylight.yangtools.yang.binding.DataContainer,
@@ -77,6 +78,11 @@ public class RegConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
                         .getOxmMatchField());
         RegCaseValue regCaseValue = ((RegCaseValue) input.getMatchEntryValue());
         nxRegBuilder.setValue(regCaseValue.getRegValues().getValue());
+
+        if (input.isHasMask()) {
+            nxRegBuilder.setMask(regCaseValue.getRegValues().getMask());
+        }
+
         return resolveAugmentation(nxRegBuilder.build(), path, resolveRegKey(input.getOxmMatchField()));
     }
 
@@ -130,7 +136,7 @@ public class RegConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see
      * org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava#convert
      * (org
@@ -144,12 +150,17 @@ public class RegConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
             throw new CodecPreconditionException(extension);
         }
         NxmNxReg nxmNxReg = matchGrouping.get().getNxmNxReg();
-        RegValuesBuilder regValuesBuilder = new RegValuesBuilder().setValue(nxmNxReg.getValue());
+        RegValuesBuilder regValuesBuilder = new RegValuesBuilder()
+            .setValue(nxmNxReg.getValue())
+            .setMask(nxmNxReg.getMask());
+
         RegCaseValueBuilder regCaseValueBuilder = new RegCaseValueBuilder();
         regCaseValueBuilder.setRegValues(regValuesBuilder.build());
         return MatchUtil.createDefaultMatchEntryBuilder(nxmNxReg.getReg(),
                 Nxm1Class.class,
-                regCaseValueBuilder.build()).build();
+                regCaseValueBuilder.build())
+            .setHasMask(Objects.nonNull(nxmNxReg.getMask()))
+            .build();
     }
 
 }
index cd4c5890eaa905c3d0cc3b651db061f3c1151453..199b94d1ba7752759878f6d93a66701890e80940 100644 (file)
@@ -167,6 +167,9 @@ module openflowplugin-extension-nicira-match {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
     grouping nxm-nx-tun-id-grouping {