Committed by
Gerrit Code Review
LINC driver updated to always use LINC's non-standard OF optical extensions.
ONOS-3399 Change-Id: I7bbd39947facfbbd53a164ea34c7da50782bfd6a
Showing
2 changed files
with
96 additions
and
3 deletions
| ... | @@ -15,8 +15,8 @@ | ... | @@ -15,8 +15,8 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.driver.handshaker; | 16 | package org.onosproject.driver.handshaker; |
| 17 | 17 | ||
| 18 | -import org.onosproject.net.Device; | ||
| 19 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
| 19 | +import org.onosproject.net.Device; | ||
| 20 | import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; | 20 | import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; |
| 21 | import org.onosproject.openflow.controller.PortDescPropertyType; | 21 | import org.onosproject.openflow.controller.PortDescPropertyType; |
| 22 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; | 22 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; |
| ... | @@ -26,6 +26,8 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta | ... | @@ -26,6 +26,8 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta |
| 26 | import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; | 26 | import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; |
| 27 | import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; | 27 | import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; |
| 28 | import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; | 28 | import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; |
| 29 | +import org.projectfloodlight.openflow.protocol.OFFlowMod; | ||
| 30 | +import org.projectfloodlight.openflow.protocol.OFFlowStatsRequest; | ||
| 29 | import org.projectfloodlight.openflow.protocol.OFMessage; | 31 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 30 | import org.projectfloodlight.openflow.protocol.OFObject; | 32 | import org.projectfloodlight.openflow.protocol.OFObject; |
| 31 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 33 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| ... | @@ -34,11 +36,19 @@ import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; | ... | @@ -34,11 +36,19 @@ import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
| 34 | import org.projectfloodlight.openflow.protocol.OFPortOptical; | 36 | import org.projectfloodlight.openflow.protocol.OFPortOptical; |
| 35 | import org.projectfloodlight.openflow.protocol.OFStatsReply; | 37 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
| 36 | import org.projectfloodlight.openflow.protocol.OFStatsType; | 38 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
| 39 | +import org.projectfloodlight.openflow.protocol.action.OFAction; | ||
| 40 | +import org.projectfloodlight.openflow.protocol.action.OFActionSetField; | ||
| 41 | +import org.projectfloodlight.openflow.protocol.match.Match; | ||
| 42 | +import org.projectfloodlight.openflow.protocol.match.MatchField; | ||
| 43 | +import org.projectfloodlight.openflow.protocol.oxm.OFOxmExpOchSigId; | ||
| 44 | +import org.projectfloodlight.openflow.types.CircuitSignalID; | ||
| 37 | import org.projectfloodlight.openflow.types.OFPort; | 45 | import org.projectfloodlight.openflow.types.OFPort; |
| 46 | +import org.projectfloodlight.openflow.types.U8; | ||
| 38 | 47 | ||
| 39 | import java.io.IOException; | 48 | import java.io.IOException; |
| 40 | import java.util.ArrayList; | 49 | import java.util.ArrayList; |
| 41 | import java.util.Collections; | 50 | import java.util.Collections; |
| 51 | +import java.util.LinkedList; | ||
| 42 | import java.util.List; | 52 | import java.util.List; |
| 43 | import java.util.Set; | 53 | import java.util.Set; |
| 44 | import java.util.concurrent.atomic.AtomicBoolean; | 54 | import java.util.concurrent.atomic.AtomicBoolean; |
| ... | @@ -52,6 +62,9 @@ import java.util.concurrent.atomic.AtomicBoolean; | ... | @@ -52,6 +62,9 @@ import java.util.concurrent.atomic.AtomicBoolean; |
| 52 | * LINC sends the tap ports (OCh for our purposes) in the regular port desc stats reply, | 62 | * LINC sends the tap ports (OCh for our purposes) in the regular port desc stats reply, |
| 53 | * while it sends *all* ports (both tap and WDM ports, i.e., OCh and OMS) in the experimenter port desc stats reply. | 63 | * while it sends *all* ports (both tap and WDM ports, i.e., OCh and OMS) in the experimenter port desc stats reply. |
| 54 | * | 64 | * |
| 65 | + * As LINC implements custom OF optical extensions (in contrast to the final standard as specified in | ||
| 66 | + * ONF TS-022 (March 15, 2015), we need to rewrite flow stat requests and flow mods in {@link #sendMsg(OFMessage)}. | ||
| 67 | + * | ||
| 55 | */ | 68 | */ |
| 56 | public class OfOpticalSwitchImplLinc13 | 69 | public class OfOpticalSwitchImplLinc13 |
| 57 | extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { | 70 | extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { |
| ... | @@ -160,6 +173,86 @@ public class OfOpticalSwitchImplLinc13 | ... | @@ -160,6 +173,86 @@ public class OfOpticalSwitchImplLinc13 |
| 160 | return Collections.EMPTY_LIST; | 173 | return Collections.EMPTY_LIST; |
| 161 | } | 174 | } |
| 162 | 175 | ||
| 176 | + /** | ||
| 177 | + * Rewrite match object to use LINC OF optical extensions. | ||
| 178 | + * | ||
| 179 | + * @param match original match | ||
| 180 | + * @return rewritten match | ||
| 181 | + */ | ||
| 182 | + private Match rewriteMatch(Match match) { | ||
| 183 | + Match.Builder mBuilder = factory().buildMatch(); | ||
| 184 | + for (MatchField mf : match.getMatchFields()) { | ||
| 185 | + if (mf == MatchField.EXP_OCH_SIG_ID) { | ||
| 186 | + mBuilder.setExact(MatchField.OCH_SIGID, (CircuitSignalID) match.get(mf)); | ||
| 187 | + continue; | ||
| 188 | + } | ||
| 189 | + if (mf == MatchField.EXP_OCH_SIGTYPE) { | ||
| 190 | + mBuilder.setExact(MatchField.OCH_SIGTYPE, (U8) match.get(mf)); | ||
| 191 | + continue; | ||
| 192 | + } | ||
| 193 | + mBuilder.setExact(mf, match.get(mf)); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + return mBuilder.build(); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * Rewrite actions to use LINC OF optical extensions. | ||
| 201 | + * | ||
| 202 | + * @param actions original actions | ||
| 203 | + * @return rewritten actions | ||
| 204 | + */ | ||
| 205 | + private List<OFAction> rewriteActions(List<OFAction> actions) { | ||
| 206 | + List<OFAction> newActions = new LinkedList<>(); | ||
| 207 | + | ||
| 208 | + for (OFAction action : actions) { | ||
| 209 | + if (!(action instanceof OFActionSetField)) { | ||
| 210 | + newActions.add(action); | ||
| 211 | + continue; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + OFActionSetField sf = (OFActionSetField) action; | ||
| 215 | + if (!(sf instanceof OFOxmExpOchSigId)) { | ||
| 216 | + newActions.add(action); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + OFOxmExpOchSigId oxm = (OFOxmExpOchSigId) sf.getField(); | ||
| 220 | + CircuitSignalID signalId = oxm.getValue(); | ||
| 221 | + | ||
| 222 | + newActions.add( | ||
| 223 | + factory().actions().circuit(factory().oxms().ochSigid(signalId))); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + return newActions; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + @Override | ||
| 230 | + public void sendMsg(OFMessage msg) { | ||
| 231 | + // Ignore everything but flow mods and stat requests | ||
| 232 | + if (!(msg instanceof OFFlowMod || msg instanceof OFFlowStatsRequest)) { | ||
| 233 | + super.sendMsg(msg); | ||
| 234 | + return; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + Match newMatch; | ||
| 238 | + OFMessage newMsg = null; | ||
| 239 | + | ||
| 240 | + if (msg instanceof OFFlowStatsRequest) { | ||
| 241 | + // Rewrite match only | ||
| 242 | + OFFlowStatsRequest fsr = (OFFlowStatsRequest) msg; | ||
| 243 | + newMatch = rewriteMatch(fsr.getMatch()); | ||
| 244 | + newMsg = fsr.createBuilder().setMatch(newMatch).build(); | ||
| 245 | + } else if (msg instanceof OFFlowMod) { | ||
| 246 | + // Rewrite match and actions | ||
| 247 | + OFFlowMod fm = (OFFlowMod) msg; | ||
| 248 | + newMatch = rewriteMatch(fm.getMatch()); | ||
| 249 | + List<OFAction> actions = rewriteActions(fm.getActions()); | ||
| 250 | + | ||
| 251 | + newMsg = fm.createBuilder().setMatch(newMatch).setActions(actions).build(); | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + super.sendMsg(newMsg); | ||
| 255 | + } | ||
| 163 | 256 | ||
| 164 | @Override | 257 | @Override |
| 165 | public Boolean supportNxRole() { | 258 | public Boolean supportNxRole() { | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
| ... | @@ -320,7 +320,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -320,7 +320,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | private OFAction buildModLambdaInstruction(ModLambdaInstruction instruction) { | 322 | private OFAction buildModLambdaInstruction(ModLambdaInstruction instruction) { |
| 323 | - return factory().actions().circuit(factory().oxms().ochSigidBasic( | 323 | + return factory().actions().circuit(factory().oxms().expOchSigId( |
| 324 | new CircuitSignalID((byte) 1, (byte) 2, instruction.lambda(), (short) 1))); | 324 | new CircuitSignalID((byte) 1, (byte) 2, instruction.lambda(), (short) 1))); |
| 325 | } | 325 | } |
| 326 | 326 | ||
| ... | @@ -329,7 +329,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -329,7 +329,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
| 329 | byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); | 329 | byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); |
| 330 | byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); | 330 | byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); |
| 331 | 331 | ||
| 332 | - return factory().actions().circuit(factory().oxms().ochSigidBasic( | 332 | + return factory().actions().circuit(factory().oxms().expOchSigId( |
| 333 | new CircuitSignalID(gridType, channelSpacing, | 333 | new CircuitSignalID(gridType, channelSpacing, |
| 334 | (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) | 334 | (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) |
| 335 | )); | 335 | )); | ... | ... |
-
Please register or login to post a comment