Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2010-2018 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _IFPGA_COMMON_H_ 6 : : #define _IFPGA_COMMON_H_ 7 : : 8 : : #include <errno.h> 9 : : #include <stdlib.h> 10 : : #include <string.h> 11 : : 12 : : #include <bus_ifpga_driver.h> 13 : : #include <rte_common.h> 14 : : 15 : : static inline int 16 : 0 : ifpga_get_string_arg(const char *key __rte_unused, const char *value, 17 : : void *extra_args) 18 : : { 19 [ # # ]: 0 : if (!value || !extra_args) 20 : : return -EINVAL; 21 : : 22 : 0 : *(char **)extra_args = strdup(value); 23 : : 24 [ # # ]: 0 : if (!*(char **)extra_args) 25 : 0 : return -ENOMEM; 26 : : 27 : : return 0; 28 : : } 29 : : 30 : : static inline int 31 : 0 : ifpga_get_integer32_arg(const char *key __rte_unused, const char *value, 32 : : void *extra_args) 33 : : { 34 [ # # ]: 0 : if (!value || !extra_args) 35 : : return -EINVAL; 36 : : 37 : 0 : *(int *)extra_args = strtoull(value, NULL, 0); 38 : : 39 : 0 : return 0; 40 : : } 41 : : 42 : : static inline int 43 : : ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0, 44 : : const struct rte_afu_id *afu_id1) 45 : : { 46 [ # # ]: 0 : if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && 47 [ # # ]: 0 : (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && 48 [ # # ]: 0 : (afu_id0->port == afu_id1->port)) { 49 : : return 0; 50 : : } else 51 : : return 1; 52 : : } 53 : : 54 : : #endif /* _IFPGA_COMMON_H_ */