blob: 6ad24ec48e1637a239cbd83c629ade766afddcef [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.
38 *
39 * @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
46 // ****************************
47 // Group related
48 // ****************************
49
50 /**
51 * Representation of a set of neighbor switch dpids. Meant to be used as a
52 * lookup-key in a hash-map to retrieve an ECMP-group that hashes packets to
53 * a set of ports connecting to the neighbors in this set.
54 */
55 public class NeighborSet {
56 Set<Dpid> dpids;
57
58 /**
59 * Constructor
60 *
61 * @param dpids A variable number of Dpids represention neighbor
62 * switches
63 */
64 public NeighborSet(Dpid... dpids) {
65 this.dpids = new HashSet<Dpid>();
66 for (Dpid d : dpids) {
67 this.dpids.add(d);
68 }
69 }
70
71 public void addDpid(Dpid d) {
72 dpids.add(d);
73 }
74
75 @Override
76 public boolean equals(Object o) {
77 if (!(o instanceof NeighborSet)) {
78 return false;
79 }
80 NeighborSet that = (NeighborSet) o;
81 return this.dpids.equals(that.dpids);
82 }
83
84 @Override
85 public int hashCode() {
86 int result = 17;
87 for (Dpid d : dpids) {
88 result = 31 * result + Longs.hashCode(d.value());
89 }
90 return result;
91 }
92
93 @Override
94 public String toString() {
95 return " Sw: {} Neighbors: " + dpids;
96 }
97 }
98
99 /**
100 * Get the ECMP group-id for the ECMP group in this switch that includes
101 * ports that connect to the neighbor-switches included in the NeighborSet
102 * 'ns'
103 *
104 * @param ns the set of Neighbor Dpids
105 * @return the ecmp group id, or -1 if no such group exists
106 */
107 public int getEcmpGroupId(NeighborSet ns);
108
109
110}