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
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 void * 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. NETCP will allocate descriptors and buffers for received packets from this heap.
126 */
127 #define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T*) NULL
130 /**
131 * @ingroup cfg_constants
132 * @brief Handle to a NETCP route.
133 * @details Application to use this handle to identify a NETCP route. A NETCP route defines the pktio channel for packets received by NETCP
134 * 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
141 * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
142 */
143 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T*) NULL
146 /**
147 * @ingroup cfg_structures
148 * @brief NETCP application defined route information.
149 * @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.
150 *
151 */
152 typedef struct NETCP_CFG_ROUTE_Tag
153 {
154 NETCP_CFG_FLOW_T * p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default flow, @ref NETCP_CFG_FLOW_T */
155 PKTIO_HANDLE_T * p_dest_q; /**<NULL for default destination queue */
156 } NETCP_CFG_ROUTE_T;
158 /**
159 * @ingroup cfg_constants
160 * @def NETCP_CFG_ACTION_DISCARD
161 * This defines the NETCP action to discard packet.
162 */
163 #define NETCP_CFG_ACTION_DISCARD 0
164 /**
165 * @ingroup cfg_constants
166 * @def NETCP_CFG_ACTION_CONTINUE
167 * This defines the NETCP action to pass packet ono the next classifier
168 */
169 #define NETCP_CFG_ACTION_CONTINUE 1
170 /**
171 * @ingroup cfg_constants
172 * @def NETCP_CFG_ACTION_TO_SW
173 * This defines the NETCP action to pass packet to User space application
174 */
175 #define NETCP_CFG_ACTION_TO_SW 2
177 /**
178 * @ingroup cfg_constants
179 * @def NETCP_CFG_ALL_EXCEPTIONS
180 * This defines NETCP configuration for all Exepction Packets.
181 */
182 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
187 /**
188 * @ingroup cfg_constants
189 * @brief Handle to NETCP VLAN configuration (FUTURE).
190 * @details Application to use this handle to identify a VLAN configuration.
191 */
192 typedef void * NETCP_CFG_VLAN_T;
194 /**
195 * @ingroup cfg_constants
196 * @brief AppID for packets matching a MAC interface rule
197 */
198 typedef uint32_t NETCP_CFG_MACIF_T;
200 /**
201 * @ingroup cfg_constants
202 * @brief AppID for packets matching an IP interface rule
203 */
204 typedef uint32_t NETCP_CFG_IP_T;
206 /**
207 * @ingroup cfg_constants
208 * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
209 */
210 typedef uint32_t NETCP_CFG_SA_T;
213 /**
214 * @ingroup cfg_constants
215 * @brief AppId for packets matching an NETCP IPSEC policy rule
216 */
217 typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
221 /**
222 * @ingroup cfg_constants
223 * @brief AppID for packets being classified as type exception.
224 */
225 typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
227 /**
228 * @ingroup cfg_constants
229 *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
230 */
231 #define NETCP_CFG_NO_INTERFACE 0xff
235 /**
236 * @note APPIDs are present in RX packet meta data and tell "how far" the packet got
237 * through the classification rules of NETCP.
238 * APPID is 32 bits:
239 * bits 31-24 = MATCH STAGE (NETAPI_NECP_MATCH_xxx below)
240 * bits 23-8 = identifier (depends on match stage)
241 * bits 7-0 = logical mac interface
242 */
244 /**
245 * @ingroup cfg_constants
246 * @def NETAPI_NETCP_MATCH_GENERIC_MAC
247 * 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.
248 * Packet did not match any other rule
249 */
250 #define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000 //lower byte==interface
252 /**
253 * @ingroup cfg_constants
254 * @def NETAPI_NETCP_MATCH_GENERIC_IP
255 * 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.
256 * Packet also matched a generic IP rule attached to that interface. The IP rule # for the interface
257 * is given in Bytes 3,2 of the APPID. Packet did not match any other rule
258 */
259 #define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000 //lower byte==interface
262 /**
263 * @ingroup cfg_constants
264 * @def NETAPI_NETCP_MATCH_CLASS
265 * 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.
266 * Packet also matched a generic IP rule attached to that interface OR a general IP rule added as part of
267 * the classifier or it matched a combination of ISPEC SA rule and a policy check. Finally,
268 * Packet matched a L4 port rule that was added as part of a classifer. Bytes 3-2
269 * give the ID of the classifier . Packet did not match any other rule
270 */
271 #define NETAPI_NETCP_MATCH_CLASS 0x80000000 //FULL MATCH or' in classifier (16 bits), lower byte==interface
273 /**
274 * @ingroup cfg_constants
275 * @def NETAPI_NETCP_MATCH_CLASS_L3
276 * 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.
277 * Packet also matched a general IP rule added as part of a classifier. But it not match a
278 * L4 port or any other rule. We cannout say what classifer partially matched so Bytes 3-2 are
279 * not applicable
280 */
281 #define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000 //MATCHED L3 but not L4. lower byte==interface
283 /**
284 * @ingroup cfg_constants
285 * @def NETAPI_NETCP_MATCH_IPSEC
286 * 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.
287 * Packet also matched an IPSEC SA rule (matched proto, dest ip and SPI). The SA id is in
288 * bytes 3-2 of APPID. Packet did not match any other rule (so may have failed a policy check)
289 */
290 #define NETAPI_NETCP_MATCH_IPSEC 0x01000000 //lower byte==interface, Or' in SA id (16 bits)
292 /**
293 * @ingroup cfg_constants
294 * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
295 * 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.
296 * Packet also matched an IPSEC SA rule (matched proto, dest ip and SPI). Packet also matched
297 * a POLICY RULE - this is a check of the inner IP. The IPSEC RX Policy ID is in
298 * bytes 3-2 of APPID. Packet did not match any other rule
299 */
300 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000 //lower byte==interface, Or' in SA id (16 bits)
302 /**
303 * @ingroup cfg_constants
304 * @def NETCP_CFG_MATCH_EXCEPTION
305 * This define is used for an APPID that indicates that a packet is of type exception. Actual exception id is in byte 0 of APPID.
306 */
307 #define NETCP_CFG_MATCH_EXCEPTION 0x08000000
311 /**
312 * @ingroup cfg_functions
313 * @brief netcp_cfgAddFlow API to add a flow
314 *
315 * @details This api is used to add a flow
316 * @param[in] h NETAPI instance handle, @ref NETAPI_T
317 * @param[in] n number of Pktlib_HeapHandle
318 * @param[in] handles[] Handles to Pktlib_HeapHandle
319 * @param[in] sizes[] must be <= heap corresponding heap size-recv_offset-any desired tail room
320 * @param[in] recv_offset bytes to save in front of packet
321 * @param[out] err pointer to error return
322 * @retval NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
323 * @pre @ref netapi_init
324 */
325 NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
326 int n,
327 Pktlib_HeapHandle handles[],
328 int sizes[],
329 int recv_offset,
330 int * err );
333 /**
334 * @ingroup cfg_functions
335 * @brief netcp_cfgDelFlow API to delete a flow
336 *
337 * @details This api is used to delete a flow.
338 * @param[in] h NETAPI instance handle, @ref NETAPI_T
339 * @param[in] p handle to NETCP flow
340 * @param[out] err pointer to error return
341 * @retval none
342 * @pre @ref netapi_init, netcp_cfgAddFlow
343 */
344 void netcp_cfgDelFlow(NETAPI_T h ,
345 NETCP_CFG_FLOW_HANDLE_T p ,
346 int * err);
348 /**
349 * @ingroup cfg_functions
350 * @brief netcp_cfgDelMac API to delete MAC interface
351 *
352 * @details This api is used to delete a MAC interface
353 * @param[in] h NETAPI instance handle, @ref NETAPI_T
354 * @param[in] iface_no interface number (0,1,..)
355 * @param[out] err pointer to error return
356 * @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
357 * @pre @ref netapi_init , @ref netcp_cfgCreateMacInterface
358 */
359 void netcp_cfgDelMac(NETAPI_T h,int iface_no, int *err);
363 /**
364 * @ingroup cfg_functions
365 * @brief API attaches an IP address and qualifier to a MAC interface
366 *
367 * @details This api is used to add an IP address to a MAC interface along
368 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
369 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
370 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables
371 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
372 * Note: An IP address must be attached to enable NETCP receive Checksum offload feature
373 * @param[in] h NETAPI instance handle, @ref NETAPI_T
374 * @param[in] iface_no interface number (0,1,..)
375 * @param[in] ipType type of IP address (V4 for V6)
376 * @param[in] ip_addr ip_address
377 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
378 * diffserv category for example.
379 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
380 * @param[out] err pointer to error return
381 * @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
382 * @pre @ref netapi_init
383 */
384 NETCP_CFG_IP_T netcp_cfgAddIp(
385 NETAPI_T h,
386 int iface_no,
387 nwal_IpType ipType,
388 nwalIpAddr_t * ip_addr,
389 nwalIpOpt_t * ip_qualifiers,
390 NETCP_CFG_ROUTE_HANDLE_T route,
391 int * err
392 );
394 /**
395 * @ingroup cfg_functions
396 * @brief netcp_cfgDelIp API to delete IP interface
397 *
398 * @details This api is used to delete an IP interface
399 * @param[in] h NETAPI instance handle, @ref NETAPI_T
400 * @param[in] iface_no interface number (0,1,..)
401 * @param[in] ipType type of IP address (V4 for V6)
402 * @param[in] ip_addr ip_address
403 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
404 * diffserv category for example.
405 * @param[in] ip_rule_id @ref NETCP_CFG_IP_T
406 * @param[out] err pointer to error return
407 * @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
408 * @pre @ref netapi_init , @ref netcp_cfgAddIp
409 */
410 void netcp_cfgDelIp(NETAPI_T h, int iface_no, nwal_IpType ipType,
411 nwalIpAddr_t * ip_addr,
412 nwalIpOpt_t * ip_qualifiers,
413 NETCP_CFG_IP_T ip_rule_id,
414 int *err);
418 /**
419 * @ingroup cfg_functions
420 * @brief netcp_cfgCreateMacInterface API to create a MAC interface
421 *
422 * @details This api is used to create a MAC interface.
423 * Once it is created, the MAC interface can be used to receive packets. The API
424 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
425 * MAC matching supplied argument and not matching any other lookup entry (see @ref netcp_cfgAddIp) to
426 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
427 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
428 * Note: The internal SOC switch (if operating in full swithc mode) may need to be "taught" that this mac
429 * address is present by transmitting a packet with destination mac = this interface mac address.
430 * @param[in] h NETAPI instance handle, @ref NETAPI_T
431 * @param[in] p_mac pointer to 6 byte MAC address for interface
432 * @param[in] iface_no interface number (0,1,..)
433 * @param[in] switch_port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly]
434 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
435 * @param[in] vlan [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
436 * @param[in] state [future] interface state (0=down, 1= up)
437 * @param[out] err pointer to error return
438 * @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
439 * @pre @ref netapi_init
440 */
441 NETCP_CFG_MACIF_T netcp_cfgCreateMacInterface(
442 NETAPI_T h,
443 uint8_t *p_mac,
444 int iface_no,
445 int switch_port,
446 NETCP_CFG_ROUTE_HANDLE_T route,
447 NETCP_CFG_VLAN_T vlan,
448 int state,
449 int * err
450 );
453 /**
454 * @brief This defines handle to installed classifier returned by API. Pkts matching this classifier will have meta data with this tag.
455 * Also used to delete classifier
456 */
457 typedef uint32_t NETCP_CFG_CLASS_T;
460 /**
461 * @ingroup cfg_structures
462 * @brief NETAPI Class L4 Configuration
463 *
464 * @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)
465 */
466 typedef struct NETCP_CFG_CLASS_L4_Tag
467 {
468 int iface; /**< Indicates which MAC interface packet should be received on*/
469 NETCP_CFG_IP_T ip; /**< IP rule to match: see @ref NETCP_CFG_IP_T */
470 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
471 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
473 } NETCP_CFG_CLASS_L4_T;
476 /**
477 * @ingroup cfg_structures
478 * @brief NETAPI Classifier L4 plus IPSEC policy configuration
479 *
480 * @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.
481 */
482 //classifier L4 + policy (L2, L3 (outer), tunnel, L3 (inner) implied by policy
483 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
484 {
485 int iface; /**< Indicates which MAC interface packet should be received from */
486 NETCP_CFG_IPSEC_POLICY_T ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
487 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
488 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
490 } NETCP_CFG_CLASS_L4_IPSEC_T;
495 /**
496 * @ingroup cfg_structures
497 * @brief NETAPI Classifier L4/L3 configuration
498 *
499 * @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.
500 */
501 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
502 {
503 int iface; /**< Indicates which MAC interface packet is from */
504 nwal_IpType ipType; /**< IP address type, IPV4 or IPV6 */
505 nwalIpAddr_t * ip_addr; /**< IP address to match */
506 nwalIpOpt_t * ip_qualifiers;/**< IP address qualifiers */
507 NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a
508 * new rule.(if exisitng rule, then existing fail
509 *route will be used). */
510 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
511 nwalAppProto_t appProto; /**< Ports or equivalent */
512 } NETCP_CFG_CLASS_L3_L4_T;
514 /**
515 * @ingroup cfg_structures
516 * @brief NETAPI Classifier configuration
517 *
518 * @details This structure contains the NETAPI classifer configuration. This is a union of the different classifier types above
519 */
520 typedef struct NETCP_CFG_CLASSIFIER_Tag
521 {
523 /**
524 * Classifer type which can be set to one of the following defines:
525 * <br>
526 * @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
527 */
528 int classType;
530 /**
531 * @def NETCP_CFG_CLASS_TYPE_L4
532 * @ingroup cfg_constants
533 * 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
534 */
535 #define NETCP_CFG_CLASS_TYPE_L4 0
537 /**
538 * @def NETCP_CFG_CLASS_TYPE_L3_L4
539 * @ingroup cfg_constants
540 * 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.
541 */
542 #define NETCP_CFG_CLASS_TYPE_L3_L4 1
544 union
545 {
546 NETCP_CFG_CLASS_L3_L4_T c_l3_l4; /**< @ref NETCP_CFG_CLASS_L3_L4_T */
547 NETCP_CFG_CLASS_L4_T c_l4; /**< @ref NETCP_CFG_CLASS_L4_T */
548 NETCP_CFG_CLASS_L4_IPSEC_T c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
549 } u; /**< union for classifier type configuration structure */
550 } NETCP_CFG_CLASSIFIER_T;
554 /**
555 * @ingroup cfg_functions
556 * @brief netcp_cfgAddClass API to attach a classifier rule to NETCP.
557 * This can be used to route a particular packet flow to a specific PKTIO channel
558 *
559 * @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific
560 * pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
561 * @param[in] h NETAPI instance handle, @ref NETAPI_T
562 * @param[in] p_class definition of the classifier
563 * @param[in] p_route handle to NETCP route.
564 * @param[in] action what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
565 * @param[out] err pointer to error return
566 * @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
567 * @pre @ref netapi_init
568 */NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
569 NETCP_CFG_CLASSIFIER_T *p_class,
570 NETCP_CFG_ROUTE_HANDLE_T p_route,
571 int action,
572 int * err);
576 /**
577 * @ingroup cfg_functions
578 * @brief netcp_cfgDelClass API to delete a preconfigured classifier
579 *
580 * @details This API can be used to delete a preconfigured classifier
581 * @param[in] h NETAPI instance handle, @ref NETAPI_T
582 * @param[in] classId
583 * @param[out] err pointer to error return
584 * @retval none
585 * @pre @ref netapi_init, @ref netcp_cfgAddClass
586 */
587 void netcp_cfgDelClass(NETAPI_T h,
588 NETCP_CFG_CLASS_T classId,
589 int *err);
592 /**
593 * @ingroup netapi_cb_functions
594 * @brief NETCP_CFG_STATS_CB Callback function that is used to return statistics from NETCP
595 *
596 * @details The application provides a callback function that NETAPI uses to report statistics.
597 * The request for stats is generated from the @ref netcp_cfgReqStats API.
598 * Note: to receive ths stats callback, the @ref netapi_netcpPoll funcition must be called
599 * @param[in] h NETAPI instance handle, @ref NETAPI_T
600 * @param[out] pPaStats the PA (NETCP packet accelerator subsystem) statistics block
601 * @retval none
602 * @pre @ref netapi_init , @ref netcp_cfgReqStats, @ref netapi_netcpPoll
603 */
604 typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
605 paSysStats_t* pPaStats);
607 /**
608 * @ingroup cfg_functions
609 * @brief netcp_cfgReqStats API to request statistics from NETCP
610 *
611 * @details This api is used to request a statistics from NETCP. This will generate a stats request
612 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
613 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
614 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
615 * @param[in] h NETAPI instance handle, @ref NETAPI_T
616 * @param[in] cb the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
617 * @param[in] doClear clear the stats in NETCP after the report (0=no, 1=yes)
618 * @param[out] err pointer to error return
619 * @retval none
620 * @pre @ref netapi_init
621 */
622 void netcp_cfgReqStats(NETAPI_T h,
623 NETCP_CFG_STATS_CB cb,
624 int doClear,
625 int *err);
628 /**
629 * @ingroup cfg_functions
630 * @brief netcp_cfgExceptions API to configure NETCP with global rules for exception packet handling
631 *
632 * @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
633 * @param[in] h NETAPI instance handle, @ref NETAPI_T
634 * @param[in] exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
635 * @param[in] p_route handle to NETCP route.
636 * @param[in] action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
637 * @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
638 * @pre @ref netapi_init
639 */
640 NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
641 int exception_id ,
642 nwal_matchAction_t action,
643 NETCP_CFG_ROUTE_HANDLE_T p_route);
644 #endif