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 } NETAPI_CFG_T;
88 /* @note:
89 each buffer will be allocated: def_heap_buf_size+def_heap_extra_size bytes
90 each descriptor attached to these buffers will have rigBufferLen of:
91 def_heap_buf_size.
92 for default RX flow, for rx packet, the bufptr will be def_flow_pkt_rx_offset.
93 for detault RX flow, threshold (ie max # of bytes in buffer) will be:
94 def_heap_buf_size - def_heap_tailroom_size-def_flow_pkt_rx_offset
97 RX Packet from NetCP
99 Headroom [Application] Packet [HW] Tailroom [Application] Extra Space [Application]
100 <-----------------------><--------------------------><------------------------><----------------------->
102 Cppi_HostDesc->origBufferLen
103 <----------------------------------------------------------------------------->
104 Cppi_HostDesc->origBuffPtr
105 |
106 \/
107 |------------def_heap_buf_size-------------------------------------------------|--def_heap_extra_size--|
108 | def_flow_pkt_rx_offset| max Cppi_HostDesc->buffLen | def_heap_tailroom_size | Extra Size |
109 ^
110 |
111 Cppi_HostDesc->buffPtr
112 */
115 /**
116 * @ingroup cfg_constants
117 * @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.
118 */
119 typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
121 /**
122 * @ingroup cfg_constants
123 * @def NETCP_DEFAULT_FLOW
124 * @brief This defines the default FLOW for NETCP to use.
125 * The default flow uses the default pktlib heap created by netapi_init; i.e.
126 * NETCP will allocate descriptors and buffers for received packets from this heap.
127 */
128 #define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T) NULL
132 /**
133 * @def NETCP_DEFAULT_ROUTE
134 * This defines the NETCP default route. This route has NETCP send received packets to the default NETCP
135 * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
136 */
137 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
140 /**
141 * @ingroup cfg_structures
142 * @brief NETCP application defined route information.
143 * @details This structure is used to define a packet receive route. A route consists of a
144 * flow where to get free descriptors and buffers to hold the packet, and a destination
145 * queue where to place the packet.
146 *
147 */
148 typedef struct NETCP_CFG_ROUTE_Tag
149 {
150 NETCP_CFG_FLOW_T* p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default flow, @ref NETCP_CFG_FLOW_T */
151 PKTIO_HANDLE_T* p_dest_q; /**<NULL for default destination queue */
152 } NETCP_CFG_ROUTE_T;
155 /**
156 * @ingroup cfg_constants
157 * @brief Handle to a NETCP route.
158 * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
159 * pktio channel for packets received by NETCP
160 * and the flow to use.
161 */
162 typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
167 /**
168 * @ingroup cfg_constants
169 * @def NETCP_CFG_ACTION_DISCARD
170 * This defines the NETCP action to discard packet.
171 */
172 #define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
173 /**
174 * @ingroup cfg_constants
175 * @def NETCP_CFG_ACTION_CONTINUE
176 * This defines the NETCP action to pass packet ono the next classifier
177 */
178 #define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
179 /**
180 * @ingroup cfg_constants
181 * @def NETCP_CFG_ACTION_TO_SW
182 * This defines the NETCP action to pass packet to User space application
183 */
184 #define NETCP_CFG_ACTION_TO_SW NWAL_MATCH_ACTION_HOST
186 /**
187 * @ingroup cfg_constants
188 * @def NETCP_CFG_ALL_EXCEPTIONS
189 * This defines NETCP configuration for all Exepction Packets.
190 */
191 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
193 /**
194 * @ingroup cfg_constants
195 * @brief General APP_ID Type definition.
196 */
197 typedef uint32_t NETCP_CFG_APP_ID_T;
200 /**
201 * @ingroup cfg_constants
202 * @brief Handle to NETCP VLAN configuration (FUTURE).
203 * @details Application to use this handle to identify a VLAN configuration.
204 */
205 typedef void * NETCP_CFG_VLAN_T;
207 /**
208 * @ingroup cfg_constants
209 * @brief NETCP PA LLD handle associated with an SA
210 * @details Application to use this handle to identify a PA PLLD handle associated with an SA.
211 */
212 typedef void * NETCP_CFG_PA_HANDLE_T;
214 /**
215 * @ingroup cfg_constants
216 * @brief NETCP SA LLD handle associated with an SA
217 * @details Application to use this handle to identify a SA LLD handle associated with an SA.
218 */
219 typedef void * NETCP_CFG_SA_HANDLE_T;
221 /**
222 * @ingroup cfg_constants
223 * @brief AppID for packets matching a MAC interface rule
224 */
225 typedef uint32_t NETCP_CFG_MACIF_T;
227 /**
228 * @ingroup cfg_constants
229 * @brief AppID for packets matching an IP interface rule
230 */
231 typedef uint32_t NETCP_CFG_IP_T;
233 /**
234 * @ingroup cfg_constants
235 * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
236 */
237 typedef uint32_t NETCP_CFG_SA_T;
240 /**
241 * @ingroup cfg_constants
242 * @brief AppId for packets matching an NETCP IPSEC policy rule
243 */
244 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
248 /**
249 * @ingroup cfg_constants
250 * @brief AppID for packets being classified as type exception.
251 */
252 typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
254 /**
255 * @ingroup cfg_constants
256 *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
257 */
258 #define NETCP_CFG_NO_INTERFACE 0xff
262 /**
263 * @note APPIDs are present in RX packet meta data and tell "how far" the packet got
264 * through the classification rules of NETCP.
265 * APPID is 32 bits:
266 * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
267 * bits 23-8 = NETAPI_NETCP_MATCH_ID identifier
268 * bits 7-0 = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
269 */
271 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0
272 #define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
274 #define NETAPI_NETCP_MATCH_ID_SHIFT 8
275 #define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
277 #define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
278 #define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
281 /**
282 * @brief Helper function to get match stage associated with application ID.
283 */
284 #define netapi_cfgGetMatchStage(appid) (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
286 /**
287 * @brief Helper function to get match id associated with application ID.
288 */
289 #define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
291 /**
292 * @brief Helper function to get logical match interface associated with application ID.
293 */
294 #define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
295 NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
298 /**
299 * @ingroup cfg_constants
300 * @def NETAPI_NETCP_MATCH_GENERIC_MAC
301 * This define is used for an APPID that indicates that a packet matched a MAC entry.
302 * Logical MAC interface location:
303 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
304 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
305 * Packet did not match any other rule.
306 */
307 #define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000
309 /**
310 * @ingroup cfg_constants
311 * @def NETAPI_NETCP_MATCH_GENERIC_IP
312 * This define is used for an APPID that indicates that a packet matched a MAC entry.
313 * Logical MAC interface location:
314 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
315 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
316 * IP rule number for this interface location:
317 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
318 * NETAPI_NETCP_MATCH_ID_MASK.
319 * Packet also matched a generic IP rule attached to that interface.
320 * Packet did not match any other rule.
321 */
322 #define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000
324 /**
325 * @ingroup cfg_constants
326 * @def NETAPI_NETCP_MATCH_CLASS
327 * This define is used for an APPID that indicates that a packet matched a MAC entry.
328 * Logical MAC interface location:
329 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
330 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
331 * Classifer ID location:
332 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
333 * NETAPI_NETCP_MATCH_ID_MASK.
334 * Packet also matched a generic IP rule attached to
335 * that interface OR a general IP rule added as part of the classifier or it matched a combination
336 * of ISPEC SA rule and a policy check. In addition, packet matched a L4 port rule that was added
337 * as part of a classifer. Packet did not match any other rule.
338 */
339 #define NETAPI_NETCP_MATCH_CLASS 0x80000000
341 /**
342 * @ingroup cfg_constants
343 * @def NETAPI_NETCP_MATCH_CLASS_L3
344 * This define is used for an APPID that indicates that a packet matched a MAC entry.
345 * Logical MAC interface location:
346 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
347 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
348 * Packet also matched a general IP rule added as part
349 * of a classifier. But it not match a L4 port or any other rule.
350 * We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
351 */
352 #define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000
354 /**
355 * @ingroup cfg_constants
356 * @def NETAPI_NETCP_MATCH_IPSEC
357 * This define is used for an APPID that indicates that a packet matched a MAC entry.
358 * Logical MAC interface location:
359 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
360 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
361 * SA ID location:
362 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
363 * NETAPI_NETCP_MATCH_ID_MASK.
364 * Packet also matched an IPSEC SA rule (matched proto, destination ip and SPI).
365 * Packet did not match any other rule (so may have failed a policy check)
366 */
367 #define NETAPI_NETCP_MATCH_IPSEC 0x01000000
370 /**
371 * @ingroup cfg_constants
372 * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
373 * This define is used for an APPID that indicates that a packet matched a MAC entry
374 * Logical MAC interface location:
375 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
376 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
377 * Packet also matched an IPSEC SA rule (matched proto,
378 * dest ip and SPI). Packet also matched a POLICY RULE (this is a check of the inner IP).
379 * IPSEC RX Policy ID location:
380 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
381 * NETAPI_NETCP_MATCH_ID_MASK.
382 * Packet did not match any other rule
383 */
384 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000 //lower byte==interface, Or' in SA id (16 bits)
386 /**
387 * @ingroup cfg_constants
388 * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
389 * This define is used for an APPID that indicates that a packet is of type exception.
390 * Actual exception id is in byte 0 of APPID.
391 */
392 #define NETAPI_NETCP_CFG_MATCH_EXCEPTION 0x08000000
396 /**
397 * @ingroup cfg_structures
398 * @brief NETCP flow configuration information.
399 * @details This structure is used to define key parameters for the receive flow to be created.
400 * These include the flow index to use (or can be left un-specified), the dma_index
401 * (specifying out of which CPPI DMA engine the flow should be allocated),
402 * the receive offset (the byte offset into each buffer where received data should be placed),
403 * and the drop policy for the DMA channel to use if there is no free buffer available (drop or block)
404 *
405 */
406 typedef struct NETCP_CFG_FLOW_CONFIG_Tag
407 {
408 int flow_index; /**< flow index to use or NETAPI_NETCP_FLOW_INDEX_ANY */
409 /**
410 * @def NETAPI_NETCP_FLOW_INDEX_ANY
411 * @ingroup cfg_constants
412 * This define is used to let NETAPI pick the flow index to use(for flow_index field)
413 */
414 #define NETAPI_NETCP_FLOW_INDEX_ANY CPPI_PARAM_NOT_SPECIFIED
416 int dma_index; /**< allocate flow out of which DMA */
417 /**
418 * @def NETAPI_DMA_INFRASTRUCTURE
419 * @ingroup cfg_constants
420 * This define is used specify a flow in the QMSS CPPI DMA (for dma_index field)
421 */
422 #define NETAPI_DMA_INFRASTRUCTURE 0
423 /**
424 * @def NETAPI_DMA_NETCP
425 * @ingroup cfg_constants
426 * This define us usee specify a flow in the NETCP CPPI DMA (for dma_index field)
427 */
428 #define NETAPI_DMA_NETCP 1
430 int recv_offset; /**< start of packet offset */
432 int block; /**< TRUE => DMA will wait for free descriptor if heap(s) are empty.
433 FALSE => DMA will discard */
434 /**
435 * @def NETAPI_FLOW_DROP
436 * @ingroup cfg_constants
437 * This define is used to indicate that the flow should institute a Block policy.
438 * This means that the DMA should wait for a free descriptor/buffer to come available if
439 * the free poll is empty (for the block field)
440 */
441 #define NETAPI_FLOW_BLOCK 1
442 /**
443 * @def NETAPI_FLOW_DROP
444 * @ingroup cfg_constants
445 * This define us used to indicate that the flow should institute a Drop policy.
446 * This means that the DMA should NOT wait for a free descriptor/buffer to come available
447 * if the free poll is empty. The transfer will be aborted and the data will dropped (for block field)
448 */
449 #define NETAPI_FLOW_DROP 0
451 PKTIO_HANDLE_T * p_dest_q; /**<destination queue for this flow (may be overwrritten by source DMA) */
452 } NETCP_CFG_FLOW_CONFIG_T;
459 /**
460 * @ingroup cfg_functions
461 * @brief netapi_netcpCfgAddFlow API to add a flow
462 *
463 * @details This api is used to add a flow
464 * @param[in] h NETAPI instance handle, @ref NETAPI_T
465 * @param[in] n number of Pktlib_HeapHandle
466 * @param[in] handles[] Handles to Pktlib_HeapHandle
467 * @param[in] sizes[] must be <= heap corresponding heap size-recv_offset-any desired tail room
468 * @param[in] p_cfg @ref NETCP_CFG_FLOW_CONFIG_T
469 * @param[out] err pointer to error return
470 * @retval NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
471 * @pre @ref netapi_init
472 */
473 NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
474 int n,
475 Pktlib_HeapHandle handles[],
476 int sizes[],
477 NETCP_CFG_FLOW_CONFIG_T * p_cfg,
478 int * err );
480 /**
481 * @ingroup cfg_functions
482 * @brief netapi_netcpCfgDelFlow API to delete a flow
483 *
484 * @details This api is used to delete a flow.
485 * @param[in] h NETAPI instance handle, @ref NETAPI_T
486 * @param[in] p handle to NETCP flow
487 * @param[out] err pointer to error return
488 * @retval none
489 * @pre @ref netapi_init, netapi_netcpCfgAddFlow
490 */
491 void netapi_netcpCfgDelFlow(NETAPI_T h ,
492 NETCP_CFG_FLOW_HANDLE_T p ,
493 int * err);
495 /**
496 * @ingroup cfg_functions
497 * @brief API attaches an IP address and qualifier to a MAC interface
498 *
499 * @details This api is used to add an IP address to a MAC interface along
500 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
501 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
502 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables.
503 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
504 * Note: An IP address must be attached to enable NETCP receive Checksum offload feature
505 * @param[in] h NETAPI instance handle, @ref NETAPI_T
506 * @param[in] iface_no interface number (0,1,..)
507 * @param[in] ipType type of IP address (V4 for V6)
508 * @param[in] ip_addr ip_address
509 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
510 * diffserv category for example.
511 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
512 * @param[in] user_data Optional: pointer to user provided data associated with IP
513 * @param[out] err pointer to error return
514 * @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
515 * @pre @ref netapi_init
516 */
517 NETCP_CFG_IP_T netapi_netcpCfgAddIp(NETAPI_T h,
518 int iface_no,
519 nwal_IpType ipType,
520 nwalIpAddr_t* ip_addr,
521 nwalIpOpt_t* ip_qualifiers,
522 NETCP_CFG_ROUTE_HANDLE_T route,
523 void* user_data,
524 int* err);
526 /**
527 * @ingroup cfg_functions
528 * @brief netapi_netcpCfgDelIp API to delete IP interface
529 *
530 * @details This api is used to delete an IP interface
531 * @param[in] h NETAPI instance handle, @ref NETAPI_T
532 * @param[in] iface_no interface number (0,1,..)
533 * @param[in] ipType type of IP address (V4 for V6)
534 * @param[in] ip_addr ip_address
535 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
536 * diffserv category for example.
537 * @param[in] ip_rule_id @ref NETCP_CFG_IP_T
538 * @param[out] err pointer to error return
539 * @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
540 * @pre @ref netapi_init , @ref netapi_netcpCfgAddIp
541 */
542 void netapi_netcpCfgDelIp(NETAPI_T h,
543 int iface_no,
544 nwal_IpType ipType,
545 nwalIpAddr_t* ip_addr,
546 nwalIpOpt_t* ip_qualifiers,
547 NETCP_CFG_IP_T ip_rule_id,
548 int* err);
550 /**
551 * @ingroup cfg_functions
552 * @brief netapi_netcpCfgCreateMacInterface API to insert a MAC interface rule in the NETCP hardware
553 * lookup engines.
554 *
555 * @details This api is used to insert a MAC interface in the NETCP hardware lookup engines.
556 * Once it is created, the MAC interface can be used to receive packets. The API
557 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
558 * MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
559 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
560 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
561 * Note: The internal SOC switch (if operating in full swithc mode) may need to be "taught" that this mac
562 * address is present by transmitting a packet with destination mac = this interface mac address.
563 * @param[in] h NETAPI instance handle, @ref NETAPI_T
564 * @param[in] p_mac pointer to 6 byte MAC address for interface
565 * @param[in] iface_no interface number (0,1,..)
566 * @param[in] switch_port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly]
567 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
568 * @param[in] vlan [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
569 * @param[in] state [future] interface state (0=down, 1= up)
570 * @param[out] err pointer to error return
571 * @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
572 * @pre @ref netapi_init
573 */
574 NETCP_CFG_MACIF_T netapi_netcpCfgCreateMacInterface(NETAPI_T h,
575 uint8_t* p_mac,
576 int iface_no,
577 int switch_port,
578 NETCP_CFG_ROUTE_HANDLE_T route,
579 NETCP_CFG_VLAN_T vlan,
580 int state,
581 int * err);
583 /**
584 * @ingroup cfg_functions
585 * @brief netapi_netcpCfgDelMac API to delete MAC interface
586 *
587 * @details This api is used to delete a MAC interface
588 * @param[in] h NETAPI instance handle, @ref NETAPI_T
589 * @param[in] iface_no interface number (0,1,..)
590 * @param[out] err pointer to error return
591 * @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
592 * @pre @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface
593 */
594 void netapi_netcpCfgDelMac(NETAPI_T h,
595 int iface_no,
596 int* err);
599 /**
600 * @brief This defines handle to installed classifier returned by API. Pkts matching this classifier will have meta data with this tag.
601 * Also used to delete classifier
602 */
603 typedef uint32_t NETCP_CFG_CLASS_T;
606 /**
607 * @ingroup cfg_structures
608 * @brief NETAPI Class L4 Configuration
609 *
610 * @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)
611 */
612 typedef struct NETCP_CFG_CLASS_L4_Tag
613 {
614 int iface; /**< Indicates which MAC interface packet should be received on*/
615 NETCP_CFG_IP_T ip; /**< IP rule to match: see @ref NETCP_CFG_IP_T */
616 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
617 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
619 } NETCP_CFG_CLASS_L4_T;
622 /**
623 * @ingroup cfg_structures
624 * @brief NETAPI Classifier L4 plus IPSEC policy configuration
625 *
626 * @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.
627 */
628 //classifier L4 + policy (L2, L3 (outer), tunnel, L3 (inner) implied by policy
629 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
630 {
631 int iface; /**< Indicates which MAC interface packet should be received from */
632 NETCP_CFG_IPSEC_POLICY_T ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
633 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
634 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
636 } NETCP_CFG_CLASS_L4_IPSEC_T;
640 /**
641 * @ingroup cfg_structures
642 * @brief NETAPI Classifier L4/L3 configuration
643 *
644 * @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.
645 */
646 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
647 {
648 int iface; /**< Indicates which MAC interface packet is from */
649 nwal_IpType ipType; /**< IP address type, IPV4 or IPV6 */
650 nwalIpAddr_t* ip_addr; /**< IP address to match */
651 nwalIpOpt_t* ip_qualifiers; /**< IP address qualifiers */
652 NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a
653 new rule.(if exisitng rule, then existing fail
654 route will be used). */
655 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
656 nwalAppProto_t appProto; /**< Ports or equivalent */
657 } NETCP_CFG_CLASS_L3_L4_T;
659 /**
660 * @ingroup cfg_structures
661 * @brief NETAPI Classifier configuration
662 *
663 * @details This structure contains the NETAPI classifer configuration. This is a union of the different classifier types above
664 */
665 typedef struct NETCP_CFG_CLASSIFIER_Tag
666 {
668 /**
669 * Classifer type which can be set to one of the following defines:
670 * <br>
671 * @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
672 */
673 int classType;
675 /**
676 * @def NETCP_CFG_CLASS_TYPE_L4
677 * @ingroup cfg_constants
678 * 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
679 */
680 #define NETCP_CFG_CLASS_TYPE_L4 0
682 /**
683 * @def NETCP_CFG_CLASS_TYPE_L3_L4
684 * @ingroup cfg_constants
685 * 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.
686 */
687 #define NETCP_CFG_CLASS_TYPE_L3_L4 1
689 union
690 {
691 NETCP_CFG_CLASS_L3_L4_T c_l3_l4; /**< @ref NETCP_CFG_CLASS_L3_L4_T */
692 NETCP_CFG_CLASS_L4_T c_l4; /**< @ref NETCP_CFG_CLASS_L4_T */
693 NETCP_CFG_CLASS_L4_IPSEC_T c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
694 } u; /**< union for classifier type configuration structure */
695 } NETCP_CFG_CLASSIFIER_T;
699 /**
700 * @ingroup cfg_functions
701 * @brief netapi_netcpCfgAddClass API to attach a classifier rule to NETCP.
702 * This can be used to route a particular packet flow to a specific PKTIO channel
703 *
704 * @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific
705 * pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
706 * @param[in] h NETAPI instance handle, @ref NETAPI_T
707 * @param[in] p_class definition of the classifier
708 * @param[in] p_route handle to NETCP route.
709 * @param[in] action what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
710 * @param[in] user_data Optional: pointer to user provided data associated with SA
711 * @param[out] err pointer to error return
712 * @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
713 * @pre @ref netapi_init
714 */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T h,
715 NETCP_CFG_CLASSIFIER_T* p_class,
716 NETCP_CFG_ROUTE_HANDLE_T p_route,
717 int action,
718 void* user_data,
719 int* err);
723 /**
724 * @ingroup cfg_functions
725 * @brief netapi_netcpCfgDelClass API to delete a preconfigured classifier
726 *
727 * @details This API can be used to delete a preconfigured classifier
728 * @param[in] h NETAPI instance handle, @ref NETAPI_T
729 * @param[in] classId
730 * @param[out] err pointer to error return
731 * @retval none
732 * @pre @ref netapi_init, @ref netapi_netcpCfgAddClass
733 */
734 void netapi_netcpCfgDelClass(NETAPI_T h,
735 NETCP_CFG_CLASS_T classId,
736 int* err);
739 /**
740 * @ingroup netapi_cb_functions
741 * @brief NETCP_CFG_STATS_CB Callback function that is used to return statistics from NETCP
742 *
743 * @details The application provides a callback function that NETAPI uses to report statistics.
744 * The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
745 * Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
746 * @param[in] h NETAPI instance handle, @ref NETAPI_T
747 * @param[out] pPaStats the PA (NETCP packet accelerator subsystem) statistics block
748 * @retval none
749 * @pre @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
750 */
751 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
752 paSysStats_t* pPaStats);
754 /**
755 * @ingroup cfg_functions
756 * @brief netapi_netcpCfgReqStats API to request statistics from NETCP
757 *
758 * @details This api is used to request a statistics from NETCP. This will generate a stats request
759 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
760 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
761 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
762 * @param[in] h NETAPI instance handle, @ref NETAPI_T
763 * @param[in] cb the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
764 * @param[in] doClear clear the stats in NETCP after the report (0=no, 1=yes)
765 * @param[out] err pointer to error return
766 * @retval none
767 * @pre @ref netapi_init
768 */
769 void netapi_netcpCfgReqStats(NETAPI_T h,
770 NETCP_CFG_STATS_CB cb,
771 int doClear,
772 int* err);
775 /**
776 * @ingroup cfg_functions
777 * @brief netapi_netcpCfgExceptions API to configure NETCP with global rules for exception packet handling
778 *
779 * @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
780 * @param[in] h NETAPI instance handle, @ref NETAPI_T
781 * @param[in] exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
782 * @param[in] p_route handle to NETCP route.
783 * @param[in] action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
784 * @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
785 * @pre @ref netapi_init
786 */
787 NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T h,
788 int exception_id ,
789 nwal_matchAction_t action,
790 NETCP_CFG_ROUTE_HANDLE_T p_route);
793 #endif