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 | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 7 | import java.util.Set; |
| 8 | |
| 9 | import net.onrc.onos.core.matchaction.MatchActionOperationEntry; |
| 10 | import net.onrc.onos.core.util.Dpid; |
Srikanth Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 11 | import net.onrc.onos.core.util.PortNumber; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 12 | |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 13 | import org.projectfloodlight.openflow.types.TableId; |
| 14 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 15 | import com.google.common.primitives.Longs; |
| 16 | |
| 17 | |
| 18 | public 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 Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 29 | * 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 Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 34 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 35 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 36 | public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 39 | * 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 Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 42 | * |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 43 | * @param matchActionOps a collection of information required to create a |
| 44 | * flowmod |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 45 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 46 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 47 | public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps) |
| 48 | throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 49 | |
Saurav Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 50 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 51 | // **************************** |
| 52 | // Group related |
| 53 | // **************************** |
| 54 | |
| 55 | /** |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 56 | * 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 Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 60 | */ |
| 61 | public class NeighborSet { |
| 62 | Set<Dpid> dpids; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 63 | int edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Constructor |
| 67 | * |
| 68 | * @param dpids A variable number of Dpids represention neighbor |
| 69 | * switches |
| 70 | */ |
| 71 | public NeighborSet(Dpid... dpids) { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 72 | this.edgeLabel = -1; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 73 | 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 Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 83 | 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 Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 99 | @Override |
| 100 | public boolean equals(Object o) { |
| 101 | if (!(o instanceof NeighborSet)) { |
| 102 | return false; |
| 103 | } |
| 104 | NeighborSet that = (NeighborSet) o; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 105 | return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel)); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 106 | } |
| 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 Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 114 | result = 31 * result + Longs.hashCode(edgeLabel); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 115 | return result; |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public String toString() { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame] | 120 | return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 121 | } |
| 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 Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 134 | public void removePortFromGroups(PortNumber port); |
| 135 | |
| 136 | public void addPortToGroups(PortNumber port); |
Saurav Das | a962a69 | 2014-10-17 14:52:38 -0700 | [diff] [blame] | 137 | |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 138 | /** |
| 139 | * give string tableType (ip, mpls, acl) |
| 140 | * @param tableType String equal to only one of (ip, mpls, acl) |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 141 | * @return TableId |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 142 | */ |
Fahad Naeem Khan | d563af6 | 2014-10-08 17:37:25 -0700 | [diff] [blame] | 143 | public TableId getTableId(String tableType); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 144 | |
Sangho Shin | e020cc3 | 2014-10-20 13:28:02 -0700 | [diff] [blame] | 145 | public int createTunnel(String tunnelId, List<String> route, NeighborSet ns); |
Sangho Shin | 15273b6 | 2014-10-16 22:22:05 -0700 | [diff] [blame] | 146 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 147 | } |