include/ccKVS/inline_util.h
static inline void poll_credits_LIN(struct ibv_cq *credit_recv_cq, struct ibv_wc *credit_wc, uint8_t credits[][MACHINE_NUM])
{
	int credits_found = 0;
	uint16_t j;
	credits_found = ibv_poll_cq(credit_recv_cq, MAX_CREDIT_WRS, credit_wc);
	if(credits_found > 0) {
		if(unlikely(credit_wc[credits_found -1].status != 0)) {
			fprintf(stderr, "Bad wc status when polling for credits to send a broadcast %d\n", credit_wc[credits_found -1].status);
			exit(0);
		}
		for (j = 0; j < credits_found; j++) {
			if (credit_wc[j].imm_data >= (2* MACHINE_NUM))
				credits[UPD_VC][credit_wc[j].imm_data - (2* MACHINE_NUM)] += CREDITS_IN_MESSAGE;
			else if (credit_wc[j].imm_data >= MACHINE_NUM)
				credits[INV_VC][credit_wc[j].imm_data - MACHINE_NUM] += CREDITS_IN_MESSAGE;
			else credits[ACK_VC][credit_wc[j].imm_data] += CREDITS_IN_MESSAGE;
		}
	}
	else if(unlikely(credits_found < 0)) {
		printf("ERROR In the credit CQ\n"); exit(0);
	}
}
// Poll for credits in LIN -- only used by acks, not broadcasts
Poll for credits in LIN -- only used by acks, not broadcasts
Poll for credits in LIN -- only used by acks not broadcasts
static inline void poll_credits_LIN(struct ibv_cq *credit_recv_cq, struct ibv_wc *credit_wc, uint8_t credits[][MACHINE_NUM])
{
	int credits_found = 0;
	uint16_t j;
	credits_found = ibv_poll_cq(credit_recv_cq, MAX_CREDIT_WRS, credit_wc);
	if(credits_found > 0) {
		if(unlikely(credit_wc[credits_found -1].status != 0)) {
			fprintf(stderr, "Bad wc status when polling for credits to send a broadcast %d\n", credit_wc[credits_found -1].status);
			exit(0);
		}
		for (j = 0; j < credits_found; j++) {
			if (credit_wc[j].imm_data >= (2* MACHINE_NUM))
				credits[UPD_VC][credit_wc[j].imm_data - (2* MACHINE_NUM)] += CREDITS_IN_MESSAGE;
			else if (credit_wc[j].imm_data >= MACHINE_NUM)
				credits[INV_VC][credit_wc[j].imm_data - MACHINE_NUM] += CREDITS_IN_MESSAGE;
			else credits[ACK_VC][credit_wc[j].imm_data] += CREDITS_IN_MESSAGE;
		}
	}
	else if(unlikely(credits_found < 0)) {
		printf("ERROR In the credit CQ\n"); exit(0);
	}
}
static inline void poll_credits_LIN ( struct ibv_cq * credit_recv_cq , struct ibv_wc * credit_wc , uint8_t credits [ ] [ MACHINE_NUM ] ) { int credits_found = 0 ; uint16_t j ; credits_found = ibv_poll_cq ( credit_recv_cq , MAX_CREDIT_WRS , credit_wc ) ; if ( credits_found > 0 ) { if ( unlikely ( credit_wc [ credits_found - 1 ] . status != 0 ) ) { fprintf ( stderr , " \n " , credit_wc [ credits_found - 1 ] . status ) ; exit ( 0 ) ; } for ( j = 0 ; j < credits_found ; j ++ ) { if ( credit_wc [ j ] . imm_data >= ( 2 * MACHINE_NUM ) ) credits [ UPD_VC ] [ credit_wc [ j ] . imm_data - ( 2 * MACHINE_NUM ) ] += CREDITS_IN_MESSAGE ; else if ( credit_wc [ j ] . imm_data >= MACHINE_NUM ) credits [ INV_VC ] [ credit_wc [ j ] . imm_data - MACHINE_NUM ] += CREDITS_IN_MESSAGE ; else credits [ ACK_VC ] [ credit_wc [ j ] . imm_data ] += CREDITS_IN_MESSAGE ; } } else if ( unlikely ( credits_found < 0 ) ) { printf ( " \n " ) ; exit ( 0 ) ; } }
Poll for credits in LIN -- only used by acks, not broadcasts
Poll for credits in LIN -- only used by acks not broadcasts