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 | /** |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 53 | * Representation of a set of neighbor switch dpids along with edge node |
| 54 | * label. Meant to be used as a lookup-key in a hash-map to retrieve an |
| 55 | * ECMP-group that hashes packets to a set of ports connecting to the |
| 56 | * neighbors in this set. |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 57 | */ |
| 58 | public class NeighborSet { |
| 59 | Set<Dpid> dpids; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 60 | int edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Constructor |
| 64 | * |
| 65 | * @param dpids A variable number of Dpids represention neighbor |
| 66 | * switches |
| 67 | */ |
| 68 | public NeighborSet(Dpid... dpids) { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 69 | this.edgeLabel = -1; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 70 | this.dpids = new HashSet<Dpid>(); |
| 71 | for (Dpid d : dpids) { |
| 72 | this.dpids.add(d); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | public void addDpid(Dpid d) { |
| 77 | dpids.add(d); |
| 78 | } |
| 79 | |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 80 | public void addDpids(Set<Dpid> d) { |
| 81 | dpids.addAll(d); |
| 82 | } |
| 83 | |
| 84 | public void setEdgeLabel(int edgeLabel) { |
| 85 | this.edgeLabel = edgeLabel; |
| 86 | } |
| 87 | |
| 88 | public Set<Dpid> getDpids() { |
| 89 | return dpids; |
| 90 | } |
| 91 | |
| 92 | public int getEdgeLabel() { |
| 93 | return edgeLabel; |
| 94 | } |
| 95 | |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 96 | @Override |
| 97 | public boolean equals(Object o) { |
| 98 | if (!(o instanceof NeighborSet)) { |
| 99 | return false; |
| 100 | } |
| 101 | NeighborSet that = (NeighborSet) o; |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 102 | return (this.dpids.equals(that.dpids) && (this.edgeLabel == that.edgeLabel)); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public int hashCode() { |
| 107 | int result = 17; |
| 108 | for (Dpid d : dpids) { |
| 109 | result = 31 * result + Longs.hashCode(d.value()); |
| 110 | } |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 111 | result = 31 * result + Longs.hashCode(edgeLabel); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 112 | return result; |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public String toString() { |
Srikanth Vavilapalli | 6814430 | 2014-10-08 15:55:24 -0700 | [diff] [blame^] | 117 | return " Neighborset Sw: " + dpids + " and Label: " + edgeLabel; |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Get the ECMP group-id for the ECMP group in this switch that includes |
| 123 | * ports that connect to the neighbor-switches included in the NeighborSet |
| 124 | * 'ns' |
| 125 | * |
| 126 | * @param ns the set of Neighbor Dpids |
| 127 | * @return the ecmp group id, or -1 if no such group exists |
| 128 | */ |
| 129 | public int getEcmpGroupId(NeighborSet ns); |
| 130 | |
Srikanth Vavilapalli | bd9b3e2 | 2014-10-02 08:57:46 -0700 | [diff] [blame] | 131 | public void removePortFromGroups(PortNumber port); |
| 132 | |
| 133 | public void addPortToGroups(PortNumber port); |
Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame] | 134 | |
| 135 | } |