src/dpdk/lib/librte_ipsec/ipsec_sad.c
static inline int
del_specific(struct rte_ipsec_sad *sad, const void *key, int key_type)
{
	void *tmp_val;
	int ret;
	uint32_t *cnt;

	/* Remove an SA from the corresponding table.*/
	ret = rte_hash_del_key_with_hash(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val));
	if (ret < 0)
		return ret;

	/* Get an index of cnt_arr entry for a given SPI */
	ret = rte_hash_lookup_with_hash_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY],
		key, rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
		sad->init_val), &tmp_val);
	if (ret < 0)
		return ret;
	cnt = (key_type == RTE_IPSEC_SAD_SPI_DIP) ?
			&sad->cnt_arr[ret].cnt_dip :
			&sad->cnt_arr[ret].cnt_dip_sip;
	if (--(*cnt) != 0)
		return 0;

	/* corresponding counter is 0, clear the bit indicating
	 * the presence of more specific rule for a given SPI.
	 */
	tmp_val = CLEAR_BIT(tmp_val, key_type);

	/* if there are no rules left with same SPI,
	 * remove an entry from SPI_only table
	 */
	if (tmp_val == NULL)
		ret = rte_hash_del_key_with_hash(
			sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
			rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
			sad->init_val));
	else
		ret = rte_hash_add_key_with_hash_data(
			sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
			rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
			sad->init_val), tmp_val);
	if (ret < 0)
		return ret;
	return 0;
}
/*
 * @internal helper function
 * Delete a rule of type SPI_DIP or SPI_DIP_SIP.
 * Deletes an entry from an appropriate hash table and decrements
 * an entry counter for given SPI.
 * If entry to remove is the last one with given SPI within the table,
 * then it will also update related entry in SPI_ONLY table.
 * Removes an entry from SPI_ONLY hash table if there no rule left
 * for this SPI in any table.
 */
@internal helper function
Delete a rule of type SPI_DIP or SPI_DIP_SIP.
Deletes an entry from an appropriate hash table and decrements
an entry counter for given SPI.
If entry to remove is the last one with given SPI within the table,
then it will also update related entry in SPI_ONLY table.
Removes an entry from SPI_ONLY hash table if there no rule left
for this SPI in any table.
@internal helper function Delete a rule of type SPI_DIP or SPI_DIP_SIP . Deletes an entry from an appropriate hash table and decrements an entry counter for given SPI . If entry to remove is the last one with given SPI within the table then it will also update related entry in SPI_ONLY table . Removes an entry from SPI_ONLY hash table if there no rule left for this SPI in any table .
static inline int
del_specific(struct rte_ipsec_sad *sad, const void *key, int key_type)
{
	void *tmp_val;
	int ret;
	uint32_t *cnt;
	ret = rte_hash_del_key_with_hash(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val));
	if (ret < 0)
		return ret;
	ret = rte_hash_lookup_with_hash_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY],
		key, rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
		sad->init_val), &tmp_val);
	if (ret < 0)
		return ret;
	cnt = (key_type == RTE_IPSEC_SAD_SPI_DIP) ?
			&sad->cnt_arr[ret].cnt_dip :
			&sad->cnt_arr[ret].cnt_dip_sip;
	if (--(*cnt) != 0)
		return 0;
	tmp_val = CLEAR_BIT(tmp_val, key_type);
	if (tmp_val == NULL)
		ret = rte_hash_del_key_with_hash(
			sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
			rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
			sad->init_val));
	else
		ret = rte_hash_add_key_with_hash_data(
			sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
			rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
			sad->init_val), tmp_val);
	if (ret < 0)
		return ret;
	return 0;
}
static inline int del_specific ( struct rte_ipsec_sad * sad , const void * key , int key_type ) { void * tmp_val ; int ret ; uint32_t * cnt ; ret = rte_hash_del_key_with_hash ( sad -> hash [ key_type ] , key , rte_hash_crc ( key , sad -> keysize [ key_type ] , sad -> init_val ) ) ; if ( ret < 0 ) return ret ; ret = rte_hash_lookup_with_hash_data ( sad -> hash [ RTE_IPSEC_SAD_SPI_ONLY ] , key , rte_hash_crc ( key , sad -> keysize [ RTE_IPSEC_SAD_SPI_ONLY ] , sad -> init_val ) , & tmp_val ) ; if ( ret < 0 ) return ret ; cnt = ( key_type == RTE_IPSEC_SAD_SPI_DIP ) ? & sad -> cnt_arr [ ret ] . cnt_dip : & sad -> cnt_arr [ ret ] . cnt_dip_sip ; if ( -- ( * cnt ) != 0 ) return 0 ; tmp_val = CLEAR_BIT ( tmp_val , key_type ) ; if ( tmp_val == NULL ) ret = rte_hash_del_key_with_hash ( sad -> hash [ RTE_IPSEC_SAD_SPI_ONLY ] , key , rte_hash_crc ( key , sad -> keysize [ RTE_IPSEC_SAD_SPI_ONLY ] , sad -> init_val ) ) ; else ret = rte_hash_add_key_with_hash_data ( sad -> hash [ RTE_IPSEC_SAD_SPI_ONLY ] , key , rte_hash_crc ( key , sad -> keysize [ RTE_IPSEC_SAD_SPI_ONLY ] , sad -> init_val ) , tmp_val ) ; if ( ret < 0 ) return ret ; return 0 ; }
@internal helper function
 Delete a rule of type SPI_DIP or SPI_DIP_SIP.
@internal helper function Delete a rule of type SPI_DIP or SPI_DIP_SIP .
/* Remove an SA from the corresponding table.*/ /* Get an index of cnt_arr entry for a given SPI */ /* corresponding counter is 0, clear the bit indicating
	 * the presence of more specific rule for a given SPI.
	 */ /* if there are no rules left with same SPI,
	 * remove an entry from SPI_only table
	 */