src/dpdk/drivers/net/hinic/hinic_pmd_ethdev.c
static int hinic_rss_hash_update(struct rte_eth_dev *dev,
			  struct rte_eth_rss_conf *rss_conf)
{
	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	u8 tmpl_idx = nic_dev->rss_tmpl_idx;
	u8 hashkey[HINIC_RSS_KEY_SIZE] = {0};
	u8 prio_tc[HINIC_DCB_UP_MAX] = {0};
	u64 rss_hf = rss_conf->rss_hf;
	struct nic_rss_type rss_type = {0};
	int err = 0;

	if (!(nic_dev->flags & ETH_MQ_RX_RSS_FLAG)) {
		PMD_DRV_LOG(WARNING, "RSS is not enabled");
		return HINIC_OK;
	}

	if (rss_conf->rss_key_len > HINIC_RSS_KEY_SIZE) {
		PMD_DRV_LOG(ERR, "Invalid rss key, rss_key_len: %d",
			    rss_conf->rss_key_len);
		return HINIC_ERROR;
	}

	if (rss_conf->rss_key) {
		memcpy(hashkey, rss_conf->rss_key, rss_conf->rss_key_len);
		err = hinic_rss_set_template_tbl(nic_dev->hwdev, tmpl_idx,
						 hashkey);
		if (err) {
			PMD_DRV_LOG(ERR, "Set rss template table failed");
			goto disable_rss;
		}
	}

	rss_type.ipv4 = (rss_hf & (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4)) ? 1 : 0;
	rss_type.tcp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) ? 1 : 0;
	rss_type.ipv6 = (rss_hf & (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6)) ? 1 : 0;
	rss_type.ipv6_ext = (rss_hf & ETH_RSS_IPV6_EX) ? 1 : 0;
	rss_type.tcp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) ? 1 : 0;
	rss_type.tcp_ipv6_ext = (rss_hf & ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
	rss_type.udp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) ? 1 : 0;
	rss_type.udp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) ? 1 : 0;

	err = hinic_set_rss_type(nic_dev->hwdev, tmpl_idx, rss_type);
	if (err) {
		PMD_DRV_LOG(ERR, "Set rss type table failed");
		goto disable_rss;
	}

	return 0;

disable_rss:
	memset(prio_tc, 0, sizeof(prio_tc));
	(void)hinic_rss_cfg(nic_dev->hwdev, 0, tmpl_idx, 0, prio_tc);
	return err;
}
/**
 * DPDK callback to update the RSS hash key and RSS hash type.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param rss_conf
 *   RSS configuration data.
 *
 * @return
 *   0 on success, negative error value otherwise.
 */
DPDK callback to update the RSS hash key and RSS hash type.
@param dev
Pointer to Ethernet device structure.
@param rss_conf
RSS configuration data.

@return
0 on success, negative error value otherwise.
DPDK callback to update the RSS hash key and RSS hash type . @param dev Pointer to Ethernet device structure . @param rss_conf RSS configuration data . @return 0 on success negative error value otherwise .
static int hinic_rss_hash_update(struct rte_eth_dev *dev,
			  struct rte_eth_rss_conf *rss_conf)
{
	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	u8 tmpl_idx = nic_dev->rss_tmpl_idx;
	u8 hashkey[HINIC_RSS_KEY_SIZE] = {0};
	u8 prio_tc[HINIC_DCB_UP_MAX] = {0};
	u64 rss_hf = rss_conf->rss_hf;
	struct nic_rss_type rss_type = {0};
	int err = 0;
	if (!(nic_dev->flags & ETH_MQ_RX_RSS_FLAG)) {
		PMD_DRV_LOG(WARNING, "RSS is not enabled");
		return HINIC_OK;
	}
	if (rss_conf->rss_key_len > HINIC_RSS_KEY_SIZE) {
		PMD_DRV_LOG(ERR, "Invalid rss key, rss_key_len: %d",
			    rss_conf->rss_key_len);
		return HINIC_ERROR;
	}
	if (rss_conf->rss_key) {
		memcpy(hashkey, rss_conf->rss_key, rss_conf->rss_key_len);
		err = hinic_rss_set_template_tbl(nic_dev->hwdev, tmpl_idx,
						 hashkey);
		if (err) {
			PMD_DRV_LOG(ERR, "Set rss template table failed");
			goto disable_rss;
		}
	}
	rss_type.ipv4 = (rss_hf & (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4)) ? 1 : 0;
	rss_type.tcp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) ? 1 : 0;
	rss_type.ipv6 = (rss_hf & (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6)) ? 1 : 0;
	rss_type.ipv6_ext = (rss_hf & ETH_RSS_IPV6_EX) ? 1 : 0;
	rss_type.tcp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) ? 1 : 0;
	rss_type.tcp_ipv6_ext = (rss_hf & ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
	rss_type.udp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) ? 1 : 0;
	rss_type.udp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) ? 1 : 0;
	err = hinic_set_rss_type(nic_dev->hwdev, tmpl_idx, rss_type);
	if (err) {
		PMD_DRV_LOG(ERR, "Set rss type table failed");
		goto disable_rss;
	}
	return 0;
disable_rss:
	memset(prio_tc, 0, sizeof(prio_tc));
	(void)hinic_rss_cfg(nic_dev->hwdev, 0, tmpl_idx, 0, prio_tc);
	return err;
}
static int hinic_rss_hash_update ( struct rte_eth_dev * dev , struct rte_eth_rss_conf * rss_conf ) { struct hinic_nic_dev * nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV ( dev ) ; u8 tmpl_idx = nic_dev -> rss_tmpl_idx ; u8 hashkey [ HINIC_RSS_KEY_SIZE ] = { 0 } ; u8 prio_tc [ HINIC_DCB_UP_MAX ] = { 0 } ; u64 rss_hf = rss_conf -> rss_hf ; struct nic_rss_type rss_type = { 0 } ; int err = 0 ; if ( ! ( nic_dev -> flags & ETH_MQ_RX_RSS_FLAG ) ) { PMD_DRV_LOG ( WARNING , " " ) ; return HINIC_OK ; } if ( rss_conf -> rss_key_len > HINIC_RSS_KEY_SIZE ) { PMD_DRV_LOG ( ERR , " " , rss_conf -> rss_key_len ) ; return HINIC_ERROR ; } if ( rss_conf -> rss_key ) { memcpy ( hashkey , rss_conf -> rss_key , rss_conf -> rss_key_len ) ; err = hinic_rss_set_template_tbl ( nic_dev -> hwdev , tmpl_idx , hashkey ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " ) ; goto disable_rss ; } } rss_type . ipv4 = ( rss_hf & ( ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 ) ) ? 1 : 0 ; rss_type . tcp_ipv4 = ( rss_hf & ETH_RSS_NONFRAG_IPV4_TCP ) ? 1 : 0 ; rss_type . ipv6 = ( rss_hf & ( ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 ) ) ? 1 : 0 ; rss_type . ipv6_ext = ( rss_hf & ETH_RSS_IPV6_EX ) ? 1 : 0 ; rss_type . tcp_ipv6 = ( rss_hf & ETH_RSS_NONFRAG_IPV6_TCP ) ? 1 : 0 ; rss_type . tcp_ipv6_ext = ( rss_hf & ETH_RSS_IPV6_TCP_EX ) ? 1 : 0 ; rss_type . udp_ipv4 = ( rss_hf & ETH_RSS_NONFRAG_IPV4_UDP ) ? 1 : 0 ; rss_type . udp_ipv6 = ( rss_hf & ETH_RSS_NONFRAG_IPV6_UDP ) ? 1 : 0 ; err = hinic_set_rss_type ( nic_dev -> hwdev , tmpl_idx , rss_type ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " ) ; goto disable_rss ; } return 0 ; disable_rss : memset ( prio_tc , 0 , sizeof ( prio_tc ) ) ; ( void ) hinic_rss_cfg ( nic_dev -> hwdev , 0 , tmpl_idx , 0 , prio_tc ) ; return err ; }
DPDK callback to update the RSS hash key and RSS hash type.
DPDK callback to update the RSS hash key and RSS hash type .