blob: 6cb5b15a662dfbe0b912b39f36e66a3d5f79a14b [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 /**
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070053 * Representation of a set of neighbor switch dpids along with edge node
54 * label. Meant to be used as a lookup-key in a hash-map to retrieve an
55 * ECMP-group that hashes packets to a set of ports connecting to the
56 * neighbors in this set.
Saurav Dasf710bd32014-09-25 16:56:00 -070057 */
58 public class NeighborSet {
59 Set<Dpid> dpids;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070060 int edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -070061
62 /**
63 * Constructor
64 *
65 * @param dpids A variable number of Dpids represention neighbor
66 * switches
67 */
68 public NeighborSet(Dpid... dpids) {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070069 this.edgeLabel = -1;
Saurav Dasf710bd32014-09-25 16:56:00 -070070 this.dpids = new HashSet<Dpid>();
71 for (Dpid d : dpids) {
72 this.dpids.add(d);
73 }
74 }
75
76 public void addDpid(Dpid d) {
77 dpids.add(d);
78 }
79
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070080 public void addDpids(Set<Dpid> d) {
81 dpids.addAll(d);
82 }
83
84 public void setEdgeLabel(int edgeLabel) {
85 this.edgeLabel = edgeLabel;
86 }
87
88 public Set<Dpid> getDpids() {
89 return dpids;
90 }
91
92 public int getEdgeLabel() {
93 return edgeLabel;
94 }
95
Saurav Dasf710bd32014-09-25 16:56:00 -070096 @Override
97 public boolean equals(Object o) {
98 if (!(o instanceof NeighborSet)) {
99 return false;
100 }
101 NeighborSet that = (NeighborSet) o;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700102 return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel));
Saurav Dasf710bd32014-09-25 16:56:00 -0700103 }
104
105 @Override
106 public int hashCode() {
107 int result = 17;
108 for (Dpid d : dpids) {
109 result = 31 * result + Longs.hashCode(d.value());
110 }
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700111 result = 31 * result + Longs.hashCode(edgeLabel);
Saurav Dasf710bd32014-09-25 16:56:00 -0700112 return result;
113 }
114
115 @Override
116 public String toString() {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700117 return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -0700118 }
119 }
120
121 /**
122 * Get the ECMP group-id for the ECMP group in this switch that includes
123 * ports that connect to the neighbor-switches included in the NeighborSet
124 * 'ns'
125 *
126 * @param ns the set of Neighbor Dpids
127 * @return the ecmp group id, or -1 if no such group exists
128 */
129 public int getEcmpGroupId(NeighborSet ns);
130
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -0700131 public void removePortFromGroups(PortNumber port);
132
133 public void addPortToGroups(PortNumber port);
Saurav Dasf710bd32014-09-25 16:56:00 -0700134
135}