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

	/* Check if the key is present in the table.
	 * Need for further accaunting in cnt_arr
	 */
	ret = rte_hash_lookup_with_hash(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val));
	notexist = (ret == -ENOENT);

	/* Add an SA to the corresponding table.*/
	ret = rte_hash_add_key_with_hash_data(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val), sa);
	if (ret != 0)
		return ret;

	/* Check if there is an entry in SPI only table with the same 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)
		tmp_val = NULL;
	tmp_val = SET_BIT(tmp_val, key_type);

	/* Add an entry into SPI only table */
	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;

	/* Update a counter for a given SPI */
	ret = rte_hash_lookup_with_hash(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
		rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
		sad->init_val));
	if (ret < 0)
		return ret;
	if (key_type == RTE_IPSEC_SAD_SPI_DIP)
		sad->cnt_arr[ret].cnt_dip += notexist;
	else
		sad->cnt_arr[ret].cnt_dip_sip += notexist;

	return 0;
}
/*
 * @internal helper function
 * Add a rule of type SPI_DIP or SPI_DIP_SIP.
 * Inserts a rule into an appropriate hash table,
 * updates the value for a given SPI in SPI_ONLY hash table
 * reflecting presence of more specific rule type in two LSBs.
 * Updates a counter that reflects the number of rules whith the same SPI.
 */
@internal helper function
Add a rule of type SPI_DIP or SPI_DIP_SIP.
Inserts a rule into an appropriate hash table,
updates the value for a given SPI in SPI_ONLY hash table
reflecting presence of more specific rule type in two LSBs.
Updates a counter that reflects the number of rules whith the same SPI.
@internal helper function Add a rule of type SPI_DIP or SPI_DIP_SIP . Inserts a rule into an appropriate hash table updates the value for a given SPI in SPI_ONLY hash table reflecting presence of more specific rule type in two LSBs . Updates a counter that reflects the number of rules whith the same SPI .
static inline int
add_specific(struct rte_ipsec_sad *sad, const void *key,
		int key_type, void *sa)
{
	void *tmp_val;
	int ret, notexist;
	ret = rte_hash_lookup_with_hash(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val));
	notexist = (ret == -ENOENT);
	ret = rte_hash_add_key_with_hash_data(sad->hash[key_type], key,
		rte_hash_crc(key, sad->keysize[key_type], sad->init_val), sa);
	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)
		tmp_val = NULL;
	tmp_val = SET_BIT(tmp_val, key_type);
	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;
	ret = rte_hash_lookup_with_hash(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
		rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
		sad->init_val));
	if (ret < 0)
		return ret;
	if (key_type == RTE_IPSEC_SAD_SPI_DIP)
		sad->cnt_arr[ret].cnt_dip += notexist;
	else
		sad->cnt_arr[ret].cnt_dip_sip += notexist;
	return 0;
}
static inline int add_specific ( struct rte_ipsec_sad * sad , const void * key , int key_type , void * sa ) { void * tmp_val ; int ret , notexist ; ret = rte_hash_lookup_with_hash ( sad -> hash [ key_type ] , key , rte_hash_crc ( key , sad -> keysize [ key_type ] , sad -> init_val ) ) ; notexist = ( ret == - ENOENT ) ; ret = rte_hash_add_key_with_hash_data ( sad -> hash [ key_type ] , key , rte_hash_crc ( key , sad -> keysize [ key_type ] , sad -> init_val ) , sa ) ; 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 ) tmp_val = NULL ; tmp_val = SET_BIT ( tmp_val , key_type ) ; 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 ; ret = rte_hash_lookup_with_hash ( sad -> hash [ RTE_IPSEC_SAD_SPI_ONLY ] , key , rte_hash_crc ( key , sad -> keysize [ RTE_IPSEC_SAD_SPI_ONLY ] , sad -> init_val ) ) ; if ( ret < 0 ) return ret ; if ( key_type == RTE_IPSEC_SAD_SPI_DIP ) sad -> cnt_arr [ ret ] . cnt_dip += notexist ; else sad -> cnt_arr [ ret ] . cnt_dip_sip += notexist ; return 0 ; }
@internal helper function
 Add a rule of type SPI_DIP or SPI_DIP_SIP.
@internal helper function Add a rule of type SPI_DIP or SPI_DIP_SIP .
/* Check if the key is present in the table.
	 * Need for further accaunting in cnt_arr
	 */ /* Add an SA to the corresponding table.*/ /* Check if there is an entry in SPI only table with the same SPI */ /* Add an entry into SPI only table */ /* Update a counter for a given SPI */