Skip to content

Commit

Permalink
Loxi support for Optical Transport extensions, onos-2472
Browse files Browse the repository at this point in the history
Change-Id: I69b9a8839fd899aec531f68103b448dd93cbbe4a
  • Loading branch information
Yafit Hadar committed Aug 31, 2015
1 parent 5fde105 commit f8caac0
Show file tree
Hide file tree
Showing 16 changed files with 919 additions and 9 deletions.
10 changes: 9 additions & 1 deletion java_gen/java_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ def gen_fixed_length_string_jtype(length):
.op(read="OFBufferId.of(bb.readInt())", write="bb.writeInt($name.getInt())", default="OFBufferId.NO_BUFFER")
lag_id = JType("LagId") \
.op(version=ANY, read="LagId.read4Bytes(bb)", write="$name.write4Bytes(bb)", default="LagId.NONE")

odu_sig_id = JType("OduSignalID") \
.op(read="OduSignalID.readFrom(bb)", \
write="$name.writeTo(bb)",
default='OduSignalID.DEFAULT')
sig_id = JType("CircuitSignalID") \
.op(version=ANY, read="CircuitSignalID.read6Bytes(bb)", write="$name.write6Bytes(bb)", default="CircuitSignalID.NONE")
vrf = JType("VRF") \
Expand Down Expand Up @@ -595,6 +598,8 @@ def gen_fixed_length_string_jtype(length):
'of_app_code_t': app_code,
'of_sig_id_t': sig_id,
'of_table_desc_t': table_desc,
'of_odu_sig_id_t': odu_sig_id,
'of_och_sig_id_t' : sig_id,
}

## Map that defines exceptions from the standard loxi->java mapping scheme
Expand Down Expand Up @@ -772,6 +777,9 @@ def gen_fixed_length_string_jtype(length):
'of_oxm_och_sigid_basic' : {'value' : sig_id},

'of_bundle_add_msg' : { 'data' : of_message },

'of_oxm_exp_odu_sigtype' : { 'value' : u8obj },
'of_oxm_exp_och_sigtype' : { 'value' : u8obj },
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.projectfloodlight.openflow.types.VRF;
import org.projectfloodlight.openflow.types.VlanPcp;
import org.projectfloodlight.openflow.types.CircuitSignalID;
import org.projectfloodlight.openflow.types.OduSignalID;

@SuppressWarnings("unchecked")
public class MatchField<F extends OFValueType<F>> {
Expand Down Expand Up @@ -289,6 +290,18 @@ private MatchField(final String name, final MatchFields id, Prerequisite<?>... p
public final static MatchField<MacAddress> BSN_INNER_ETH_SRC =
new MatchField<MacAddress>("bsn_inner_eth_src", MatchFields.BSN_INNER_ETH_SRC);

public final static MatchField<OduSignalID> EXP_ODU_SIG_ID =
new MatchField<OduSignalID>("exp_odu_sig_id", MatchFields.EXP_ODU_SIG_ID);

public final static MatchField<U8> EXP_ODU_SIGTYPE =
new MatchField<U8>("exp_odu_sigtype", MatchFields.EXP_ODU_SIGTYPE);

public final static MatchField<CircuitSignalID> EXP_OCH_SIG_ID =
new MatchField<CircuitSignalID>("exp_och_sig_id", MatchFields.EXP_OCH_SIG_ID);

public final static MatchField<U8> EXP_OCH_SIGTYPE =
new MatchField<U8>("exp_och_sigtype", MatchFields.EXP_OCH_SIGTYPE);

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ public enum MatchFields {
OCH_SIGTYPE_BASIC,
OCH_SIGID,
OCH_SIGID_BASIC,
EXP_ODU_SIG_ID,
EXP_ODU_SIGTYPE,
EXP_OCH_SIG_ID,
EXP_OCH_SIGTYPE,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* Copyright 2015, ECI Telecom, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.projectfloodlight.openflow.types;


import java.util.List;

import org.jboss.netty.buffer.ChannelBuffer;

import com.google.common.collect.ComparisonChain;
import com.google.common.primitives.UnsignedBytes;
import com.google.common.hash.PrimitiveSink;

import org.projectfloodlight.openflow.exceptions.OFParseError;
import org.projectfloodlight.openflow.protocol.*;
import com.google.common.hash.Funnel;
import org.projectfloodlight.openflow.util.*;
import java.util.Arrays;

public class OduSignalID implements OFValueType<OduSignalID> {

// version: 1.3
final static byte WIRE_VERSION = 4;
final static int MINIMUM_LENGTH = 4;

private final static int DEFAULT_TPN = 0x0;
private final static int DEFAULT_TSLEN = 80;
private final static byte[] DEFAULT_TSMAP = new byte[10];

// OF message fields
private final int tpn;
private final int tslen;
private final byte[] tsmap;

// Immutable default instance
public final static OduSignalID DEFAULT = new OduSignalID(
DEFAULT_TPN, DEFAULT_TSLEN, DEFAULT_TSMAP
);

// package private constructor - used by readers, builders, and factory
public OduSignalID(int tpn, int tslen, byte[] tsmap) {
this.tpn = tpn;
this.tslen = tslen;
this.tsmap = tsmap;
}

public int getTpn() {
return tpn;
}

public int getTslen() {
return tslen;
}

public byte[] getTsmap() {
return tsmap;
}


@Override
public int getLength() {
return MINIMUM_LENGTH + 12; // tslen == 80
}

public void writeTo(ChannelBuffer c) {
c.writeShort(tpn);
c.writeShort(tslen);
c.writeBytes(tsmap); // 10 bytes
c.writeZero(2); // write bytes for add padding alignment (the size of bytes in tsmap must be divided in 4)
}

public static OduSignalID readFrom(ChannelBuffer c) {
int tpn = U16.f(c.readShort());
int tslen = U16.f(c.readShort());
byte[] tsmap = null;
tsmap =ChannelUtils.readBytes(c, 10);
ChannelUtils.readBytes(c, 2); // skip padding
OduSignalID oduSigId = new OduSignalID(
tpn,
tslen,
tsmap
);
return oduSigId;
}


public void putTo(PrimitiveSink sink) {
FUNNEL.funnel(this, sink);
}

final static OduSignalIDFunnel FUNNEL = new OduSignalIDFunnel();
static class OduSignalIDFunnel implements Funnel< OduSignalID> {
private static final long serialVersionUID = 1L;
@Override
public void funnel( OduSignalID message, PrimitiveSink sink) {
sink.putInt(message.tpn);
sink.putInt(message.tslen);
sink.putBytes(message.tsmap);
}
}

@Override
public String toString() {
StringBuilder b = new StringBuilder(" OduSignalID(");
b.append("tpn=").append(tpn);
b.append(", ");
b.append("tslen=").append(tslen);
b.append(", ");
b.append("tsmap=").append(Arrays.toString(tsmap));
b.append(")");
return b.toString();
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
OduSignalID other = (OduSignalID) obj;

if( tpn != other.tpn)
return false;
if( tslen != other.tslen)
return false;
if (!Arrays.equals(tsmap, other.tsmap))
return false;
return true;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;

result = prime * result + tpn;
result = prime * result + tslen;
result = prime * result + Arrays.hashCode(tsmap);
return result;
}

@Override
public OduSignalID applyMask(OduSignalID mask) {
byte[] maskTsmap = null;
if (this.tsmap!=null && this.tsmap.length > 0) {
maskTsmap = new byte[this.tsmap.length];
int i = 0;
for (byte b : this.tsmap){
maskTsmap[i] =(byte) (b & mask.tsmap[i++]);
}
}
return new OduSignalID(this.tpn & mask.tpn,
(short) (this.tslen & mask
.tslen),
maskTsmap);
}

@Override
public int compareTo(OduSignalID o) {
return ComparisonChain.start()
.compare(tpn,o.tpn)
.compare(tslen,o.tslen)
.compare(tsmap,o.tsmap, UnsignedBytes.lexicographicalComparator())
.result();
}

}
2 changes: 2 additions & 0 deletions loxi_ir/ir_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
of_app_code_t = (15,True),
of_sig_id_t = (6, True),
of_bitmap_512_t = (64, True),
of_odu_sig_id_t = (16, True),
of_och_sig_id_t = (6, True),
)

def type_dec_to_count_base(m_type):
Expand Down
2 changes: 1 addition & 1 deletion openflow_input/circuit
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum ofp_channel_spacing {
};

/* Layer classes (families) supported for optical transport port. */
enum ofp_port_optical_transport_layer_class {
enum ofp_port_optical_transport_layer_class(wire_type=uint8_t){
OFPPOTL_PORT = 1, /* Class of base port layer signal types */
OFPPOTL_OCH = 2, /* Class of OCH layer signal types*/
OFPPOTL_ODU = 3, /* Class of ODU layer signal types*/
Expand Down
Loading

0 comments on commit f8caac0

Please sign in to comment.