OpenFlow Data Plane Abstraction (OF-DPA) API Guide and Reference Manual
ofdpa_api.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * (C) Copyright Broadcom Corporation 2003-2014
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 **********************************************************************
26 *
27 * @filename ofdpa_api.h
28 *
29 * @purpose OF-DPA API header
30 *
31 * @component OF-DPA
32 *
33 * @note none
34 *
35 * @create 03/22/2013
36 *
37 * @end
38 *
39 **********************************************************************/
40 #ifndef INCLUDE_OFDPA_API_H
41 #define INCLUDE_OFDPA_API_H
42 
43 #include <stdint.h>
44 #include <sys/time.h>
45 #include <netinet/in.h>
46 #include "ofdpa_datatypes.h"
47 
48 /*
49  * All clients must register first.
50  */
51 /*****************************************************************/
64 OFDPA_ERROR_t ofdpaClientInitialize(char *clientName);
65 
66 /*
67  * Debugging and Logging definitions
68  */
69 
70 /*****************************************************************/
81 int ofdpaCltLogPrintf(int priority, char *fmt, ...);
82 
83 /*****************************************************************/
93 int ofdpaCltLogBuf(int priority, ofdpa_buffdesc message);
94 
95 /*****************************************************************/
108 int ofdpaCltDebugPrintf(const char *functionName, ofdpaComponentIds_t component, ofdpaDebugLevels_t verbosity, const char *format, ...);
109 
110 /*****************************************************************/
122 int ofdpaCltDebugBuf(ofdpa_buffdesc functionName, ofdpaComponentIds_t component, ofdpaDebugLevels_t verbosity, ofdpa_buffdesc message);
123 
124 /* Flow Tables.
125 */
126 
127 /*****************************************************************/
138 
139 /*****************************************************************/
154 
155 /*****************************************************************/
167 
168 /*****************************************************************/
181 
182 /*****************************************************************/
202 
203 /*****************************************************************/
215 
216 /*****************************************************************/
230 
231 /*****************************************************************/
241 OFDPA_ERROR_t ofdpaFlowByCookieDelete(uint64_t cookie);
242 
243 /*------------------------------------------------------------------------------------*/
244 /* group table APIs */
245 
246 /*
247  The Group Table contains one entry for each Group. The table is indexed
248  by the groupId which identifies the group entry. Data is encoded into the groupId to specify the OF-DPA
249  group entry type and information required by OF-DPA to configure the datapath.
250 
251  The groupId encoding method is:
252 
253  L2 Interface, L2 Rewrite types:
254  (MSB to LSB) 4 bits encode the Group Table Entry type |12 bits of VLAN ID | 16 bits of port identifier
255 
256  L2 Multicast, L2 Flood, L3 Multicast, and L3 Interface types:
257  (MSB to LSB) 4 bits encode the Group Table Entry type |12 bits of VLAN ID | 16 bits of index
258 
259  L3 Unicast and L3 ECMP types:
260  (MSB to LSB) 4 bits encode the Group Table Entry type | 28 bits of index
261 
262 */
263 
264 /* APIs for getting/setting group IDs -- set APIs must set the type first. */
265 
266 /*****************************************************************/
277 OFDPA_ERROR_t ofdpaGroupTypeGet(uint32_t groupId, uint32_t *type);
278 
279 /*****************************************************************/
292 OFDPA_ERROR_t ofdpaGroupVlanGet(uint32_t groupId, uint32_t *vlanId);
293 
294 /*****************************************************************/
306 OFDPA_ERROR_t ofdpaGroupPortIdGet(uint32_t groupId, uint32_t *portId);
307 
308 /*****************************************************************/
320 OFDPA_ERROR_t ofdpaGroupIndexShortGet(uint32_t groupId, uint32_t *index);
321 
322 /*****************************************************************/
334 OFDPA_ERROR_t ofdpaGroupIndexGet(uint32_t groupId, uint32_t *index);
335 
336 /*****************************************************************/
347 OFDPA_ERROR_t ofdpaGroupTypeSet(uint32_t *groupId, uint32_t type);
348 
349 /*****************************************************************/
362 OFDPA_ERROR_t ofdpaGroupVlanSet(uint32_t *groupId, uint32_t vlanId);
363 
364 /*****************************************************************/
376 OFDPA_ERROR_t ofdpaGroupOverlayTunnelIdSet(uint32_t *groupId, uint32_t tunnelId);
377 
378 /*****************************************************************/
391 
392 /*****************************************************************/
404 OFDPA_ERROR_t ofdpaGroupOverlayIndexSet(uint32_t *groupId, uint32_t index);
405 
406 /*****************************************************************/
418 OFDPA_ERROR_t ofdpaGroupPortIdSet(uint32_t *groupId, uint32_t portId);
419 
420 /*****************************************************************/
432 OFDPA_ERROR_t ofdpaGroupIndexShortSet(uint32_t *groupId, uint32_t index);
433 
434 /*****************************************************************/
446 OFDPA_ERROR_t ofdpaGroupIndexSet(uint32_t *groupId, uint32_t index);
447 
448 /*****************************************************************/
459 OFDPA_ERROR_t ofdpaGroupDecode(uint32_t groupId, char *outBuf, int bufSize);
460 
461 /*****************************************************************/
476 
477 /*****************************************************************/
488 OFDPA_ERROR_t ofdpaGroupDelete(uint32_t groupId);
489 
490 /*****************************************************************/
501 OFDPA_ERROR_t ofdpaGroupNextGet(uint32_t groupId, ofdpaGroupEntry_t *nextGroup);
502 
503 /*****************************************************************/
515 OFDPA_ERROR_t ofdpaGroupTypeNextGet(uint32_t groupId,
516  OFDPA_GROUP_ENTRY_TYPE_t groupType,
517  ofdpaGroupEntry_t *nextGroup);
518 
519 /*****************************************************************/
530 OFDPA_ERROR_t ofdpaGroupStatsGet(uint32_t groupId, ofdpaGroupEntryStats_t *groupStats);
531 
532 /*
533  Group Table entries contain one or more Action Buckets depending on their type.
534  The Group Bucket Table stores these references. It is indexed by groupId and referenceGroupId. The presence
535  of an entry in this table creates a referral by the Group Table entry specified in groupId to the Group Table
536  entry specified in referenceGroupId. Restrictions on the number of references and the allowable type of the
537  referenced Group Table entries varies by entry type.
538 */
539 
540 /*****************************************************************/
558 
559 /*****************************************************************/
573 OFDPA_ERROR_t ofdpaGroupBucketEntryDelete(uint32_t groupId, uint32_t bucketIndex);
574 
575 /*****************************************************************/
587 OFDPA_ERROR_t ofdpaGroupBucketsDeleteAll(uint32_t groupId);
588 
589 /*****************************************************************/
601 OFDPA_ERROR_t ofdpaGroupBucketEntryGet(uint32_t groupId, uint32_t bucketIndex,
602  ofdpaGroupBucketEntry_t *groupBucket);
603 
604 /*****************************************************************/
616  ofdpaGroupBucketEntry_t *firstGroupBucket);
617 
618 /*****************************************************************/
630 OFDPA_ERROR_t ofdpaGroupBucketEntryNextGet(uint32_t groupId, uint32_t bucketIndex,
631  ofdpaGroupBucketEntry_t *nextBucketEntry);
632 
633 /*****************************************************************/
646 
647 /*****************************************************************/
659 
660 /*****************************************************************/
669 void ofdpaPortTypeGet(uint32_t portNum, uint32_t *type);
670 
671 /*****************************************************************/
680 void ofdpaPortTypeSet(uint32_t *portNum, uint32_t type);
681 
682 /*****************************************************************/
691 void ofdpaPortIndexGet(uint32_t portNum, uint32_t *index);
692 
693 /*****************************************************************/
702 void ofdpaPortIndexSet(uint32_t *portNum, uint32_t index);
703 
704 /*****************************************************************/
715 OFDPA_ERROR_t ofdpaPortNextGet(uint32_t portNum, uint32_t *nextPortNum);
716 
717 /*****************************************************************/
728 OFDPA_ERROR_t ofdpaPortMacGet(uint32_t portNum, ofdpaMacAddr_t *mac);
729 
730 /*****************************************************************/
745 OFDPA_ERROR_t ofdpaPortNameGet(uint32_t portNum, ofdpa_buffdesc *name);
746 
747 /*****************************************************************/
758 OFDPA_ERROR_t ofdpaPortStateGet(uint32_t portNum, OFDPA_PORT_STATE_t *state);
759 
760 /*****************************************************************/
771 OFDPA_ERROR_t ofdpaPortConfigSet(uint32_t portNum, OFDPA_PORT_CONFIG_t config);
772 
773 /*****************************************************************/
784 OFDPA_ERROR_t ofdpaPortConfigGet(uint32_t portNum, OFDPA_PORT_CONFIG_t *config);
785 
786 /*****************************************************************/
797 OFDPA_ERROR_t ofdpaPortMaxSpeedGet(uint32_t portNum, uint32_t *maxSpeed);
798 
799 /*****************************************************************/
810 OFDPA_ERROR_t ofdpaPortCurrSpeedGet(uint32_t portNum, uint32_t *currSpeed);
811 
812 /*****************************************************************/
823 OFDPA_ERROR_t ofdpaPortFeatureGet(uint32_t portNum, ofdpaPortFeature_t *feature);
824 
825 /*****************************************************************/
836 OFDPA_ERROR_t ofdpaPortAdvertiseFeatureSet(uint32_t portNum, uint32_t advertise);
837 
838 /*****************************************************************/
849 OFDPA_ERROR_t ofdpaPortStatsClear(uint32_t portNum);
850 
851 /*****************************************************************/
864 OFDPA_ERROR_t ofdpaPortStatsGet(uint32_t portNum, ofdpaPortStats_t *stats);
865 
866 /*****************************************************************/
882 
883 /*****************************************************************/
894 OFDPA_ERROR_t ofdpaTunnelPortDelete(uint32_t portNum);
895 
896 /*****************************************************************/
914 OFDPA_ERROR_t ofdpaTunnelPortGet(uint32_t portNum,
915  ofdpaTunnelPortConfig_t *config,
916  ofdpaTunnelPortStatus_t *status);
917 
918 /*****************************************************************/
929 OFDPA_ERROR_t ofdpaTunnelPortNextGet(uint32_t portNum, uint32_t *nextPortNum);
930 
931 /*****************************************************************/
948 OFDPA_ERROR_t ofdpaTunnelPortTenantAdd(uint32_t portNum, uint32_t tunnelId);
949 
950 /*****************************************************************/
961 OFDPA_ERROR_t ofdpaTunnelPortTenantDelete(uint32_t portNum, uint32_t tunnelId);
962 
963 /*****************************************************************/
981 OFDPA_ERROR_t ofdpaTunnelPortTenantGet(uint32_t portNum, uint32_t tunnelId, ofdpaTunnelPortTenantStatus_t *status);
982 
983 /*****************************************************************/
997 OFDPA_ERROR_t ofdpaTunnelPortTenantNextGet(uint32_t portNum, uint32_t tunnelId, uint32_t *nextTunnelId);
998 
999 /*****************************************************************/
1015 
1016 /*****************************************************************/
1029 OFDPA_ERROR_t ofdpaTunnelTenantDelete(uint32_t tunnelId);
1030 
1031 /*****************************************************************/
1049 OFDPA_ERROR_t ofdpaTunnelTenantGet(uint32_t tunnelId,
1050  ofdpaTunnelTenantConfig_t *config,
1051  ofdpaTunnelTenantStatus_t *status);
1052 
1053 /*****************************************************************/
1064 OFDPA_ERROR_t ofdpaTunnelTenantNextGet(uint32_t tunnelId, uint32_t *nextTunnelId);
1065 
1066 /*****************************************************************/
1081 
1082 /*****************************************************************/
1095 OFDPA_ERROR_t ofdpaTunnelNextHopDelete(uint32_t nextHopId);
1096 
1097 /*****************************************************************/
1117 
1118 /*****************************************************************/
1136 OFDPA_ERROR_t ofdpaTunnelNextHopGet(uint32_t nextHopId,
1138  ofdpaTunnelNextHopStatus_t *status);
1139 
1140 /*****************************************************************/
1151 OFDPA_ERROR_t ofdpaTunnelNextHopNextGet(uint32_t nextHopId, uint32_t *nextNextHopId);
1152 
1153 /*****************************************************************/
1168 
1169 /*****************************************************************/
1182 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupDelete(uint32_t ecmpNextHopGroupId);
1183 
1184 /*****************************************************************/
1202 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupGet(uint32_t ecmpNextHopGroupId,
1205 
1206 /*****************************************************************/
1217 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupNextGet(uint32_t ecmpNextHopGroupId, uint32_t *nextEcmpNextHopGroupId);
1218 
1219 /*****************************************************************/
1230 
1231 /*****************************************************************/
1248 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupMemberAdd(uint32_t ecmpNextHopGroupId, uint32_t nextHopId);
1249 
1250 /*****************************************************************/
1262 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupMemberDelete(uint32_t ecmpNextHopGroupId, uint32_t nextHopId);
1263 
1264 /*****************************************************************/
1274 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupMemberGet(uint32_t ecmpNextHopListGroupId, uint32_t nextHopId);
1275 
1276 /*****************************************************************/
1288 OFDPA_ERROR_t ofdpaTunnelEcmpNextHopGroupMemberNextGet(uint32_t ecmpNextHopListGroupId, uint32_t nextHopId, uint32_t *nextNextHopId);
1289 
1290 /*****************************************************************/
1316 OFDPA_ERROR_t ofdpaPktSend(ofdpa_buffdesc *pkt, uint32_t flags, uint32_t outPortNum, uint32_t inPortNum);
1317 
1318 /*****************************************************************/
1328 OFDPA_ERROR_t ofdpaMaxPktSizeGet(uint32_t *pktSize);
1329 
1330 /*------------------------------------------------------------------------------------*/
1331 /* Event APIs */
1332 
1333 /*
1334  Asynchronous events: Have classified them into two broad category:
1335  Packet In : Packet received from the hardware to be sent to the controller
1336  Control messages: Events like Port creation, deletion, link state, Flow age and Error
1337 
1338  The packet In events can have a high frequency, so we want to ensure that there is
1339  separate control for polling of these two event types to give flexibility to the agent
1340 */
1341 
1342 /*****************************************************************/
1349 int ofdpaClientEventSockFdGet(void);
1350 
1351 /*****************************************************************/
1358 int ofdpaClientPktSockFdGet(void);
1359 
1360 /*****************************************************************/
1392 OFDPA_ERROR_t ofdpaPktReceive(struct timeval *timeout, ofdpaPacket_t *pkt);
1393 
1394 
1395 /*****************************************************************/
1406 OFDPA_ERROR_t ofdpaEventReceive(struct timeval *timeout);
1407 
1408 /*****************************************************************/
1422 
1423 /*****************************************************************/
1437 
1438 /*------------------------------------------------------------------------------------*/
1439 /* Table APIs */
1440 
1441 /* Get information for a given table Id */
1442 
1443 /*****************************************************************/
1455 
1456 /*------------------------------------------------------------------------------------*/
1457 /* Queue APIs */
1458 
1459 /*****************************************************************/
1472 OFDPA_ERROR_t ofdpaNumQueuesGet(uint32_t portNum, uint32_t *numQueues);
1473 
1474 /*****************************************************************/
1488 OFDPA_ERROR_t ofdpaQueueStatsGet(uint32_t portNum, uint32_t queueId, ofdpaPortQueueStats_t *stats);
1489 
1490 /*****************************************************************/
1503 OFDPA_ERROR_t ofdpaQueueStatsClear(uint32_t portNum, uint32_t queueId);
1504 
1505 /*****************************************************************/
1521 OFDPA_ERROR_t ofdpaQueueRateSet(uint32_t portNum, uint32_t queueId, uint32_t minRate, uint32_t maxRate);
1522 
1523 /*****************************************************************/
1539 OFDPA_ERROR_t ofdpaQueueRateGet(uint32_t portNum, uint32_t queueId, uint32_t *minRate, uint32_t *maxRate);
1540 
1541 /*------------------------------------------------------------------------------------*/
1542 /* Vendor Extension APIs */
1543 
1544 /*****************************************************************/
1562 
1563 /*****************************************************************/
1578 
1579 /*****************************************************************/
1590 
1591 /*****************************************************************/
1602 
1603 
1604 /* Development utility APIs */
1605 /*****************************************************************/
1613 int ofdpaDebugLvl(int lvl);
1614 
1615 /*****************************************************************/
1622 int ofdpaDebugLvlGet(void);
1623 
1624 /*****************************************************************/
1634 int ofdpaComponentNameGet(int component, ofdpa_buffdesc *name);
1635 
1636 /*****************************************************************/
1646 int ofdpaDebugComponentSet(int component, int enable);
1647 
1648 /*****************************************************************/
1656 int ofdpaDebugComponentGet(int component);
1657 
1658 /*****************************************************************/
1667 int ofdpaBcmCommand(ofdpa_buffdesc buffer);
1668 
1669 #endif /* INCLUDE_OFDPA_API_H */
1670