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