src/dpdk/drivers/net/e1000/igb_ethdev.c
static inline int
ntuple_filter_to_5tuple_82576(struct rte_eth_ntuple_filter *filter,
			struct e1000_5tuple_filter_info *filter_info)
{
	if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576)
		return -EINVAL;
	if (filter->priority > E1000_2TUPLE_MAX_PRI)
		return -EINVAL;  /* filter index is out of range. */
	if (filter->tcp_flags > RTE_NTUPLE_TCP_FLAGS_MASK)
		return -EINVAL;  /* flags is invalid. */

	switch (filter->dst_ip_mask) {
	case UINT32_MAX:
		filter_info->dst_ip_mask = 0;
		filter_info->dst_ip = filter->dst_ip;
		break;
	case 0:
		filter_info->dst_ip_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
		return -EINVAL;
	}

	switch (filter->src_ip_mask) {
	case UINT32_MAX:
		filter_info->src_ip_mask = 0;
		filter_info->src_ip = filter->src_ip;
		break;
	case 0:
		filter_info->src_ip_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid src_ip mask.");
		return -EINVAL;
	}

	switch (filter->dst_port_mask) {
	case UINT16_MAX:
		filter_info->dst_port_mask = 0;
		filter_info->dst_port = filter->dst_port;
		break;
	case 0:
		filter_info->dst_port_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid dst_port mask.");
		return -EINVAL;
	}

	switch (filter->src_port_mask) {
	case UINT16_MAX:
		filter_info->src_port_mask = 0;
		filter_info->src_port = filter->src_port;
		break;
	case 0:
		filter_info->src_port_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid src_port mask.");
		return -EINVAL;
	}

	switch (filter->proto_mask) {
	case UINT8_MAX:
		filter_info->proto_mask = 0;
		filter_info->proto = filter->proto;
		break;
	case 0:
		filter_info->proto_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid protocol mask.");
		return -EINVAL;
	}

	filter_info->priority = (uint8_t)filter->priority;
	if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG)
		filter_info->tcp_flags = filter->tcp_flags;
	else
		filter_info->tcp_flags = 0;

	return 0;
}
/* translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info*/
translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info
translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info
static inline int
ntuple_filter_to_5tuple_82576(struct rte_eth_ntuple_filter *filter,
			struct e1000_5tuple_filter_info *filter_info)
{
	if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576)
		return -EINVAL;
	if (filter->priority > E1000_2TUPLE_MAX_PRI)
		return -EINVAL;  
	if (filter->tcp_flags > RTE_NTUPLE_TCP_FLAGS_MASK)
		return -EINVAL;  
	switch (filter->dst_ip_mask) {
	case UINT32_MAX:
		filter_info->dst_ip_mask = 0;
		filter_info->dst_ip = filter->dst_ip;
		break;
	case 0:
		filter_info->dst_ip_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
		return -EINVAL;
	}
	switch (filter->src_ip_mask) {
	case UINT32_MAX:
		filter_info->src_ip_mask = 0;
		filter_info->src_ip = filter->src_ip;
		break;
	case 0:
		filter_info->src_ip_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid src_ip mask.");
		return -EINVAL;
	}
	switch (filter->dst_port_mask) {
	case UINT16_MAX:
		filter_info->dst_port_mask = 0;
		filter_info->dst_port = filter->dst_port;
		break;
	case 0:
		filter_info->dst_port_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid dst_port mask.");
		return -EINVAL;
	}
	switch (filter->src_port_mask) {
	case UINT16_MAX:
		filter_info->src_port_mask = 0;
		filter_info->src_port = filter->src_port;
		break;
	case 0:
		filter_info->src_port_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid src_port mask.");
		return -EINVAL;
	}
	switch (filter->proto_mask) {
	case UINT8_MAX:
		filter_info->proto_mask = 0;
		filter_info->proto = filter->proto;
		break;
	case 0:
		filter_info->proto_mask = 1;
		break;
	default:
		PMD_DRV_LOG(ERR, "invalid protocol mask.");
		return -EINVAL;
	}
	filter_info->priority = (uint8_t)filter->priority;
	if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG)
		filter_info->tcp_flags = filter->tcp_flags;
	else
		filter_info->tcp_flags = 0;
	return 0;
}
static inline int ntuple_filter_to_5tuple_82576 ( struct rte_eth_ntuple_filter * filter , struct e1000_5tuple_filter_info * filter_info ) { if ( filter -> queue >= IGB_MAX_RX_QUEUE_NUM_82576 ) return - EINVAL ; if ( filter -> priority > E1000_2TUPLE_MAX_PRI ) return - EINVAL ; if ( filter -> tcp_flags > RTE_NTUPLE_TCP_FLAGS_MASK ) return - EINVAL ; switch ( filter -> dst_ip_mask ) { case UINT32_MAX : filter_info -> dst_ip_mask = 0 ; filter_info -> dst_ip = filter -> dst_ip ; break ; case 0 : filter_info -> dst_ip_mask = 1 ; break ; default : PMD_DRV_LOG ( ERR , " " ) ; return - EINVAL ; } switch ( filter -> src_ip_mask ) { case UINT32_MAX : filter_info -> src_ip_mask = 0 ; filter_info -> src_ip = filter -> src_ip ; break ; case 0 : filter_info -> src_ip_mask = 1 ; break ; default : PMD_DRV_LOG ( ERR , " " ) ; return - EINVAL ; } switch ( filter -> dst_port_mask ) { case UINT16_MAX : filter_info -> dst_port_mask = 0 ; filter_info -> dst_port = filter -> dst_port ; break ; case 0 : filter_info -> dst_port_mask = 1 ; break ; default : PMD_DRV_LOG ( ERR , " " ) ; return - EINVAL ; } switch ( filter -> src_port_mask ) { case UINT16_MAX : filter_info -> src_port_mask = 0 ; filter_info -> src_port = filter -> src_port ; break ; case 0 : filter_info -> src_port_mask = 1 ; break ; default : PMD_DRV_LOG ( ERR , " " ) ; return - EINVAL ; } switch ( filter -> proto_mask ) { case UINT8_MAX : filter_info -> proto_mask = 0 ; filter_info -> proto = filter -> proto ; break ; case 0 : filter_info -> proto_mask = 1 ; break ; default : PMD_DRV_LOG ( ERR , " " ) ; return - EINVAL ; } filter_info -> priority = ( uint8_t ) filter -> priority ; if ( filter -> flags & RTE_NTUPLE_FLAGS_TCP_FLAG ) filter_info -> tcp_flags = filter -> tcp_flags ; else filter_info -> tcp_flags = 0 ; return 0 ; }
translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info
translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info
/* filter index is out of range. */ /* flags is invalid. */