blob: 9e1b95a158edc6769b3c12e39b6192341941fb1d [file] [log] [blame]
Saurav Dasf710bd32014-09-25 16:56:00 -07001package net.floodlightcontroller.core;
2
Saurav Dasfc5e3eb2014-09-25 19:05:21 -07003import java.io.IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -07004import java.util.Collection;
5import java.util.HashSet;
6import java.util.Set;
7
8import net.onrc.onos.core.matchaction.MatchActionOperationEntry;
9import net.onrc.onos.core.util.Dpid;
10
11import com.google.common.primitives.Longs;
12
13
14public interface IOF13Switch extends IOFSwitch {
15
16 // **************************
17 // Flow related
18 // **************************
19
20 /**
21 * Pushes a single flow to the switch as described by the match-action
22 * operation and match-action definition, and subject to the TTP supported
23 * by a switch implementing this interface. It is up to the implementation
24 * to translate the 'matchActionOp' into a match-instruction with actions,
Saurav Das0a344b02014-09-26 14:18:52 -070025 * as expected by OF 1.3 switches. For better performance, use
26 * {@link pushFlows}
27 *
28 * @param matchActionOp information required to create a flow-mod and push
29 * it to the switch
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070030 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070031 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070032 public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070033
34 /**
Saurav Das0a344b02014-09-26 14:18:52 -070035 * Pushes a collection of flows to the switch, at the same time. Can result
36 * in better performance, when compared to sending flows one at a time using
37 * {@link pushFlow}, especially if the number of flows is large.
Saurav Dasd84178f2014-09-29 17:48:54 -070038 *
Saurav Das0a344b02014-09-26 14:18:52 -070039 * @param matchActionOps a collection of information required to create a
40 * flowmod
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070041 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070042 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070043 public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps)
44 throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070045
Saurav Dasd84178f2014-09-29 17:48:54 -070046
Saurav Dasf710bd32014-09-25 16:56:00 -070047 // ****************************
48 // Group related
49 // ****************************
50
51 /**
52 * Representation of a set of neighbor switch dpids. Meant to be used as a
53 * lookup-key in a hash-map to retrieve an ECMP-group that hashes packets to
54 * a set of ports connecting to the neighbors in this set.
55 */
56 public class NeighborSet {
57 Set<Dpid> dpids;
58
59 /**
60 * Constructor
61 *
62 * @param dpids A variable number of Dpids represention neighbor
63 * switches
64 */
65 public NeighborSet(Dpid... dpids) {
66 this.dpids = new HashSet<Dpid>();
67 for (Dpid d : dpids) {
68 this.dpids.add(d);
69 }
70 }
71
72 public void addDpid(Dpid d) {
73 dpids.add(d);
74 }
75
76 @Override
77 public boolean equals(Object o) {
78 if (!(o instanceof NeighborSet)) {
79 return false;
80 }
81 NeighborSet that = (NeighborSet) o;
82 return this.dpids.equals(that.dpids);
83 }
84
85 @Override
86 public int hashCode() {
87 int result = 17;
88 for (Dpid d : dpids) {
89 result = 31 * result + Longs.hashCode(d.value());
90 }
91 return result;
92 }
93
94 @Override
95 public String toString() {
96 return " Sw: {} Neighbors: " + dpids;
97 }
98 }
99
100 /**
101 * Get the ECMP group-id for the ECMP group in this switch that includes
102 * ports that connect to the neighbor-switches included in the NeighborSet
103 * 'ns'
104 *
105 * @param ns the set of Neighbor Dpids
106 * @return the ecmp group id, or -1 if no such group exists
107 */
108 public int getEcmpGroupId(NeighborSet ns);
109
110
111}