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