X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=mdsalutil%2Fmdsalutil-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fgenius%2Fmdsalutil%2FMetaDataUtil.java;h=03be7092c2ee3de6707ca873bdac75bab36f5a41;hb=676af66f0d56d99615d93084f4f62bd2a6e3d9f9;hp=c02e7c445bfd5306638524077371145e398fc3e3;hpb=ae4513ac7e9d2eb4904e9b092af1b3ac68806b27;p=genius.git diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/MetaDataUtil.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/MetaDataUtil.java index c02e7c445..03be7092c 100644 --- a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/MetaDataUtil.java +++ b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/MetaDataUtil.java @@ -9,12 +9,12 @@ package org.opendaylight.genius.mdsalutil; import java.math.BigInteger; -public class MetaDataUtil { +public final class MetaDataUtil { public static final BigInteger METADATA_MASK_LPORT_TAG = new BigInteger("0FFFFF0000000000", 16); public static final BigInteger METADATA_MASK_SERVICE = new BigInteger("000000FFFF000000", 16); public static final BigInteger METADATA_MASK_SERVICE_INDEX = new BigInteger("F000000000000000", 16); public static final BigInteger METADATA_MASK_VRFID = new BigInteger("0000000000FFFFFE", 16); - public static final BigInteger METADATA_MASK_REMOTE_ACL_ID = new BigInteger("0000000000FFFFFE", 16); + public static final BigInteger METADATA_MASK_REMOTE_ACL_TAG = new BigInteger("0000000000FFFFF0", 16); public static final BigInteger METADATA_MASK_POLICY_CLASSIFER_ID = new BigInteger("0000000000FFFFFE", 16); public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16); @@ -25,6 +25,15 @@ public class MetaDataUtil { public static final BigInteger METADATA_MASK_SH_FLAG = new BigInteger("0000000000000001", 16); public static final BigInteger METADATA_MASK_ELAN_SUBNET_ROUTE = new BigInteger("000000FFFF000000", 16); public static final BigInteger METADATA_MASK_SUBNET_ROUTE = new BigInteger("000000FFFFFFFFFE", 16); + public static final BigInteger METADATA_MASK_ACL_CONNTRACK_CLASSIFIER_TYPE = new BigInteger("0000000000000002", 16); + public static final BigInteger METADATA_MASK_ACL_DROP = new BigInteger("0000000000000004", 16); + + public static final int METADATA_ELAN_TAG_OFFSET = 24; + public static final int METADATA_ELAN_TAG_BITLEN = 16; + public static final int METADATA_VPN_ID_OFFSET = 1; + public static final int METADATA_VPN_ID_BITLEN = 23; + + private MetaDataUtil() { } public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) { return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag)); @@ -105,6 +114,27 @@ public class MetaDataUtil { return getVpnIdFromMetadata(metadata); } + /** + * Gets the ACL conntrack classifier type from meta data.
+ * Second bit in metadata is used for this purpose.
+ * + *

+ * Conntrack supported traffic is identified by value 0 (0000 in binary) + * i.e., 0x0/0x2
+ * Non-conntrack supported traffic is identified by value 2 (0010 in binary) + * i.e., 0x2/0x2 + * + * @param conntrackClassifierType the conntrack classifier flag + * @return the acl conntrack classifier flag from meta data + */ + public static BigInteger getAclConntrackClassifierTypeFromMetaData(BigInteger conntrackClassifierType) { + return METADATA_MASK_ACL_CONNTRACK_CLASSIFIER_TYPE.and(conntrackClassifierType.shiftLeft(1)); + } + + public static BigInteger getAclDropMetaData(BigInteger dropFlag) { + return METADATA_MASK_ACL_DROP.and(dropFlag.shiftLeft(2)); + } + public static BigInteger getVpnIdMetadata(long vrfId) { return METADATA_MASK_VRFID.and(BigInteger.valueOf(vrfId).shiftLeft(1)); } @@ -129,12 +159,40 @@ public class MetaDataUtil { return new BigInteger("F", 16).and(BigInteger.valueOf(serviceIndex)).shiftLeft(28); } + public static BigInteger getInterfaceTypeForReg6(int tunnelType) { + return new BigInteger("F", 16).and(BigInteger.valueOf(tunnelType)).shiftLeft(4); + } + public static long getReg6ValueForLPortDispatcher(int lportTag, short serviceIndex) { return getServiceIndexForReg6(serviceIndex).or(getLportTagForReg6(lportTag)).longValue(); } + /** Utility to fetch the register value for lport dispatcher table. + * Register6 used for service binding will have first 4 bits of service-index, next 20 bits for lportTag, + * and next 4 bits for interface-type + */ + public static long getReg6ValueForLPortDispatcher(int lportTag, short serviceIndex, short interfaceType) { + return getServiceIndexForReg6(serviceIndex).or(getLportTagForReg6(lportTag) + .or(getInterfaceTypeForReg6(interfaceType))).longValue(); + } + public static long getLportTagMaskForReg6() { return METADATA_MASK_LPORT_TAG.shiftRight(32).longValue(); } + public static long getElanMaskForReg() { + return METADATA_MASK_SERVICE.shiftRight(24).longValue(); + } + + public static long getVpnIdMaskForReg() { + return METADATA_MASK_VRFID.shiftRight(1).longValue(); + } + + public static BigInteger mergeMetadataValues(BigInteger metadata, BigInteger metadata2) { + return metadata.or(metadata2); + } + + public static BigInteger mergeMetadataMask(BigInteger mask, BigInteger mask2) { + return mask.or(mask2); + } }