]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blob - ti/runtime/netapi/netcp_cfg.h
cd4bb2d9142228348aef0dc27645afacb5116991
[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 #include "netapi.h"
55 /**
56  *  @ingroup cfg_structures
57  *  @brief NETCP Flow ID configuaration informaation
58  *  @details A flow defines a set of free queues (pktlib heap) for hardware to use to get
59  *          free packet descriptor(s) and buffer(s) to use when receiving a packet. CPPI flow ID for
60  *          default case, use NETCP_DEFAULT_FLOW
61  */
62 typedef struct NETCP_CFG_FLOW_Tag
63 {
64     int flowid;         /**< flow id*/
65     int dma_engine;     /**< dma engine (QMSS, NETCP)*/
66 } NETCP_CFG_FLOW_T;
69 /**
70  *  @ingroup cfg_structures
71  *  @brief NETAPI configuration information
72  *
73  *  @details The parameters in this structure are used to configure NETAPI.
74  */
75 typedef struct NETAPI_CFG_Tag
76 {
77  int def_mem_size;                  /**<  Bytes of CMA memory we have allocated */
78  int def_flow_pkt_rx_offset;        /**<  Offset in pkt buffer for hw to start RX */
79  int def_max_descriptors;           /**<  Number of descriptors in system  (must be power of 2), 2^14 max */
80  int def_tot_descriptors_for_us;    /**<  Number of descriptors to create in our region (must be power of 2)*/
81  int def_heap_n_descriptors;        /**<  Number of descriptor plus buffers in default heap*/
82  int def_heap_n_zdescriptors;       /**<  Number of zero len descriptors in defaut heap*/
83  int def_heap_buf_size;             /**<  Size of buffers in default heap, max amount of area for packet data */
84  int def_heap_tailroom_size;        /**<  Size of tailroom in reserve */
85  int def_heap_extra_size;           /**<  Size of extra space at end of buffer */ 
86  int def_multi_process;             /**<  Flag to indicate if NETAPI init is for multi-process environment */
87 }  NETAPI_CFG_T;
89 /* @note:
90    each buffer will be allocated:  def_heap_buf_size+def_heap_extra_size bytes
91    each descriptor attached to these buffers will have rigBufferLen of:
92       def_heap_buf_size.
93    for default RX flow,  for rx packet, the bufptr  will be def_flow_pkt_rx_offset.
94    for detault RX flow,  threshold (ie max # of bytes in buffer) will be:
95        def_heap_buf_size - def_heap_tailroom_size-def_flow_pkt_rx_offset
98  RX Packet from NetCP
100 Headroom [Application]     Packet [HW]                Tailroom [Application]    Extra Space [Application]
101 <-----------------------><--------------------------><------------------------><----------------------->
103 Cppi_HostDesc->origBufferLen
104 <----------------------------------------------------------------------------->
105 Cppi_HostDesc->origBuffPtr
107 \/
108 |------------def_heap_buf_size-------------------------------------------------|--def_heap_extra_size--|
109 | def_flow_pkt_rx_offset| max Cppi_HostDesc->buffLen | def_heap_tailroom_size  |   Extra Size          |
110                         ^
111                         |
112                      Cppi_HostDesc->buffPtr
113 */
116 /**
117  * @ingroup cfg_constants
118  * @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.
119  */
120 typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
122 /**
123  * @ingroup cfg_constants
124  * @def NETCP_DEFAULT_FLOW
125  * @brief This defines the default FLOW for NETCP to use.
126  * The default flow uses the default pktlib heap created by netapi_init; i.e.
127  * NETCP will allocate descriptors and buffers for received packets from this heap.
128  */
129 #define NETCP_DEFAULT_FLOW  (NETCP_CFG_FLOW_HANDLE_T) NULL
133 /**
134  * @ingroup cfg_constants
135  * @def NETCP_DEFAULT_ROUTE
136  * @brief This defines the NETCP default route.  This route has NETCP send received packets to the default NETCP 
137  * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
138  */
139 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
142 /**
143  *  @ingroup cfg_constants
144  *  @{
145  *
146  *  @name   Valid Parameter configuration for NETCP_CFG_ROUTE_T
147  *  @brief  Valid Parameter configuration
148  *
149  *  @details Valid Parameter to configure optional parameters.
150  */
151 /* @{ */
152 /**
153  *  @def  NETCP_CFG_VALID_PARAM_ROUTE_TYPE
154  *        Valid Route Type configuration
155  *
156  */
158 #define NETCP_CFG_VALID_PARAM_ROUTE_TYPE        0x01
159 /*  @}  */
160 /** @} */
164 /**
165  *  @ingroup cfg_structures
166  *  @brief NETCP application defined route information.
167  *  @details This structure is used to define a packet receive route.  A route consists of a 
168  *           flow where to get free descriptors and buffers to hold the packet, and a destination 
169  *           queue where to place the packet. Priority routing based on VLAN priority bits,
170  *           DSCP/TOS, and received input port is supported. In the case
171  *           of priority based routing, the PASS will forward the matchd packeed to the desired
172  *           queue which is equal to the base queue plus an offset. This offset is sepcififed
173  *           by the VLAN prioirty or DSCP/TOS value, or received input port.
174  *
175  */
176 typedef struct NETCP_CFG_ROUTE_Tag
178     uint32_t            valid_params;       /**< Specifies which route config params
179                                                  are valid */
180     NETCP_CFG_FLOW_T    *p_flow;            /**< NULL or NETCP_DEFAULT_FLOW for default
181                                               *flow,@ref NETCP_CFG_FLOW_T
182                                               */
183     PKTIO_HANDLE_T      *p_dest_q;          /**< NULL for default destination queue */
185     nwalRouteType_t     routeType;          /**< Optional: Routing priority,
186                                               *  @see nwal.h for nwalRouteType_t
187                                               */
188 } NETCP_CFG_ROUTE_T;
191 /**
192  * @ingroup cfg_constants
193  * @brief  Handle to a NETCP route.
194  * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
195  *          pktio channel for packets received by NETCP
196  *    and the flow to use.
197  */
198 typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
203 /**
204  * @ingroup cfg_constants
205  * @def NETCP_CFG_ACTION_DISCARD
206  *      This defines the NETCP action to discard packet.
207  */
208 #define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
209 /**
210  * @ingroup cfg_constants
211  * @def  NETCP_CFG_ACTION_CONTINUE
212  *      This defines the NETCP action to pass packet ono the next classifier
213  */
214 #define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
215 /**
216  * @ingroup cfg_constants
217  * @def NETCP_CFG_ACTION_TO_SW
218  *      This defines the NETCP action to pass packet to User space application
219  */
220 #define NETCP_CFG_ACTION_TO_SW    NWAL_MATCH_ACTION_HOST
222 /**
223  * @ingroup cfg_constants
224  * @def NETCP_CFG_ALL_EXCEPTIONS
225  *      This defines NETCP configuration for all Exepction Packets.
226  */
227 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
229 /**
230  * @ingroup cfg_constants
231  * @brief General APP_ID Type definition.
232  */
233 typedef uint32_t NETCP_CFG_APP_ID_T;
236 /**
237  * @ingroup cfg_constants
238  * @brief  Handle to NETCP VLAN configuration (FUTURE).
239  * @details Application to use this handle to identify a VLAN configuration.
240  */
241 typedef void * NETCP_CFG_VLAN_T;
243 /**
244  * @ingroup cfg_constants
245  * @brief  NETCP PA LLD handle associated with an SA
246  * @details Application to use this handle to identify a PA PLLD handle associated with an SA.
247  */
248 typedef void * NETCP_CFG_PA_HANDLE_T;
250 /**
251  * @ingroup cfg_constants
252  * @brief  NETCP SA LLD handle associated with an SA
253  * @details Application to use this handle to identify a SA LLD handle associated with an SA.
254  */
255 typedef void * NETCP_CFG_SA_HANDLE_T;
257 /**
258  * @ingroup cfg_constants
259  * @brief  AppID for packets matching a  MAC interface rule
260  */
261 typedef uint32_t NETCP_CFG_MACIF_T;
263 /**
264  * @ingroup cfg_constants
265  * @brief AppID for packets matching an IP interface rule
266  */
267 typedef uint32_t NETCP_CFG_IP_T;
269 /**
270  * @ingroup cfg_constants
271  * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
272  */
273 typedef uint32_t NETCP_CFG_SA_T;
276 /**
277  * @ingroup cfg_constants
278  * @brief AppId for packets matching an NETCP IPSEC policy rule
279  */
280 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
284 /**
285  * @ingroup cfg_constants
286  * @brief  AppID for packets being classified as  type exception.
287  */
288 typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
290 /**
291  * @ingroup cfg_constants
292  *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
293  */
294 #define NETCP_CFG_NO_INTERFACE 0xff
298 /**
299  * @note  APPIDs are present in RX packet meta data and tell "how far" the packet got
300  * through the classification rules of NETCP. 
301  * APPID is 32 bits:
302  * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
303  * bits 23-8  = NETAPI_NETCP_MATCH_ID identifier 
304  * bits  7-0  = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
305 */
307 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0 
308 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
310 #define NETAPI_NETCP_MATCH_ID_SHIFT 8 
311 #define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
313 #define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
314 #define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
317 /**
318  * @brief Helper function to get match stage associated with application ID.
319  */
320 #define netapi_cfgGetMatchStage(appid)  (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
322 /**
323  * @brief Helper function to get match id associated with application ID.
324  */
325 #define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
327 /**
328  * @brief Helper function to get logical match interface associated with application ID.
329  */
330 #define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
331                                                     NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
334 /**
335  * @ingroup cfg_constants
336  * @def NETAPI_NETCP_MATCH_GENERIC_MAC
337  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
338  *      Logical MAC interface location:
339  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
340  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
341  *      Packet did not match any other rule.
342  */
343 #define NETAPI_NETCP_MATCH_GENERIC_MAC  0x10000000
345 /**
346  * @ingroup cfg_constants
347  * @def NETAPI_NETCP_MATCH_GENERIC_IP
348  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
349  *      Logical MAC interface location:
350  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
351  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
352  *       IP rule number for this interface location:
353  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
354  *          NETAPI_NETCP_MATCH_ID_MASK.
355  *      Packet also matched a generic IP rule attached to that interface.
356  *      Packet did not match any other rule.
357  */
358 #define NETAPI_NETCP_MATCH_GENERIC_IP   0x20000000
360 /**
361  * @ingroup cfg_constants
362  * @def NETAPI_NETCP_MATCH_CLASS
363  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
364  *      Logical MAC interface location:
365  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
366  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
367  *      Classifer ID location:
368  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
369  *          NETAPI_NETCP_MATCH_ID_MASK.
370  *      Packet also matched a generic IP rule attached to 
371  *      that interface OR a general IP rule added as part of the classifier or it matched a combination
372  *      of ISPEC SA rule and a policy check.  In addition, packet matched a L4 port rule that was added 
373  *      as part of a classifer. Packet did not match any other rule.
374  */
375 #define NETAPI_NETCP_MATCH_CLASS        0x80000000
377 /**
378  * @ingroup cfg_constants
379  * @def NETAPI_NETCP_MATCH_CLASS_L3
380  *      This define is used for an APPID that indicates that a  packet matched a MAC entry.
381  *      Logical MAC interface location:
382  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
383  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
384  *      Packet also  matched a general IP rule added as part 
385  *      of a classifier.  But it not match a L4 port or any other rule. 
386  *      We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
387  */
388 #define NETAPI_NETCP_MATCH_CLASS_L3     0x40000000
390 /**
391  * @ingroup cfg_constants
392  * @def NETAPI_NETCP_MATCH_IPSEC
393  *      This define is used for an APPID that indicates that a packet matched a MAC entry.
394  *      Logical MAC interface location:
395  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
396  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
397  *      SA ID location:
398  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
399  *          NETAPI_NETCP_MATCH_ID_MASK.
400  *      Packet also matched an IPSEC SA  rule (matched proto, destination ip and SPI).  
401  *      Packet did not match any other rule (so may have failed a policy check)
402  */
403 #define NETAPI_NETCP_MATCH_IPSEC        0x01000000  
406 /**
407  * @ingroup cfg_constants
408  * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
409  *      This define is used for an APPID that indicates that a packet matched a MAC entry
410  *      Logical MAC interface location:
411  *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
412  *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
413  *      Packet also matched an IPSEC SA rule (matched proto, 
414  *      dest ip and SPI).  Packet also matched a POLICY RULE (this is a check of the inner IP).
415  *      IPSEC RX Policy ID location:
416  *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
417  *          NETAPI_NETCP_MATCH_ID_MASK.
418  *      Packet did not match any other rule 
419  */
420 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000  //lower byte==interface, Or' in SA id (16 bits)
422 /**
423  * @ingroup cfg_constants
424  * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
425  *      This define is used for an APPID that indicates that a packet is of type exception. 
426  *      Actual exception id is in byte 0 of APPID.
427  */
428 #define NETAPI_NETCP_CFG_MATCH_EXCEPTION     0x08000000
432 /**
433  *  @ingroup cfg_structures
434  *  @brief NETCP flow configuration information.
435  *  @details This structure is used to define key parameters for the receive flow to be created.
436  *           These include the flow index to use (or can be left un-specified), the dma_index
437  *           (specifying out of which CPPI DMA engine the flow should be allocated),
438  *           the receive offset (the byte offset into each buffer where received data should be placed),
439  *           and the drop policy for the DMA channel to use if there is no free buffer available (drop or block)
440  *
441  */
442 typedef struct NETCP_CFG_FLOW_CONFIG_Tag
444    int              flow_index;     /**< flow index to use or NETAPI_NETCP_FLOW_INDEX_ANY */
445 /**
446  * @def NETAPI_NETCP_FLOW_INDEX_ANY
447  * @ingroup cfg_constants
448  *      This define is used to let NETAPI pick the flow index to use(for flow_index field)
449  */
450 #define NETAPI_NETCP_FLOW_INDEX_ANY  CPPI_PARAM_NOT_SPECIFIED
452    int              dma_index;      /**< allocate flow out of which DMA */
453 /**
454  * @def NETAPI_DMA_INFRASTRUCTURE
455  * @ingroup cfg_constants
456  *      This define is used specify a flow in the QMSS CPPI DMA (for dma_index field)
457  */
458 #define NETAPI_DMA_INFRASTRUCTURE 0
459 /**
460  * @def NETAPI_DMA_NETCP
461  * @ingroup cfg_constants
462  *      This define us usee specify a flow in the NETCP CPPI DMA (for dma_index field)
463  */
464 #define NETAPI_DMA_NETCP 1
466    int              recv_offset;    /**< start of packet offset */
468    int              block;          /**< TRUE => DMA will wait for free descriptor if heap(s) are empty.
469                                          FALSE => DMA will discard */
470 /**
471  * @def NETAPI_FLOW_DROP
472  * @ingroup cfg_constants
473  *      This define is used to indicate that the flow should institute a Block policy.
474  *      This means that the DMA should wait for a free descriptor/buffer to come available if
475  *      the free poll is empty (for the block field)
476  */
477 #define NETAPI_FLOW_BLOCK 1
478 /**
479  * @def NETAPI_FLOW_DROP
480  * @ingroup cfg_constants
481  *      This define us used to indicate that the flow should institute a Drop policy.
482  *      This means that the DMA should NOT wait for a free descriptor/buffer to come available
483  *      if the free poll is empty. The transfer will be aborted and the data will dropped (for block field)
484  */
485 #define NETAPI_FLOW_DROP 0
487    PKTIO_HANDLE_T * p_dest_q;       /**<destination queue for this flow (may be overwrritten by source DMA) */
488 } NETCP_CFG_FLOW_CONFIG_T;
495 /**
496  *  @ingroup cfg_functions
497  *  @brief netapi_netcpCfgAddFlow   API to add a flow
498  * 
499  *  @details This api is used to add a flow
500  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
501  *  @param[in]  n    number of Pktlib_HeapHandle
502  *  @param[in]  handles[]   Handles to Pktlib_HeapHandle
503  *  @param[in]  sizes[]     must be <= heap corresponding heap size-recv_offset-any desired tail room
504  *  @param[in]  p_cfg   @ref NETCP_CFG_FLOW_CONFIG_T
505  *  @param[out] err     pointer to error return
506  *  @retval     NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
507  *  @pre       @ref netapi_init
508  */
509 NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
510                                             int n, 
511                                             Pktlib_HeapHandle handles[],
512                                             int sizes[],
513                                             NETCP_CFG_FLOW_CONFIG_T * p_cfg,
514                                             int * err );
516 /**
517  *  @ingroup cfg_functions
518  *  @brief netapi_netcpCfgDelFlow   API to delete a flow
519  * 
520  *  @details This api is used to delete a flow.
521  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
522  *  @param[in]  p    handle to NETCP  flow
523  *  @param[out] err     pointer to error return
524  *  @retval     none
525  *  @pre       @ref netapi_init, netapi_netcpCfgAddFlow
526  */
527 void netapi_netcpCfgDelFlow(NETAPI_T h ,
528                                             NETCP_CFG_FLOW_HANDLE_T p ,
529                                             int * err);
531 /**
532  *  @ingroup cfg_functions
533  *  @brief  API attaches an IP address and qualifier to a MAC interface
534  * 
535  *  @details This api is used to add an IP address to a MAC interface along
536  *            with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default 
537  *            may be specified to indicate where to send packets matching the MAC interface MAC address, the
538  *            supplied IP address and any qualifier.  This API adds a rule to the NETCP level 1 lookup tables.
539  *            Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_IP
540  *            Note: An IP address must be attached to enable NETCP receive Checksum offload feature
541  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
542  *  @param[in]  iface_no    interface number (0,1,..)
543  *  @param[in]  ipType  type of IP address (V4 for V6)
544  *  @param[in]  ip_addr destination or local
545  *  @param[in]  ip_rem_addr source or remote
546  *  @param[in]  ip_qualifiers   ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
547  *                              diffserv category for example.
548  *  @param[in]  route       handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
549  *  @param[in]  user_data     Optional: pointer to user provided data associated with IP
550  *  @param[in]  ip_addr remote
551  *  @param[out] err     pointer to error return
552  
553  *  @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
554  *  @pre       @ref netapi_init
555  */
556 NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                   h,
557                                      int                        iface_no,
558                                      nwal_IpType                ipType,
559                                      nwalIpAddr_t*              ip_addr,
560                                      nwalIpAddr_t*              ip_rem_addr,
561                                      nwalIpOpt_t*               ip_qualifiers,
562                                      NETCP_CFG_ROUTE_HANDLE_T   route,
563                                      void*                      user_data,
564                                      int*                       err);
566 /**
567  *  @ingroup cfg_functions
568  *  @brief netapi_netcpCfgDelIp   API to delete IP interface
569  * 
570  *  @details This api is used to delete an IP interface
571  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
572  *  @param[in]  iface_no    interface number (0,1,..)
573  *  @param[in]  ipType  type of IP address (V4 for V6)
574  *  @param[in]  ip_addr      ip_address
575  *  @param[in]  ip_qualifiers   ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
576  *                  diffserv category for example.
577  *  @param[in]  ip_rule_id      @ref NETCP_CFG_IP_T
578  *  @param[out] err     pointer to error return
579  *  @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
580  *  @pre       @ref netapi_init , @ref netapi_netcpCfgAddIp
581  */
582 void netapi_netcpCfgDelIp(NETAPI_T          h, 
583                           int               iface_no,
584                           nwal_IpType       ipType,
585                           nwalIpAddr_t*     ip_addr,
586                           nwalIpOpt_t*      ip_qualifiers, 
587                           NETCP_CFG_IP_T    ip_rule_id,
588                           int*              err);
590 /**
591  *  @ingroup cfg_functions
592  *  @brief netapi_netcpCfgCreateMacInterface  API to insert a MAC interface rule in the NETCP hardware
593  *  lookup engines.
594  * 
595  *  @details This api is used to insert a MAC interface in the NETCP hardware lookup engines.
596  *      Once it is created, the MAC interface can be used to receive packets. The API
597  *      adds a rule to the NETCP 1st level lookup tables to route all packets with destination
598  *      MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
599  *      the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
600  *      Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_MAC
601  *      Note: The internal SOC switch (if operating in full swithc mode) may need to  be "taught" that this mac
602  *      address is present by transmitting a packet with destination mac = this interface mac address.
603  *  @param[in]  h   NETAPI instance handle, @ref NETAPI_T
604  *  @param[in]  p_mac   pointer to 6 byte MAC address for local interface
605  *  @param[in]  p_mac_remote   pointer to 6 byte MAC address for remote interface
606  *  @param[in]  iface_no    interface number (0,1,..) 
607  *  @param[in]  switch_port     (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly] 
608  *  @param[in]  route   handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
609  *  @param[in]  vlan    [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
610  *  @param[in]  state   [future] interface state (0=down, 1= up)
611  *  @param[out] err     pointer to error return
612  *  @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
613  *  @pre       @ref netapi_init 
614  */
615 NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T                   h,
616                                                      uint8_t*                   p_mac,
617                                                      uint8_t*                   p_mac_remote,
618                                                      int                        iface_no,
619                                                      int                        switch_port,
620                                                      NETCP_CFG_ROUTE_HANDLE_T   route,
621                                                      NETCP_CFG_VLAN_T           vlan,
622                                                      int                        state,
623                                                      int *                      err);
625 /**
626  *  @ingroup cfg_functions
627  *  @brief netapi_netcpCfgDelMac   API to delete MAC  interface
628  * 
629  *  @details This api is used to delete a MAC interface
630  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
631  *  @param[in]  iface_no    interface number (0,1,..)
632  *  @param[out] err     pointer to error return
633  *  @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
634  *  @pre       @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface 
635  */
636 void netapi_netcpCfgDelMac(NETAPI_T     h,
637                            int          iface_no,
638                            int*         err);
641 /**
642  * @brief This defines handle to installed classifier returned by API.  Pkts matching this classifier will have meta data with this tag.
643  *  Also used to delete classifier
644  */
645 typedef uint32_t NETCP_CFG_CLASS_T;
648 /**
649  *  @ingroup cfg_structures
650  *  @brief NETAPI Class L4 Configuration
651  *
652  *  @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)
653  */
654 typedef struct NETCP_CFG_CLASS_L4_Tag
656     int                 iface;      /**< Indicates which MAC interface packet should be received on*/
657     NETCP_CFG_IP_T      ip;         /**< IP rule to match: see @ref NETCP_CFG_IP_T */
658     nwal_appProtoType_t proto;      /**< L4 proto (-1 for don't care)*/
659     nwalAppProto_t      appProto;   /**< L4 Ports or equivalent */
661 } NETCP_CFG_CLASS_L4_T;
664 /**
665  *  @ingroup cfg_structures
666  *  @brief NETAPI Classifier L4 plus IPSEC policy configuration
667  *
668  *  @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. 
669  */
670 //classifier L4 + policy  (L2, L3 (outer), tunnel, L3 (inner)  implied by policy
671 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
673     int                       iface;      /**< Indicates which MAC interface packet should be received from */
674     NETCP_CFG_IPSEC_POLICY_T  ip_policy;  /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
675     nwal_appProtoType_t       proto;      /**< L4 proto (-1 for don't care)*/
676     nwalAppProto_t            appProto;   /**< L4 Ports or equivalent */
678 } NETCP_CFG_CLASS_L4_IPSEC_T;
682 /**
683  *  @ingroup cfg_structures
684  *  @brief NETAPI Classifier L4/L3 configuration
685  *
686  *  @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.
687  */
688 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
690     int                         iface;          /**< Indicates which MAC interface packet is from */
691     nwal_IpType                 ipType;         /**< IP address type, IPV4 or IPV6 */
692     nwalIpAddr_t*               ip_addr;        /**< IP address to match */
693     nwalIpOpt_t*                ip_qualifiers;  /**< IP address qualifiers */
694     NETCP_CFG_ROUTE_HANDLE_T    p_fail_route;   /**< What to do if L3 matches but L4 fails AND L3 is a 
695                                                      new rule.(if exisitng rule, then existing fail
696                                                      route will be used). */
697     nwal_appProtoType_t         proto;          /**< L4 proto (-1 for don't care)*/
698     nwalAppProto_t              appProto;       /**< Ports or equivalent */
699 } NETCP_CFG_CLASS_L3_L4_T;
701 /**
702  *  @ingroup cfg_structures
703  *  @brief NETAPI Classifier configuration
704  *
705  *  @details This structure contains the NETAPI classifer configuration.  This is a union of the different classifier types above
706  */
707 typedef struct NETCP_CFG_CLASSIFIER_Tag
710 /**
711  * Classifer type which can be set to one of the following defines:
712  * <br>
713  *      @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
714  */
715     int classType;
717 /**
718  * @def NETCP_CFG_CLASS_TYPE_L4
719  * @ingroup cfg_constants
720  *      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
721  */
722 #define NETCP_CFG_CLASS_TYPE_L4  0
724 /**
725  * @def NETCP_CFG_CLASS_TYPE_L3_L4
726  * @ingroup cfg_constants
727  *      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.
728  */
729 #define NETCP_CFG_CLASS_TYPE_L3_L4  1
731      union
732     {
733         NETCP_CFG_CLASS_L3_L4_T     c_l3_l4;    /**< @ref NETCP_CFG_CLASS_L3_L4_T */
734         NETCP_CFG_CLASS_L4_T        c_l4;       /**< @ref NETCP_CFG_CLASS_L4_T */
735         NETCP_CFG_CLASS_L4_IPSEC_T  c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
736     } u;                                        /**< union for classifier type configuration structure */
737 } NETCP_CFG_CLASSIFIER_T;
741 /**
742  *  @ingroup cfg_functions
743  *  @brief netapi_netcpCfgAddClass   API to attach a classifier rule to NETCP.
744  *      This can be used to route a particular packet flow to a specific PKTIO channel
745  * 
746  *  @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific 
747  *  pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
748  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
749  *  @param[in]  p_class definition of the classifier
750  *  @param[in]  p_route handle to NETCP route.
751  *  @param[in]  action       what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
752  *  @param[in]  user_data     Optional: pointer to user provided data associated with SA
753  *  @param[out] err     pointer to error return
754  *  @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
755  *  @pre       @ref netapi_init
756  */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                   h,
757                                              NETCP_CFG_CLASSIFIER_T*    p_class,
758                                              NETCP_CFG_ROUTE_HANDLE_T   p_route,
759                                              int                        action,
760                                              void*                      user_data,
761                                              int*                       err);
765 /**
766  *  @ingroup cfg_functions
767  *  @brief netapi_netcpCfgDelClass   API to delete a preconfigured classifier
768  * 
769  *  @details This API can be used to delete a preconfigured classifier
770  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
771  *  @param[in]  classId
772  *  @param[out] err     pointer to error return
773  *  @retval     none
774  *  @pre       @ref netapi_init, @ref netapi_netcpCfgAddClass
775  */
776 void netapi_netcpCfgDelClass(NETAPI_T           h,
777                              NETCP_CFG_CLASS_T  classId,
778                              int*               err);
781 /**
782  *  @ingroup netapi_cb_functions
783  *  @brief NETCP_CFG_STATS_CB   Callback function that is used to return statistics from NETCP
784  * 
785  *  @details The application provides a callback function that NETAPI  uses to report statistics.
786  *  The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
787  *  Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
788  *  @param[in]  h   NETAPI instance handle, @ref NETAPI_T
789  *  @param[out]  pPaStats    the PA (NETCP packet accelerator subsystem) statistics block 
790  *  @retval     none 
791  *  @pre       @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
792  */
793 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T      h,
794                                    paSysStats_t* pPaStats);
796 /**
797  *  @ingroup cfg_functions
798  *  @brief netapi_netcpCfgReqStats   API to request statistics from NETCP
799  * 
800  *  @details This api is used to request a statistics from NETCP.  This will generate a stats request
801  *  command to NETCP. Sometime later, the statistics result will arrive and will be passed to 
802  *  the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
803  *  Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
804  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
805  *  @param[in]  cb   the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
806  *  @param[in]  doClear     clear the stats in NETCP after the report (0=no, 1=yes) 
807  *  @param[out] err     pointer to error return
808  *  @retval     none 
809  *  @pre       @ref netapi_init 
810  */
811 void netapi_netcpCfgReqStats(NETAPI_T               h,
812                              NETCP_CFG_STATS_CB     cb,
813                              int                    doClear,
814                              int*                   err);
817 /**
818  *  @ingroup cfg_functions
819  *  @brief netapi_netcpCfgExceptions    API to configure NETCP with global rules for exception packet handling
820  *
821  *  @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
822  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
823  *  @param[in]  exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
824  *  @param[in]  p_route handle to NETCP route.
825  *  @param[in]  action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
826  *  @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
827  *  @pre       @ref netapi_init 
828  */
829 NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T                    h,
830                                                     int                         exception_id ,
831                                                     nwal_matchAction_t          action,
832                                                     NETCP_CFG_ROUTE_HANDLE_T    p_route);
835 #endif