Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 1 | package net.floodlightcontroller.core; |
| 2 | |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 3 | import java.io.IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 4 | import java.util.Collection; |
| 5 | import java.util.HashSet; |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 6 | import java.util.List; |
Saurav Das | 2d41a43 | 2014-10-21 20:40:10 -0700 | [diff] [blame] | 7 | import java.util.Map; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 8 | import java.util.Set; |
| 9 | |
| 10 | import net.onrc.onos.core.matchaction.MatchActionOperationEntry; |
| 11 | import net.onrc.onos.core.util.Dpid; |
Srikanth Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 12 | import net.onrc.onos.core.util.PortNumber; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 13 | |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 14 | import org.projectfloodlight.openflow.types.TableId; |
| 15 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 16 | import com.google.common.primitives.Longs; |
| 17 | |
| 18 | |
| 19 | public 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 Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 30 | * 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 Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 35 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 36 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 37 | public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 40 | * 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 Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 43 | * |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 44 | * @param matchActionOps a collection of information required to create a |
| 45 | * flowmod |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 46 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 47 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 48 | public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps) |
| 49 | throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 50 | |
Saurav Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 51 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 52 | // **************************** |
| 53 | // Group related |
| 54 | // **************************** |
| 55 | |
| 56 | /** |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 57 | * 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 Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 61 | */ |
| 62 | public class NeighborSet { |
| 63 | Set<Dpid> dpids; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 64 | int edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Constructor |
| 68 | * |
| 69 | * @param dpids A variable number of Dpids represention neighbor |
| 70 | * switches |
| 71 | */ |
| 72 | public NeighborSet(Dpid... dpids) { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 73 | this.edgeLabel = -1; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 74 | 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 Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 84 | 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 Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 100 | @Override |
| 101 | public boolean equals(Object o) { |
| 102 | if (!(o instanceof NeighborSet)) { |
| 103 | return false; |
| 104 | } |
| 105 | NeighborSet that = (NeighborSet) o; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 106 | return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel)); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 107 | } |
| 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 Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 115 | result = 31 * result + Longs.hashCode(edgeLabel); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 116 | return result; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public String toString() { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 121 | return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 122 | } |
| 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 Vavilapalli | 6027317 | 2014-10-22 11:28:05 -0700 | [diff] [blame] | 135 | /** |
| 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 Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 143 | public void removePortFromGroups(PortNumber port); |
| 144 | |
Srikanth Vavilapalli | 6027317 | 2014-10-22 11:28:05 -0700 | [diff] [blame] | 145 | /** |
| 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 Vavilapalli | 2edeada | 2014-10-22 19:19:01 -0700 | [diff] [blame] | 149 | * |
Srikanth Vavilapalli | 6027317 | 2014-10-22 11:28:05 -0700 | [diff] [blame] | 150 | * @param port Port Number to be added to groups |
| 151 | * @return None |
| 152 | */ |
Srikanth Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 153 | public void addPortToGroups(PortNumber port); |
Saurav Das | a962a69 | 2014-10-17 14:52:38 -0700 | [diff] [blame] | 154 | |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 155 | /** |
| 156 | * give string tableType (ip, mpls, acl) |
| 157 | * @param tableType String equal to only one of (ip, mpls, acl) |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 158 | * @return TableId |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 159 | */ |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 160 | public TableId getTableId(String tableType); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 161 | |
Sangho Shin | 4b46bcd | 2014-10-20 15:48:47 -0700 | [diff] [blame] | 162 | /** |
Srikanth Vavilapalli | 1167d0c | 2014-10-23 09:43:42 -0700 | [diff] [blame] | 163 | * Create a group chain with the specified label stack for a given set of |
| 164 | * ports. This API can be used by user to create groups for a tunnel based |
| 165 | * policy routing scenario. NOTE: This API can not be used if a group to be |
| 166 | * created with different label stacks for each port in the given set of |
| 167 | * ports. Use XXX API for this purpose |
Srikanth Vavilapalli | 2edeada | 2014-10-22 19:19:01 -0700 | [diff] [blame] | 168 | * |
Srikanth Vavilapalli | 1167d0c | 2014-10-23 09:43:42 -0700 | [diff] [blame] | 169 | * @param labelStack list of router segment Ids to be pushed. Can be empty. |
| 170 | * labelStack is processed from left to right with leftmost |
| 171 | * representing the outermost label and rightmost representing |
| 172 | * innermost label to be pushed |
| 173 | * @param ports List of ports on this switch to get to the first router in |
| 174 | * the labelStack |
Srikanth Vavilapalli | 2edeada | 2014-10-22 19:19:01 -0700 | [diff] [blame] | 175 | * @return group identifier |
| 176 | */ |
| 177 | public int createGroup(List<Integer> labelStack, List<PortNumber> ports); |
| 178 | |
| 179 | /** |
Srikanth Vavilapalli | 2edeada | 2014-10-22 19:19:01 -0700 | [diff] [blame] | 180 | * Remove the specified group |
| 181 | * |
| 182 | * @param groupId group identifier |
| 183 | * @return success/fail |
| 184 | */ |
| 185 | public boolean removeGroup(int groupId); |
| 186 | |
Saurav Das | 2d41a43 | 2014-10-21 20:40:10 -0700 | [diff] [blame] | 187 | public Map<String, String> getPublishAttributes(); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 188 | } |