include/ccKVS/inline_util.h
static inline void increment_credits_based_on_protocol(int credits_found, struct ibv_wc* credit_wc, uint8_t credits[][MACHINE_NUM], int protocol)
{
	uint16_t j;
	if (protocol == LINEARIZABILITY) {
		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 (protocol == SEQUENTIAL_CONSISTENCY) {
		for (j = 0; j < credits_found; j++) credits[SC_UPD_VC][credit_wc[j].imm_data] += SC_CREDITS_IN_MESSAGE;
	}
}
// Used after polling for received credits, to increment the right Virtual Channel's credits depending on the protocol
Used after polling for received credits, to increment the right Virtual Channel's credits depending on the protocol
Used after polling for received credits to increment the right Virtual Channel ' s credits depending on the protocol
static inline void increment_credits_based_on_protocol(int credits_found, struct ibv_wc* credit_wc, uint8_t credits[][MACHINE_NUM], int protocol)
{
	uint16_t j;
	if (protocol == LINEARIZABILITY) {
		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 (protocol == SEQUENTIAL_CONSISTENCY) {
		for (j = 0; j < credits_found; j++) credits[SC_UPD_VC][credit_wc[j].imm_data] += SC_CREDITS_IN_MESSAGE;
	}
}
static inline void increment_credits_based_on_protocol ( int credits_found , struct ibv_wc * credit_wc , uint8_t credits [ ] [ MACHINE_NUM ] , int protocol ) { uint16_t j ; if ( protocol == LINEARIZABILITY ) { 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 ( protocol == SEQUENTIAL_CONSISTENCY ) { for ( j = 0 ; j < credits_found ; j ++ ) credits [ SC_UPD_VC ] [ credit_wc [ j ] . imm_data ] += SC_CREDITS_IN_MESSAGE ; } }
Used after polling for received credits, to increment the right Virtual Channel's credits depending on the protocol
Used after polling for received credits to increment the right Virtual Channel ' s credits depending on the protocol