Charles Chan
Committed by Gerrit Code Review

Fix group handler in CpqD OFDPA driver

We should not use OFDPA extension VLAN ID in CpqD OFDPA driver (gerrit#8609)

Change-Id: Ife451c25c48a7aba2c4f7f8c66f71c9f362ab37c
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.driver.pipeline;
18 +
19 +import org.onlab.packet.MacAddress;
20 +import org.onlab.packet.VlanId;
21 +import org.onosproject.core.ApplicationId;
22 +import org.onosproject.core.DefaultGroupId;
23 +import org.onosproject.net.flow.DefaultTrafficTreatment;
24 +import org.onosproject.net.flow.TrafficSelector;
25 +import org.onosproject.net.flow.TrafficTreatment;
26 +import org.onosproject.net.flow.criteria.Criterion;
27 +import org.onosproject.net.flow.criteria.VlanIdCriterion;
28 +import org.onosproject.net.flow.instructions.Instruction;
29 +import org.onosproject.net.flow.instructions.Instructions;
30 +import org.onosproject.net.flow.instructions.L2ModificationInstruction;
31 +import org.onosproject.net.group.DefaultGroupBucket;
32 +import org.onosproject.net.group.DefaultGroupDescription;
33 +import org.onosproject.net.group.DefaultGroupKey;
34 +import org.onosproject.net.group.GroupBucket;
35 +import org.onosproject.net.group.GroupBuckets;
36 +import org.onosproject.net.group.GroupDescription;
37 +import org.onosproject.net.group.GroupKey;
38 +import org.slf4j.Logger;
39 +
40 +import java.util.Collections;
41 +
42 +import static org.slf4j.LoggerFactory.getLogger;
43 +
44 +/**
45 + * Group handler for CpqD OFDPA pipeline.
46 + */
47 +public class CpqdOfdpa2GroupHandler extends Ofdpa2GroupHandler {
48 + private final Logger log = getLogger(getClass());
49 +
50 + @Override
51 + protected GroupInfo createL2L3Chain(TrafficTreatment treatment, int nextId,
52 + ApplicationId appId, boolean mpls,
53 + TrafficSelector meta) {
54 + // for the l2interface group, get vlan and port info
55 + // for the outer group, get the src/dst mac, and vlan info
56 + TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
57 + TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
58 + VlanId vlanid = null;
59 + long portNum = 0;
60 + boolean setVlan = false, popVlan = false;
61 + MacAddress srcMac = MacAddress.ZERO;
62 + MacAddress dstMac = MacAddress.ZERO;
63 + for (Instruction ins : treatment.allInstructions()) {
64 + if (ins.type() == Instruction.Type.L2MODIFICATION) {
65 + L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
66 + switch (l2ins.subtype()) {
67 + case ETH_DST:
68 + dstMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
69 + outerTtb.setEthDst(dstMac);
70 + break;
71 + case ETH_SRC:
72 + srcMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
73 + outerTtb.setEthSrc(srcMac);
74 + break;
75 + case VLAN_ID:
76 + vlanid = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
77 + outerTtb.setVlanId(vlanid);
78 + setVlan = true;
79 + break;
80 + case VLAN_POP:
81 + innerTtb.popVlan();
82 + popVlan = true;
83 + break;
84 + case DEC_MPLS_TTL:
85 + case MPLS_LABEL:
86 + case MPLS_POP:
87 + case MPLS_PUSH:
88 + case VLAN_PCP:
89 + case VLAN_PUSH:
90 + default:
91 + break;
92 + }
93 + } else if (ins.type() == Instruction.Type.OUTPUT) {
94 + portNum = ((Instructions.OutputInstruction) ins).port().toLong();
95 + innerTtb.add(ins);
96 + } else {
97 + log.warn("Driver does not handle this type of TrafficTreatment"
98 + + " instruction in nextObjectives: {}", ins.type());
99 + }
100 + }
101 +
102 + if (vlanid == null && meta != null) {
103 + // use metadata if available
104 + Criterion vidCriterion = meta.getCriterion(Criterion.Type.VLAN_VID);
105 + if (vidCriterion != null) {
106 + vlanid = ((VlanIdCriterion) vidCriterion).vlanId();
107 + }
108 + // if vlan is not set, use the vlan in metadata for outerTtb
109 + if (vlanid != null && !setVlan) {
110 + outerTtb.setVlanId(vlanid);
111 + }
112 + }
113 +
114 + if (vlanid == null) {
115 + log.error("Driver cannot process an L2/L3 group chain without "
116 + + "egress vlan information for dev: {} port:{}",
117 + deviceId, portNum);
118 + return null;
119 + }
120 +
121 + if (!setVlan && !popVlan) {
122 + // untagged outgoing port
123 + TrafficTreatment.Builder temp = DefaultTrafficTreatment.builder();
124 + temp.popVlan();
125 + innerTtb.build().allInstructions().forEach(i -> temp.add(i));
126 + innerTtb = temp;
127 + }
128 +
129 + // assemble information for ofdpa l2interface group
130 + int l2groupId = L2_INTERFACE_TYPE | (vlanid.toShort() << 16) | (int) portNum;
131 + // a globally unique groupkey that is different for ports in the same device,
132 + // but different for the same portnumber on different devices. Also different
133 + // for the various group-types created out of the same next objective.
134 + int l2gk = l2InterfaceGroupKey(deviceId, vlanid, portNum);
135 + final GroupKey l2groupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l2gk));
136 +
137 + // assemble information for outer group
138 + GroupDescription outerGrpDesc = null;
139 + if (mpls) {
140 + // outer group is MPLSInteface
141 + int mplsInterfaceIndex = getNextAvailableIndex();
142 + int mplsgroupId = MPLS_INTERFACE_TYPE | (SUBTYPE_MASK & mplsInterfaceIndex);
143 + final GroupKey mplsgroupkey = new DefaultGroupKey(
144 + Ofdpa2Pipeline.appKryo.serialize(mplsInterfaceIndex));
145 + outerTtb.group(new DefaultGroupId(l2groupId));
146 + // create the mpls-interface group description to wait for the
147 + // l2 interface group to be processed
148 + GroupBucket mplsinterfaceGroupBucket =
149 + DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
150 + outerGrpDesc = new DefaultGroupDescription(
151 + deviceId,
152 + GroupDescription.Type.INDIRECT,
153 + new GroupBuckets(Collections.singletonList(
154 + mplsinterfaceGroupBucket)),
155 + mplsgroupkey,
156 + mplsgroupId,
157 + appId);
158 + log.debug("Trying MPLS-Interface: device:{} gid:{} gkey:{} nextid:{}",
159 + deviceId, Integer.toHexString(mplsgroupId),
160 + mplsgroupkey, nextId);
161 + } else {
162 + // outer group is L3Unicast
163 + int l3unicastIndex = getNextAvailableIndex();
164 + int l3groupId = L3_UNICAST_TYPE | (TYPE_MASK & l3unicastIndex);
165 + final GroupKey l3groupkey = new DefaultGroupKey(
166 + Ofdpa2Pipeline.appKryo.serialize(l3unicastIndex));
167 + outerTtb.group(new DefaultGroupId(l2groupId));
168 + // create the l3unicast group description to wait for the
169 + // l2 interface group to be processed
170 + GroupBucket l3unicastGroupBucket =
171 + DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
172 + outerGrpDesc = new DefaultGroupDescription(
173 + deviceId,
174 + GroupDescription.Type.INDIRECT,
175 + new GroupBuckets(Collections.singletonList(
176 + l3unicastGroupBucket)),
177 + l3groupkey,
178 + l3groupId,
179 + appId);
180 + log.debug("Trying L3Unicast: device:{} gid:{} gkey:{} nextid:{}",
181 + deviceId, Integer.toHexString(l3groupId),
182 + l3groupkey, nextId);
183 + }
184 +
185 + // store l2groupkey with the groupChainElem for the outer-group that depends on it
186 + GroupChainElem gce = new GroupChainElem(outerGrpDesc, 1, false);
187 + updatePendingGroups(l2groupkey, gce);
188 +
189 + // create group description for the inner l2interfacegroup
190 + GroupBucket l2InterfaceGroupBucket =
191 + DefaultGroupBucket.createIndirectGroupBucket(innerTtb.build());
192 + GroupDescription l2groupDescription =
193 + new DefaultGroupDescription(
194 + deviceId,
195 + GroupDescription.Type.INDIRECT,
196 + new GroupBuckets(Collections.singletonList(
197 + l2InterfaceGroupBucket)),
198 + l2groupkey,
199 + l2groupId,
200 + appId);
201 + log.debug("Trying L2Interface: device:{} gid:{} gkey:{} nextId:{}",
202 + deviceId, Integer.toHexString(l2groupId),
203 + l2groupkey, nextId);
204 + return new GroupInfo(l2groupDescription, outerGrpDesc);
205 + }
206 +}
...@@ -32,15 +32,20 @@ import org.onlab.packet.MacAddress; ...@@ -32,15 +32,20 @@ import org.onlab.packet.MacAddress;
32 import org.onlab.packet.IpPrefix; 32 import org.onlab.packet.IpPrefix;
33 import org.onlab.packet.VlanId; 33 import org.onlab.packet.VlanId;
34 import org.onosproject.core.ApplicationId; 34 import org.onosproject.core.ApplicationId;
35 +import org.onosproject.core.CoreService;
36 +import org.onosproject.net.DeviceId;
35 import org.onosproject.net.Port; 37 import org.onosproject.net.Port;
36 import org.onosproject.net.PortNumber; 38 import org.onosproject.net.PortNumber;
37 import org.onosproject.net.behaviour.NextGroup; 39 import org.onosproject.net.behaviour.NextGroup;
40 +import org.onosproject.net.behaviour.PipelinerContext;
41 +import org.onosproject.net.device.DeviceService;
38 import org.onosproject.net.flow.DefaultFlowRule; 42 import org.onosproject.net.flow.DefaultFlowRule;
39 import org.onosproject.net.flow.DefaultTrafficSelector; 43 import org.onosproject.net.flow.DefaultTrafficSelector;
40 import org.onosproject.net.flow.DefaultTrafficTreatment; 44 import org.onosproject.net.flow.DefaultTrafficTreatment;
41 import org.onosproject.net.flow.FlowRule; 45 import org.onosproject.net.flow.FlowRule;
42 import org.onosproject.net.flow.FlowRuleOperations; 46 import org.onosproject.net.flow.FlowRuleOperations;
43 import org.onosproject.net.flow.FlowRuleOperationsContext; 47 import org.onosproject.net.flow.FlowRuleOperationsContext;
48 +import org.onosproject.net.flow.FlowRuleService;
44 import org.onosproject.net.flow.TrafficSelector; 49 import org.onosproject.net.flow.TrafficSelector;
45 import org.onosproject.net.flow.TrafficTreatment; 50 import org.onosproject.net.flow.TrafficTreatment;
46 import org.onosproject.net.flow.criteria.Criteria; 51 import org.onosproject.net.flow.criteria.Criteria;
...@@ -60,6 +65,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective; ...@@ -60,6 +65,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
60 import org.onosproject.net.flowobjective.ObjectiveError; 65 import org.onosproject.net.flowobjective.ObjectiveError;
61 import org.onosproject.net.group.Group; 66 import org.onosproject.net.group.Group;
62 import org.onosproject.net.group.GroupKey; 67 import org.onosproject.net.group.GroupKey;
68 +import org.onosproject.net.group.GroupService;
63 import org.slf4j.Logger; 69 import org.slf4j.Logger;
64 70
65 71
...@@ -75,6 +81,27 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline { ...@@ -75,6 +81,27 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
75 81
76 private final Logger log = getLogger(getClass()); 82 private final Logger log = getLogger(getClass());
77 83
84 + @Override
85 + public void init(DeviceId deviceId, PipelinerContext context) {
86 + this.deviceId = deviceId;
87 +
88 + // Initialize OFDPA group handler
89 + groupHandler = new CpqdOfdpa2GroupHandler();
90 + groupHandler.init(deviceId, context);
91 +
92 + serviceDirectory = context.directory();
93 + coreService = serviceDirectory.get(CoreService.class);
94 + flowRuleService = serviceDirectory.get(FlowRuleService.class);
95 + groupService = serviceDirectory.get(GroupService.class);
96 + flowObjectiveStore = context.store();
97 + deviceService = serviceDirectory.get(DeviceService.class);
98 +
99 + driverId = coreService.registerApplication(
100 + "org.onosproject.driver.CpqdOfdpa2Pipeline");
101 +
102 + initializePipeline();
103 + }
104 +
78 /* 105 /*
79 * CPQD emulation does not require special untagged packet handling, unlike 106 * CPQD emulation does not require special untagged packet handling, unlike
80 * the real ofdpa. 107 * the real ofdpa.
...@@ -253,13 +280,13 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline { ...@@ -253,13 +280,13 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
253 280
254 for (PortNumber pnum : portnums) { 281 for (PortNumber pnum : portnums) {
255 // update storage 282 // update storage
256 - ofdpa2GroupHandler.port2Vlan.put(pnum, storeVlan); 283 + groupHandler.port2Vlan.put(pnum, storeVlan);
257 - Set<PortNumber> vlanPorts = ofdpa2GroupHandler.vlan2Port.get(storeVlan); 284 + Set<PortNumber> vlanPorts = groupHandler.vlan2Port.get(storeVlan);
258 if (vlanPorts == null) { 285 if (vlanPorts == null) {
259 vlanPorts = Collections.newSetFromMap( 286 vlanPorts = Collections.newSetFromMap(
260 new ConcurrentHashMap<PortNumber, Boolean>()); 287 new ConcurrentHashMap<PortNumber, Boolean>());
261 vlanPorts.add(pnum); 288 vlanPorts.add(pnum);
262 - ofdpa2GroupHandler.vlan2Port.put(storeVlan, vlanPorts); 289 + groupHandler.vlan2Port.put(storeVlan, vlanPorts);
263 } else { 290 } else {
264 vlanPorts.add(pnum); 291 vlanPorts.add(pnum);
265 } 292 }
......
...@@ -25,13 +25,18 @@ import java.util.List; ...@@ -25,13 +25,18 @@ import java.util.List;
25 import org.onlab.packet.Ethernet; 25 import org.onlab.packet.Ethernet;
26 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
27 import org.onosproject.core.ApplicationId; 27 import org.onosproject.core.ApplicationId;
28 +import org.onosproject.core.CoreService;
29 +import org.onosproject.net.DeviceId;
28 import org.onosproject.net.Port; 30 import org.onosproject.net.Port;
29 import org.onosproject.net.PortNumber; 31 import org.onosproject.net.PortNumber;
30 import org.onosproject.net.behaviour.NextGroup; 32 import org.onosproject.net.behaviour.NextGroup;
33 +import org.onosproject.net.behaviour.PipelinerContext;
34 +import org.onosproject.net.device.DeviceService;
31 import org.onosproject.net.flow.DefaultFlowRule; 35 import org.onosproject.net.flow.DefaultFlowRule;
32 import org.onosproject.net.flow.DefaultTrafficSelector; 36 import org.onosproject.net.flow.DefaultTrafficSelector;
33 import org.onosproject.net.flow.DefaultTrafficTreatment; 37 import org.onosproject.net.flow.DefaultTrafficTreatment;
34 import org.onosproject.net.flow.FlowRule; 38 import org.onosproject.net.flow.FlowRule;
39 +import org.onosproject.net.flow.FlowRuleService;
35 import org.onosproject.net.flow.TrafficSelector; 40 import org.onosproject.net.flow.TrafficSelector;
36 import org.onosproject.net.flow.TrafficTreatment; 41 import org.onosproject.net.flow.TrafficTreatment;
37 import org.onosproject.net.flow.criteria.Criteria; 42 import org.onosproject.net.flow.criteria.Criteria;
...@@ -46,6 +51,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective; ...@@ -46,6 +51,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
46 import org.onosproject.net.flowobjective.ObjectiveError; 51 import org.onosproject.net.flowobjective.ObjectiveError;
47 import org.onosproject.net.group.Group; 52 import org.onosproject.net.group.Group;
48 import org.onosproject.net.group.GroupKey; 53 import org.onosproject.net.group.GroupKey;
54 +import org.onosproject.net.group.GroupService;
49 import org.slf4j.Logger; 55 import org.slf4j.Logger;
50 56
51 57
...@@ -63,6 +69,27 @@ public class CpqdOfdpa2VlanPipeline extends CpqdOfdpa2Pipeline { ...@@ -63,6 +69,27 @@ public class CpqdOfdpa2VlanPipeline extends CpqdOfdpa2Pipeline {
63 69
64 private final Logger log = getLogger(getClass()); 70 private final Logger log = getLogger(getClass());
65 71
72 + @Override
73 + public void init(DeviceId deviceId, PipelinerContext context) {
74 + this.deviceId = deviceId;
75 +
76 + // Initialize OFDPA group handler
77 + groupHandler = new CpqdOfdpa2GroupHandler();
78 + groupHandler.init(deviceId, context);
79 +
80 + serviceDirectory = context.directory();
81 + coreService = serviceDirectory.get(CoreService.class);
82 + flowRuleService = serviceDirectory.get(FlowRuleService.class);
83 + groupService = serviceDirectory.get(GroupService.class);
84 + flowObjectiveStore = context.store();
85 + deviceService = serviceDirectory.get(DeviceService.class);
86 +
87 + driverId = coreService.registerApplication(
88 + "org.onosproject.driver.CpqdOfdpa2VlanPipeline");
89 +
90 + initializePipeline();
91 + }
92 +
66 /* 93 /*
67 * Cpqd emulation does not handle vlan tags and mpls labels correctly. 94 * Cpqd emulation does not handle vlan tags and mpls labels correctly.
68 * Since this driver does not deal with MPLS, there is no need for 95 * Since this driver does not deal with MPLS, there is no need for
......
...@@ -92,28 +92,28 @@ public class Ofdpa2GroupHandler { ...@@ -92,28 +92,28 @@ public class Ofdpa2GroupHandler {
92 * L2 Flood Groups have <4bits-4><12bits-vlanid><16bits-index> 92 * L2 Flood Groups have <4bits-4><12bits-vlanid><16bits-index>
93 * L3 VPN Groups have <4bits-9><4bits-2><24bits-index> 93 * L3 VPN Groups have <4bits-9><4bits-2><24bits-index>
94 */ 94 */
95 - private static final int L2_INTERFACE_TYPE = 0x00000000; 95 + protected static final int L2_INTERFACE_TYPE = 0x00000000;
96 - private static final int L3_INTERFACE_TYPE = 0x50000000; 96 + protected static final int L3_INTERFACE_TYPE = 0x50000000;
97 - private static final int L3_UNICAST_TYPE = 0x20000000; 97 + protected static final int L3_UNICAST_TYPE = 0x20000000;
98 - private static final int L3_MULTICAST_TYPE = 0x60000000; 98 + protected static final int L3_MULTICAST_TYPE = 0x60000000;
99 - private static final int MPLS_INTERFACE_TYPE = 0x90000000; 99 + protected static final int MPLS_INTERFACE_TYPE = 0x90000000;
100 - private static final int MPLS_L3VPN_SUBTYPE = 0x92000000; 100 + protected static final int MPLS_L3VPN_SUBTYPE = 0x92000000;
101 - private static final int L3_ECMP_TYPE = 0x70000000; 101 + protected static final int L3_ECMP_TYPE = 0x70000000;
102 - private static final int L2_FLOOD_TYPE = 0x40000000; 102 + protected static final int L2_FLOOD_TYPE = 0x40000000;
103 - 103 +
104 - private static final int TYPE_MASK = 0x0fffffff; 104 + protected static final int TYPE_MASK = 0x0fffffff;
105 - private static final int SUBTYPE_MASK = 0x00ffffff; 105 + protected static final int SUBTYPE_MASK = 0x00ffffff;
106 - private static final int TYPE_VLAN_MASK = 0x0000ffff; 106 + protected static final int TYPE_VLAN_MASK = 0x0000ffff;
107 - 107 +
108 - private static final int PORT_LOWER_BITS_MASK = 0x3f; 108 + protected static final int PORT_LOWER_BITS_MASK = 0x3f;
109 - private static final long PORT_HIGHER_BITS_MASK = ~PORT_LOWER_BITS_MASK; 109 + protected static final long PORT_HIGHER_BITS_MASK = ~PORT_LOWER_BITS_MASK;
110 110
111 private final Logger log = getLogger(getClass()); 111 private final Logger log = getLogger(getClass());
112 private ServiceDirectory serviceDirectory; 112 private ServiceDirectory serviceDirectory;
113 protected GroupService groupService; 113 protected GroupService groupService;
114 protected StorageService storageService; 114 protected StorageService storageService;
115 115
116 - private DeviceId deviceId; 116 + protected DeviceId deviceId;
117 private FlowObjectiveStore flowObjectiveStore; 117 private FlowObjectiveStore flowObjectiveStore;
118 private Cache<GroupKey, List<OfdpaNextGroup>> pendingNextObjectives; 118 private Cache<GroupKey, List<OfdpaNextGroup>> pendingNextObjectives;
119 private ConcurrentHashMap<GroupKey, Set<GroupChainElem>> pendingGroups; 119 private ConcurrentHashMap<GroupKey, Set<GroupChainElem>> pendingGroups;
...@@ -282,8 +282,8 @@ public class Ofdpa2GroupHandler { ...@@ -282,8 +282,8 @@ public class Ofdpa2GroupHandler {
282 /** 282 /**
283 * Creates one of two possible group-chains from the treatment 283 * Creates one of two possible group-chains from the treatment
284 * passed in. Depending on the MPLS boolean, this method either creates 284 * passed in. Depending on the MPLS boolean, this method either creates
285 - * an L3Unicast Group --> L2Interface Group, if mpls is false; 285 + * an L3Unicast Group --&gt; L2Interface Group, if mpls is false;
286 - * or MPLSInterface Group --> L2Interface Group, if mpls is true; 286 + * or MPLSInterface Group --&gt; L2Interface Group, if mpls is true;
287 * The returned 'inner' group description is always the L2 Interface group. 287 * The returned 'inner' group description is always the L2 Interface group.
288 * 288 *
289 * @param treatment that needs to be broken up to create the group chain 289 * @param treatment that needs to be broken up to create the group chain
...@@ -296,7 +296,7 @@ public class Ofdpa2GroupHandler { ...@@ -296,7 +296,7 @@ public class Ofdpa2GroupHandler {
296 * L3Unicast/MPLSInterface group. May return null if there is an 296 * L3Unicast/MPLSInterface group. May return null if there is an
297 * error in processing the chain 297 * error in processing the chain
298 */ 298 */
299 - private GroupInfo createL2L3Chain(TrafficTreatment treatment, int nextId, 299 + protected GroupInfo createL2L3Chain(TrafficTreatment treatment, int nextId,
300 ApplicationId appId, boolean mpls, 300 ApplicationId appId, boolean mpls,
301 TrafficSelector meta) { 301 TrafficSelector meta) {
302 // for the l2interface group, get vlan and port info 302 // for the l2interface group, get vlan and port info
...@@ -1039,7 +1039,7 @@ public class Ofdpa2GroupHandler { ...@@ -1039,7 +1039,7 @@ public class Ofdpa2GroupHandler {
1039 } 1039 }
1040 } 1040 }
1041 1041
1042 - private void updatePendingGroups(GroupKey gkey, GroupChainElem gce) { 1042 + protected void updatePendingGroups(GroupKey gkey, GroupChainElem gce) {
1043 Set<GroupChainElem> gceSet = Collections.newSetFromMap( 1043 Set<GroupChainElem> gceSet = Collections.newSetFromMap(
1044 new ConcurrentHashMap<GroupChainElem, Boolean>()); 1044 new ConcurrentHashMap<GroupChainElem, Boolean>());
1045 gceSet.add(gce); 1045 gceSet.add(gce);
...@@ -1145,7 +1145,7 @@ public class Ofdpa2GroupHandler { ...@@ -1145,7 +1145,7 @@ public class Ofdpa2GroupHandler {
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 - private int getNextAvailableIndex() { 1148 + protected int getNextAvailableIndex() {
1149 return (int) nextIndex.incrementAndGet(); 1149 return (int) nextIndex.incrementAndGet();
1150 } 1150 }
1151 1151
...@@ -1160,7 +1160,7 @@ public class Ofdpa2GroupHandler { ...@@ -1160,7 +1160,7 @@ public class Ofdpa2GroupHandler {
1160 * @param portNumber Port number 1160 * @param portNumber Port number
1161 * @return L2 interface group key 1161 * @return L2 interface group key
1162 */ 1162 */
1163 - private int l2InterfaceGroupKey( 1163 + protected int l2InterfaceGroupKey(
1164 DeviceId deviceId, VlanId vlanId, long portNumber) { 1164 DeviceId deviceId, VlanId vlanId, long portNumber) {
1165 int portLowerBits = (int) portNumber & PORT_LOWER_BITS_MASK; 1165 int portLowerBits = (int) portNumber & PORT_LOWER_BITS_MASK;
1166 long portHigherBits = portNumber & PORT_HIGHER_BITS_MASK; 1166 long portHigherBits = portNumber & PORT_HIGHER_BITS_MASK;
...@@ -1171,7 +1171,7 @@ public class Ofdpa2GroupHandler { ...@@ -1171,7 +1171,7 @@ public class Ofdpa2GroupHandler {
1171 /** 1171 /**
1172 * Utility class for moving group information around. 1172 * Utility class for moving group information around.
1173 */ 1173 */
1174 - private class GroupInfo { 1174 + protected class GroupInfo {
1175 /** 1175 /**
1176 * Description of the inner-most group of the group chain. 1176 * Description of the inner-most group of the group chain.
1177 * It is always an L2 interface group. 1177 * It is always an L2 interface group.
...@@ -1240,7 +1240,7 @@ public class Ofdpa2GroupHandler { ...@@ -1240,7 +1240,7 @@ public class Ofdpa2GroupHandler {
1240 * class are meant to be temporary and live as long as it is needed to wait for 1240 * class are meant to be temporary and live as long as it is needed to wait for
1241 * preceding groups in the group chain to be created. 1241 * preceding groups in the group chain to be created.
1242 */ 1242 */
1243 - private class GroupChainElem { 1243 + protected class GroupChainElem {
1244 private GroupDescription groupDescription; 1244 private GroupDescription groupDescription;
1245 private AtomicInteger waitOnGroups; 1245 private AtomicInteger waitOnGroups;
1246 private boolean addBucketToGroup; 1246 private boolean addBucketToGroup;
......
...@@ -108,9 +108,9 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -108,9 +108,9 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
108 protected static final int LOWEST_PRIORITY = 0x0; 108 protected static final int LOWEST_PRIORITY = 0x0;
109 109
110 private final Logger log = getLogger(getClass()); 110 private final Logger log = getLogger(getClass());
111 - private ServiceDirectory serviceDirectory; 111 + protected ServiceDirectory serviceDirectory;
112 protected FlowRuleService flowRuleService; 112 protected FlowRuleService flowRuleService;
113 - private CoreService coreService; 113 + protected CoreService coreService;
114 protected GroupService groupService; 114 protected GroupService groupService;
115 protected FlowObjectiveStore flowObjectiveStore; 115 protected FlowObjectiveStore flowObjectiveStore;
116 protected DeviceId deviceId; 116 protected DeviceId deviceId;
...@@ -125,20 +125,20 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -125,20 +125,20 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
125 .register(ArrayDeque.class) 125 .register(ArrayDeque.class)
126 .build(); 126 .build();
127 127
128 - protected Ofdpa2GroupHandler ofdpa2GroupHandler; 128 + protected Ofdpa2GroupHandler groupHandler;
129 129
130 protected Set<IPCriterion> sentIpFilters = Collections.newSetFromMap( 130 protected Set<IPCriterion> sentIpFilters = Collections.newSetFromMap(
131 new ConcurrentHashMap<>()); 131 new ConcurrentHashMap<>());
132 132
133 @Override 133 @Override
134 public void init(DeviceId deviceId, PipelinerContext context) { 134 public void init(DeviceId deviceId, PipelinerContext context) {
135 - this.serviceDirectory = context.directory();
136 this.deviceId = deviceId; 135 this.deviceId = deviceId;
137 136
138 // Initialize OFDPA group handler 137 // Initialize OFDPA group handler
139 - ofdpa2GroupHandler = new Ofdpa2GroupHandler(); 138 + groupHandler = new Ofdpa2GroupHandler();
140 - ofdpa2GroupHandler.init(deviceId, context); 139 + groupHandler.init(deviceId, context);
141 140
141 + serviceDirectory = context.directory();
142 coreService = serviceDirectory.get(CoreService.class); 142 coreService = serviceDirectory.get(CoreService.class);
143 flowRuleService = serviceDirectory.get(FlowRuleService.class); 143 flowRuleService = serviceDirectory.get(FlowRuleService.class);
144 groupService = serviceDirectory.get(GroupService.class); 144 groupService = serviceDirectory.get(GroupService.class);
...@@ -146,7 +146,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -146,7 +146,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
146 deviceService = serviceDirectory.get(DeviceService.class); 146 deviceService = serviceDirectory.get(DeviceService.class);
147 147
148 driverId = coreService.registerApplication( 148 driverId = coreService.registerApplication(
149 - "org.onosproject.driver.OFDPA2Pipeline"); 149 + "org.onosproject.driver.Ofdpa2Pipeline");
150 150
151 initializePipeline(); 151 initializePipeline();
152 } 152 }
...@@ -224,19 +224,19 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -224,19 +224,19 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
224 } 224 }
225 log.debug("Processing NextObjective id{} in dev{} - add group", 225 log.debug("Processing NextObjective id{} in dev{} - add group",
226 nextObjective.id(), deviceId); 226 nextObjective.id(), deviceId);
227 - ofdpa2GroupHandler.addGroup(nextObjective); 227 + groupHandler.addGroup(nextObjective);
228 break; 228 break;
229 case ADD_TO_EXISTING: 229 case ADD_TO_EXISTING:
230 if (nextGroup != null) { 230 if (nextGroup != null) {
231 log.debug("Processing NextObjective id{} in dev{} - add bucket", 231 log.debug("Processing NextObjective id{} in dev{} - add bucket",
232 nextObjective.id(), deviceId); 232 nextObjective.id(), deviceId);
233 - ofdpa2GroupHandler.addBucketToGroup(nextObjective, nextGroup); 233 + groupHandler.addBucketToGroup(nextObjective, nextGroup);
234 } else { 234 } else {
235 // it is possible that group-chain has not been fully created yet 235 // it is possible that group-chain has not been fully created yet
236 log.debug("Waiting to add bucket to group for next-id:{} in dev:{}", 236 log.debug("Waiting to add bucket to group for next-id:{} in dev:{}",
237 nextObjective.id(), deviceId); 237 nextObjective.id(), deviceId);
238 // by design only one pending bucket is allowed for the group 238 // by design only one pending bucket is allowed for the group
239 - ofdpa2GroupHandler.pendingBuckets.put(nextObjective.id(), nextObjective); 239 + groupHandler.pendingBuckets.put(nextObjective.id(), nextObjective);
240 } 240 }
241 break; 241 break;
242 case REMOVE: 242 case REMOVE:
...@@ -247,7 +247,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -247,7 +247,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
247 } 247 }
248 log.debug("Processing NextObjective id{} in dev{} - remove group", 248 log.debug("Processing NextObjective id{} in dev{} - remove group",
249 nextObjective.id(), deviceId); 249 nextObjective.id(), deviceId);
250 - ofdpa2GroupHandler.removeGroup(nextObjective, nextGroup); 250 + groupHandler.removeGroup(nextObjective, nextGroup);
251 break; 251 break;
252 case REMOVE_FROM_EXISTING: 252 case REMOVE_FROM_EXISTING:
253 if (nextGroup == null) { 253 if (nextGroup == null) {
...@@ -257,7 +257,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -257,7 +257,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
257 } 257 }
258 log.debug("Processing NextObjective id{} in dev{} - remove bucket", 258 log.debug("Processing NextObjective id{} in dev{} - remove bucket",
259 nextObjective.id(), deviceId); 259 nextObjective.id(), deviceId);
260 - ofdpa2GroupHandler.removeBucketFromGroup(nextObjective, nextGroup); 260 + groupHandler.removeBucketFromGroup(nextObjective, nextGroup);
261 break; 261 break;
262 default: 262 default:
263 log.warn("Unsupported operation {}", nextObjective.op()); 263 log.warn("Unsupported operation {}", nextObjective.op());
...@@ -500,13 +500,13 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -500,13 +500,13 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
500 500
501 for (PortNumber pnum : portnums) { 501 for (PortNumber pnum : portnums) {
502 // update storage 502 // update storage
503 - ofdpa2GroupHandler.port2Vlan.put(pnum, storeVlan); 503 + groupHandler.port2Vlan.put(pnum, storeVlan);
504 - Set<PortNumber> vlanPorts = ofdpa2GroupHandler.vlan2Port.get(storeVlan); 504 + Set<PortNumber> vlanPorts = groupHandler.vlan2Port.get(storeVlan);
505 if (vlanPorts == null) { 505 if (vlanPorts == null) {
506 vlanPorts = Collections.newSetFromMap( 506 vlanPorts = Collections.newSetFromMap(
507 new ConcurrentHashMap<PortNumber, Boolean>()); 507 new ConcurrentHashMap<PortNumber, Boolean>());
508 vlanPorts.add(pnum); 508 vlanPorts.add(pnum);
509 - ofdpa2GroupHandler.vlan2Port.put(storeVlan, vlanPorts); 509 + groupHandler.vlan2Port.put(storeVlan, vlanPorts);
510 } else { 510 } else {
511 vlanPorts.add(pnum); 511 vlanPorts.add(pnum);
512 } 512 }
......