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; |
| 6 | import java.util.Set; |
| 7 | |
| 8 | import net.onrc.onos.core.matchaction.MatchActionOperationEntry; |
| 9 | import net.onrc.onos.core.util.Dpid; |
| 10 | |
| 11 | import com.google.common.primitives.Longs; |
| 12 | |
| 13 | |
| 14 | public interface IOF13Switch extends IOFSwitch { |
| 15 | |
| 16 | // ************************** |
| 17 | // Flow related |
| 18 | // ************************** |
| 19 | |
| 20 | /** |
| 21 | * Pushes a single flow to the switch as described by the match-action |
| 22 | * operation and match-action definition, and subject to the TTP supported |
| 23 | * by a switch implementing this interface. It is up to the implementation |
| 24 | * to translate the 'matchActionOp' into a match-instruction with actions, |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 25 | * as expected by OF 1.3 switches. For better performance, use |
| 26 | * {@link pushFlows} |
| 27 | * |
| 28 | * @param matchActionOp information required to create a flow-mod and push |
| 29 | * it to the switch |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 30 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 31 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 32 | public void pushFlow(MatchActionOperationEntry matchActionOp) throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 35 | * Pushes a collection of flows to the switch, at the same time. Can result |
| 36 | * in better performance, when compared to sending flows one at a time using |
| 37 | * {@link pushFlow}, especially if the number of flows is large. |
Saurav Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 38 | * |
Saurav Das | 0a344b0 | 2014-09-26 14:18:52 -0700 | [diff] [blame] | 39 | * @param matchActionOps a collection of information required to create a |
| 40 | * flowmod |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 41 | * @throws IOException |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 42 | */ |
Saurav Das | fc5e3eb | 2014-09-25 19:05:21 -0700 | [diff] [blame] | 43 | public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps) |
| 44 | throws IOException; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 45 | |
Saurav Das | d84178f | 2014-09-29 17:48:54 -0700 | [diff] [blame] | 46 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 47 | // **************************** |
| 48 | // Group related |
| 49 | // **************************** |
| 50 | |
| 51 | /** |
| 52 | * Representation of a set of neighbor switch dpids. Meant to be used as a |
| 53 | * lookup-key in a hash-map to retrieve an ECMP-group that hashes packets to |
| 54 | * a set of ports connecting to the neighbors in this set. |
| 55 | */ |
| 56 | public class NeighborSet { |
| 57 | Set<Dpid> dpids; |
| 58 | |
| 59 | /** |
| 60 | * Constructor |
| 61 | * |
| 62 | * @param dpids A variable number of Dpids represention neighbor |
| 63 | * switches |
| 64 | */ |
| 65 | public NeighborSet(Dpid... dpids) { |
| 66 | this.dpids = new HashSet<Dpid>(); |
| 67 | for (Dpid d : dpids) { |
| 68 | this.dpids.add(d); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public void addDpid(Dpid d) { |
| 73 | dpids.add(d); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public boolean equals(Object o) { |
| 78 | if (!(o instanceof NeighborSet)) { |
| 79 | return false; |
| 80 | } |
| 81 | NeighborSet that = (NeighborSet) o; |
| 82 | return this.dpids.equals(that.dpids); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public int hashCode() { |
| 87 | int result = 17; |
| 88 | for (Dpid d : dpids) { |
| 89 | result = 31 * result + Longs.hashCode(d.value()); |
| 90 | } |
| 91 | return result; |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public String toString() { |
| 96 | return " Sw: {} Neighbors: " + dpids; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Get the ECMP group-id for the ECMP group in this switch that includes |
| 102 | * ports that connect to the neighbor-switches included in the NeighborSet |
| 103 | * 'ns' |
| 104 | * |
| 105 | * @param ns the set of Neighbor Dpids |
| 106 | * @return the ecmp group id, or -1 if no such group exists |
| 107 | */ |
| 108 | public int getEcmpGroupId(NeighborSet ns); |
| 109 | |
| 110 | |
| 111 | } |