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