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