blob: 53f90f3851f9753cd5657412049486fd9852c04e [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
Fahad Naeem Khand563af62014-10-08 17:37:25 -07008import org.projectfloodlight.openflow.types.TableId;
9
Saurav Dasf710bd32014-09-25 16:56:00 -070010import net.onrc.onos.core.matchaction.MatchActionOperationEntry;
11import net.onrc.onos.core.util.Dpid;
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -070012import net.onrc.onos.core.util.PortNumber;
Saurav Dasf710bd32014-09-25 16:56:00 -070013
14import com.google.common.primitives.Longs;
15
16
17public interface IOF13Switch extends IOFSwitch {
18
19 // **************************
20 // Flow related
21 // **************************
22
23 /**
24 * Pushes a single flow to the switch as described by the match-action
25 * operation and match-action definition, and subject to the TTP supported
26 * by a switch implementing this interface. It is up to the implementation
27 * to translate the 'matchActionOp' into a match-instruction with actions,
Saurav Das0a344b02014-09-26 14:18:52 -070028 * as expected by OF 1.3 switches. For better performance, use
29 * {@link pushFlows}
30 *
31 * @param matchActionOp information required to create a flow-mod and push
32 * it to the switch
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070033 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070034 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070035 public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070036
37 /**
Saurav Das0a344b02014-09-26 14:18:52 -070038 * Pushes a collection of flows to the switch, at the same time. Can result
39 * in better performance, when compared to sending flows one at a time using
40 * {@link pushFlow}, especially if the number of flows is large.
Saurav Dasd84178f2014-09-29 17:48:54 -070041 *
Saurav Das0a344b02014-09-26 14:18:52 -070042 * @param matchActionOps a collection of information required to create a
43 * flowmod
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070044 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070045 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070046 public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps)
47 throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070048
Saurav Dasd84178f2014-09-29 17:48:54 -070049
Saurav Dasf710bd32014-09-25 16:56:00 -070050 // ****************************
51 // Group related
52 // ****************************
53
54 /**
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070055 * Representation of a set of neighbor switch dpids along with edge node
56 * label. Meant to be used as a lookup-key in a hash-map to retrieve an
57 * ECMP-group that hashes packets to a set of ports connecting to the
58 * neighbors in this set.
Saurav Dasf710bd32014-09-25 16:56:00 -070059 */
60 public class NeighborSet {
61 Set<Dpid> dpids;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070062 int edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -070063
64 /**
65 * Constructor
66 *
67 * @param dpids A variable number of Dpids represention neighbor
68 * switches
69 */
70 public NeighborSet(Dpid... dpids) {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070071 this.edgeLabel = -1;
Saurav Dasf710bd32014-09-25 16:56:00 -070072 this.dpids = new HashSet<Dpid>();
73 for (Dpid d : dpids) {
74 this.dpids.add(d);
75 }
76 }
77
78 public void addDpid(Dpid d) {
79 dpids.add(d);
80 }
81
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070082 public void addDpids(Set<Dpid> d) {
83 dpids.addAll(d);
84 }
85
86 public void setEdgeLabel(int edgeLabel) {
87 this.edgeLabel = edgeLabel;
88 }
89
90 public Set<Dpid> getDpids() {
91 return dpids;
92 }
93
94 public int getEdgeLabel() {
95 return edgeLabel;
96 }
97
Saurav Dasf710bd32014-09-25 16:56:00 -070098 @Override
99 public boolean equals(Object o) {
100 if (!(o instanceof NeighborSet)) {
101 return false;
102 }
103 NeighborSet that = (NeighborSet) o;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700104 return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel));
Saurav Dasf710bd32014-09-25 16:56:00 -0700105 }
106
107 @Override
108 public int hashCode() {
109 int result = 17;
110 for (Dpid d : dpids) {
111 result = 31 * result + Longs.hashCode(d.value());
112 }
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700113 result = 31 * result + Longs.hashCode(edgeLabel);
Saurav Dasf710bd32014-09-25 16:56:00 -0700114 return result;
115 }
116
117 @Override
118 public String toString() {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700119 return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -0700120 }
121 }
122
123 /**
124 * Get the ECMP group-id for the ECMP group in this switch that includes
125 * ports that connect to the neighbor-switches included in the NeighborSet
126 * 'ns'
127 *
128 * @param ns the set of Neighbor Dpids
129 * @return the ecmp group id, or -1 if no such group exists
130 */
131 public int getEcmpGroupId(NeighborSet ns);
132
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -0700133 public void removePortFromGroups(PortNumber port);
134
135 public void addPortToGroups(PortNumber port);
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700136 /**
137 * give string tableType (ip, mpls, acl)
138 * @param tableType String equal to only one of (ip, mpls, acl)
139 * @return TableId
140 */
141
142 public TableId getTableId(String tableType);
Saurav Dasf710bd32014-09-25 16:56:00 -0700143
144}