Marc De Leenheer
Committed by Gerrit Code Review

Fine tuning of flow rules on Lumentum ROADM

Change-Id: I9220d63f1b6dfb2efd83c0c216a899d8668784b0
...@@ -23,6 +23,15 @@ import org.onosproject.net.flow.FlowId; ...@@ -23,6 +23,15 @@ import org.onosproject.net.flow.FlowId;
23 import java.util.HashMap; 23 import java.util.HashMap;
24 import java.util.Map; 24 import java.util.Map;
25 25
26 +/**
27 + * Simple implementation of a local flow rule cache that stores the flow ID and priority.
28 + *
29 + * Use this if you have a device that does not allow you to store these fields.
30 + *
31 + * WARNING: Be aware that this implementation makes no attempt to use a distributed store
32 + * for the cache, so do not rely on it to support fail-over in multi-instance deployments.
33 + * If the instance which holds the cache goes down, you *will* be in trouble.
34 + */
26 @Component(immediate = true, enabled = true) 35 @Component(immediate = true, enabled = true)
27 @Service 36 @Service
28 public class DefaultCrossConnectCache implements CrossConnectCache { 37 public class DefaultCrossConnectCache implements CrossConnectCache {
......
...@@ -62,12 +62,27 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements ...@@ -62,12 +62,27 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements
62 62
63 private static final Logger log = 63 private static final Logger log =
64 LoggerFactory.getLogger(LumentumFlowRuleDriver.class); 64 LoggerFactory.getLogger(LumentumFlowRuleDriver.class);
65 - private static final int DEFAULT_ATTENUATION = 160; 65 +
66 + // Default values
67 + private static final int DEFAULT_TARGET_GAIN_PREAMP = 150;
68 + private static final int DEFAULT_TARGET_GAIN_BOOSTER = 200;
69 + private static final int DISABLE_CHANNEL_TARGET_POWER = -650;
70 + private static final int DEFAULT_CHANNEL_TARGET_POWER = -30;
71 + private static final int DISABLE_CHANNEL_ABSOLUTE_ATTENUATION = 160;
72 + private static final int DEFAULT_CHANNEL_ABSOLUTE_ATTENUATION = 50;
66 private static final int OUT_OF_SERVICE = 1; 73 private static final int OUT_OF_SERVICE = 1;
67 private static final int IN_SERVICE = 2; 74 private static final int IN_SERVICE = 2;
75 + private static final int OPEN_LOOP = 1;
76 + private static final int CLOSED_LOOP = 2;
77 +
78 + // OIDs
68 private static final String CTRL_AMP_MODULE_SERVICE_STATE_PREAMP = ".1.3.6.1.4.1.46184.1.4.4.1.2.1"; 79 private static final String CTRL_AMP_MODULE_SERVICE_STATE_PREAMP = ".1.3.6.1.4.1.46184.1.4.4.1.2.1";
69 private static final String CTRL_AMP_MODULE_SERVICE_STATE_BOOSTER = ".1.3.6.1.4.1.46184.1.4.4.1.2.2"; 80 private static final String CTRL_AMP_MODULE_SERVICE_STATE_BOOSTER = ".1.3.6.1.4.1.46184.1.4.4.1.2.2";
81 + private static final String CTRL_AMP_MODULE_TARGET_GAIN_PREAMP = ".1.3.6.1.4.1.46184.1.4.4.1.8.1";
82 + private static final String CTRL_AMP_MODULE_TARGET_GAIN_BOOSTER = ".1.3.6.1.4.1.46184.1.4.4.1.8.2";
70 private static final String CTRL_CHANNEL_STATE = ".1.3.6.1.4.1.46184.1.4.2.1.3."; 83 private static final String CTRL_CHANNEL_STATE = ".1.3.6.1.4.1.46184.1.4.2.1.3.";
84 + private static final String CTRL_CHANNEL_MODE = ".1.3.6.1.4.1.46184.1.4.2.1.4.";
85 + private static final String CTRL_CHANNEL_TARGET_POWER = ".1.3.6.1.4.1.46184.1.4.2.1.6.";
71 private static final String CTRL_CHANNEL_ADD_DROP_PORT_INDEX = ".1.3.6.1.4.1.46184.1.4.2.1.13."; 86 private static final String CTRL_CHANNEL_ADD_DROP_PORT_INDEX = ".1.3.6.1.4.1.46184.1.4.2.1.13.";
72 private static final String CTRL_CHANNEL_ABSOLUTE_ATTENUATION = ".1.3.6.1.4.1.46184.1.4.2.1.5."; 87 private static final String CTRL_CHANNEL_ABSOLUTE_ATTENUATION = ".1.3.6.1.4.1.46184.1.4.2.1.5.";
73 88
...@@ -184,13 +199,19 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements ...@@ -184,13 +199,19 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements
184 PDU pdu = new PDU(); 199 PDU pdu = new PDU();
185 pdu.setType(PDU.SET); 200 pdu.setType(PDU.SET);
186 201
187 - // Enable preamp & booster for service 202 + // Enable preamp & booster
188 List<OID> oids = Arrays.asList(new OID(CTRL_AMP_MODULE_SERVICE_STATE_PREAMP), 203 List<OID> oids = Arrays.asList(new OID(CTRL_AMP_MODULE_SERVICE_STATE_PREAMP),
189 new OID(CTRL_AMP_MODULE_SERVICE_STATE_BOOSTER)); 204 new OID(CTRL_AMP_MODULE_SERVICE_STATE_BOOSTER));
190 oids.forEach( 205 oids.forEach(
191 oid -> pdu.add(new VariableBinding(oid, new Integer32(IN_SERVICE))) 206 oid -> pdu.add(new VariableBinding(oid, new Integer32(IN_SERVICE)))
192 ); 207 );
193 208
209 + // Set target gain on preamp & booster
210 + OID ctrlAmpModuleTargetGainPreamp = new OID(CTRL_AMP_MODULE_TARGET_GAIN_PREAMP);
211 + pdu.add(new VariableBinding(ctrlAmpModuleTargetGainPreamp, new Integer32(DEFAULT_TARGET_GAIN_PREAMP)));
212 + OID ctrlAmpModuleTargetGainBooster = new OID(CTRL_AMP_MODULE_TARGET_GAIN_BOOSTER);
213 + pdu.add(new VariableBinding(ctrlAmpModuleTargetGainBooster, new Integer32(DEFAULT_TARGET_GAIN_BOOSTER)));
214 +
194 // Enable the channel 215 // Enable the channel
195 OID ctrlChannelState = new OID(CTRL_CHANNEL_STATE + (xc.isAddRule() ? "1." : "2.") + channel); 216 OID ctrlChannelState = new OID(CTRL_CHANNEL_STATE + (xc.isAddRule() ? "1." : "2.") + channel);
196 pdu.add(new VariableBinding(ctrlChannelState, new Integer32(IN_SERVICE))); 217 pdu.add(new VariableBinding(ctrlChannelState, new Integer32(IN_SERVICE)));
...@@ -200,10 +221,22 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements ...@@ -200,10 +221,22 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements
200 (xc.isAddRule() ? "1." : "2.") + channel); 221 (xc.isAddRule() ? "1." : "2.") + channel);
201 pdu.add(new VariableBinding(ctrlChannelAddDropPortIndex, new UnsignedInteger32(addDrop))); 222 pdu.add(new VariableBinding(ctrlChannelAddDropPortIndex, new UnsignedInteger32(addDrop)));
202 223
203 - // Set attenuation to zero 224 + // Add rules use closed loop, drop rules open loop
204 - OID ctrlChannelAbsoluteAttenuation = new OID(CTRL_CHANNEL_ABSOLUTE_ATTENUATION + 225 + // Add rules are set to target power, drop rules are attenuated
205 - (xc.isAddRule() ? "1." : "2.") + channel); 226 + if (xc.isAddRule()) {
206 - pdu.add(new VariableBinding(ctrlChannelAbsoluteAttenuation, new UnsignedInteger32(0))); 227 + OID ctrlChannelMode = new OID(CTRL_CHANNEL_MODE + "1." + channel);
228 + pdu.add(new VariableBinding(ctrlChannelMode, new Integer32(CLOSED_LOOP)));
229 +
230 + OID ctrlChannelTargetPower = new OID(CTRL_CHANNEL_TARGET_POWER + "1." + channel);
231 + pdu.add(new VariableBinding(ctrlChannelTargetPower, new Integer32(DEFAULT_CHANNEL_TARGET_POWER)));
232 + } else {
233 + OID ctrlChannelMode = new OID(CTRL_CHANNEL_MODE + "2." + channel);
234 + pdu.add(new VariableBinding(ctrlChannelMode, new Integer32(OPEN_LOOP)));
235 +
236 + OID ctrlChannelAbsoluteAttenuation = new OID(CTRL_CHANNEL_ABSOLUTE_ATTENUATION + "2." + channel);
237 + pdu.add(new VariableBinding(
238 + ctrlChannelAbsoluteAttenuation, new UnsignedInteger32(DEFAULT_CHANNEL_ABSOLUTE_ATTENUATION)));
239 + }
207 240
208 try { 241 try {
209 ResponseEvent response = snmp.set(pdu); 242 ResponseEvent response = snmp.set(pdu);
...@@ -234,11 +267,19 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements ...@@ -234,11 +267,19 @@ public class LumentumFlowRuleDriver extends AbstractHandlerBehaviour implements
234 (xc.isAddRule() ? "1." : "2.") + channel); 267 (xc.isAddRule() ? "1." : "2.") + channel);
235 pdu.add(new VariableBinding(ctrlChannelAddDropPortIndex, new UnsignedInteger32(OUT_OF_SERVICE))); 268 pdu.add(new VariableBinding(ctrlChannelAddDropPortIndex, new UnsignedInteger32(OUT_OF_SERVICE)));
236 269
237 - // Set attenuation to default value 270 + // Put port/channel back to open loop
238 - OID ctrlChannelAbsoluteAttenuation = new OID(CTRL_CHANNEL_ABSOLUTE_ATTENUATION + 271 + OID ctrlChannelMode = new OID(CTRL_CHANNEL_MODE + (xc.isAddRule() ? "1." : "2.") + channel);
239 - (xc.isAddRule() ? "1." : "2.") + channel); 272 + pdu.add(new VariableBinding(ctrlChannelMode, new Integer32(OPEN_LOOP)));
240 - pdu.add(new VariableBinding(ctrlChannelAbsoluteAttenuation, new UnsignedInteger32(DEFAULT_ATTENUATION)) 273 +
241 - ); 274 + // Add rules are set to target power, drop rules are attenuated
275 + if (xc.isAddRule()) {
276 + OID ctrlChannelTargetPower = new OID(CTRL_CHANNEL_TARGET_POWER + "1." + channel);
277 + pdu.add(new VariableBinding(ctrlChannelTargetPower, new Integer32(DISABLE_CHANNEL_TARGET_POWER)));
278 + } else {
279 + OID ctrlChannelAbsoluteAttenuation = new OID(CTRL_CHANNEL_ABSOLUTE_ATTENUATION + "2." + channel);
280 + pdu.add(new VariableBinding(
281 + ctrlChannelAbsoluteAttenuation, new UnsignedInteger32(DISABLE_CHANNEL_ABSOLUTE_ATTENUATION)));
282 + }
242 283
243 try { 284 try {
244 ResponseEvent response = snmp.set(pdu); 285 ResponseEvent response = snmp.set(pdu);
......