blob: 3c50cbcef2d9f04eb002e1a0f8a95da16ef8110f [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 Dasf710bd32014-09-25 16:56:00 -07007import java.util.Set;
8
9import net.onrc.onos.core.matchaction.MatchActionOperationEntry;
10import net.onrc.onos.core.util.Dpid;
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -070011import net.onrc.onos.core.util.PortNumber;
Saurav Dasf710bd32014-09-25 16:56:00 -070012
Sangho Shin15273b62014-10-16 22:22:05 -070013import org.projectfloodlight.openflow.types.TableId;
14
Saurav Dasf710bd32014-09-25 16:56:00 -070015import com.google.common.primitives.Longs;
16
17
18public interface IOF13Switch extends IOFSwitch {
19
20 // **************************
21 // Flow related
22 // **************************
23
24 /**
25 * Pushes a single flow to the switch as described by the match-action
26 * operation and match-action definition, and subject to the TTP supported
27 * by a switch implementing this interface. It is up to the implementation
28 * to translate the 'matchActionOp' into a match-instruction with actions,
Saurav Das0a344b02014-09-26 14:18:52 -070029 * as expected by OF 1.3 switches. For better performance, use
30 * {@link pushFlows}
31 *
32 * @param matchActionOp information required to create a flow-mod and push
33 * it to the switch
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070034 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070035 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070036 public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070037
38 /**
Saurav Das0a344b02014-09-26 14:18:52 -070039 * Pushes a collection of flows to the switch, at the same time. Can result
40 * in better performance, when compared to sending flows one at a time using
41 * {@link pushFlow}, especially if the number of flows is large.
Saurav Dasd84178f2014-09-29 17:48:54 -070042 *
Saurav Das0a344b02014-09-26 14:18:52 -070043 * @param matchActionOps a collection of information required to create a
44 * flowmod
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070045 * @throws IOException
Saurav Dasf710bd32014-09-25 16:56:00 -070046 */
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070047 public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps)
48 throws IOException;
Saurav Dasf710bd32014-09-25 16:56:00 -070049
Saurav Dasd84178f2014-09-29 17:48:54 -070050
Saurav Dasf710bd32014-09-25 16:56:00 -070051 // ****************************
52 // Group related
53 // ****************************
54
55 /**
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070056 * Representation of a set of neighbor switch dpids along with edge node
57 * label. Meant to be used as a lookup-key in a hash-map to retrieve an
58 * ECMP-group that hashes packets to a set of ports connecting to the
59 * neighbors in this set.
Saurav Dasf710bd32014-09-25 16:56:00 -070060 */
61 public class NeighborSet {
62 Set<Dpid> dpids;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070063 int edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -070064
65 /**
66 * Constructor
67 *
68 * @param dpids A variable number of Dpids represention neighbor
69 * switches
70 */
71 public NeighborSet(Dpid... dpids) {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070072 this.edgeLabel = -1;
Saurav Dasf710bd32014-09-25 16:56:00 -070073 this.dpids = new HashSet<Dpid>();
74 for (Dpid d : dpids) {
75 this.dpids.add(d);
76 }
77 }
78
79 public void addDpid(Dpid d) {
80 dpids.add(d);
81 }
82
Srikanth Vavilapalli68144302014-10-08 15:55:24 -070083 public void addDpids(Set<Dpid> d) {
84 dpids.addAll(d);
85 }
86
87 public void setEdgeLabel(int edgeLabel) {
88 this.edgeLabel = edgeLabel;
89 }
90
91 public Set<Dpid> getDpids() {
92 return dpids;
93 }
94
95 public int getEdgeLabel() {
96 return edgeLabel;
97 }
98
Saurav Dasf710bd32014-09-25 16:56:00 -070099 @Override
100 public boolean equals(Object o) {
101 if (!(o instanceof NeighborSet)) {
102 return false;
103 }
104 NeighborSet that = (NeighborSet) o;
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700105 return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel));
Saurav Dasf710bd32014-09-25 16:56:00 -0700106 }
107
108 @Override
109 public int hashCode() {
110 int result = 17;
111 for (Dpid d : dpids) {
112 result = 31 * result + Longs.hashCode(d.value());
113 }
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700114 result = 31 * result + Longs.hashCode(edgeLabel);
Saurav Dasf710bd32014-09-25 16:56:00 -0700115 return result;
116 }
117
118 @Override
119 public String toString() {
Srikanth Vavilapalli68144302014-10-08 15:55:24 -0700120 return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel;
Saurav Dasf710bd32014-09-25 16:56:00 -0700121 }
122 }
123
124 /**
125 * Get the ECMP group-id for the ECMP group in this switch that includes
126 * ports that connect to the neighbor-switches included in the NeighborSet
127 * 'ns'
128 *
129 * @param ns the set of Neighbor Dpids
130 * @return the ecmp group id, or -1 if no such group exists
131 */
132 public int getEcmpGroupId(NeighborSet ns);
133
Srikanth Vavilapallibd9b3e22014-10-02 08:57:46 -0700134 public void removePortFromGroups(PortNumber port);
135
136 public void addPortToGroups(PortNumber port);
Saurav Dasa962a692014-10-17 14:52:38 -0700137
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700138 /**
139 * give string tableType (ip, mpls, acl)
140 * @param tableType String equal to only one of (ip, mpls, acl)
Sangho Shin15273b62014-10-16 22:22:05 -0700141 * @return TableId
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700142 */
Fahad Naeem Khand563af62014-10-08 17:37:25 -0700143 public TableId getTableId(String tableType);
Saurav Dasf710bd32014-09-25 16:56:00 -0700144
Sangho Shine020cc32014-10-20 13:28:02 -0700145 public int createTunnel(String tunnelId, List<String> route, NeighborSet ns);
Sangho Shin15273b62014-10-16 22:22:05 -0700146
Saurav Dasf710bd32014-09-25 16:56:00 -0700147}