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 2010-2011
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"
54 #include "ti/drv/pa/pa.h"
55 #include "ti/runtime/pktlib/pktlib.h"
58 /**
59 * @ingroup cfg_structures
60 * @brief CPPI flow ID for default case, use NETCP_DEFAULT_FLOW
61 * @details A flow defines a set of free queues (@pktlib heap) for h/w to use to get free packet descriptor(s) and buffer(s) to use when receiving a packet
62 */
63 typedef struct NETCP_CFG_FLOW_Tag
64 {
65 int flowid; /**< flow id*/
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
114 */
117 /**
118 * @ingroup cfg_constants
119 * @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.
120 */
121 typedef void * NETCP_CFG_FLOW_HANDLE_T;
123 /**
124 * @ingroup cfg_constants
125 * @def NETCP_DEFAULT_FLOW
126 * @brief This defines the default FLOW for NETCP to use. The default flow uses the default @pktlib heap created by netapi_init; i.e. NETCP will allocate descriptors and buffers for received packets from this heap.
127 */
128 #define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T*) NULL
131 /**
132 * @ingroup cfg_constants
133 * @brief Handle to a NETCP route.
134 * @details Application to use this handle to identify a NETCP route. A NETCP route defines the pktio channel for packets received by NETCP and the flow to use
135 */
136 typedef void * NETCP_CFG_ROUTE_HANDLE_T;
138 /**
139 * @def NETCP_DEFAULT_ROUTE
140 * This defines the NETCP default route. This route has NETCP send received packets to the default NETCP pktio channel using descriptors and buffers from the default flow. The default route is created by @netapi_init
141 */
142 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T*) NULL
145 /**
146 * @ingroup cfg_structures
147 * @brief NETCP application defined route information.
148 * @details This structure is used to define a packet receive route. A route consists of a flow where to get free descriptors and buffers to hold the packet, and a destination queue where to place the packet.
149 *
150 */
151 typedef struct NETCP_CFG_ROUTE_Tag
152 {
153 NETCP_CFG_FLOW_T * p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default flow, @ref NETCP_CFG_FLOW_T */
154 PKTIO_HANDLE_T * p_dest_q; /**<NULL for default destination queue */
155 } NETCP_CFG_ROUTE_T;
157 /**
158 * @ingroup cfg_constants
159 * @def NETCP_CFG_ACTION_DISCARD
160 * This defines the NETCP action to discard packet.
161 */
162 #define NETCP_CFG_ACTION_DISCARD 0
163 /**
164 * @ingroup cfg_constants
165 * @def NETCP_CFG_ACTION_CONTINUE
166 * This defines the NETCP action to pass packet ono the next classifier
167 */
168 #define NETCP_CFG_ACTION_CONTINUE 1
169 /**
170 * @ingroup cfg_constants
171 * @def NETCP_CFG_ACTION_TO_SW
172 * This defines the NETCP action to pass packet to User space application
173 */
174 #define NETCP_CFG_ACTION_TO_SW 2
177 /**
178 * @ingroup cfg_constants
179 * @brief Handle to NETCP VLAN configuration (FUTURE).
180 * @details Application to use this handle to identify a VLAN configutation.
181 */
182 typedef void * NETCP_CFG_VLAN_T;
184 /**
185 * @ingroup cfg_constants
186 * @brief AppID for packets matching a MAC interface rule
187 */
188 typedef uint32_t NETCP_CFG_MACIF_T;
190 /**
191 * @ingroup cfg_constants
192 * @brief AppID for packets matching an IP interface rule
193 */
194 typedef uint32_t NETCP_CFG_IP_T;
198 /**
199 * @ingroup cfg_constants
200 * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
201 */
202 typedef uint32_t NETCP_CFG_SA_T;
205 /**
206 * @ingroup cfg_constants
207 * @brief AppId for packets matching an NETCP IPSEC policy rule
208 */
209 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
212 /**
213 * @ingroup cfg_constants
214 * @def NETCP_CFG_NO_INTERFACE
215 * This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
216 */
217 #define NETCP_CFG_NO_INTERFACE 0xff
221 /**
222 * @note APPIDs are present in RX packet meta data and tell "how far" the packet got
223 * through the classification rules of NETCP.
224 * APPID is 32 bits:
225 * bits 31-24 = MATCH STAGE (NETAPI_NECP_MATCH_xxx below)
226 * bits 23-8 = identifier (depends on match stage)
227 * bits 7-0 = logical mac interface
228 */
230 /**
231 * @ingroup cfg_constants
232 * @def NETAPI_NETCP_MATCH_GENERIC_MAC
233 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
234 * Packet did not match any other rule
235 */
236 #define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000 //lower byte==interface
238 /**
239 * @ingroup cfg_constants
240 * @def NETAPI_NETCP_MATCH_GENERIC_IP
241 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
242 * Packet also matched a generic IP rule attached to that interface. The IP rule # for the interface
243 * is given in Bytes 3,2 of the APPID. Packet did not match any other rule
244 */
245 #define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000 //lower byte==interface
248 /**
249 * @ingroup cfg_constants
250 * @def NETAPI_NETCP_MATCH_CLASS
251 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
252 * Packet also matched a generic IP rule attached to that interface OR a general IP rule added as part of
253 * the classifier or it matched a combination of ISPEC SA rule and a policy check. Finally,
254 * Packet matched a L4 port rule that was added as part of a classifer. Bytes 3-2
255 * give the ID of the classifier . Packet did not match any other rule
256 */
257 #define NETAPI_NETCP_MATCH_CLASS 0x80000000 //FULL MATCH or' in classifier (16 bits), lower byte==interface
259 /**
260 * @ingroup cfg_constants
261 * @def NETAPI_NETCP_MATCH_CLASS_L3
262 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
263 * Packet also matched a general IP rule added as part of a classifier. But it not match a
264 * L4 port or any other rule. We cannout say what classifer partially matched so Bytes 3-2 are
265 * not applicable
266 */
267 #define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000 //MATCHED L3 but not L4. lower byte==interface
269 /**
270 * @ingroup cfg_constants
271 * @def NETAPI_NETCP_MATCH_IPSEC
272 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
273 * Packet also matched an IPSEC SA rule (matched proto, dest ip and SPI). The SA id is in
274 * bytes 3-2 of APPID. Packet did not match any other rule (so may have failed a policy check)
275 */
276 #define NETAPI_NETCP_MATCH_IPSEC 0x01000000 //lower byte==interface, Or' in SA id (16 bits)
278 /**
279 * @ingroup cfg_constants
280 * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
281 * This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
282 * Packet also matched an IPSEC SA rule (matched proto, dest ip and SPI). Packet also matched
283 * a POLICY RULE - this is a check of the inner IP. The IPSEC RX Policy ID is in
284 * bytes 3-2 of APPID. Packet did not match any other rule
285 */
286 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000 //lower byte==interface, Or' in SA id (16 bits)
292 /**
293 * @ingroup cfg_functions
294 * @brief netcp_cfgAddFlow API to add a flow
295 *
296 * @details This api is used to add a flow
297 * @param[in] h NETAPI instance handle, @ref NETAPI_T
298 * @param[in] n number of Pktlib_HeapHandle
299 * @param[in] handles[] Handles to Pktlib_HeapHandle
300 * @param[in] sizes[] must be <= heap corresponding heap size-recv_offset-any desired tail room
301 * @param[in] recv_offset bytes to save in front of packet
302 * @param[out] err pointer to error return
303 * @retval NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
304 * @pre @ref netapi_init
305 */
306 NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
307 int n,
308 Pktlib_HeapHandle handles[],
309 int sizes[],
310 int recv_offset,
311 int * err );
314 /**
315 * @ingroup cfg_functions
316 * @brief netcp_cfgDelFlow API to delete a flow
317 *
318 * @details This api is used to delete a flow previousy added.
319 * @param[in] h NETAPI instance handle, @ref NETAPI_T
320 * @param[in] p handle to NETCP flow
321 * @param[out] err pointer to error return
322 * @retval none
323 * @pre @ref netapi_init, netcp_cfgAddFlow
324 */
325 void netcp_cfgDelFlow(NETAPI_T h ,
326 NETCP_CFG_FLOW_HANDLE_T p ,
327 int * err);
329 /**
330 * @ingroup cfg_functions
331 * @brief netcp_cfgDelMac API to delete MAC interface
332 *
333 * @details This api is used to delete a MAC interface
334 * @param[in] h NETAPI instance handle, @ref NETAPI_T
335 * @param[in] iface_no interface number (0,1,..)
336 * @param[out] err pointer to error return
337 * @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
338 * @pre @ref netapi_init , @ref netcp_cfgCreateMacInterface
339 */
340 void netcp_cfgDelMac(NETAPI_T h,int iface_no, int *err);
344 /**
345 * @ingroup cfg_functions
346 * @brief API attaches an IP address and qualifier to a MAC interface
347 *
348 * @details This api is used to add an IP address to a MAC interface along
349 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
350 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
351 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables
352 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
353 * Note: An IP address must be attached to enable NETCP receive Checksum offload feature
354 * @param[in] h NETAPI instance handle, @ref NETAPI_T
355 * @param[in] iface_no interface number (0,1,..)
356 * @param[in] ipType type of IP address (V4 for V6)
357 * @param[in] ip_addr ip_address
358 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
359 * diffserv category for example.
360 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
361 * @param[out] err pointer to error return
362 * @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
363 * @pre @ref netapi_init
364 */
365 NETCP_CFG_IP_T netcp_cfgAddIp(
366 NETAPI_T h,
367 int iface_no,
368 nwal_IpType ipType,
369 nwalIpAddr_t * ip_addr,
370 nwalIpOpt_t * ip_qualifiers,
371 NETCP_CFG_ROUTE_HANDLE_T route,
372 int * err
373 );
375 /**
376 * @ingroup cfg_functions
377 * @brief netcp_cfgDelIp API to delete IP interface
378 *
379 * @details This api is used to delete an IP interface
380 * @param[in] h NETAPI instance handle, @ref NETAPI_T
381 * @param[in] iface_no interface number (0,1,..)
382 * @param[in] ipType type of IP address (V4 for V6)
383 * @param[in] ip_addr ip_address
384 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
385 * diffserv category for example.
386 * @param[in] ip_rule_id @ref NETCP_CFG_IP_T
387 * @param[out] err pointer to error return
388 * @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
389 * @pre @ref netapi_init , @ref netcp_cfgAddIp
390 */
391 void netcp_cfgDelIp(NETAPI_T h, int iface_no, nwal_IpType ipType,
392 nwalIpAddr_t * ip_addr,
393 nwalIpOpt_t * ip_qualifiers,
394 NETCP_CFG_IP_T ip_rule_id,
395 int *err);
399 /**
400 * @ingroup cfg_functions
401 * @brief netcp_cfgCreateMacInterface API to create a MAC interface
402 *
403 * @details This api is used to create a MAC interface.
404 * Once it is created, the MAC interface can be used to receive packets. The API
405 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
406 * MAC matching supplied argument and not matching any other lookup entry (see @ref netcp_cfgAddIp) to
407 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
408 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
409 * Note: The internal SOC switch (if operating in full swithc mode) may need to be "taught" that this mac
410 * address is present by transmitting a packet with destination mac = this interface mac address.
411 * @param[in] h NETAPI instance handle, @ref NETAPI_T
412 * @param[in] p_mac pointer to 6 byte MAC address for interface
413 * @param[in] iface_no interface number (0,1,..)
414 * @param[in] switch_port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly]
415 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
416 * @param[in] vlan [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
417 * @param[in] state [future] interface state (0=down, 1= up)
418 * @param[out] err pointer to error return
419 * @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
420 * @pre @ref netapi_init
421 */
422 NETCP_CFG_MACIF_T netcp_cfgCreateMacInterface(
423 NETAPI_T h,
424 uint8_t *p_mac,
425 int iface_no,
426 int switch_port,
427 NETCP_CFG_ROUTE_HANDLE_T route,
428 NETCP_CFG_VLAN_T vlan,
429 int state,
430 int * err
431 );
434 /**
435 * @brief This defines handle to installed classifier returned by API. Pkts matching this classifier will have meta data with this tag.
436 * Also used to delete classifier
437 */
438 typedef uint32_t NETCP_CFG_CLASS_T;
441 /**
442 * @ingroup cfg_structures
443 * @brief NETAPI Class L4 Configuration
444 *
445 * @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)
446 */
447 typedef struct NETCP_CFG_CLASS_L4_Tag
448 {
449 int iface; /**< Indicates which MAC interface packet should be received on*/
450 NETCP_CFG_IP_T ip; /**< IP rule to match: see @ref NETCP_CFG_IP_T */
451 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
452 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
454 } NETCP_CFG_CLASS_L4_T;
457 /**
458 * @ingroup cfg_structures
459 * @brief NETAPI Classifier L4 plus IPSEC policy configuration
460 *
461 * @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.
462 */
463 //classifier L4 + policy (L2, L3 (outer), tunnel, L3 (inner) implied by policy
464 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
465 {
466 int iface; /**< Indicates which MAC interface packet should be received from */
467 NETCP_CFG_IPSEC_POLICY_T ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
468 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
469 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
471 } NETCP_CFG_CLASS_L4_IPSEC_T;
476 /**
477 * @ingroup cfg_structures
478 * @brief NETAPI Classifier L4/L3 configuration
479 *
480 * @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.
481 */
482 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
483 {
484 int iface; /**< Indicates which MAC interface packet is from */
485 nwal_IpType ipType; /**< IP address type, IPV4 or IPV6 */
486 nwalIpAddr_t * ip_addr; /**< IP address to match */
487 nwalIpOpt_t * ip_qualifiers;/**< IP address qualifiers */
488 NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a
489 * new rule.(if exisitng rule, then existing fail
490 *route will be usedi). */
491 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
492 nwalAppProto_t appProto; /**< Ports or equivalent */
493 } NETCP_CFG_CLASS_L3_L4_T;
495 /**
496 * @ingroup cfg_structures
497 * @brief NETAPI Classifier configuration
498 *
499 * @details This structure contains the NETAPI classifer configuration. This is a union of the different classifier types above
500 */
501 typedef struct NETCP_CFG_CLASSIFIER_Tag
502 {
504 /**
505 * Classifer type which can be set to one of the following defines:
506 * <br>
507 * @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
508 */
509 int classType;
511 /**
512 * @def NETCP_CFG_CLASS_TYPE_L4
513 * @ingroup cfg_constants
514 * 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
515 #define NETCP_CFG_CLASS_TYPE_L4 0
517 /**
518 * @def NETCP_CFG_CLASS_TYPE_L3_L4
519 * @ingroup cfg_constants
520 * 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.
521 */
522 #define NETCP_CFG_CLASS_TYPE_L3_L4 1
524 union
525 {
526 NETCP_CFG_CLASS_L3_L4_T c_l3_l4; /**< @ref NETCP_CFG_CLASS_L3_L4_T */
527 NETCP_CFG_CLASS_L4_T c_l4; /**< @ref NETCP_CFG_CLASS_L4_T */
528 NETCP_CFG_CLASS_L4_IPSEC_T c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
529 } u; /**< union for classifier type configuration structure */
530 } NETCP_CFG_CLASSIFIER_T;
534 /**
535 * @ingroup cfg_functions
536 * @brief netcp_cfgAddClass API can be used to attach a classifier rule to NETCP. This can be used to route a particular packet flow to a specific PKTIO channel
537 *
538 * @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific
539 * pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
540 * @param[in] h NETAPI instance handle, @ref NETAPI_T
541 * @param[in] p_class -> definition of the classifier
542 * @param[in] p_route -> route for packet or default
543 * @param[in] action -> what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
544 * @param[out] err pointer to error return
545 * @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
546 * @pre @ref netapi_init
547 */NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
548 NETCP_CFG_CLASSIFIER_T *p_class,
549 NETCP_CFG_ROUTE_HANDLE_T p_route,
550 int action,
551 int * err);
555 /**
556 * @ingroup cfg_functions
557 * @brief netcp_cfgDelClass API can be used to delete a preconfigured classifier
558 *
559 * @details This API can be used to delete a preconfigured classifier
560 * @param[in] h NETAPI instance handle, @ref NETAPI_T
561 * @param[in] classId
562 * @param[out] err pointer to error return
563 * @retval none
564 * @pre @ref netapi_init, @ref netcp_cfgAddClass
565 */
566 void netcp_cfgDelClass(NETAPI_T h,
567 NETCP_CFG_CLASS_T classId,
568 int *err);
571 /**
572 * @ingroup netapi_cb_functions
573 * @brief NETCP_CFG_STATS_CB Callback function that is used to return statistics from NETCP
574 *
575 * @details The application provides a callback function that NETAPI uses to report statistics.
576 * The request for stats is generated from the @ref netcp_cfgReqStats API.
577 * Note: to receive ths stats callback, the @ref netapi_netcpPoll funcition must be called
578 * @param[in] h NETAPI instance handle, @ref NETAPI_T
579 * @param[out] pPaStats the PA (NETCP packet accelerator subsystem) statistics block
580 * @retval none
581 * @pre @ref netapi_init , @ref netcp_cfgReqStats, @ref netapi_netcpPoll
582 */
583 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
584 paSysStats_t* pPaStats);
586 /**
587 * @ingroup cfg_functions
588 * @brief netcp_cfgReqStats API to request statistics from NETCP
589 *
590 * @details This api is used to request a statistics from NETCP. This will generate a stats request
591 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
592 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
593 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
594 * @param[in] h NETAPI instance handle, @ref NETAPI_T
595 * @param[in] cb the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
596 * @param[in] doClear clear the stats in NETCP after the report (0=no, 1=yes)
597 * @param[out] err pointer to error return
598 * @retval none
599 * @pre @ref netapi_init
600 */
601 void netcp_cfgReqStats(NETAPI_T h,
602 NETCP_CFG_STATS_CB cb,
603 int doClear,
604 int *err);
608 #endif