Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,593 changes: 168 additions & 3,425 deletions prov/cxi/include/cxip.h

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions prov/cxi/include/cxip/addr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_ADDR_H_
#define _CXIP_ADDR_H_

#include <stdint.h>

/* Macros */
#define CXIP_ADDR_EQUAL(a, b) ((a).nic == (b).nic && (a).pid == (b).pid)

#define CXIP_ADDR_VNI_EQUAL(a, b) (CXIP_ADDR_EQUAL(a, b) && (a).vni == (b).vni)

#define CXIP_ADDR_PORT_BITS 6

#define CXIP_ADDR_SWITCH_BITS 5

#define CXIP_ADDR_GROUP_BITS 9

#define CXIP_ADDR_FATTREE_PORT_BITS 6

#define CXIP_ADDR_FATTREE_SWITCH_BITS 14

/* Type definitions */
struct cxip_addr {
uint32_t pid : C_DFA_PID_BITS_MAX;
uint32_t nic : C_DFA_NIC_BITS;
uint32_t pad : 3;
uint16_t vni;
};

#endif /* _CXIP_ADDR_H_ */
32 changes: 32 additions & 0 deletions prov/cxi/include/cxip/atomic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_ATOMIC_H_
#define _CXIP_ATOMIC_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/* Forward declarations */
struct cxip_cntr;
struct cxip_txc;

/* Function declarations */
int cxip_amo_common(enum cxip_amo_req_type req_type, struct cxip_txc *txc,
uint32_t tclass, const struct fi_msg_atomic *msg,
const struct fi_ioc *comparev, void **comparedesc,
size_t compare_count, const struct fi_ioc *resultv,
void **resultdesc, size_t result_count, uint64_t flags,
bool triggered, uint64_t trig_thresh,
struct cxip_cntr *trig_cntr, struct cxip_cntr *comp_cntr);

int _cxip_atomic_opcode(enum cxip_amo_req_type req_type, enum fi_datatype dt,
enum fi_op op, int amo_remap_to_pcie_fadd,
enum c_atomic_op *cop, enum c_atomic_type *cdt,
enum c_cswap_op *copswp, unsigned int *cdtlen);

#endif /* _CXIP_ATOMIC_H_ */
15 changes: 15 additions & 0 deletions prov/cxi/include/cxip/auth.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_AUTH_H_
#define _CXIP_AUTH_H_

/* Function declarations */
int cxip_check_auth_key_info(struct fi_info *info);

int cxip_gen_auth_key(struct fi_info *info, struct cxi_auth_key *key);

#endif /* _CXIP_AUTH_H_ */
132 changes: 132 additions & 0 deletions prov/cxi/include/cxip/av.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_AV_H_
#define _CXIP_AV_H_

#include <ofi_atom.h>
#include <ofi_list.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/* Forward declarations */
struct cxip_addr;
struct cxip_coll_mc;
struct cxip_domain;
struct cxip_ep;

/* Type definitions */
struct cxip_av_auth_key_entry {
ofi_atomic32_t use_cnt;
ofi_atomic32_t ref_cnt;
UT_hash_handle hh;
struct dlist_entry entry;
struct cxi_auth_key key;
fi_addr_t fi_addr;
};

struct cxip_av_entry {
ofi_atomic32_t use_cnt;
UT_hash_handle hh;
struct cxip_addr addr;
fi_addr_t fi_addr;
struct cxip_av_auth_key_entry *auth_key;
};

struct cxip_av {
struct fid_av av_fid;
struct cxip_domain *domain;

/* List of endpoints bound to this AV. Each bind takes a reference
* as well.
*/
struct dlist_entry ep_list;
ofi_atomic32_t ref;

/* Memory used to implement lookups. Two data structures are used.
* 1. ibuf pool for O(1) lookup on the data path
* 2. hash table for O(1) on the receive path
*/
struct cxip_av_entry *av_entry_hash;
struct ofi_bufpool *av_entry_pool;
ofi_atomic32_t av_entry_cnt;

/* Memory used to support AV authorization key. Three data structures
* are needed.
* 1. ibuf pool for memory allocation and lookup O(1) access.
* 2. hash table for O(1) reverse lookup
* 3. List for iterating
*/
struct cxip_av_auth_key_entry *auth_key_entry_hash;
struct ofi_bufpool *auth_key_entry_pool;
struct dlist_entry auth_key_entry_list;
ofi_atomic32_t auth_key_entry_cnt;
size_t auth_key_entry_max;

/* Single lock is used to protect entire AV. With domain level
* threading, this lock is not used.
*/
bool lockless;
pthread_rwlock_t lock;

/* AV is configured as symmetric. This is an optimization which enables
* endpoints to use logical address.
*/
bool symmetric;

/* Address vector type. */
enum fi_av_type type;

/* Whether or not the AV is operating in FI_AV_AUTH_KEY mode. */
bool av_auth_key;

/* Whether or not the AV was opened with FI_AV_USER_ID. */
bool av_user_id;
};

struct cxip_av_set {
struct fid_av_set av_set_fid;
struct cxip_av *cxi_av; // associated AV
struct cxip_coll_mc *mc_obj; // reference MC
fi_addr_t *fi_addr_ary; // addresses in set
size_t fi_addr_cnt; // count of addresses
struct cxip_comm_key comm_key; // communication key
uint64_t flags;
};

/* Function declarations */
int cxip_av_auth_key_get_vnis(struct cxip_av *av, uint16_t **vni,
size_t *vni_count);

void cxip_av_auth_key_put_vnis(struct cxip_av *av, uint16_t *vni,
size_t vni_count);

extern struct cxip_addr *(*cxip_av_addr_in)(const void *addr);

extern void (*cxip_av_addr_out)(struct cxip_addr *addr_out,
struct cxip_addr *addr);

int cxip_av_lookup_addr(struct cxip_av *av, fi_addr_t fi_addr,
struct cxip_addr *addr);

fi_addr_t cxip_av_lookup_fi_addr(struct cxip_av *av,
const struct cxip_addr *addr);

fi_addr_t cxip_av_lookup_auth_key_fi_addr(struct cxip_av *av, unsigned int vni);

int cxip_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
struct fid_av **av, void *context);

int cxip_av_bind_ep(struct cxip_av *av, struct cxip_ep *ep);

void cxip_av_unbind_ep(struct cxip_av *av, struct cxip_ep *ep);

int cxip_av_set(struct fid_av *av, struct fi_av_set_attr *attr,
struct fid_av_set **av_set_fid, void *context);

#endif /* _CXIP_AV_H_ */
70 changes: 70 additions & 0 deletions prov/cxi/include/cxip/cmdq.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_CMDQ_H_
#define _CXIP_CMDQ_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/* Forward declarations */
struct cxip_lni;

/* Type definitions */
struct cxip_cmdq {
struct cxi_cq *dev_cmdq;
struct c_cstate_cmd c_state;
enum cxip_llring_mode llring_mode;

struct cxi_cp *cur_cp;
struct cxi_cp *prev_cp;
struct cxip_lni *lni;
};

/* Function declarations */
int cxip_cmdq_emit_idc_put(struct cxip_cmdq *cmdq,
const struct c_cstate_cmd *c_state,
const struct c_idc_put_cmd *put, const void *buf,
size_t len, uint64_t flags);

int cxip_cmdq_emit_dma(struct cxip_cmdq *cmdq, struct c_full_dma_cmd *dma,
uint64_t flags);

int cxip_cmdq_emic_idc_amo(struct cxip_cmdq *cmdq,
const struct c_cstate_cmd *c_state,
const struct c_idc_amo_cmd *amo, uint64_t flags,
bool fetching, bool flush);

int cxip_cmdq_emit_dma_amo(struct cxip_cmdq *cmdq, struct c_dma_amo_cmd *amo,
uint64_t flags, bool fetching, bool flush);

int cxip_cmdq_emit_idc_msg(struct cxip_cmdq *cmdq,
const struct c_cstate_cmd *c_state,
const struct c_idc_msg_hdr *msg, const void *buf,
size_t len, uint64_t flags);

enum cxi_traffic_class cxip_ofi_to_cxi_tc(uint32_t ofi_tclass);

int cxip_cmdq_cp_set(struct cxip_cmdq *cmdq, uint16_t vni,
enum cxi_traffic_class tc,
enum cxi_traffic_class_type tc_type);

int cxip_cmdq_cp_modify(struct cxip_cmdq *cmdq, uint16_t vni,
enum cxi_traffic_class tc);

int cxip_cmdq_alloc(struct cxip_lni *lni, struct cxi_eq *evtq,
struct cxi_cq_alloc_opts *cq_opts, uint16_t vni,
enum cxi_traffic_class tc,
enum cxi_traffic_class_type tc_type,
struct cxip_cmdq **cmdq);

void cxip_cmdq_free(struct cxip_cmdq *cmdq);

int cxip_cmdq_emit_c_state(struct cxip_cmdq *cmdq,
const struct c_cstate_cmd *cmd);

#endif /* _CXIP_CMDQ_H_ */
59 changes: 59 additions & 0 deletions prov/cxi/include/cxip/cntr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only
*
* Copyright (c) 2018-2024 Hewlett Packard Enterprise Development LP
*/

#ifndef _CXIP_CNTR_H_
#define _CXIP_CNTR_H_

#include <ofi_atom.h>
#include <ofi_list.h>
#include <stdbool.h>
#include <stdint.h>

/* Forward declarations */
struct cxip_cmdq;
struct cxip_domain;

/* Type definitions */
struct cxip_cntr {
struct fid_cntr cntr_fid;
struct cxip_domain *domain; // parent domain
ofi_atomic32_t ref;
struct fi_cntr_attr attr; // copy of user or default attributes
struct fid_wait *wait;
/* Contexts to which counter is bound */
struct dlist_entry ctx_list;

/* Triggered cmdq for bound counters */
struct cxip_cmdq *trig_cmdq;

struct ofi_genlock lock;

struct cxi_ct *ct;
struct c_ct_writeback *wb;
uint64_t wb_device;
enum fi_hmem_iface wb_iface;
uint64_t wb_handle;
bool wb_handle_valid;
struct c_ct_writeback lwb;

struct dlist_entry dom_entry;

/* Counter for number of operations which need progress. A separate lock
* is needed since these functions may be called without counter lock
* held.
*/
struct ofi_genlock progress_count_lock;
int progress_count;
};

/* Function declarations */
int cxip_cntr_mod(struct cxip_cntr *cxi_cntr, uint64_t value, bool set,
bool err);

int cxip_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
struct fid_cntr **cntr, void *context);

#endif /* _CXIP_CNTR_H_ */
Loading