blob: f5648afd22c915d33eee83d1a80d4b7b847c1384 [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;
Sangho Shin15273b62014-10-16 22:22:05 -07006import java.util.List;
Saurav Das2d41a432014-10-21 20:40:10 -07007import java.util.Map;
Saurav Dasf710bd32014-09-25 16:56:00 -07008import java.util.Set;
9
10import 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
Sangho Shin15273b62014-10-16 22:22:05 -070014import org.projectfloodlight.openflow.types.TableId;
15
Saurav Dasf710bd32014-09-25 16:56:00 -070016import com.google.common.primitives.Longs;
17
18
19public interface IOF13Switch extends IOFSwitch {
20
21 // **************************
22 // Flow related
23 // **************************
24
25 /**
26 * Pushes a single flow to the switch as described by the match-action
27 * operation and match-action definition, and subject to the TTP supported
28 * by a switch implementing this interface. It is up to the implementation
29 * to translate the 'matchActionOp' into a match-instruction with actions,
Saurav Das0a344b02014-09-26 14:18:52 -070030 * as expected by OF 1.3 switches. For better performance, use
31 * {@link pushFlows}
32 *
33 * @param matchActionOp information required to create a flow-mod and push
34 * it to the switch
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070035 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070036 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070037 public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070038
39 /**
Saurav Das0a344b02014-09-26 14:18:52 -070040 * Pushes a collection of flows to the switch, at the same time. Can result
41 * in better performance, when compared to sending flows one at a time using
42 * {@link pushFlow}, especially if the number of flows is large.
Saurav Dasd84178f2014-09-29 17:48:54 -070043 *
Saurav Das0a344b02014-09-26 14:18:52 -070044 * @param matchActionOps a collection of information required to create a
45 * flowmod
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070046 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070047 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070048 public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps)
49 throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070050
Saurav Dasd84178f2014-09-29 17:48:54 -070051
Saurav Dasf710bd32014-09-25 16:56:00 -070052 // ****************************
53 // Group related
54 // ****************************
55
56 /**
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070057 * Representation of a set of neighbor switch dpids along with edge node
58 * label. Meant to be used as a lookup-key in a hash-map to retrieve an
59 * ECMP-group that hashes packets to a set of ports connecting to the
60 * neighbors in this set.
Saurav Dasf710bd32014-09-25 16:56:00 -070061 */
62 public class NeighborSet {
63 Set<Dpid> dpids;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070064 int edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -070065
66 /**
67 * Constructor
68 *
69 * @param dpids A variable number of Dpids represention neighbor
70 * switches
71 */
72 public NeighborSet(Dpid... dpids) {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070073 this.edgeLabel = -1;
Saurav Dasf710bd32014-09-25 16:56:00 -070074 this.dpids = new HashSet<Dpid>();
75 for (Dpid d : dpids) {
76 this.dpids.add(d);
77 }
78 }
79
80 public void addDpid(Dpid d) {
81 dpids.add(d);
82 }
83
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070084 public void addDpids(Set<Dpid> d) {
85 dpids.addAll(d);
86 }
87
88 public void setEdgeLabel(int edgeLabel) {
89 this.edgeLabel = edgeLabel;
90 }
91
92 public Set<Dpid> getDpids() {
93 return dpids;
94 }
95
96 public int getEdgeLabel() {
97 return edgeLabel;
98 }
99
Saurav Dasf710bd32014-09-25 16:56:00 -0700100 @Override
101 public boolean equals(Object o) {
102 if (!(o instanceof NeighborSet)) {
103 return false;
104 }
105 NeighborSet that = (NeighborSet) o;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700106 return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel));
Saurav Dasf710bd32014-09-25 16:56:00 -0700107 }
108
109 @Override
110 public int hashCode() {
111 int result = 17;
112 for (Dpid d : dpids) {
113 result = 31 * result + Longs.hashCode(d.value());
114 }
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700115 result = 31 * result + Longs.hashCode(edgeLabel);
Saurav Dasf710bd32014-09-25 16:56:00 -0700116 return result;
117 }
118
119 @Override
120 public String toString() {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700121 return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -0700122 }
123 }
124
125 /**
126 * Get the ECMP group-id for the ECMP group in this switch that includes
127 * ports that connect to the neighbor-switches included in the NeighborSet
128 * 'ns'
129 *
130 * @param ns the set of Neighbor Dpids
131 * @return the ecmp group id, or -1 if no such group exists
132 */
133 public int getEcmpGroupId(NeighborSet ns);
134
Srikanth Vavilapalli60273172014-10-22 11:28:05 -0700135 /**
136 * Remove the OFBucket that contains the specified port from all the OF
137 * groups. This API can be used by applications, when a port goes down, to
138 * remove that port from all the group that it is part of
139 *
140 * @param port Port Number to be removed from groups
141 * @return None
142 */
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -0700143 public void removePortFromGroups(PortNumber port);
144
Srikanth Vavilapalli60273172014-10-22 11:28:05 -0700145 /**
146 * Add the OFBucket to groups that have reachability through the given port.
147 * This API can be used by applications, when a port is operational again,
148 * to add that port to all the relevant groups
Srikanth Vavilapalli2edeada2014-10-22 19:19:01 -0700149 *
Srikanth Vavilapalli60273172014-10-22 11:28:05 -0700150 * @param port Port Number to be added to groups
151 * @return None
152 */
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -0700153 public void addPortToGroups(PortNumber port);
Saurav Dasa962a692014-10-17 14:52:38 -0700154
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700155 /**
156 * give string tableType (ip, mpls, acl)
157 * @param tableType String equal to only one of (ip, mpls, acl)
Sangho Shin15273b62014-10-16 22:22:05 -0700158 * @return TableId
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700159 */
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700160 public TableId getTableId(String tableType);
Saurav Dasf710bd32014-09-25 16:56:00 -0700161
Sangho Shin4b46bcd2014-10-20 15:48:47 -0700162 /**
163 * Create a tunnel for policy routing
164 *
165 * @param tunnelId tunnel ID for the tunnel
166 * @param route list of router DPIDs for the tunnel
167 * @param ns NeighborSet to get to the first router of the tunnel
168 */
169 public void createTunnel(String tunnelId, List<String> route, NeighborSet ns);
170
171 /**
Srikanth Vavilapalli2edeada2014-10-22 19:19:01 -0700172 * Create a group chain with the same label stack for a given set of ports
173 * in the neighborset. This can be used for a basic scenario of tunnel based
174 * policy routing.
175 *
176 * @param labelStack list of router segment Ids to be pushed
177 * @param ns neighborSet to get to the first router in the labelStack. NOTE:
178 * The edgeLabel inside the neighborSet is ignored and user should
179 * explicitly push that label on to the labelStack that is passed as
180 * first argument
181 * @return group identifier
182 */
183 public int createGroup(List<Integer> labelStack, List<PortNumber> ports);
184
185 /**
Sangho Shin4b46bcd2014-10-20 15:48:47 -0700186 * Remove all groups for the tunnel
187 *
188 * @param tunnelId tunnel ID to remove
189 */
190 public void removeTunnel(String tunnelId);
Sangho Shin15273b62014-10-16 22:22:05 -0700191
Sangho Shin1ad7be02014-10-20 16:56:49 -0700192 /**
Srikanth Vavilapalli2edeada2014-10-22 19:19:01 -0700193 * Remove the specified group
194 *
195 * @param groupId group identifier
196 * @return success/fail
197 */
198 public boolean removeGroup(int groupId);
199
200 /**
Sangho Shin1ad7be02014-10-20 16:56:49 -0700201 * Return the first group ID for the tunnel.
202 * If the router is not the source of the tunnel, it returns -1
203 *
204 * @param tunnelID tunnel ID for the tunnel
205 * @param srcDpid source router DPID
206 * @return first Group ID for the tunnel or -1 if not found
207 */
208 public int getTunnelGroupId(String tunnelID);
Saurav Das2d41a432014-10-21 20:40:10 -0700209
210 public Map<String, String> getPublishAttributes();
Saurav Dasf710bd32014-09-25 16:56:00 -0700211}