Showing
1 changed file
with
88 additions
and
0 deletions
1 | package org.onlab.onos.of.drivers.impl; | 1 | package org.onlab.onos.of.drivers.impl; |
2 | 2 | ||
3 | +import java.io.IOException; | ||
4 | +import java.util.ArrayList; | ||
3 | import java.util.Collections; | 5 | import java.util.Collections; |
4 | import java.util.List; | 6 | import java.util.List; |
5 | import java.util.concurrent.atomic.AtomicBoolean; | 7 | import java.util.concurrent.atomic.AtomicBoolean; |
... | @@ -12,7 +14,14 @@ import org.onlab.onos.of.controller.driver.SwitchDriverSubHandshakeNotStarted; | ... | @@ -12,7 +14,14 @@ import org.onlab.onos.of.controller.driver.SwitchDriverSubHandshakeNotStarted; |
12 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; | 14 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; |
13 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; | 15 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
14 | import org.projectfloodlight.openflow.protocol.OFFactory; | 16 | import org.projectfloodlight.openflow.protocol.OFFactory; |
17 | +import org.projectfloodlight.openflow.protocol.OFMatchV3; | ||
15 | import org.projectfloodlight.openflow.protocol.OFMessage; | 18 | import org.projectfloodlight.openflow.protocol.OFMessage; |
19 | +import org.projectfloodlight.openflow.protocol.OFOxmList; | ||
20 | +import org.projectfloodlight.openflow.protocol.action.OFAction; | ||
21 | +import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ||
22 | +import org.projectfloodlight.openflow.types.OFBufferId; | ||
23 | +import org.projectfloodlight.openflow.types.OFPort; | ||
24 | +import org.projectfloodlight.openflow.types.TableId; | ||
16 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
17 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
18 | 27 | ||
... | @@ -30,6 +39,9 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { | ... | @@ -30,6 +39,9 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { |
30 | private OFFactory factory; | 39 | private OFFactory factory; |
31 | private long barrierXidToWaitFor = -1; | 40 | private long barrierXidToWaitFor = -1; |
32 | 41 | ||
42 | + private static final short MIN_PRIORITY = 0x0; | ||
43 | + private static final int OFPCML_NO_BUFFER = 0xffff; | ||
44 | + | ||
33 | public OFSwitchImplOVS13(Dpid dpid, OFDescStatsReply desc) { | 45 | public OFSwitchImplOVS13(Dpid dpid, OFDescStatsReply desc) { |
34 | super(dpid); | 46 | super(dpid); |
35 | driverHandshakeComplete = new AtomicBoolean(false); | 47 | driverHandshakeComplete = new AtomicBoolean(false); |
... | @@ -113,6 +125,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { | ... | @@ -113,6 +125,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { |
113 | 125 | ||
114 | 126 | ||
115 | private void configureSwitch() { | 127 | private void configureSwitch() { |
128 | + populateTableMissEntry(0, true, false, false, 0); | ||
116 | sendBarrier(true); | 129 | sendBarrier(true); |
117 | } | 130 | } |
118 | 131 | ||
... | @@ -144,4 +157,79 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { | ... | @@ -144,4 +157,79 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { |
144 | public void write(List<OFMessage> msgs) { | 157 | public void write(List<OFMessage> msgs) { |
145 | channel.write(msgs); | 158 | channel.write(msgs); |
146 | } | 159 | } |
160 | + | ||
161 | + /** | ||
162 | + * By default if none of the booleans in the call are set, then the | ||
163 | + * table-miss entry is added with no instructions, which means that pipeline | ||
164 | + * execution will stop, and the action set associated with the packet will | ||
165 | + * be executed. | ||
166 | + * | ||
167 | + * @param tableToAdd | ||
168 | + * @param toControllerNow as an APPLY_ACTION instruction | ||
169 | + * @param toControllerWrite as a WRITE_ACITION instruction | ||
170 | + * @param toTable as a GOTO_TABLE instruction | ||
171 | + * @param tableToSend | ||
172 | + * @throws IOException | ||
173 | + */ | ||
174 | + @SuppressWarnings("unchecked") | ||
175 | + private void populateTableMissEntry(int tableToAdd, boolean toControllerNow, | ||
176 | + boolean toControllerWrite, | ||
177 | + boolean toTable, int tableToSend) { | ||
178 | + OFOxmList oxmList = OFOxmList.EMPTY; | ||
179 | + OFMatchV3 match = factory.buildMatchV3() | ||
180 | + .setOxmList(oxmList) | ||
181 | + .build(); | ||
182 | + OFAction outc = factory.actions() | ||
183 | + .buildOutput() | ||
184 | + .setPort(OFPort.CONTROLLER) | ||
185 | + .setMaxLen(OFPCML_NO_BUFFER) | ||
186 | + .build(); | ||
187 | + List<OFInstruction> instructions = new ArrayList<OFInstruction>(); | ||
188 | + if (toControllerNow) { | ||
189 | + // table-miss instruction to send to controller immediately | ||
190 | + OFInstruction instr = factory.instructions() | ||
191 | + .buildApplyActions() | ||
192 | + .setActions(Collections.singletonList(outc)) | ||
193 | + .build(); | ||
194 | + instructions.add(instr); | ||
195 | + } | ||
196 | + | ||
197 | + if (toControllerWrite) { | ||
198 | + // table-miss instruction to write-action to send to controller | ||
199 | + // this will be executed whenever the action-set gets executed | ||
200 | + OFInstruction instr = factory.instructions() | ||
201 | + .buildWriteActions() | ||
202 | + .setActions(Collections.singletonList(outc)) | ||
203 | + .build(); | ||
204 | + instructions.add(instr); | ||
205 | + } | ||
206 | + | ||
207 | + if (toTable) { | ||
208 | + // table-miss instruction to goto-table x | ||
209 | + OFInstruction instr = factory.instructions() | ||
210 | + .gotoTable(TableId.of(tableToSend)); | ||
211 | + instructions.add(instr); | ||
212 | + } | ||
213 | + | ||
214 | + if (!toControllerNow && !toControllerWrite && !toTable) { | ||
215 | + // table-miss has no instruction - at which point action-set will be | ||
216 | + // executed - if there is an action to output/group in the action | ||
217 | + // set | ||
218 | + // the packet will be sent there, otherwise it will be dropped. | ||
219 | + instructions = Collections.EMPTY_LIST; | ||
220 | + } | ||
221 | + | ||
222 | + OFMessage tableMissEntry = factory.buildFlowAdd() | ||
223 | + .setTableId(TableId.of(tableToAdd)) | ||
224 | + .setMatch(match) // match everything | ||
225 | + .setInstructions(instructions) | ||
226 | + .setPriority(MIN_PRIORITY) | ||
227 | + .setBufferId(OFBufferId.NO_BUFFER) | ||
228 | + .setIdleTimeout(0) | ||
229 | + .setHardTimeout(0) | ||
230 | + .setXid(getNextTransactionId()) | ||
231 | + .build(); | ||
232 | + sendMsg(tableMissEntry); | ||
233 | + } | ||
234 | + | ||
147 | } | 235 | } | ... | ... |
-
Please register or login to post a comment