16ab0f966cb0b3b86c2cc260ee451d6e25180b34
[sfc.git] /
1 /*
2  * Copyright (c) 2014, 2017 Ericsson Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.sfc.ofrenderer.openflow;
10
11 import java.util.List;
12 import java.util.Set;
13 import java.util.concurrent.ExecutionException;
14 import org.opendaylight.sfc.genius.util.appcoexistence.SfcTableIndexMapper;
15 import org.opendaylight.sfc.ofrenderer.sfg.GroupBucketInfo;
16 import org.opendaylight.sfc.util.openflow.writer.SfcOfFlowWriterInterface;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
21
22 /**
23  * An interface to be implemented by concrete classes that will write to
24  * OpenFlow or OVS switches.
25  *
26  * @author Brady Johnson ([email protected])
27  * @since 2015-02-24
28  */
29 public interface SfcOfFlowProgrammerInterface {
30
31     void shutdown() throws ExecutionException, InterruptedException;
32
33     // These table methods are used for app-coexistence
34
35     short getTableBase();
36
37     void setTableBase(short tableBase);
38
39     short getMaxTableOffset();
40
41     short getTableEgress();
42
43     void setTableEgress(short tableEgress);
44
45     // Set the RSP Id that subsequent flow creations belong to
46     void setFlowRspId(Long rspId);
47
48     /**
49      * Deletes all flows created for a particular RSP and removes initialization
50      * flows from SFFs if the last RSP was removed.
51      *
52      * @param rspId
53      *            the id of the RSP to be deleted
54      *
55      * @return Node IDs from which initialization flows were removed.
56      */
57     Set<NodeId> deleteRspFlows(long rspId);
58
59     // Write any buffered flows to the data store
60     void flushFlows();
61
62     // Purge any unwritten flows not written yet. This should be called upon
63     // errors, when the remaining buffered flows should not be written.
64     void purgeFlows();
65
66     // Set FlowWriter implementation
67     void setFlowWriter(SfcOfFlowWriterInterface sfcOfFlowWriter);
68
69     //
70     // Configure Table 1, Transport Ingress
71     //
72     void configureIpv4TransportIngressFlow(String sffNodeName);
73
74     void configureVlanTransportIngressFlow(String sffNodeName);
75
76     void configureMacChainingTransportIngressFlow(String sffNodeName);
77
78     // These 2 are work-around flows until the OVS NSH patch is completed
79     void configureNshVxgpeSfLoopbackEncapsulatedEgressFlow(String sffNodeName, String sfIp, short vxlanUdpPort,
80             long sffPort);
81
82     void configureNshVxgpeSfReturnLoopbackIngressFlow(String sffNodeName, short vxlanUdpPort, long sffPort);
83
84     void configureNshVxgpeTransportIngressFlow(String sffNodeName, long nshNsp, short nshNsi);
85
86     void configureMplsTransportIngressFlow(String sffNodeName);
87
88     void configureArpTransportIngressFlow(String sffNodeName, String mac);
89
90     //
91     // Configure Table 2, Path Mapper
92     //
93     void configureMplsPathMapperFlow(String sffNodeName, long label, long pathId, boolean isSf);
94
95     void configureVlanPathMapperFlow(String sffNodeName, int vlan, long pathId, boolean isSf);
96     // PathMapper not needed for NshVxgpe NSH
97     // configureNshVxgpePathMapperFlow()
98
99     //
100     // Table 3, NextHop
101     //
102     void configureMacNextHopFlow(String sffNodeName, long sfpId, String srcMac, String dstMac);
103
104     void configureGroupNextHopFlow(String sffNodeName, long sfpId, String srcMac, long groupId, String groupName);
105
106     void configureMacChainingNextHopFlow(String sffNodeName, String vmac, String dstSfMac,
107                                          String nextVMac, boolean l2Tranparent);
108
109
110     void configureNshVxgpeNextHopFlow(String sffNodeName, String dstIp, String nshProxyIp, long nsp, short nsi);
111
112     /**
113      * Configure nsh next hop flow.
114      *
115      * @param sffNodeName
116      *            The openflow node name
117      * @param srcMac
118      *            MAC address used by the openflow port to which the SF is
119      *            connected
120      * @param dstMac
121      *            MAC address used by the SF
122      * @param nsp
123      *            the NSH NSP
124      * @param nsi
125      *            the NSH NSI
126      */
127     void configureNshEthNextHopFlow(String sffNodeName, String srcMac, String dstMac, long nsp, short nsi);
128
129     //
130     // Table 10, Transport Egress
131     //
132     void configureVlanSfTransportEgressFlow(String sffNodeName, String srcMac, String dstMac, int dstVlan, String port,
133             long pathId, boolean doPktin);
134
135     void configureVlanTransportEgressFlow(String sffNodeName, String srcMac, String dstMac, int dstVlan, String port,
136             long pathId);
137
138     void configureMacChainingSfTransportEgressFlow(String sffNodeName, String dstMac, String port, String vmac);
139
140     void configureVlanLastHopTransportEgressFlow(String sffNodeName, String srcMac, String dstMac, int dstVlan,
141             String port, long pathId);
142
143     void configureMplsTransportEgressFlow(String sffNodeName, String srcMac, String dstMac, long mplsLabel, String port,
144             long pathId);
145
146     void configureMplsLastHopTransportEgressFlow(String sffNodeName, String srcMac, String dstMac, long mplsLabel,
147             String port, long pathId);
148
149     void configureNshVxgpeTransportEgressFlow(String sffNodeName, long nshNsp, short nshNsi, String port);
150
151     void configureNshVxgpeAppCoexistTransportEgressFlow(String sffNodeName, long nshNsp, short nshNsi, String sffIp);
152
153     void configureNshVxgpeLastHopTransportEgressFlow(String sffNodeName, long nshNsp, short nshNsi, String port);
154
155     void configureNshNscTransportEgressFlow(String sffNodeName, long nshNsp, short nshNsi, String switchPort);
156
157     /**
158      * Configure transport egress flows, using a list of externally provided
159      * actions.
160      *
161      * @param sffOpenFlowNodeName
162      *            The openflow identifier for the node on which the flows are to
163      *            be written
164      * @param nshNsp
165      *            NSP to use in the match part
166      * @param nshNsi
167      *            NSI to use in the match part
168      * @param actionList
169      *            List of actions to use in the actions part
170      * @param flowName
171      *            A unique flow name, also used as a flow key
172      */
173     void configureNshEthTransportEgressFlow(String sffOpenFlowNodeName, long nshNsp, short nshNsi,
174             List<Action> actionList, String flowName);
175
176     void configureNshEthTransportEgressFlow(String sffNodeName, long nshNsp, short nshNsi, String port);
177
178     //
179     // Configure the MatchAny entry specifying if it should drop or goto the
180     // next table
181     // Classifier MatchAny will go to Ingress
182     // TransportIngress MatchAny will go to PathMapper
183     // PathMapper MatchAny will go to PathMapperAcl
184     // PathMapperAcl MatchAny will go to NextHop
185     // NextHop MatchAny will go to TransportEgress
186     //
187     void configureClassifierTableMatchAny(String sffNodeName);
188
189     void configureTransportIngressTableMatchAny(String sffNodeName);
190
191     void configureTransportIngressTableMatchAnyResubmit(String sffNodeName, short nextTableId);
192
193     void configurePathMapperTableMatchAny(String sffNodeName);
194
195     void configurePathMapperAclTableMatchAny(String sffNodeName);
196
197     void configureNextHopTableMatchAny(String sffNodeName);
198
199     void configureTransportEgressTableMatchAny(String sffNodeName);
200
201     /**
202      * Set the match any flow in the Transport Egress table to resubmit.
203      *
204      * @param sffNodeName
205      *            - the SFF to write the flow to
206      * @param nextTableId
207      *            - the table to resubmit
208      */
209     void configureTransportEgressTableMatchAnyResubmit(String sffNodeName, short nextTableId);
210
211     /* OVS DPDK only, these APIs will add extra flows for OVS DPDK */
212     void configureClassifierTableDpdkOutput(String sffNodeName, Long outPort);
213
214     void configureClassifierTableDpdkInput(String sffNodeName, Long inPort);
215
216     // group configuration
217     void configureGroup(String sffNodeName, String openflowNodeId, String sfgName, long sfgId, int groupType,
218             List<GroupBucketInfo> bucketInfos, boolean isAddGroup);
219
220     /**
221      * Used by logical sff processor in order to write chain egress flows.
222      * The sff ip address is optional, if not provided it is assumed that
223      * the sff has no dataplane tunnel endpoints.
224      *
225      * @param sffNodeName
226      *            last openflow node in the chain
227      * @param sffIpAddress
228      *            the sff ip address
229      * @param sfMacAddress
230      *            the last sf mac address
231      * @param nshNsp
232      *            nsp for the match
233      * @param nshNsi
234      *            nsi for the match
235      */
236     void configureNshEthLastHopTransportEgressFlow(String sffNodeName, IpAddress sffIpAddress,
237                                                    MacAddress sfMacAddress, long nshNsp, short nshNsi);
238
239     /**
240      * Setter for the table index mapper (class which provides the tables to use
241      * for Genius-based application coexistence).
242      *
243      * @param tableIndexMapper
244      *            The table index mapper
245      */
246     void setTableIndexMapper(SfcTableIndexMapper tableIndexMapper);
247 }