#ifndef UCP_PROTO_H_
#define UCP_PROTO_H_
#include "lane_type.h"
#include <ucp/core/ucp_types.h>
#include <ucs/datastruct/linear_func.h>
#include <ucs/datastruct/string_buffer.h>
#define UCP_PROTO_MAX_LANES UCP_MAX_LANES
#define UCP_PROTO_MAX_PERF_RANGES 24
#define UCP_PROTO_PRIV_MAX 1024
#define UCP_PROTO_MAX_COUNT 64
#define UCP_PROTO_ID_INVALID ((ucp_proto_id_t)-1)
#define UCP_PROTO_CONFIG_STR_MAX 128
typedef unsigned ucp_proto_id_t;
typedef uint64_t ucp_proto_id_mask_t;
enum {
UCP_PROTO_STAGE_START = 0,
UCP_PROTO_STAGE_LAST = 8
};
enum {
UCP_PROTO_FLAG_AM_SHORT = UCS_BIT(0),
UCP_PROTO_FLAG_PUT_SHORT = UCS_BIT(1),
UCP_PROTO_FLAG_TAG_SHORT = UCS_BIT(2),
UCP_PROTO_FLAG_INVALID = UCS_BIT(3)
};
typedef struct {
uint8_t op_id;
uint8_t op_flags;
uint8_t dt_class;
uint8_t mem_type;
uint8_t sys_dev;
uint8_t sg_count;
uint8_t padding[2];
} UCS_S_PACKED ucp_proto_select_param_t;
typedef enum {
UCP_PROTO_PERF_TYPE_SINGLE,
UCP_PROTO_PERF_TYPE_MULTI,
UCP_PROTO_PERF_TYPE_LAST
} ucp_proto_perf_type_t;
typedef struct {
size_t max_length;
ucs_linear_func_t perf[UCP_PROTO_PERF_TYPE_LAST];
} ucp_proto_perf_range_t;
typedef struct {
size_t cfg_thresh;
unsigned cfg_priority;
size_t min_length;
unsigned num_ranges;
ucp_proto_perf_range_t ranges[UCP_PROTO_MAX_PERF_RANGES];
} ucp_proto_caps_t;
typedef struct {
ucp_worker_h worker;
const ucp_proto_select_param_t *select_param;
ucp_worker_cfg_index_t ep_cfg_index;
ucp_worker_cfg_index_t rkey_cfg_index;
const ucp_ep_config_key_t *ep_config_key;
const ucp_rkey_config_key_t *rkey_config_key;
const char *proto_name;
void *priv;
size_t *priv_size;
ucp_proto_caps_t *caps;
} ucp_proto_init_params_t;
typedef ucs_status_t
(*ucp_proto_init_func_t)(const ucp_proto_init_params_t *params);
typedef void (*ucp_proto_config_str_func_t)(size_t min_length,
size_t max_length, const void *priv,
ucs_string_buffer_t *strb);
struct ucp_proto {
const char *name;
unsigned flags;
ucp_proto_init_func_t init;
ucp_proto_config_str_func_t config_str;
uct_pending_callback_t progress[UCP_PROTO_STAGE_LAST];
};
#define UCP_PROTO_REGISTER(_proto) \
UCS_STATIC_INIT { \
ucs_assert_always(ucp_protocols_count < UCP_PROTO_MAX_COUNT); \
ucp_protocols[ucp_protocols_count++] = (_proto); \
}
#define ucp_proto_id_field(_proto_id, _field) \
(ucp_protocols[(_proto_id)]->_field)
#define ucp_proto_id_call(_proto_id, _func, ...) \
ucp_proto_id_field(_proto_id, _func)(__VA_ARGS__)
extern const ucp_proto_t *ucp_protocols[UCP_PROTO_MAX_COUNT];
extern unsigned ucp_protocols_count;
extern const char *ucp_proto_perf_types[];
#endif