1 /******************************************************************************
2 * FILE PURPOSE: Top level interface file for NWAL Module
3 ******************************************************************************
4 * FILE NAME: pktio.h
5 *
6 * DESCRIPTION: netapi PKTIO module header file
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 */
42 /**
43 * @file pktio.h
44 * @brief pktio module main header file for user space transport library
45 * @details: pktio provides an abstraction to H/W queues that are used to transmit and receive packets,
46 * IPC messages, etc. Pktio channels can be created by user but there are also several canned
47 * channels available for NETCP transmit, receive, SA sideband crypto transmit and receive
48 */
52 #ifndef __PKTIO__H
53 #define __PKTIO__H
54 #include "netapi.h"
55 #include "ti/drv/nwal/nwal.h"
56 #include "ti/drv/nwal/nwal_util.h"
58 /**
59 * @def NETCP_TX
60 * @ingroup pktio_constants
61 * This defines the default PKTIO NETCP transmit channel name
62 */
63 #define NETCP_TX "NETCP_TX"
65 /**
66 * @def NETCP_RX
67 * @ingroup pktio_constants
68 * @brief This defines the default PKTIO NETCP receive channel name
69 */
70 #define NETCP_RX "NETCP_RX"
72 /**
73 * @def NETCP_SB_RX
74 * @ingroup pktio_constants
75 * @brief This defines the PKTIO NETCP-SA receive SIDEBAND channel name.
76 This channel is used to receive the results from sideband crypto operations
77 */
78 #define NETCP_SB_RX "NETCP_SB_RX"
80 /**
81 * @def NETCP_SB_TX
82 * @ingroup pktio_constants
83 * @brief This defines the PKTIO NETCP-SA transmit SIDEBAND channel name.
84 This channel is used to send packets for sideband crypto operations
85 */
86 #define NETCP_SB_TX "NETCP_SB_TX"
88 /**
89 * @def PKTIO_MAX_NAME
90 * @ingroup pktio_constants
91 * This defines the maximum length of a pktio channel name
92 */
93 #define PKTIO_MAX_NAME 19
95 /**
96 * @ingroup pktio_structures
97 * @brief PKTIO meta data information .
98 *
99 * @details PKTIO meta data information. meta data is used to convey the results of NETCP pre-processing on receive packets and to tell NETCP what functions to perform on transmitted packets. It is a union of sub-structures (one for TX, one for RX, one for sideband rx, one for sideband tx).
100 */
101 typedef struct PKTIO_METADATA_Tag
102 {
104 int flags1; /**< Configuration flags for PKTIO channel, @ref PKTIO_META_RX,
105 @ref PKTIO_META_TX,
106 @ref PKTIO_META_SB_RX,
107 @ref PKTIO_META_SB_TX*/
109 /**
110 * @def PKTIO_META_RX
111 * @ingroup pktio_constants
112 * This defines the PKTIO NETCP receive INFLOW channel
113 */
114 #define PKTIO_META_RX 0x01
116 /**
117 * @def PKTIO_META_TX
118 * @ingroup pktio_constants
119 * This defines the PKTIO NETCP transmit INFLOW channel
120 */
121 #define PKTIO_META_TX 0x02
123 /**
124 * @def PKTIO_META_SB_RX
125 * @ingroup pktio_constants
126 * This defines the PKTIO NETCP SIDEBAND channel channel
127 */
128 #define PKTIO_META_SB_RX 0x4
130 /**
131 * @def PKTIO_META_SB_TX
132 * @ingroup pktio_constants
133 * This defines the PKTIO NETCP transmit SIDEBAND channel
134 */
135 #define PKTIO_META_SB_TX 0x8
137 /**
138 * @def PKTIO_META_APP_DEF
139 * @ingroup pktio_constants
140 * This allows user space application to define custom packet types.
141 */
142 #define PKTIO_META_APP_DEF 0x80000000
144 /**
145 * @brief NWAL Packet meta data information
146 */
147 union
148 {
149 nwalRxPktInfo_t * rx_meta; /**< NWAL Packet meta data information for incoming packet */
150 nwalTxPktInfo_t * tx_meta; /**< NWAL Packet meta data information for outgoing packet */
151 nwalDmRxPayloadInfo_t * rx_sb_meta; /**<NWAL Data mode meta data payload information from NetCP */
152 nwalDmTxPayloadInfo_t * tx_sb_meta; /**< NWAL Data Mode Payload information for packet to SA */
153 } u; /**< union NWAL Packet meta data information */
155 void * sa_handle; /** This contains the appplication id associated with created SA.
156 details This is used when crypto is to be performed on the
157 egress packet */
158 } PKTIO_METADATA_T;
160 /**
161 * @ingroup pktio_structures
162 * @brief PKTIO fast path configuration structure.
163 *
164 * @details This strucuture allows user space applications to specify the PKTIO packet send function.
165 *
166 * @note This configuration is not expected at time of @ref pktio_open but can be updated via
167 * @ref pktio_control API.
168 */
169 typedef struct PKTIO_FAST_PATH_CONFIG_Tag
170 {
171 int fp_send_option; /** PKTIO_FP_NONE, @ref PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT,
172 PKTIO_FP_L4CKSUM_PORT, @ref PKTIO_FP_ESP_L4CKSUM_PORT,
173 @ref PKTIO_FP_AH_L4CKSUM_PORT, @ref PKTIO_FP_ESP_PORT,
174 @ref PKTIO_FP_AH_PORT */
176 /**
177 * @def PKTIO_FP_NO_CRYPTO_PORT
178 * @ingroup pktio_constants
179 * Use this define to reconfigure the PKTIO channel send function to not use any PKTIO fast path
180 send functions.
181 */
182 #define PKTIO_FP_NONE 0
184 /**
185 * @def PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT
186 * @ingroup pktio_constants
187 * Use this define to send packet with updates to ENET port, no crypto operation,
188 * no L4 checksum to be performed.
189 */
190 #define PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT 1
192 /**
193 * @def PKTIO_FP_L4CKSUM_PORT
194 * @ingroup pktio_constants
195 * Use this define to send packet with updates to L4 checksum, ENET port, no crypto operation
196 * to be performed.
197 */
198 #define PKTIO_FP_L4CKSUM_PORT 2
200 /**
201 * @def PKTIO_FP_ESP_L4CKSUM_PORT
202 * @ingroup pktio_constants
203 * Use this define to send packet with Crypto ESP, UDP checksum, updates to ENET port
204 */
205 #define PKTIO_FP_ESP_L4CKSUM_PORT 3
207 /**
208 * @def PKTIO_FP_AH_L4CKSUM_PORT
209 * @ingroup pktio_constants
210 * Use this define to send packet with Cypto AH, UDP checksum, updates to ENET port
211 */
212 #define PKTIO_FP_AH_L4CKSUM_PORT 4
214 /**
215 * @def PKTIO_FP_ESP_PORT
216 * @ingroup pktio_constants
217 * TUse this define to send packet with Crypto ESP packet
218 */
219 #define PKTIO_FP_ESP_PORT 5
221 /**
222 * @def PKTIO_FP_AH_PORT
223 * @ingroup pktio_constants
224 * TUse this define to send packet with AH packet
225 */
226 #define PKTIO_FP_AH_PORT 6
228 nwalTxPktInfo_t *txPktInfo; /** <The parameters in this structure are used to
229 provide additional details for the outgoing packet*/
230 } PKTIO_FAST_PATH_CONFIG_T;
234 struct PKTIO_HANDLE_tag;
235 /**
236 * @ingroup pktio_structures
237 * @brief PKTIO configuration information
238 *
239 * @details PKTIO :q information
240 */
241 typedef struct PKTIO_CFG_Tag
242 {
243 /**
244 * @def PKTIO_RX
245 * @ingroup pktio_constants
246 * This defines the pktio channel as type read, i.e., for ingress
247 */
248 #define PKTIO_RX 0x1
250 /**
251 * @def PKTIO_TX
252 * @ingroup pktio_constants
253 * This defines the pktio channel as type write, i.e. for egress
254 */
255 #define PKTIO_TX 0x2
257 /**
258 * @def PKTIO_RX_TX
259 * @ingroup pktio_constants
260 * This defines the pktio channel as type read/write
261 */
262 #define PKTIO_RX_TX (PKTIO_RX | PKTIO_TX)
264 /**
265 * Flags for PKTIO channel configuration
266 * <br>
267 * The following are flags used to configure the pktio channel:
268 * @ref PKTIO_RX , @ref PKTIO_TX, @ref PKTIO_RX_TX
269 */
270 int flags1;
272 /**
273 * @def PKTIO_GLOBAL
274 * @ingroup pktio_constants
275 * This defines the pktio channel as type global.
276 Type global means that this channel can be used by all worker threads/cores
277 */
278 #define PKTIO_GLOBAL 0x1
280 /**
281 * @def PKTIO_LOCAL
282 * @ingroup pktio_constants
283 * This defines the pktio channel as type local.
284 Type local means that thi s channel can only be used by the the thread/core that created it;
285 its name will not be visible to other threads/cores
286 */
287 #define PKTIO_LOCAL 0x2
289 /**
290 * @def PKTIO_PKT
291 * @ingroup pktio_constants
292 * This defines the pktio channel is for NETCP
293 */
294 #define PKTIO_PKT 0x4
296 /**
297 * @def PKTIO_SB
298 * @ingroup pktio_constants
299 * This defines the pktio channel is for sideband crypto
300 */
301 #define PKTIO_SB 0x8
303 int flags2; /**< Flags for PKTIO channel configuration, @ref PKTIO_LOCAL , @ref PKTIO_GLOBAL,
304 @ref PKTIO_PKT, @ref PKTIO_SB*/
306 /**
307 * @def PKTIO_Q_ANY
308 * @ingroup pktio_constants
309 * This defines the pktio IO queue number to be specified by the transport library.
310 */
311 #define PKTIO_Q_ANY -1
313 int qnum; /**< PKTIO channel queue number */
314 int max_n; /**< Maximum number of packets read in 1 poll */
315 PKTIO_FAST_PATH_CONFIG_T fast_path_cfg; /** < @ref PKTIO_FAST_PATH_CONFIG_T */
316 } PKTIO_CFG_T;
319 /**
320 * @ingroup pktio_structures
321 * @brief PKTIO polling control struct, currently NOT_IMPLEMENTED
322 *
323 * @details PKTIO polling control struct, currently NOT_IMPLEMENTED
324 */
325 typedef struct PKTIO_POLL_Tag
326 {
327 } PKTIO_POLL_T;
329 /**
330 * @ingroup netapi_cb_functions
331 * @brief PKTIO_CB Callback function to be issued on packet receive
332 *
333 * @details The application provides a callback function that gets invoked on packet receive
334 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
335 * @param[in] p_recv Pointer to the packets received.
336 * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
337 * @param[in] n_pkts Number of packets received.
338 * @param[in] ts Timestamp associted with received packets.
339 * @retval none
340 * @pre @ref pktio_open
341 */
342 typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
343 Ti_Pkt* p_recv[],
344 PKTIO_METADATA_T p_meta[],
345 int n_pkts,
346 uint64_t ts);
348 /**
349 * @ingroup pktio_functions
350 * @brief PKTIO_SEND PKTIO specific send function
351 *
352 * @details The application calls this PKTIO specific send function to transmit packet
353 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
354 * @param[in] p_send Pointer to the packet to send
355 * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
356 * @param[out] p_err Pointer to error code.
357 * @retval none
358 * @pre @ref pktio_open
359 */
360 typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
361 Ti_Pkt* p_send,
362 PKTIO_METADATA_T *p_meta,
363 int * p_err);
366 /**
367 * @ingroup pktio_functions
368 * @brief PKTIO_POLL PKTIO specific poll function
369 *
370 * @details The application calls this PKTIO specific POLL function
371 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
372 * @param[in] p_poll_cfg @ref PKTIO_POLL_T, currently NOT_IMPLEMENTED
373 * @param[out] p_err Pointer to error code.
374 * @retval none
375 * @pre @ref pktio_open
376 */
377 typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
378 PKTIO_POLL_T * p_poll_cfg,
379 int * p_err);
382 /**
383 * @brief This defines an unused packet io channel slot
384 */
385 #define PKTIO_NA 0
388 struct NETAPI_tag;
390 /**
391 * @ingroup pktio_structures
392 * @brief PKTIO handle structure definition.
393 *
394 * @details PKTIO handle strucutre which is returned from call to @ref pktio_create
395 */
396 typedef struct PKTIO_HANDLE_Tag
397 {
398 /**
399 * @def PKTIO_INUSE
400 * @ingroup pktio_constants
401 * This defines whether the pktio channel entry is valid.
402 */
403 #define PKTIO_INUSE 0xfeedfeed
405 int inuse; /**<true is pktio channel is in use */
407 /**
408 * Set the "use_nwal" field to one of the defines listed below.
409 * <br>
410 * The following defines are used to populate the use_nwal field:
411 * @ref PKTIO_4_IPC , @ref PKTIO_4_ADJ_NWAL, @ref PKTIO_DEF_NWAL. @ref PKTIO_4_ADJ_SB., @ref PKTIO_DEF_SB
412 */
413 int use_nwal;
415 /**
416 * @def PKTIO_4_IPC
417 * @ingroup pktio_constants
418 * This define is for channels used for IPC between cores
419 */
420 #define PKTIO_4_IPC 0
422 /**
423 * @def PKTIO_4_ADJ_NWAL
424 * @ingroup pktio_constants
425 * This define is for NETCP (RX) channels whose associated queues are managed by NWAL
426 */
427 #define PKTIO_4_ADJ_NWAL 1
429 /**
430 * @def PKTIO_DEF_NWAL
431 * @ingroup pktio_constants
432 * This define is for NETCP channels that are tied to the default NWAL RX/TX queues
433 */
434 #define PKTIO_DEF_NWAL 2
436 /**
437 * @def PKTIO_4_ADJ_SB
438 * This define is for (RX) channels used to get crypto side band results via application managed queues
439 * @ingroup pktio_constants
440 */
441 #define PKTIO_4_ADJ_SB 3
443 /**
444 * @def PKTIO_DEF_SB
445 * @ingroup pktio_constants
446 * This define is for channels tied to the default crypto side band queues
447 */
448 #define PKTIO_DEF_SB 4
450 struct NETAPI_tag * back; /**< back handle to NETPAI instance */
451 void * nwalInstanceHandle; /**<save here for conveninece this is the nwal handle set at init time*/
452 PKTIO_CB cb; /**< callback for channel (for Rx) */
453 PKTIO_CFG_T cfg; /**<configuration of channel */
454 Qmss_QueueHnd q; /**<the associated queue handle for channel */
455 Qmss_Queue qInfo; /**<and its qm#/q# */
456 int max_n; /**<max # of pkts to read in one poll */
457 void * cookie; /**<app specific */
458 PKTIO_SEND _send; /**<pktio type specific send function */
459 PKTIO_POLL _poll; /**<pktio type specific POLL function */
460 int poll_flags; /**< pktio flags to control polling options */
461 char name[PKTIO_MAX_NAME+1]; /**< Name of pktio channel */
462 nwalTxPSCmdInfo_t tx_psCmdInfo; /**<Command Label to be sent to NetCP for the packet flow */
463 } PKTIO_HANDLE_T;
466 /**
467 * @ingroup pktio_structures
468 * @brief PKTIO control structure
469 *
470 * @details PKTIO control stucture for the control API. Allows operations on pktio channel such as CLEAR , DIVERT, etc
471 */
472 typedef struct PKTIO_CONTROL_Tag
473 {
474 /**
475 * @def PKTIO_CLEAR
476 * This defines is used to clear out the pktio channel
477 */
478 #define PKTIO_CLEAR 0x1
480 // @cond NOT_IMPLEMENTED
481 /**
482 * @def PKTIO_DIVERT
483 * This define is used to divert to a dest pktio channel
484 */
485 #define PKTIO_DIVERT 0x2
486 /// @endcond
488 /**
489 * @def PKTIO_SET_POLL_FLAGS
490 * This define is used to set poll flags for a pktio channel
491 */
492 #define PKTIO_SET_POLL_FLAGS 0x4 //control poll flags (netcp_rx only)
493 /**
494 * @def PKTIO_UPDATE_FAST_PATH
495 * This define is used to update the command information template for
496 * INFLOW mode of operation of a ptktio channel (netcp_tx only)
497 */
498 #define PKTIO_UPDATE_FAST_PATH 0x8
500 /**<max # of pkts to read in one poll */
501 /**
502 * @def PKTIO_UPDATE_MAX_PKTS_PER_POLL
503 * This define is used to update the maximum number of packets to read in 1 poll
504 * period for the pktio channel.
505 */
506 #define PKTIO_UPDATE_MAX_PKTS_PER_POLL 0x10
508 int op; /**< Control operation (CLEAR, DIVERT, ..) */
509 PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel (for DIVERT) */
510 int poll_flags; /**< Flags to indicate polling options */
511 } PKTIO_CONTROL_T;
513 /**
514 * @ingroup pktio_functions
515 * @brief API creates a NETAPI PKTIO channel
516 *
517 * @details This assigns global resources to a NETAPI pktio channel.
518 * Once created, the channel can be used to send and/or receive
519 * a Ti_Pkt. This can be used for communication with the
520 * the Network co-processor (NETCP) or for internal inter-processor
521 * communication. The channel is saved under the assigned name
522 * and can be opened by other netapi threads instances.
523 * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
524 * @param[in] name A pointer to the char string name for channel
525 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
526 * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
527 * @param[out] err Pointer to error code.
528 * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
529 * @pre @ref netapi_init
530 */
531 PKTIO_HANDLE_T * pktio_create(NETAPI_T netapi_handle,
532 char * name,
533 PKTIO_CB cb,
534 PKTIO_CFG_T* p_cfg,
535 int * err);
537 /**
538 * @ingroup pktio_functions
539 * @brief API opens an existing NETAPI PKTIO channel
540 *
541 * @details This opens an NETAPI pktio channel for use. The channel
542 * must have already been created via @ref pktio_create or may have
543 * been created internally during the netapi intialization.
544 * Once opened, the channel can be used to send and/or receive
545 * a Ti_Pkt. This can be used for communication with the
546 * the Network co-processor (NETCP) or for internal inter-processor
547 * communication.
548 *
549 * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
550 * @param[in] name A pointer to the char string name for channel to open
551 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
552 * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
553 * @param[out] err Pointer to error code.
554 * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
555 * @pre @ref netapi_init, @ref pktio_create
556 */
557 PKTIO_HANDLE_T * pktio_open(NETAPI_T netapi_handle,
558 char *name,
559 PKTIO_CB cb,
560 PKTIO_CFG_T *p_cfg,
561 int * err);
563 /**
564 * @ingroup pktio_functions
565 * @brief API controls an existing NETAPI PKTIO channel
566 *
567 * @details This controls an opened pktio channel
568 *
569 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
570 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
571 * @param[in] p_cfg Pointer to channel configuration which (optional), @ref PKTIO_CFG_T
572 * @param[in] p_control Pointer to PKTIO control information (optional), @ref PKTIO_CONTROL_T
573 * @param[out] err Pointer to error code.
574 * @retval none
575 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
576 */
577 void pktio_control(PKTIO_HANDLE_T * handle,
578 PKTIO_CB cb,
579 PKTIO_CFG_T * p_cfg,
580 PKTIO_CONTROL_T *p_control,
581 int *err);
583 /**
584 * @ingroup pktio_functions
585 * @brief API closes a NETAPI PKTIO channel
586 *
587 * @details This closes a PKTIO channel
588 *
589 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
590 * @param[out] err Pointer to error code.
591 * @retval none
592 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
593 */
594 void pktio_close(PKTIO_HANDLE_T * handle,
595 int * err);
597 /**
598 * @ingroup pktio_functions
599 * @brief API deletes a NETAPI PKTIO channel
600 *
601 * @details This deletes a PKTIO channel
602 *
603 * @param[in] handle The PKTIO handle, @ref PKTIO_HANDLE_T
604 * @param[out] err Pointer to error code.
605 * @retval none
606 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
607 */
608 void pktio_delete(PKTIO_HANDLE_T * handle,
609 int * err);
611 /**
612 * @ingroup pktio_functions
613 * @brief API sends a packet to a NETAPI PKTIO channel
614 *
615 * @details This sends a Ti_Pkt and associated meta data,
616 * @ref PKTIO_METADATA_T to a channel. The channel
617 * must have already been created via @ref pktio_create or opened
618 * via @ref pktio_open. It may have
619 * been created internally during the netapi intialization.
620 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
621 * @param[in] pkt Pointer to the packet to send
622 * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
623 * @param[out] err Pointer to error code.
624 * @retval 1 if packet sent, 0 if error
625 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
626 */
627 static inline int pktio_send(PKTIO_HANDLE_T * handle,
628 Ti_Pkt *pkt,
629 PKTIO_METADATA_T *m,
630 int * err)
631 {
632 return handle->_send((struct PKTIO_HANDLE_tag *)handle, pkt, m, err);
633 }
635 /**
636 * @ingroup pktio_functions
637 * @brief API sends multiple packets to a NETAPI PKTIO channel
638 *
639 * @details This sends an array of Ti_Pkt and associated meta data,
640 * @ref PKTIO_METADATA_T to a channel. The channel
641 * must have already been created via @ref pktio_create or opened
642 * via @ref pktio_open. It may have
643 * been created internally during the netapi intialization.
644 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
645 * @param[in] pkt Pointer to the packet to send
646 * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
647 * @param[in] np The number of packets in list to send
648 * @param[out] err Pointer to error code.
649 * @retval Number of packets sent, 0 if error
650 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
651 */
652 int pktio_sendMulti(PKTIO_HANDLE_T *handle,
653 Ti_Pkt * pkt[],
654 PKTIO_METADATA_T * m[],
655 int np,
656 int * err);
658 /**
659 * @ingroup pktio_functions
660 * @brief API polls a NETAPI PKTIO channel for received packets
661 *
662 * @details This api polls a pktio channel. Any pending data in the channel is
663 * passed to the @ref PKTIO_CB registered when the channel was
664 * created or opened. The channel must
665 * have already been created via @ref pktio_create or opened
666 * via @ref pktio_open. It may have
667 * been created internally during the netapi intialization.
668 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
669 * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
670 * @param[out] err Pointer to error code.
671 * @retval Number of packets received by poll
672 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
673 */
674 static inline int pktio_poll(PKTIO_HANDLE_T * handle,
675 PKTIO_POLL_T * p_poll_cfg,
676 int * err)
677 {
678 return handle->_poll((struct PKTIO_HANDLE_tag *) handle, p_poll_cfg, err);
679 }
681 /**
682 * @ingroup pktio_functions
683 * @brief API polls all NETAPI PKTIO channels associated with @ref NETAPI_T instance
684 * for received packets
685 *
686 * @details This api polls all pktio channels attached to an instance.
687 * Any pending data in these channels are
688 * passed to the @ref PKTIO_CB registered when the channel was
689 * created or opened. The channels must
690 * have already been created via @ref pktio_create or opened
691 * via @ref pktio_open. They may have
692 * been created internally during the netapi intialization.
693 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
694 * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
695 * @param[out] err Pointer to error code.
696 * @retval Number of packets received by poll
697 * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
698 */
699 int pktio_pollAll(NETAPI_T handle,
700 PKTIO_POLL_T * p_poll_cfg,
701 int *err);
704 /* update max_n for poll */
707 /**
708 * @brief This define sets the max number of pkts to read in one poll in the @ref PKTIO_HANDLE_T
709 */
710 #define pktio_set_max_n(handle,max_n) (handle)->max_n=max_n;
712 /**
713 * @brief This define returns NETAPI handle stored in the @ref PKTIO_HANDLE_T
714 */
715 #define pktio_get_netapi_handle(handle) (handle)->back
717 /**
718 * @brief This define sets a user space application cookie in the @ref PKTIO_HANDLE_T
719 */
720 #define pktio_set_cookie(handle, cookie) (handle)->cookie = cookie
722 /**
723 * @brief This define returns a previously set user space application cookie stored in the @ref PKTIO_HANDLE_T
724 */
725 #define pktio_get_cookie(handle) (handle)->cookie
728 /**
729 * @brief This define returns a associate queue handle stored in the @ref PKTIO_HANDLE_T
730 */
732 #define pktio_get_q(handle) (handle)->q
734 /*-----------------Extra Fast Path pkt meta data macros--------------------*/
735 #include "cppi_desc.h"
736 #include "ti/drv/pa/pa.h"
737 #include "ti/drv/pa/pasahost.h"
740 /**
741 * @ingroup pktio_functions
742 * @brief API returns default packet queue to poll for netcp RX
743 * @note: these are expensive calls, so call once and save
744 */
745 static inline Qmss_QueueHnd pktio_mGetDefaultNetCpQ(PKTIO_HANDLE_T *h)
746 {
747 nwalGlobCxtInfo_t Info;
748 nwal_getGlobCxtInfo(h->nwalInstanceHandle,&Info);
749 return Info.rxDefPktQ;
750 }
753 /**
754 * @ingroup pktio_functions
755 * @brief API returns L4Queue to poll for netcp RX (L4 classifier queue).
756 * @note: these are expensive calls, so call once and save
757 */
758 static inline Qmss_QueueHnd pktio_mGetDefaultNetCPL4Q(PKTIO_HANDLE_T *h)
759 {
760 nwalLocCxtInfo_t Info;
761 nwal_getLocCxtInfo(h->nwalInstanceHandle,&Info);
762 return Info.rxL4PktQ;
763 }
766 /**
767 * @ingroup pktio_functions
768 * @brief API to perform descriptor push to QMSS Queue
769 */
770 static inline void pktio_mQmssQueuePushDescSizeRaw(Qmss_QueueHnd hnd,
771 void *descAddr,
772 uint32_t descSize)
773 {
774 return(Qmss_queuePushDescSizeRaw(hnd,descAddr,descSize));
775 }
777 /**
778 * @ingroup pktio_functions
779 * @brief API to perform descriptor pop from QMSS Queue
780 */
781 static inline void* pktio_mQmssQueuePopRaw(Qmss_QueueHnd hnd)
782 {
783 return(Qmss_queuePopRaw(hnd));
784 }
786 /**
787 * @ingroup pktio_functions
788 * @brief API to retrieve NWAL global instance handle.
789 */
790 static inline nwal_Inst pktio_mGetNwalInstance(PKTIO_HANDLE_T *h)
791 {
792 return h->nwalInstanceHandle;
793 }
796 #endif