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 void *rmHandle; /**< Optional: Resource Manager (RM) server handle to use RM for re souce allocations*/
92 } NETAPI_CFG_T;
94 /* @note:
95 each buffer will be allocated: def_heap_buf_size+def_heap_extra_size bytes
96 each descriptor attached to these buffers will have rigBufferLen of:
97 def_heap_buf_size.
98 for default RX flow, for rx packet, the bufptr will be def_flow_pkt_rx_offset.
99 for detault RX flow, threshold (ie max # of bytes in buffer) will be:
100 def_heap_buf_size - def_heap_tailroom_size-def_flow_pkt_rx_offset
103 RX Packet from NetCP
105 Headroom [Application] Packet [HW] Tailroom [Application] Extra Space [Application]
106 <-----------------------><--------------------------><------------------------><----------------------->
108 Cppi_HostDesc->origBufferLen
109 <----------------------------------------------------------------------------->
110 Cppi_HostDesc->origBuffPtr
111 |
112 \/
113 |------------def_heap_buf_size-------------------------------------------------|--def_heap_extra_size--|
114 | def_flow_pkt_rx_offset| max Cppi_HostDesc->buffLen | def_heap_tailroom_size | Extra Size |
115 ^
116 |
117 Cppi_HostDesc->buffPtr
118 */
121 /**
122 * @ingroup cfg_constants
123 * @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.
124 */
125 typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
127 /**
128 * @ingroup cfg_constants
129 * @def NETCP_DEFAULT_FLOW
130 * @brief This defines the default FLOW for NETCP to use.
131 * The default flow uses the default pktlib heap created by netapi_init; i.e.
132 * NETCP will allocate descriptors and buffers for received packets from this heap.
133 */
134 #define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T) NULL
138 /**
139 * @ingroup cfg_constants
140 * @def NETCP_DEFAULT_ROUTE
141 * @brief This defines the NETCP default route. This route has NETCP send received packets to the default NETCP
142 * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
143 */
144 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
147 /**
148 * @ingroup cfg_constants
149 * @{
150 *
151 * @name Valid Parameter configuration for NETCP_CFG_ROUTE_T
152 * @brief Valid Parameter configuration
153 *
154 * @details Valid Parameter to configure optional parameters.
155 */
156 /* @{ */
157 /**
158 * @def NETCP_CFG_VALID_PARAM_ROUTE_TYPE
159 * Valid Route Type configuration
160 *
161 */
163 #define NETCP_CFG_VALID_PARAM_ROUTE_TYPE 0x01
164 /* @} */
165 /** @} */
169 /**
170 * @ingroup cfg_structures
171 * @brief NETCP application defined route information.
172 * @details This structure is used to define a packet receive route. A route consists of a
173 * flow where to get free descriptors and buffers to hold the packet, and a destination
174 * queue where to place the packet. Priority routing based on VLAN priority bits,
175 * DSCP/TOS, and received input port is supported. In the case
176 * of priority based routing, the PASS will forward the matchd packeed to the desired
177 * queue which is equal to the base queue plus an offset. This offset is sepcififed
178 * by the VLAN prioirty or DSCP/TOS value, or received input port.
179 *
180 */
181 typedef struct NETCP_CFG_ROUTE_Tag
182 {
183 uint32_t valid_params; /**< Specifies which route config params
184 are valid */
185 NETCP_CFG_FLOW_T *p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default
186 *flow,@ref NETCP_CFG_FLOW_T
187 */
188 PKTIO_HANDLE_T *p_dest_q; /**< NULL for default destination queue */
190 nwalRouteType_t routeType; /**< Optional: Routing priority,
191 * @see nwal.h for nwalRouteType_t
192 */
193 } NETCP_CFG_ROUTE_T;
196 /**
197 * @ingroup cfg_constants
198 * @brief Handle to a NETCP route.
199 * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
200 * pktio channel for packets received by NETCP
201 * and the flow to use.
202 */
203 typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
208 /**
209 * @ingroup cfg_constants
210 * @def NETCP_CFG_ACTION_DISCARD
211 * This defines the NETCP action to discard packet.
212 */
213 #define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
214 /**
215 * @ingroup cfg_constants
216 * @def NETCP_CFG_ACTION_CONTINUE
217 * This defines the NETCP action to pass packet ono the next classifier
218 */
219 #define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
220 /**
221 * @ingroup cfg_constants
222 * @def NETCP_CFG_ACTION_TO_SW
223 * This defines the NETCP action to pass packet to User space application
224 */
225 #define NETCP_CFG_ACTION_TO_SW NWAL_MATCH_ACTION_HOST
227 /**
228 * @ingroup cfg_constants
229 * @def NETCP_CFG_ALL_EXCEPTIONS
230 * This defines NETCP configuration for all Exepction Packets.
231 */
232 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
234 /**
235 * @ingroup cfg_constants
236 * @brief General APP_ID Type definition.
237 */
238 typedef uint32_t NETCP_CFG_APP_ID_T;
241 /**
242 * @ingroup cfg_constants
243 * @brief Handle to NETCP VLAN configuration (FUTURE).
244 * @details Application to use this handle to identify a VLAN configuration.
245 */
246 typedef void * NETCP_CFG_VLAN_T;
248 /**
249 * @ingroup cfg_constants
250 * @brief NETCP PA LLD handle associated with an SA
251 * @details Application to use this handle to identify a PA PLLD handle associated with an SA.
252 */
253 typedef void * NETCP_CFG_PA_HANDLE_T;
255 /**
256 * @ingroup cfg_constants
257 * @brief NETCP SA LLD handle associated with an SA
258 * @details Application to use this handle to identify a SA LLD handle associated with an SA.
259 */
260 typedef void * NETCP_CFG_SA_HANDLE_T;
262 /**
263 * @ingroup cfg_constants
264 * @brief AppID for packets matching a MAC interface rule
265 */
266 typedef uint32_t NETCP_CFG_MACIF_T;
268 /**
269 * @ingroup cfg_constants
270 * @brief AppID for packets matching an IP interface rule
271 */
272 typedef uint32_t NETCP_CFG_IP_T;
274 /**
275 * @ingroup cfg_constants
276 * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
277 */
278 typedef uint32_t NETCP_CFG_SA_T;
281 /**
282 * @ingroup cfg_constants
283 * @brief AppId for packets matching an NETCP IPSEC policy rule
284 */
285 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
289 /**
290 * @ingroup cfg_constants
291 * @brief AppID for packets being classified as type exception.
292 */
293 typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
295 /**
296 * @ingroup cfg_constants
297 *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
298 */
299 #define NETCP_CFG_NO_INTERFACE 0xff
303 /**
304 * @note APPIDs are present in RX packet meta data and tell "how far" the packet got
305 * through the classification rules of NETCP.
306 * APPID is 32 bits:
307 * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
308 * bits 23-8 = NETAPI_NETCP_MATCH_ID identifier
309 * bits 7-0 = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
310 */
312 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0
313 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
315 #define NETAPI_NETCP_MATCH_ID_SHIFT 8
316 #define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
318 #define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
319 #define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
322 /**
323 * @brief Helper function to get match stage associated with application ID.
324 */
325 #define netapi_cfgGetMatchStage(appid) (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
327 /**
328 * @brief Helper function to get match id associated with application ID.
329 */
330 #define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
332 /**
333 * @brief Helper function to get logical match interface associated with application ID.
334 */
335 #define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
336 NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
339 /**
340 * @ingroup cfg_constants
341 * @def NETAPI_NETCP_MATCH_GENERIC_MAC
342 * This define is used for an APPID that indicates that a packet matched a MAC entry.
343 * Logical MAC interface location:
344 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
345 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
346 * Packet did not match any other rule.
347 */
348 #define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000
350 /**
351 * @ingroup cfg_constants
352 * @def NETAPI_NETCP_MATCH_GENERIC_IP
353 * This define is used for an APPID that indicates that a packet matched a MAC entry.
354 * Logical MAC interface location:
355 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
356 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
357 * IP rule number for this interface location:
358 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
359 * NETAPI_NETCP_MATCH_ID_MASK.
360 * Packet also matched a generic IP rule attached to that interface.
361 * Packet did not match any other rule.
362 */
363 #define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000
365 /**
366 * @ingroup cfg_constants
367 * @def NETAPI_NETCP_MATCH_CLASS
368 * This define is used for an APPID that indicates that a packet matched a MAC entry.
369 * Logical MAC interface location:
370 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
371 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
372 * Classifer ID location:
373 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
374 * NETAPI_NETCP_MATCH_ID_MASK.
375 * Packet also matched a generic IP rule attached to
376 * that interface OR a general IP rule added as part of the classifier or it matched a combination
377 * of ISPEC SA rule and a policy check. In addition, packet matched a L4 port rule that was added
378 * as part of a classifer. Packet did not match any other rule.
379 */
380 #define NETAPI_NETCP_MATCH_CLASS 0x80000000
382 /**
383 * @ingroup cfg_constants
384 * @def NETAPI_NETCP_MATCH_CLASS_L3
385 * This define is used for an APPID that indicates that a packet matched a MAC entry.
386 * Logical MAC interface location:
387 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
388 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
389 * Packet also matched a general IP rule added as part
390 * of a classifier. But it not match a L4 port or any other rule.
391 * We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
392 */
393 #define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000
395 /**
396 * @ingroup cfg_constants
397 * @def NETAPI_NETCP_MATCH_IPSEC
398 * This define is used for an APPID that indicates that a packet matched a MAC entry.
399 * Logical MAC interface location:
400 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
401 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
402 * SA ID location:
403 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
404 * NETAPI_NETCP_MATCH_ID_MASK.
405 * Packet also matched an IPSEC SA rule (matched proto, destination ip and SPI).
406 * Packet did not match any other rule (so may have failed a policy check)
407 */
408 #define NETAPI_NETCP_MATCH_IPSEC 0x01000000
411 /**
412 * @ingroup cfg_constants
413 * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
414 * This define is used for an APPID that indicates that a packet matched a MAC entry
415 * Logical MAC interface location:
416 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
417 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
418 * Packet also matched an IPSEC SA rule (matched proto,
419 * dest ip and SPI). Packet also matched a POLICY RULE (this is a check of the inner IP).
420 * IPSEC RX Policy ID location:
421 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
422 * NETAPI_NETCP_MATCH_ID_MASK.
423 * Packet did not match any other rule
424 */
425 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000 //lower byte==interface, Or' in SA id (16 bits)
427 /**
428 * @ingroup cfg_constants
429 * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
430 * This define is used for an APPID that indicates that a packet is of type exception.
431 * Actual exception id is in byte 0 of APPID.
432 */
433 #define NETAPI_NETCP_CFG_MATCH_EXCEPTION 0x08000000
437 /**
438 * @ingroup cfg_structures
439 * @brief NETCP flow configuration information.
440 * @details This structure is used to define key parameters for the receive flow to be created.
441 * These include the flow index to use (or can be left un-specified), the dma_index
442 * (specifying out of which CPPI DMA engine the flow should be allocated),
443 * the receive offset (the byte offset into each buffer where received data should be placed),
444 * and the drop policy for the DMA channel to use if there is no free buffer available (drop or block)
445 *
446 */
447 typedef struct NETCP_CFG_FLOW_CONFIG_Tag
448 {
449 int flow_index; /**< flow index to use or NETAPI_NETCP_FLOW_INDEX_ANY */
450 /**
451 * @def NETAPI_NETCP_FLOW_INDEX_ANY
452 * @ingroup cfg_constants
453 * This define is used to let NETAPI pick the flow index to use(for flow_index field)
454 */
455 #define NETAPI_NETCP_FLOW_INDEX_ANY CPPI_PARAM_NOT_SPECIFIED
457 int dma_index; /**< allocate flow out of which DMA */
458 /**
459 * @def NETAPI_DMA_INFRASTRUCTURE
460 * @ingroup cfg_constants
461 * This define is used specify a flow in the QMSS CPPI DMA (for dma_index field)
462 */
463 #define NETAPI_DMA_INFRASTRUCTURE 0
464 /**
465 * @def NETAPI_DMA_NETCP
466 * @ingroup cfg_constants
467 * This define us usee specify a flow in the NETCP CPPI DMA (for dma_index field)
468 */
469 #define NETAPI_DMA_NETCP 1
471 int recv_offset; /**< start of packet offset */
473 int block; /**< TRUE => DMA will wait for free descriptor if heap(s) are empty.
474 FALSE => DMA will discard */
475 /**
476 * @def NETAPI_FLOW_DROP
477 * @ingroup cfg_constants
478 * This define is used to indicate that the flow should institute a Block policy.
479 * This means that the DMA should wait for a free descriptor/buffer to come available if
480 * the free poll is empty (for the block field)
481 */
482 #define NETAPI_FLOW_BLOCK 1
483 /**
484 * @def NETAPI_FLOW_DROP
485 * @ingroup cfg_constants
486 * This define us used to indicate that the flow should institute a Drop policy.
487 * This means that the DMA should NOT wait for a free descriptor/buffer to come available
488 * if the free poll is empty. The transfer will be aborted and the data will dropped (for block field)
489 */
490 #define NETAPI_FLOW_DROP 0
492 PKTIO_HANDLE_T * p_dest_q; /**<destination queue for this flow (may be overwrritten by source DMA) */
493 } NETCP_CFG_FLOW_CONFIG_T;
495 /**
496 * @ingroup cfg_structures
497 * @brief
498 * The structure contains the NETAPI Physical Memory Address Device configuration for
499 * QMSS and PASS Perihperals.
500 *
501 * @details
502 * The structure contains the NETAPI Physical Memory Address Device configuration for
503 * QMSS and PASS Perihperals.
504 */
505 typedef struct NETCP_CFG_GLOB_DEVICE_PARAMS_Tag
506 {
507 int fNssGen2; /**< 1: NSS Gen2 device */
508 uint32_t cslNetCpCfgRegs; /**< Base address of NETCP configuration Registers */
509 uint32_t cslQmssCfgBase; /**< Base address of QMSS configuration Registers */
510 uint32_t cslQmssDataBase; /**< Base address of QMSS Data Registers */
511 uint32_t cslNetCpCfgSaCfgRegs;/**< Base address of SA configuration Registers */
513 } NETCP_CFG_GLOB_DEVICE_PARAMS_T;
518 /**
519 * @ingroup cfg_functions
520 * @brief netapi_netcpCfgAddFlow API to add a flow
521 *
522 * @details This api is used to add a flow
523 * @param[in] h NETAPI instance handle, @ref NETAPI_T
524 * @param[in] n number of Pktlib_HeapHandle
525 * @param[in] handles[] Handles to Pktlib_HeapHandle
526 * @param[in] sizes[] must be <= heap corresponding heap size-recv_offset-any desired tail room
527 * @param[in] p_cfg @ref NETCP_CFG_FLOW_CONFIG_T
528 * @param[out] err pointer to error return
529 * @retval NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
530 * @pre @ref netapi_init
531 */
532 NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
533 int n,
534 Pktlib_HeapHandle handles[],
535 int sizes[],
536 NETCP_CFG_FLOW_CONFIG_T * p_cfg,
537 int * err );
539 /**
540 * @ingroup cfg_functions
541 * @brief netapi_netcpCfgDelFlow API to delete a flow
542 *
543 * @details This api is used to delete a flow.
544 * @param[in] h NETAPI instance handle, @ref NETAPI_T
545 * @param[in] p handle to NETCP flow
546 * @param[out] err pointer to error return
547 * @retval none
548 * @pre @ref netapi_init, netapi_netcpCfgAddFlow
549 */
550 void netapi_netcpCfgDelFlow(NETAPI_T h ,
551 NETCP_CFG_FLOW_HANDLE_T p ,
552 int * err);
554 /**
555 * @ingroup cfg_functions
556 * @brief API attaches an IP address and qualifier to a MAC interface
557 *
558 * @details This api is used to add an IP address to a MAC interface along
559 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
560 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
561 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables.
562 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
563 * Note: An IP address must be attached to enable NETCP receive Checksum offload feature
564 * @param[in] h NETAPI instance handle, @ref NETAPI_T
565 * @param[in] iface_no interface number (0,1,..)
566 * @param[in] ipType type of IP address (V4 for V6)
567 * @param[in] ip_addr destination or local
568 * @param[in] ip_rem_addr source or remote
569 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
570 * diffserv category for example.
571 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
572 * @param[in] user_data Optional: pointer to user provided data associated with IP
573 * @param[in] ip_addr remote
574 * @param[out] err pointer to error return
576 * @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
577 * @pre @ref netapi_init
578 */
579 NETCP_CFG_IP_T netapi_netcpCfgAddIp(NETAPI_T h,
580 int iface_no,
581 nwal_IpType ipType,
582 nwalIpAddr_t* ip_addr,
583 nwalIpAddr_t* ip_rem_addr,
584 nwalIpOpt_t* ip_qualifiers,
585 NETCP_CFG_ROUTE_HANDLE_T route,
586 void* user_data,
587 int* err);
589 /**
590 * @ingroup cfg_functions
591 * @brief netapi_netcpCfgDelIp API to delete IP interface
592 *
593 * @details This api is used to delete an IP interface
594 * @param[in] h NETAPI instance handle, @ref NETAPI_T
595 * @param[in] iface_no interface number (0,1,..)
596 * @param[in] ipType type of IP address (V4 for V6)
597 * @param[in] ip_addr ip_address
598 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
599 * diffserv category for example.
600 * @param[in] ip_rule_id @ref NETCP_CFG_IP_T
601 * @param[out] err pointer to error return
602 * @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
603 * @pre @ref netapi_init , @ref netapi_netcpCfgAddIp
604 */
605 void netapi_netcpCfgDelIp(NETAPI_T h,
606 int iface_no,
607 nwal_IpType ipType,
608 nwalIpAddr_t* ip_addr,
609 nwalIpOpt_t* ip_qualifiers,
610 NETCP_CFG_IP_T ip_rule_id,
611 int* err);
613 /**
614 * @ingroup cfg_functions
615 * @brief netapi_netcpCfgCreateMacInterface API to insert a MAC interface rule in the NETCP hardware
616 * lookup engines.
617 *
618 * @details This api is used to insert a MAC interface in the NETCP hardware lookup engines.
619 * Once it is created, the MAC interface can be used to receive packets. The API
620 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
621 * MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
622 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
623 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
624 * Note: The internal SOC switch (if operating in full swithc mode) may need to be "taught" that this mac
625 * address is present by transmitting a packet with destination mac = this interface mac address.
626 * @param[in] h NETAPI instance handle, @ref NETAPI_T
627 * @param[in] p_mac pointer to 6 byte MAC address for local interface
628 * @param[in] p_mac_remote pointer to 6 byte MAC address for remote interface
629 * @param[in] iface_no interface number (0,1,..)
630 * @param[in] switch_port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly]
631 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
632 * @param[in] vlan [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
633 * @param[in] state [future] interface state (0=down, 1= up)
634 * @param[out] err pointer to error return
635 * @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
636 * @pre @ref netapi_init
637 */
638 NETCP_CFG_MACIF_T netapi_netcpCfgCreateMacInterface(NETAPI_T h,
639 uint8_t* p_mac,
640 uint8_t* p_mac_remote,
641 int iface_no,
642 int switch_port,
643 NETCP_CFG_ROUTE_HANDLE_T route,
644 NETCP_CFG_VLAN_T vlan,
645 int state,
646 int * err);
648 /**
649 * @ingroup cfg_functions
650 * @brief netapi_netcpCfgDelMac API to delete MAC interface
651 *
652 * @details This api is used to delete a MAC interface
653 * @param[in] h NETAPI instance handle, @ref NETAPI_T
654 * @param[in] iface_no interface number (0,1,..)
655 * @param[out] err pointer to error return
656 * @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
657 * @pre @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface
658 */
659 void netapi_netcpCfgDelMac(NETAPI_T h,
660 int iface_no,
661 int* err);
664 /**
665 * @brief This defines handle to installed classifier returned by API. Pkts matching this classifier will have meta data with this tag.
666 * Also used to delete classifier
667 */
668 typedef uint32_t NETCP_CFG_CLASS_T;
671 /**
672 * @ingroup cfg_structures
673 * @brief NETAPI Class L4 Configuration
674 *
675 * @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)
676 */
677 typedef struct NETCP_CFG_CLASS_L4_Tag
678 {
679 int iface; /**< Indicates which MAC interface packet should be received on*/
680 NETCP_CFG_IP_T ip; /**< IP rule to match: see @ref NETCP_CFG_IP_T */
681 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
682 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
684 } NETCP_CFG_CLASS_L4_T;
687 /**
688 * @ingroup cfg_structures
689 * @brief NETAPI Classifier L4 plus IPSEC policy configuration
690 *
691 * @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.
692 */
693 //classifier L4 + policy (L2, L3 (outer), tunnel, L3 (inner) implied by policy
694 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
695 {
696 int iface; /**< Indicates which MAC interface packet should be received from */
697 NETCP_CFG_IPSEC_POLICY_T ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
698 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
699 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
701 } NETCP_CFG_CLASS_L4_IPSEC_T;
705 /**
706 * @ingroup cfg_structures
707 * @brief NETAPI Classifier L4/L3 configuration
708 *
709 * @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.
710 */
711 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
712 {
713 int iface; /**< Indicates which MAC interface packet is from */
714 nwal_IpType ipType; /**< IP address type, IPV4 or IPV6 */
715 nwalIpAddr_t* ip_addr; /**< IP address to match */
716 nwalIpOpt_t* ip_qualifiers; /**< IP address qualifiers */
717 NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a
718 new rule.(if exisitng rule, then existing fail
719 route will be used). */
720 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
721 nwalAppProto_t appProto; /**< Ports or equivalent */
722 } NETCP_CFG_CLASS_L3_L4_T;
724 /**
725 * @ingroup cfg_structures
726 * @brief NETAPI Classifier configuration
727 *
728 * @details This structure contains the NETAPI classifer configuration. This is a union of the different classifier types above
729 */
730 typedef struct NETCP_CFG_CLASSIFIER_Tag
731 {
733 /**
734 * Classifer type which can be set to one of the following defines:
735 * <br>
736 * @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
737 */
738 int classType;
740 /**
741 * @def NETCP_CFG_CLASS_TYPE_L4
742 * @ingroup cfg_constants
743 * 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
744 */
745 #define NETCP_CFG_CLASS_TYPE_L4 0
747 /**
748 * @def NETCP_CFG_CLASS_TYPE_L3_L4
749 * @ingroup cfg_constants
750 * 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.
751 */
752 #define NETCP_CFG_CLASS_TYPE_L3_L4 1
754 union
755 {
756 NETCP_CFG_CLASS_L3_L4_T c_l3_l4; /**< @ref NETCP_CFG_CLASS_L3_L4_T */
757 NETCP_CFG_CLASS_L4_T c_l4; /**< @ref NETCP_CFG_CLASS_L4_T */
758 NETCP_CFG_CLASS_L4_IPSEC_T c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
759 } u; /**< union for classifier type configuration structure */
760 } NETCP_CFG_CLASSIFIER_T;
764 /**
765 * @ingroup cfg_functions
766 * @brief netapi_netcpCfgAddClass API to attach a classifier rule to NETCP.
767 * This can be used to route a particular packet flow to a specific PKTIO channel
768 *
769 * @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific
770 * pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
771 * @param[in] h NETAPI instance handle, @ref NETAPI_T
772 * @param[in] p_class definition of the classifier
773 * @param[in] p_route handle to NETCP route.
774 * @param[in] action what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
775 * @param[in] user_data Optional: pointer to user provided data associated with SA
776 * @param[out] err pointer to error return
777 * @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
778 * @pre @ref netapi_init
779 */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T h,
780 NETCP_CFG_CLASSIFIER_T* p_class,
781 NETCP_CFG_ROUTE_HANDLE_T p_route,
782 int action,
783 void* user_data,
784 int* err);
788 /**
789 * @ingroup cfg_functions
790 * @brief netapi_netcpCfgDelClass API to delete a preconfigured classifier
791 *
792 * @details This API can be used to delete a preconfigured classifier
793 * @param[in] h NETAPI instance handle, @ref NETAPI_T
794 * @param[in] classId
795 * @param[out] err pointer to error return
796 * @retval none
797 * @pre @ref netapi_init, @ref netapi_netcpCfgAddClass
798 */
799 void netapi_netcpCfgDelClass(NETAPI_T h,
800 NETCP_CFG_CLASS_T classId,
801 int* err);
804 /**
805 * @ingroup netapi_cb_functions
806 * @brief NETCP_CFG_STATS_CB Callback function that is used to return statistics from NETCP
807 *
808 * @details The application provides a callback function that NETAPI uses to report statistics.
809 * The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
810 * Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
811 * @param[in] h NETAPI instance handle, @ref NETAPI_T
812 * @param[out] pPaStats the PA (NETCP packet accelerator subsystem) statistics block
813 * @retval none
814 * @pre @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
815 */
816 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
817 paSysStats_t* pPaStats);
819 /**
820 * @ingroup cfg_functions
821 * @brief netapi_netcpCfgReqStats API to request statistics from NETCP
822 *
823 * @details This api is used to request a statistics from NETCP. This will generate a stats request
824 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
825 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
826 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
827 * @param[in] h NETAPI instance handle, @ref NETAPI_T
828 * @param[in] cb the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
829 * @param[in] doClear clear the stats in NETCP after the report (0=no, 1=yes)
830 * @param[out] err pointer to error return
831 * @retval none
832 * @pre @ref netapi_init
833 */
834 void netapi_netcpCfgReqStats(NETAPI_T h,
835 NETCP_CFG_STATS_CB cb,
836 int doClear,
837 int* err);
840 /**
841 * @ingroup cfg_functions
842 * @brief netapi_netcpCfgExceptions API to configure NETCP with global rules for exception packet handling
843 *
844 * @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
845 * @param[in] h NETAPI instance handle, @ref NETAPI_T
846 * @param[in] exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
847 * @param[in] p_route handle to NETCP route.
848 * @param[in] action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
849 * @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
850 * @pre @ref netapi_init
851 */
852 NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T h,
853 int exception_id ,
854 nwal_matchAction_t action,
855 NETCP_CFG_ROUTE_HANDLE_T p_route);
858 #ifdef __cplusplus
859 }
860 #endif
861 #endif