1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2019 IBM Corporation. All rights reserved.
4 * Copyright (c) 2019 Mellanox Technologies, Inc.
5 * All rights reserved.
6 * $COPYRIGHT$
7 *
8 * Additional copyrights may follow
9 *
10 * $HEADER$
11 */
12
13 /**
14 * @file
15 *
16 * This interface is for the encoding/decoding of basic types and the
17 * compression/decompression of larger blobs of data (i.e., modex).
18 *
19 * Available plugins may be defined at runtime via the typical MCA parameter
20 * syntax.
21 */
22
23 #ifndef PMIX_PSQUASH_H
24 #define PMIX_PSQUASH_H
25
26 #include <src/include/pmix_config.h>
27
28 #include "src/mca/mca.h"
29 #include "src/mca/base/pmix_mca_base_var.h"
30 #include "src/mca/base/pmix_mca_base_framework.h"
31
32 BEGIN_C_DECLS
33
34 /****** MODULE DEFINITION ******/
35
36 /**
37 * Initialize the module
38 */
39 typedef pmix_status_t (*pmix_psquash_base_module_init_fn_t)(void);
40
41 /**
42 * Finalize the module
43 */
44 typedef void (*pmix_psquash_base_module_finalize_fn_t)(void);
45
46 /**
47 * Maximum size of the type.
48 *
49 * type - Type (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
50 * size - size of the type
51 */
52 typedef pmix_status_t (*pmix_psquash_get_max_size_fn_t) (pmix_data_type_t type,
53 size_t *size);
54
55 /**
56 * Encode a basic integer type into a contiguous destination buffer.
57 *
58 * type - Type of the 'src' pointer (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
59 * src - pointer to a single basic integer type
60 * dest - pointer to buffer to store data
61 * dst_len - pointer to the packed size of dest, in bytes
62 */
63
64 typedef pmix_status_t (*pmix_psquash_encode_int_fn_t) (pmix_data_type_t type,
65 void *src, void *dest,
66 size_t *dst_len);
67
68 /**
69 * Decode a basic a contiguous destination buffer into a basic integer type.
70 *
71 * type - Type of the 'dest' pointer (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
72 * src - pointer to buffer where data was stored
73 * src_len - length, in bytes, of the src buffer
74 * dest - pointer to a single basic integer type
75 * dst_len - pointer to the unpacked size of dest, in bytes
76 */
77 typedef pmix_status_t (*pmix_psquash_decode_int_fn_t) (pmix_data_type_t type,
78 void *src, size_t src_len,
79 void *dest, size_t *dst_len);
80
81 /**
82 * Base structure for a PSQUASH module
83 */
84 typedef struct {
85 const char *name;
86 /* flag indicating if the type is encoded within the value, otherwise, it is necessary to further pack the type with the value. */
87 bool int_type_is_encoded;
88
89 /** init/finalize */
90 pmix_psquash_base_module_init_fn_t init;
91 pmix_psquash_base_module_finalize_fn_t finalize;
92
93 pmix_psquash_get_max_size_fn_t get_max_size;
94
95 /** Integer compression */
96 pmix_psquash_encode_int_fn_t encode_int;
97 pmix_psquash_decode_int_fn_t decode_int;
98 } pmix_psquash_base_module_t;
99
100 /**
101 * Base structure for a PSQUASH component
102 */
103 struct pmix_psquash_base_component_t {
104 pmix_mca_base_component_t base;
105 pmix_mca_base_component_data_t data;
106 int priority;
107 };
108 typedef struct pmix_psquash_base_component_t pmix_psquash_base_component_t;
109
110 PMIX_EXPORT extern pmix_psquash_base_module_t pmix_psquash;
111
112 /*
113 * Macro for use in components that are of type psquash
114 */
115 #define PMIX_PSQUASH_BASE_VERSION_1_0_0 \
116 PMIX_MCA_BASE_VERSION_1_0_0("psquash", 1, 0, 0)
117
118 END_C_DECLS
119
120 #endif