include/ccKVS/inline_util.h
static inline void send_credits(uint16_t credit_wr_i, struct ibv_sge* coh_recv_sgl, struct hrd_ctrl_blk* cb,
								int* push_ptr, struct ibv_recv_wr* coh_recv_wr, struct ibv_qp* coh_recv_qp,
								struct ibv_send_wr* credit_send_wr, uint16_t credits_in_message, uint32_t clt_buf_slots,
								void* buf)
{
	// For every credit message we send back, prepare x receives for the broadcasts
	uint16_t i, j, recv_iter = 0;
	struct ibv_recv_wr *bad_recv_wr;
	struct ibv_send_wr *bad_send_wr;
	for(i = 0; i < credit_wr_i; i++) {
		for (j = 0; j < credits_in_message; j++) {
			recv_iter = i * credits_in_message + j;
			coh_recv_sgl[recv_iter].addr = (uintptr_t) buf + ((*push_ptr) * UD_REQ_SIZE);
			HRD_MOD_ADD(*push_ptr, clt_buf_slots);
			//			if (*push_ptr == 0) *push_ptr = 1;
			coh_recv_wr[recv_iter].next = (recv_iter == (credit_wr_i * credits_in_message) - 1) ?
										  NULL : &coh_recv_wr[recv_iter + 1];
		}
	}
	int ret = ibv_post_recv(coh_recv_qp, &coh_recv_wr[0], &bad_recv_wr);
	CPE(ret, "ibv_post_recv error", ret);

	credit_send_wr[credit_wr_i - 1].next = NULL;
	// yellow_printf("I am sending %d credit message(s)\n", credit_wr_i);
	ret = ibv_post_send(cb->dgram_qp[FC_UD_QP_ID], &credit_send_wr[0], &bad_send_wr);
	CPE(ret, "ibv_post_send error in credits", ret);
}
// Post Receives for coherence and then Send out the credits
Post Receives for coherence and then Send out the credits
Post Receives for coherence and then Send out the credits
static inline void send_credits(uint16_t credit_wr_i, struct ibv_sge* coh_recv_sgl, struct hrd_ctrl_blk* cb,
								int* push_ptr, struct ibv_recv_wr* coh_recv_wr, struct ibv_qp* coh_recv_qp,
								struct ibv_send_wr* credit_send_wr, uint16_t credits_in_message, uint32_t clt_buf_slots,
								void* buf)
{
	uint16_t i, j, recv_iter = 0;
	struct ibv_recv_wr *bad_recv_wr;
	struct ibv_send_wr *bad_send_wr;
	for(i = 0; i < credit_wr_i; i++) {
		for (j = 0; j < credits_in_message; j++) {
			recv_iter = i * credits_in_message + j;
			coh_recv_sgl[recv_iter].addr = (uintptr_t) buf + ((*push_ptr) * UD_REQ_SIZE);
			HRD_MOD_ADD(*push_ptr, clt_buf_slots);
			coh_recv_wr[recv_iter].next = (recv_iter == (credit_wr_i * credits_in_message) - 1) ?
										  NULL : &coh_recv_wr[recv_iter + 1];
		}
	}
	int ret = ibv_post_recv(coh_recv_qp, &coh_recv_wr[0], &bad_recv_wr);
	CPE(ret, "ibv_post_recv error", ret);
	credit_send_wr[credit_wr_i - 1].next = NULL;
	ret = ibv_post_send(cb->dgram_qp[FC_UD_QP_ID], &credit_send_wr[0], &bad_send_wr);
	CPE(ret, "ibv_post_send error in credits", ret);
}
static inline void send_credits ( uint16_t credit_wr_i , struct ibv_sge * coh_recv_sgl , struct hrd_ctrl_blk * cb , int * push_ptr , struct ibv_recv_wr * coh_recv_wr , struct ibv_qp * coh_recv_qp , struct ibv_send_wr * credit_send_wr , uint16_t credits_in_message , uint32_t clt_buf_slots , void * buf ) { uint16_t i , j , recv_iter = 0 ; struct ibv_recv_wr * bad_recv_wr ; struct ibv_send_wr * bad_send_wr ; for ( i = 0 ; i < credit_wr_i ; i ++ ) { for ( j = 0 ; j < credits_in_message ; j ++ ) { recv_iter = i * credits_in_message + j ; coh_recv_sgl [ recv_iter ] . addr = ( uintptr_t ) buf + ( ( * push_ptr ) * UD_REQ_SIZE ) ; HRD_MOD_ADD ( * push_ptr , clt_buf_slots ) ; coh_recv_wr [ recv_iter ] . next = ( recv_iter == ( credit_wr_i * credits_in_message ) - 1 ) ? NULL : & coh_recv_wr [ recv_iter + 1 ] ; } } int ret = ibv_post_recv ( coh_recv_qp , & coh_recv_wr [ 0 ] , & bad_recv_wr ) ; CPE ( ret , " " , ret ) ; credit_send_wr [ credit_wr_i - 1 ] . next = NULL ; ret = ibv_post_send ( cb -> dgram_qp [ FC_UD_QP_ID ] , & credit_send_wr [ 0 ] , & bad_send_wr ) ; CPE ( ret , " " , ret ) ; }
Post Receives for coherence and then Send out the credits
Post Receives for coherence and then Send out the credits
// For every credit message we send back, prepare x receives for the broadcasts //			if (*push_ptr == 0) *push_ptr = 1; // yellow_printf("I am sending %d credit message(s)\n", credit_wr_i);