]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blob - ti/runtime/netapi/netcp_cfg.h
Fix for SDOCM00107501:Compilation issues observed when compiling with C++
[keystone-rtos/netapi.git] / ti / runtime / netapi / netcp_cfg.h
1 /******************************************************************************
2  * FILE PURPOSE:  netapi NETCP configuration API header file
3  ******************************************************************************
4  * FILE NAME:   netcp_cfg.h
5  *
6  * DESCRIPTION:netapi NETCP configuration API header  file for user space transport library
7  *
8  * REVISION HISTORY:
9  *
10  *  Copyright (c) Texas Instruments Incorporated 2013
11  *
12  *  Redistribution and use in source and binary forms, with or without
13  *  modification, are permitted provided that the following conditions
14  *  are met:
15  *
16  *    Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  *
19  *    Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the
22  *    distribution.
23  *
24  *    Neither the name of Texas Instruments Incorporated nor the names of
25  *    its contributors may be used to endorse or promote products derived
26  *    from this software without specific prior written permission.
27  *
28  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  */
41 /* ============================================================= */
43 /**
44  *   @file netcp_cfg.h
45  *   @brief Netapi NETCP configuration API header file for user space transport library
46  */
50 #ifndef __NETCP_CFG__H
51 #define __NETCP_CFG__H
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
57 #include "netapi.h"
59 /**
60  *  @ingroup cfg_structures
61  *  @brief NETCP Flow ID configuaration informaation
62  *  @details A flow defines a set of free queues (pktlib heap) for hardware to use to get
63  *          free packet descriptor(s) and buffer(s) to use when receiving a packet. CPPI flow ID for
64  *          default case, use NETCP_DEFAULT_FLOW
65  */
66 typedef struct NETCP_CFG_FLOW_Tag
67 {
68     int flowid;         /**< flow id*/
69     int dma_engine;     /**< dma engine (QMSS, NETCP)*/
70 } NETCP_CFG_FLOW_T;
73 /**
74  *  @ingroup cfg_structures
75  *  @brief NETAPI configuration information
76  *
77  *  @details The parameters in this structure are used to configure NETAPI.
78  */
79 typedef struct NETAPI_CFG_Tag
80 {
81  int def_mem_size;                  /**<  Bytes of CMA memory we have allocated */
82  int def_flow_pkt_rx_offset;        /**<  Offset in pkt buffer for hw to start RX */
83  int def_max_descriptors;           /**<  Number of descriptors in system  (must be power of 2), 2^14 max */
84  int def_tot_descriptors_for_us;    /**<  Number of descriptors to create in our region (must be power of 2)*/
85  int def_heap_n_descriptors;        /**<  Number of descriptor plus buffers in default heap*/
86  int def_heap_n_zdescriptors;       /**<  Number of zero len descriptors in defaut heap*/
87  int def_heap_buf_size;             /**<  Size of buffers in default heap, max amount of area for packet data */
88  int def_heap_tailroom_size;        /**<  Size of tailroom in reserve */
89  int def_heap_extra_size;           /**<  Size of extra space at end of buffer */ 
90  int def_multi_process;             /**<  Flag to indicate if NETAPI init is for multi-process environment */
91 }  NETAPI_CFG_T;
93 /* @note:
94    each buffer will be allocated:  def_heap_buf_size+def_heap_extra_size bytes
95    each descriptor attached to these buffers will have rigBufferLen of:
96       def_heap_buf_size.
97    for default RX flow,  for rx packet, the bufptr  will be def_flow_pkt_rx_offset.
98    for detault RX flow,  threshold (ie max # of bytes in buffer) will be:
99        def_heap_buf_size - def_heap_tailroom_size-def_flow_pkt_rx_offset
102  RX Packet from NetCP
104 Headroom [Application]     Packet [HW]                Tailroom [Application]    Extra Space [Application]
105 <-----------------------><--------------------------><------------------------><----------------------->
107 Cppi_HostDesc->origBufferLen
108 <----------------------------------------------------------------------------->
109 Cppi_HostDesc->origBuffPtr
111 \/
112 |------------def_heap_buf_size-------------------------------------------------|--def_heap_extra_size--|
113 | def_flow_pkt_rx_offset| max Cppi_HostDesc->buffLen | def_heap_tailroom_size  |   Extra Size          |
114                         ^
115                         |
116                      Cppi_HostDesc->buffPtr
117 */
120 /**
121  * @ingroup cfg_constants
122  * @brief  This defines the handle to a NETCP configured Flow. A Flow is a set of pktlib heaps that h/w can use to obtain free packets.
123  */
124 typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
126 /**
127  * @ingroup cfg_constants
128  * @def NETCP_DEFAULT_FLOW
129  * @brief This defines the default FLOW for NETCP to use.
130  * The default flow uses the default pktlib heap created by netapi_init; i.e.
131  * NETCP will allocate descriptors and buffers for received packets from this heap.
132  */
133 #define NETCP_DEFAULT_FLOW  (NETCP_CFG_FLOW_HANDLE_T) NULL
137 /**
138  * @ingroup cfg_constants
139  * @def NETCP_DEFAULT_ROUTE
140  * @brief This defines the NETCP default route.  This route has NETCP send received packets to the default NETCP 
141  * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
142  */
143 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
146 /**
147  *  @ingroup cfg_constants
148  *  @{
149  *
150  *  @name   Valid Parameter configuration for NETCP_CFG_ROUTE_T
151  *  @brief  Valid Parameter configuration
152  *
153  *  @details Valid Parameter to configure optional parameters.
154  */
155 /* @{ */
156 /**
157  *  @def  NETCP_CFG_VALID_PARAM_ROUTE_TYPE
158  *        Valid Route Type configuration
159  *
160  */
162 #define NETCP_CFG_VALID_PARAM_ROUTE_TYPE        0x01
163 /*  @}  */
164 /** @} */
168 /**
169  *  @ingroup cfg_structures
170  *  @brief NETCP application defined route information.
171  *  @details This structure is used to define a packet receive route.  A route consists of a 
172  *           flow where to get free descriptors and buffers to hold the packet, and a destination 
173  *           queue where to place the packet. Priority routing based on VLAN priority bits,
174  *           DSCP/TOS, and received input port is supported. In the case
175  *           of priority based routing, the PASS will forward the matchd packeed to the desired
176  *           queue which is equal to the base queue plus an offset. This offset is sepcififed
177  *           by the VLAN prioirty or DSCP/TOS value, or received input port.
178  *
179  */
180 typedef struct NETCP_CFG_ROUTE_Tag
182     uint32_t            valid_params;       /**< Specifies which route config params
183                                                  are valid */
184     NETCP_CFG_FLOW_T    *p_flow;            /**< NULL or NETCP_DEFAULT_FLOW for default
185                                               *flow,@ref NETCP_CFG_FLOW_T
186                                               */
187     PKTIO_HANDLE_T      *p_dest_q;          /**< NULL for default destination queue */
189     nwalRouteType_t     routeType;          /**< Optional: Routing priority,
190                                               *  @see nwal.h for nwalRouteType_t
191                                               */
192 } NETCP_CFG_ROUTE_T;
195 /**
196  * @ingroup cfg_constants
197  * @brief  Handle to a NETCP route.
198  * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
199  *          pktio channel for packets received by NETCP
200  *    and the flow to use.
201  */
202 typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
207 /**
208  * @ingroup cfg_constants
209  * @def NETCP_CFG_ACTION_DISCARD
210  *      This defines the NETCP action to discard packet.
211  */
212 #define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
213 /**
214  * @ingroup cfg_constants
215  * @def  NETCP_CFG_ACTION_CONTINUE
216  *      This defines the NETCP action to pass packet ono the next classifier
217  */
218 #define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
219 /**
220  * @ingroup cfg_constants
221  * @def NETCP_CFG_ACTION_TO_SW
222  *      This defines the NETCP action to pass packet to User space application
223  */
224 #define NETCP_CFG_ACTION_TO_SW    NWAL_MATCH_ACTION_HOST
226 /**
227  * @ingroup cfg_constants
228  * @def NETCP_CFG_ALL_EXCEPTIONS
229  *      This defines NETCP configuration for all Exepction Packets.
230  */
231 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
233 /**
234  * @ingroup cfg_constants
235  * @brief General APP_ID Type definition.
236  */
237 typedef uint32_t NETCP_CFG_APP_ID_T;
240 /**
241  * @ingroup cfg_constants
242  * @brief  Handle to NETCP VLAN configuration (FUTURE).
243  * @details Application to use this handle to identify a VLAN configuration.
244  */
245 typedef void * NETCP_CFG_VLAN_T;
247 /**
248  * @ingroup cfg_constants
249  * @brief  NETCP PA LLD handle associated with an SA
250  * @details Application to use this handle to identify a PA PLLD handle associated with an SA.
251  */
252 typedef void * NETCP_CFG_PA_HANDLE_T;
254 /**
255  * @ingroup cfg_constants
256  * @brief  NETCP SA LLD handle associated with an SA
257  * @details Application to use this handle to identify a SA LLD handle associated with an SA.
258  */
259 typedef void * NETCP_CFG_SA_HANDLE_T;
261 /**
262  * @ingroup cfg_constants
263  * @brief  AppID for packets matching a  MAC interface rule
264  */
265 typedef uint32_t NETCP_CFG_MACIF_T;
267 /**
268  * @ingroup cfg_constants
269  * @brief AppID for packets matching an IP interface rule
270  */
271 typedef uint32_t NETCP_CFG_IP_T;
273 /**
274  * @ingroup cfg_constants
275  * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
276  */
277 typedef uint32_t NETCP_CFG_SA_T;
280 /**
281  * @ingroup cfg_constants
282  * @brief AppId for packets matching an NETCP IPSEC policy rule
283  */
284 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
288 /**
289  * @ingroup cfg_constants
290  * @brief  AppID for packets being classified as  type exception.
291  */
292 typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
294 /**
295  * @ingroup cfg_constants
296  *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
297  */
298 #define NETCP_CFG_NO_INTERFACE 0xff
302 /**
303  * @note  APPIDs are present in RX packet meta data and tell "how far" the packet got
304  * through the classification rules of NETCP. 
305  * APPID is 32 bits:
306  * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
307  * bits 23-8  = NETAPI_NETCP_MATCH_ID identifier 
308  * bits  7-0  = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
309 */
311 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0 
312 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
314 #define NETAPI_NETCP_MATCH_ID_SHIFT 8 
315 #define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
317 #define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
318 #define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
321 /**
322  * @brief Helper function to get match stage associated with application ID.
323  */
324 #define netapi_cfgGetMatchStage(appid)  (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
326 /**
327  * @brief Helper function to get match id associated with application ID.
328  */
329 #define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
331 /**
332  * @brief Helper function to get logical match interface associated with application ID.
333  */
334 #define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
335                                                     NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
338 /**
339  * @ingroup cfg_constants
340  * @def NETAPI_NETCP_MATCH_GENERIC_MAC
341  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
342  *      Logical MAC interface location:
343  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
344  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
345  *      Packet did not match any other rule.
346  */
347 #define NETAPI_NETCP_MATCH_GENERIC_MAC  0x10000000
349 /**
350  * @ingroup cfg_constants
351  * @def NETAPI_NETCP_MATCH_GENERIC_IP
352  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
353  *      Logical MAC interface location:
354  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
355  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
356  *       IP rule number for this interface location:
357  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
358  *          NETAPI_NETCP_MATCH_ID_MASK.
359  *      Packet also matched a generic IP rule attached to that interface.
360  *      Packet did not match any other rule.
361  */
362 #define NETAPI_NETCP_MATCH_GENERIC_IP   0x20000000
364 /**
365  * @ingroup cfg_constants
366  * @def NETAPI_NETCP_MATCH_CLASS
367  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
368  *      Logical MAC interface location:
369  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
370  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
371  *      Classifer ID location:
372  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
373  *          NETAPI_NETCP_MATCH_ID_MASK.
374  *      Packet also matched a generic IP rule attached to 
375  *      that interface OR a general IP rule added as part of the classifier or it matched a combination
376  *      of ISPEC SA rule and a policy check.  In addition, packet matched a L4 port rule that was added 
377  *      as part of a classifer. Packet did not match any other rule.
378  */
379 #define NETAPI_NETCP_MATCH_CLASS        0x80000000
381 /**
382  * @ingroup cfg_constants
383  * @def NETAPI_NETCP_MATCH_CLASS_L3
384  *      This define is used for an APPID that indicates that a  packet matched a MAC entry.
385  *      Logical MAC interface location:
386  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
387  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
388  *      Packet also  matched a general IP rule added as part 
389  *      of a classifier.  But it not match a L4 port or any other rule. 
390  *      We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
391  */
392 #define NETAPI_NETCP_MATCH_CLASS_L3     0x40000000
394 /**
395  * @ingroup cfg_constants
396  * @def NETAPI_NETCP_MATCH_IPSEC
397  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
398  *      Logical MAC interface location:
399  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
400  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
401  *      SA ID location:
402  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
403  *          NETAPI_NETCP_MATCH_ID_MASK.
404  *      Packet also matched an IPSEC SA  rule (matched proto, destination ip and SPI).  
405  *      Packet did not match any other rule (so may have failed a policy check)
406  */
407 #define NETAPI_NETCP_MATCH_IPSEC        0x01000000  
410 /**
411  * @ingroup cfg_constants
412  * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
413  *      This define is used for an APPID that indicates that a packet matched a MAC entry
414  *      Logical MAC interface location:
415  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
416  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
417  *      Packet also matched an IPSEC SA rule (matched proto, 
418  *      dest ip and SPI).  Packet also matched a POLICY RULE (this is a check of the inner IP).
419  *      IPSEC RX Policy ID location:
420  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
421  *          NETAPI_NETCP_MATCH_ID_MASK.
422  *      Packet did not match any other rule 
423  */
424 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000  //lower byte==interface, Or' in SA id (16 bits)
426 /**
427  * @ingroup cfg_constants
428  * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
429  *      This define is used for an APPID that indicates that a packet is of type exception. 
430  *      Actual exception id is in byte 0 of APPID.
431  */
432 #define NETAPI_NETCP_CFG_MATCH_EXCEPTION     0x08000000
436 /**
437  *  @ingroup cfg_structures
438  *  @brief NETCP flow configuration information.
439  *  @details This structure is used to define key parameters for the receive flow to be created.
440  *           These include the flow index to use (or can be left un-specified), the dma_index
441  *           (specifying out of which CPPI DMA engine the flow should be allocated),
442  *           the receive offset (the byte offset into each buffer where received data should be placed),
443  *           and the drop policy for the DMA channel to use if there is no free buffer available (drop or block)
444  *
445  */
446 typedef struct NETCP_CFG_FLOW_CONFIG_Tag
448    int              flow_index;     /**< flow index to use or NETAPI_NETCP_FLOW_INDEX_ANY */
449 /**
450  * @def NETAPI_NETCP_FLOW_INDEX_ANY
451  * @ingroup cfg_constants
452  *      This define is used to let NETAPI pick the flow index to use(for flow_index field)
453  */
454 #define NETAPI_NETCP_FLOW_INDEX_ANY  CPPI_PARAM_NOT_SPECIFIED
456    int              dma_index;      /**< allocate flow out of which DMA */
457 /**
458  * @def NETAPI_DMA_INFRASTRUCTURE
459  * @ingroup cfg_constants
460  *      This define is used specify a flow in the QMSS CPPI DMA (for dma_index field)
461  */
462 #define NETAPI_DMA_INFRASTRUCTURE 0
463 /**
464  * @def NETAPI_DMA_NETCP
465  * @ingroup cfg_constants
466  *      This define us usee specify a flow in the NETCP CPPI DMA (for dma_index field)
467  */
468 #define NETAPI_DMA_NETCP 1
470    int              recv_offset;    /**< start of packet offset */
472    int              block;          /**< TRUE => DMA will wait for free descriptor if heap(s) are empty.
473                                          FALSE => DMA will discard */
474 /**
475  * @def NETAPI_FLOW_DROP
476  * @ingroup cfg_constants
477  *      This define is used to indicate that the flow should institute a Block policy.
478  *      This means that the DMA should wait for a free descriptor/buffer to come available if
479  *      the free poll is empty (for the block field)
480  */
481 #define NETAPI_FLOW_BLOCK 1
482 /**
483  * @def NETAPI_FLOW_DROP
484  * @ingroup cfg_constants
485  *      This define us used to indicate that the flow should institute a Drop policy.
486  *      This means that the DMA should NOT wait for a free descriptor/buffer to come available
487  *      if the free poll is empty. The transfer will be aborted and the data will dropped (for block field)
488  */
489 #define NETAPI_FLOW_DROP 0
491    PKTIO_HANDLE_T * p_dest_q;       /**<destination queue for this flow (may be overwrritten by source DMA) */
492 } NETCP_CFG_FLOW_CONFIG_T;
499 /**
500  *  @ingroup cfg_functions
501  *  @brief netapi_netcpCfgAddFlow   API to add a flow
502  * 
503  *  @details This api is used to add a flow
504  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
505  *  @param[in]  n    number of Pktlib_HeapHandle
506  *  @param[in]  handles[]   Handles to Pktlib_HeapHandle
507  *  @param[in]  sizes[]     must be <= heap corresponding heap size-recv_offset-any desired tail room
508  *  @param[in]  p_cfg   @ref NETCP_CFG_FLOW_CONFIG_T
509  *  @param[out] err     pointer to error return
510  *  @retval     NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
511  *  @pre       @ref netapi_init
512  */
513 NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
514                                             int n, 
515                                             Pktlib_HeapHandle handles[],
516                                             int sizes[],
517                                             NETCP_CFG_FLOW_CONFIG_T * p_cfg,
518                                             int * err );
520 /**
521  *  @ingroup cfg_functions
522  *  @brief netapi_netcpCfgDelFlow   API to delete a flow
523  * 
524  *  @details This api is used to delete a flow.
525  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
526  *  @param[in]  p    handle to NETCP  flow
527  *  @param[out] err     pointer to error return
528  *  @retval     none
529  *  @pre       @ref netapi_init, netapi_netcpCfgAddFlow
530  */
531 void netapi_netcpCfgDelFlow(NETAPI_T h ,
532                                             NETCP_CFG_FLOW_HANDLE_T p ,
533                                             int * err);
535 /**
536  *  @ingroup cfg_functions
537  *  @brief  API attaches an IP address and qualifier to a MAC interface
538  * 
539  *  @details This api is used to add an IP address to a MAC interface along
540  *            with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default 
541  *            may be specified to indicate where to send packets matching the MAC interface MAC address, the
542  *            supplied IP address and any qualifier.  This API adds a rule to the NETCP level 1 lookup tables.
543  *            Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_IP
544  *            Note: An IP address must be attached to enable NETCP receive Checksum offload feature
545  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
546  *  @param[in]  iface_no    interface number (0,1,..)
547  *  @param[in]  ipType  type of IP address (V4 for V6)
548  *  @param[in]  ip_addr destination or local
549  *  @param[in]  ip_rem_addr source or remote
550  *  @param[in]  ip_qualifiers   ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
551  *                              diffserv category for example.
552  *  @param[in]  route       handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
553  *  @param[in]  user_data     Optional: pointer to user provided data associated with IP
554  *  @param[in]  ip_addr remote
555  *  @param[out] err     pointer to error return
556  
557  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
558  *  @pre       @ref netapi_init
559  */
560 NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                   h,
561                                      int                        iface_no,
562                                      nwal_IpType                ipType,
563                                      nwalIpAddr_t*              ip_addr,
564                                      nwalIpAddr_t*              ip_rem_addr,
565                                      nwalIpOpt_t*               ip_qualifiers,
566                                      NETCP_CFG_ROUTE_HANDLE_T   route,
567                                      void*                      user_data,
568                                      int*                       err);
570 /**
571  *  @ingroup cfg_functions
572  *  @brief netapi_netcpCfgDelIp   API to delete IP interface
573  * 
574  *  @details This api is used to delete an IP interface
575  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
576  *  @param[in]  iface_no    interface number (0,1,..)
577  *  @param[in]  ipType  type of IP address (V4 for V6)
578  *  @param[in]  ip_addr      ip_address
579  *  @param[in]  ip_qualifiers   ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
580  *                  diffserv category for example.
581  *  @param[in]  ip_rule_id      @ref NETCP_CFG_IP_T
582  *  @param[out] err     pointer to error return
583  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
584  *  @pre       @ref netapi_init , @ref netapi_netcpCfgAddIp
585  */
586 void netapi_netcpCfgDelIp(NETAPI_T          h, 
587                           int               iface_no,
588                           nwal_IpType       ipType,
589                           nwalIpAddr_t*     ip_addr,
590                           nwalIpOpt_t*      ip_qualifiers, 
591                           NETCP_CFG_IP_T    ip_rule_id,
592                           int*              err);
594 /**
595  *  @ingroup cfg_functions
596  *  @brief netapi_netcpCfgCreateMacInterface  API to insert a MAC interface rule in the NETCP hardware
597  *  lookup engines.
598  * 
599  *  @details This api is used to insert a MAC interface in the NETCP hardware lookup engines.
600  *      Once it is created, the MAC interface can be used to receive packets. The API
601  *      adds a rule to the NETCP 1st level lookup tables to route all packets with destination
602  *      MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
603  *      the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
604  *      Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_MAC
605  *      Note: The internal SOC switch (if operating in full swithc mode) may need to  be "taught" that this mac
606  *      address is present by transmitting a packet with destination mac = this interface mac address.
607  *  @param[in]  h   NETAPI instance handle, @ref NETAPI_T
608  *  @param[in]  p_mac   pointer to 6 byte MAC address for local interface
609  *  @param[in]  p_mac_remote   pointer to 6 byte MAC address for remote interface
610  *  @param[in]  iface_no    interface number (0,1,..) 
611  *  @param[in]  switch_port     (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly] 
612  *  @param[in]  route   handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
613  *  @param[in]  vlan    [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
614  *  @param[in]  state   [future] interface state (0=down, 1= up)
615  *  @param[out] err     pointer to error return
616  *  @retval     returns AppID for interface (this is returned in meta data for received packets matching this rule an no others, @ref NETCP_CFG_MACIF_T
617  *  @pre       @ref netapi_init 
618  */
619 NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T                   h,
620                                                      uint8_t*                   p_mac,
621                                                      uint8_t*                   p_mac_remote,
622                                                      int                        iface_no,
623                                                      int                        switch_port,
624                                                      NETCP_CFG_ROUTE_HANDLE_T   route,
625                                                      NETCP_CFG_VLAN_T           vlan,
626                                                      int                        state,
627                                                      int *                      err);
629 /**
630  *  @ingroup cfg_functions
631  *  @brief netapi_netcpCfgDelMac   API to delete MAC  interface
632  * 
633  *  @details This api is used to delete a MAC interface
634  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
635  *  @param[in]  iface_no    interface number (0,1,..)
636  *  @param[out] err     pointer to error return
637  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
638  *  @pre       @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface 
639  */
640 void netapi_netcpCfgDelMac(NETAPI_T     h,
641                            int          iface_no,
642                            int*         err);
645 /**
646  * @brief This defines handle to installed classifier returned by API.  Pkts matching this classifier will have meta data with this tag.
647  *  Also used to delete classifier
648  */
649 typedef uint32_t NETCP_CFG_CLASS_T;
652 /**
653  *  @ingroup cfg_structures
654  *  @brief NETAPI Class L4 Configuration
655  *
656  *  @details This structure contains Classifier L4 Configuration. In this type of classifier, the  L2 and L3 header match criteria are implied by the iface and ip entries.  L4 packet match criteria are defined by the proto and appProto fields ( L4 protocol id and ports)
657  */
658 typedef struct NETCP_CFG_CLASS_L4_Tag
660     int                 iface;      /**< Indicates which MAC interface packet should be received on*/
661     NETCP_CFG_IP_T      ip;         /**< IP rule to match: see @ref NETCP_CFG_IP_T */
662     nwal_appProtoType_t proto;      /**< L4 proto (-1 for don't care)*/
663     nwalAppProto_t      appProto;   /**< L4 Ports or equivalent */
665 } NETCP_CFG_CLASS_L4_T;
668 /**
669  *  @ingroup cfg_structures
670  *  @brief NETAPI Classifier L4 plus IPSEC policy configuration
671  *
672  *  @details This structure contains Classifier L4 plus IPSEC policy configuration. In this type of classifier, the  L2,L3 header match criteria are implied by the iface and ip_policy fields. The L4 match criteria are implied by the proto and appProto fields. 
673  */
674 //classifier L4 + policy  (L2, L3 (outer), tunnel, L3 (inner)  implied by policy
675 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
677     int                       iface;      /**< Indicates which MAC interface packet should be received from */
678     NETCP_CFG_IPSEC_POLICY_T  ip_policy;  /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
679     nwal_appProtoType_t       proto;      /**< L4 proto (-1 for don't care)*/
680     nwalAppProto_t            appProto;   /**< L4 Ports or equivalent */
682 } NETCP_CFG_CLASS_L4_IPSEC_T;
686 /**
687  *  @ingroup cfg_structures
688  *  @brief NETAPI Classifier L4/L3 configuration
689  *
690  *  @details This structure contains Class L4 + L3 Classifier configuration. In this type of classifier the L2 header match criteria is implied by the iface field.  The L3 header match criteria is implied by the ipType, ip_addr and ip_qulaifier fields.  L4 match criteris is implied by the proto and appProto fields.  A failed route can be optionally included to tell NETCP what to do if the L3 portion of the classifier matches but not the L4 portion.
691  */
692 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
694     int                         iface;          /**< Indicates which MAC interface packet is from */
695     nwal_IpType                 ipType;         /**< IP address type, IPV4 or IPV6 */
696     nwalIpAddr_t*               ip_addr;        /**< IP address to match */
697     nwalIpOpt_t*                ip_qualifiers;  /**< IP address qualifiers */
698     NETCP_CFG_ROUTE_HANDLE_T    p_fail_route;   /**< What to do if L3 matches but L4 fails AND L3 is a 
699                                                      new rule.(if exisitng rule, then existing fail
700                                                      route will be used). */
701     nwal_appProtoType_t         proto;          /**< L4 proto (-1 for don't care)*/
702     nwalAppProto_t              appProto;       /**< Ports or equivalent */
703 } NETCP_CFG_CLASS_L3_L4_T;
705 /**
706  *  @ingroup cfg_structures
707  *  @brief NETAPI Classifier configuration
708  *
709  *  @details This structure contains the NETAPI classifer configuration.  This is a union of the different classifier types above
710  */
711 typedef struct NETCP_CFG_CLASSIFIER_Tag
714 /**
715  * Classifer type which can be set to one of the following defines:
716  * <br>
717  *      @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
718  */
719     int classType;
721 /**
722  * @def NETCP_CFG_CLASS_TYPE_L4
723  * @ingroup cfg_constants
724  *      This defines classifier type to be Class L4. Class L4 classifiers specifiy the L4 protocol information of the packets to matched;  the L2,L3 portions of the classifier are implied by supplied handles from the mac interface create and IP Add APIs
725  */
726 #define NETCP_CFG_CLASS_TYPE_L4  0
728 /**
729  * @def NETCP_CFG_CLASS_TYPE_L3_L4
730  * @ingroup cfg_constants
731  *      This defines classifier type to be Class L4/L3 .  Class L3_L4 classifiers specify both the IP address (L3) and the L4 protocol information of the packets to be matched.
732  */
733 #define NETCP_CFG_CLASS_TYPE_L3_L4  1
735      union
736     {
737         NETCP_CFG_CLASS_L3_L4_T     c_l3_l4;    /**< @ref NETCP_CFG_CLASS_L3_L4_T */
738         NETCP_CFG_CLASS_L4_T        c_l4;       /**< @ref NETCP_CFG_CLASS_L4_T */
739         NETCP_CFG_CLASS_L4_IPSEC_T  c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
740     } u;                                        /**< union for classifier type configuration structure */
741 } NETCP_CFG_CLASSIFIER_T;
745 /**
746  *  @ingroup cfg_functions
747  *  @brief netapi_netcpCfgAddClass   API to attach a classifier rule to NETCP.
748  *      This can be used to route a particular packet flow to a specific PKTIO channel
749  * 
750  *  @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific 
751  *  pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
752  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
753  *  @param[in]  p_class definition of the classifier
754  *  @param[in]  p_route handle to NETCP route.
755  *  @param[in]  action       what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
756  *  @param[in]  user_data     Optional: pointer to user provided data associated with SA
757  *  @param[out] err     pointer to error return
758  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
759  *  @pre       @ref netapi_init
760  */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                   h,
761                                              NETCP_CFG_CLASSIFIER_T*    p_class,
762                                              NETCP_CFG_ROUTE_HANDLE_T   p_route,
763                                              int                        action,
764                                              void*                      user_data,
765                                              int*                       err);
769 /**
770  *  @ingroup cfg_functions
771  *  @brief netapi_netcpCfgDelClass   API to delete a preconfigured classifier
772  * 
773  *  @details This API can be used to delete a preconfigured classifier
774  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
775  *  @param[in]  classId
776  *  @param[out] err     pointer to error return
777  *  @retval     none
778  *  @pre       @ref netapi_init, @ref netapi_netcpCfgAddClass
779  */
780 void netapi_netcpCfgDelClass(NETAPI_T           h,
781                              NETCP_CFG_CLASS_T  classId,
782                              int*               err);
785 /**
786  *  @ingroup netapi_cb_functions
787  *  @brief NETCP_CFG_STATS_CB   Callback function that is used to return statistics from NETCP
788  * 
789  *  @details The application provides a callback function that NETAPI  uses to report statistics.
790  *  The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
791  *  Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
792  *  @param[in]  h   NETAPI instance handle, @ref NETAPI_T
793  *  @param[out]  pPaStats    the PA (NETCP packet accelerator subsystem) statistics block 
794  *  @retval     none 
795  *  @pre       @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
796  */
797 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T      h,
798                                    paSysStats_t* pPaStats);
800 /**
801  *  @ingroup cfg_functions
802  *  @brief netapi_netcpCfgReqStats   API to request statistics from NETCP
803  * 
804  *  @details This api is used to request a statistics from NETCP.  This will generate a stats request
805  *  command to NETCP. Sometime later, the statistics result will arrive and will be passed to 
806  *  the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
807  *  Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
808  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
809  *  @param[in]  cb   the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
810  *  @param[in]  doClear     clear the stats in NETCP after the report (0=no, 1=yes) 
811  *  @param[out] err     pointer to error return
812  *  @retval     none 
813  *  @pre       @ref netapi_init 
814  */
815 void netapi_netcpCfgReqStats(NETAPI_T               h,
816                              NETCP_CFG_STATS_CB     cb,
817                              int                    doClear,
818                              int*                   err);
821 /**
822  *  @ingroup cfg_functions
823  *  @brief netapi_netcpCfgExceptions    API to configure NETCP with global rules for exception packet handling
824  *
825  *  @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
826  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
827  *  @param[in]  exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
828  *  @param[in]  p_route handle to NETCP route.
829  *  @param[in]  action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
830  *  @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
831  *  @pre       @ref netapi_init 
832  */
833 NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T                    h,
834                                                     int                         exception_id ,
835                                                     nwal_matchAction_t          action,
836                                                     NETCP_CFG_ROUTE_HANDLE_T    p_route);
839 #ifdef __cplusplus
841 #endif
842 #endif