1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Intel Corporation 3 */ 4 #ifndef __INCLUDE_RTE_SWX_EXTERN_H__ 5 #define __INCLUDE_RTE_SWX_EXTERN_H__ 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 /** 12 * @file 13 * RTE SWX Extern objects and functions 14 * 15 * Extern object and extern function interfaces. The extern objects and extern 16 * functions provide the mechanisms to hook external functionality into the 17 * packet processing pipeline. 18 */ 19 20 #include <stdint.h> 21 22 /* 23 * Extern type 24 */ 25 26 /** 27 * Extern object constructor 28 * 29 * @param[in] args 30 * Extern object constructor arguments. It may be NULL. 31 * @return 32 * Extern object handle. 33 */ 34 typedef void * 35 (*rte_swx_extern_type_constructor_t)(const char *args); 36 37 /** 38 * Extern object destructor 39 * 40 * @param[in] object 41 * Extern object handle. 42 */ 43 typedef void 44 (*rte_swx_extern_type_destructor_t)(void *object); 45 46 /** 47 * Extern object member function 48 * 49 * The mailbox is used to pass input arguments to the member function and 50 * retrieve the output results. The mailbox mechanism allows for multiple 51 * concurrent executions of the same member function for the same extern object. 52 * 53 * Multiple invocations of the same member function may be required in order for 54 * the associated operation to complete. The completion is flagged by a return 55 * value of 1, in which case the results are available in the mailbox; in case 56 * of a return value of 0, the operation is not yet completed, so the member 57 * function must be invoked again with exactly the same object and mailbox 58 * arguments. 59 * 60 * @param[in] object 61 * Extern object handle. 62 * @param[in] mailbox 63 * Extern object mailbox. 64 * @return 65 * 0 when the operation is not yet completed, and 1 when the operation is 66 * completed. No other return values are allowed. 67 */ 68 typedef int 69 (*rte_swx_extern_type_member_func_t)(void *object, void *mailbox); 70 71 /* 72 * Extern function 73 */ 74 75 /** The mailbox is used to pass input arguments to the extern function and 76 * retrieve the output results. The mailbox mechanism allows for multiple 77 * concurrent executions of the same extern function. 78 * 79 * Multiple invocations of the same extern function may be required in order for 80 * the associated operation to complete. The completion is flagged by a return 81 * value of 1, in which case the results are available in the mailbox; in case 82 * of a return value of 0, the operation is not yet completed, so the extern 83 * function must be invoked again with exactly the same mailbox argument. 84 * 85 * @param[in] mailbox 86 * Extern object mailbox. 87 * @return 88 * 0 when the operation is not yet completed, and 1 when the operation is 89 * completed. No other return values are allowed. 90 */ 91 typedef int 92 (*rte_swx_extern_func_t)(void *mailbox); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif 99