src/dpdk/drivers/net/iavf/iavf_hash.c
static void
iavf_refine_proto_hdrs_l234(struct virtchnl_proto_hdrs *proto_hdrs,
			    uint64_t rss_type)
{
	struct virtchnl_proto_hdr *hdr;
	int i;

	for (i = 0; i < proto_hdrs->count; i++) {
		hdr = &proto_hdrs->proto_hdr[i];
		switch (hdr->type) {
		case VIRTCHNL_PROTO_HDR_ETH:
			if (!(rss_type & ETH_RSS_ETH))
				hdr->field_selector = 0;
			else if (rss_type & ETH_RSS_L2_SRC_ONLY)
				REFINE_PROTO_FLD(DEL, ETH_DST);
			else if (rss_type & ETH_RSS_L2_DST_ONLY)
				REFINE_PROTO_FLD(DEL, ETH_SRC);
			break;
		case VIRTCHNL_PROTO_HDR_IPV4:
			if (rss_type &
			    (ETH_RSS_IPV4 |
			     ETH_RSS_NONFRAG_IPV4_UDP |
			     ETH_RSS_NONFRAG_IPV4_TCP |
			     ETH_RSS_NONFRAG_IPV4_SCTP)) {
				if (rss_type & ETH_RSS_L3_SRC_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV4_DST);
				} else if (rss_type & ETH_RSS_L3_DST_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV4_SRC);
				} else if (rss_type &
					 (ETH_RSS_L4_SRC_ONLY |
					  ETH_RSS_L4_DST_ONLY)) {
					REFINE_PROTO_FLD(DEL, IPV4_DST);
					REFINE_PROTO_FLD(DEL, IPV4_SRC);
				}
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_IPV6:
			if (rss_type &
			    (ETH_RSS_IPV6 |
			     ETH_RSS_NONFRAG_IPV6_UDP |
			     ETH_RSS_NONFRAG_IPV6_TCP |
			     ETH_RSS_NONFRAG_IPV6_SCTP)) {
				if (rss_type & ETH_RSS_L3_SRC_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV6_DST);
				} else if (rss_type & ETH_RSS_L3_DST_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV6_SRC);
				} else if (rss_type &
					 (ETH_RSS_L4_SRC_ONLY |
					  ETH_RSS_L4_DST_ONLY)) {
					REFINE_PROTO_FLD(DEL, IPV6_DST);
					REFINE_PROTO_FLD(DEL, IPV6_SRC);
				}
			} else {
				hdr->field_selector = 0;
			}
			if (rss_type & RTE_ETH_RSS_L3_PRE64) {
				if (REFINE_PROTO_FLD(TEST, IPV6_SRC))
					REPALCE_PROTO_FLD(IPV6_SRC,
							  IPV6_PREFIX64_SRC);
				if (REFINE_PROTO_FLD(TEST, IPV6_DST))
					REPALCE_PROTO_FLD(IPV6_DST,
							  IPV6_PREFIX64_DST);
			}
			break;
		case VIRTCHNL_PROTO_HDR_UDP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_UDP |
			     ETH_RSS_NONFRAG_IPV6_UDP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, UDP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, UDP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_TCP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_TCP |
			     ETH_RSS_NONFRAG_IPV6_TCP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, TCP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, TCP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_SCTP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_SCTP |
			     ETH_RSS_NONFRAG_IPV6_SCTP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, SCTP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, SCTP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_S_VLAN:
			if (!(rss_type & ETH_RSS_S_VLAN))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_C_VLAN:
			if (!(rss_type & ETH_RSS_C_VLAN))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_L2TPV3:
			if (!(rss_type & ETH_RSS_L2TPV3))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_ESP:
			if (!(rss_type & ETH_RSS_ESP))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_AH:
			if (!(rss_type & ETH_RSS_AH))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_PFCP:
			if (!(rss_type & ETH_RSS_PFCP))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_ECPRI:
			if (!(rss_type & ETH_RSS_ECPRI))
				hdr->field_selector = 0;
			break;
		default:
			break;
		}
	}
}
/* refine proto hdrs base on l2, l3, l4 rss type */
refine proto hdrs base on l2, l3, l4 rss type
refine proto hdrs base on l2 l3 l4 rss type
static void
iavf_refine_proto_hdrs_l234(struct virtchnl_proto_hdrs *proto_hdrs,
			    uint64_t rss_type)
{
	struct virtchnl_proto_hdr *hdr;
	int i;
	for (i = 0; i < proto_hdrs->count; i++) {
		hdr = &proto_hdrs->proto_hdr[i];
		switch (hdr->type) {
		case VIRTCHNL_PROTO_HDR_ETH:
			if (!(rss_type & ETH_RSS_ETH))
				hdr->field_selector = 0;
			else if (rss_type & ETH_RSS_L2_SRC_ONLY)
				REFINE_PROTO_FLD(DEL, ETH_DST);
			else if (rss_type & ETH_RSS_L2_DST_ONLY)
				REFINE_PROTO_FLD(DEL, ETH_SRC);
			break;
		case VIRTCHNL_PROTO_HDR_IPV4:
			if (rss_type &
			    (ETH_RSS_IPV4 |
			     ETH_RSS_NONFRAG_IPV4_UDP |
			     ETH_RSS_NONFRAG_IPV4_TCP |
			     ETH_RSS_NONFRAG_IPV4_SCTP)) {
				if (rss_type & ETH_RSS_L3_SRC_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV4_DST);
				} else if (rss_type & ETH_RSS_L3_DST_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV4_SRC);
				} else if (rss_type &
					 (ETH_RSS_L4_SRC_ONLY |
					  ETH_RSS_L4_DST_ONLY)) {
					REFINE_PROTO_FLD(DEL, IPV4_DST);
					REFINE_PROTO_FLD(DEL, IPV4_SRC);
				}
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_IPV6:
			if (rss_type &
			    (ETH_RSS_IPV6 |
			     ETH_RSS_NONFRAG_IPV6_UDP |
			     ETH_RSS_NONFRAG_IPV6_TCP |
			     ETH_RSS_NONFRAG_IPV6_SCTP)) {
				if (rss_type & ETH_RSS_L3_SRC_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV6_DST);
				} else if (rss_type & ETH_RSS_L3_DST_ONLY) {
					REFINE_PROTO_FLD(DEL, IPV6_SRC);
				} else if (rss_type &
					 (ETH_RSS_L4_SRC_ONLY |
					  ETH_RSS_L4_DST_ONLY)) {
					REFINE_PROTO_FLD(DEL, IPV6_DST);
					REFINE_PROTO_FLD(DEL, IPV6_SRC);
				}
			} else {
				hdr->field_selector = 0;
			}
			if (rss_type & RTE_ETH_RSS_L3_PRE64) {
				if (REFINE_PROTO_FLD(TEST, IPV6_SRC))
					REPALCE_PROTO_FLD(IPV6_SRC,
							  IPV6_PREFIX64_SRC);
				if (REFINE_PROTO_FLD(TEST, IPV6_DST))
					REPALCE_PROTO_FLD(IPV6_DST,
							  IPV6_PREFIX64_DST);
			}
			break;
		case VIRTCHNL_PROTO_HDR_UDP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_UDP |
			     ETH_RSS_NONFRAG_IPV6_UDP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, UDP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, UDP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_TCP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_TCP |
			     ETH_RSS_NONFRAG_IPV6_TCP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, TCP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, TCP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_SCTP:
			if (rss_type &
			    (ETH_RSS_NONFRAG_IPV4_SCTP |
			     ETH_RSS_NONFRAG_IPV6_SCTP)) {
				if (rss_type & ETH_RSS_L4_SRC_ONLY)
					REFINE_PROTO_FLD(DEL, SCTP_DST_PORT);
				else if (rss_type & ETH_RSS_L4_DST_ONLY)
					REFINE_PROTO_FLD(DEL, SCTP_SRC_PORT);
				else if (rss_type &
					 (ETH_RSS_L3_SRC_ONLY |
					  ETH_RSS_L3_DST_ONLY))
					hdr->field_selector = 0;
			} else {
				hdr->field_selector = 0;
			}
			break;
		case VIRTCHNL_PROTO_HDR_S_VLAN:
			if (!(rss_type & ETH_RSS_S_VLAN))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_C_VLAN:
			if (!(rss_type & ETH_RSS_C_VLAN))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_L2TPV3:
			if (!(rss_type & ETH_RSS_L2TPV3))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_ESP:
			if (!(rss_type & ETH_RSS_ESP))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_AH:
			if (!(rss_type & ETH_RSS_AH))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_PFCP:
			if (!(rss_type & ETH_RSS_PFCP))
				hdr->field_selector = 0;
			break;
		case VIRTCHNL_PROTO_HDR_ECPRI:
			if (!(rss_type & ETH_RSS_ECPRI))
				hdr->field_selector = 0;
			break;
		default:
			break;
		}
	}
}
static void iavf_refine_proto_hdrs_l234 ( struct virtchnl_proto_hdrs * proto_hdrs , uint64_t rss_type ) { struct virtchnl_proto_hdr * hdr ; int i ; for ( i = 0 ; i < proto_hdrs -> count ; i ++ ) { hdr = & proto_hdrs -> proto_hdr [ i ] ; switch ( hdr -> type ) { case VIRTCHNL_PROTO_HDR_ETH : if ( ! ( rss_type & ETH_RSS_ETH ) ) hdr -> field_selector = 0 ; else if ( rss_type & ETH_RSS_L2_SRC_ONLY ) REFINE_PROTO_FLD ( DEL , ETH_DST ) ; else if ( rss_type & ETH_RSS_L2_DST_ONLY ) REFINE_PROTO_FLD ( DEL , ETH_SRC ) ; break ; case VIRTCHNL_PROTO_HDR_IPV4 : if ( rss_type & ( ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_SCTP ) ) { if ( rss_type & ETH_RSS_L3_SRC_ONLY ) { REFINE_PROTO_FLD ( DEL , IPV4_DST ) ; } else if ( rss_type & ETH_RSS_L3_DST_ONLY ) { REFINE_PROTO_FLD ( DEL , IPV4_SRC ) ; } else if ( rss_type & ( ETH_RSS_L4_SRC_ONLY | ETH_RSS_L4_DST_ONLY ) ) { REFINE_PROTO_FLD ( DEL , IPV4_DST ) ; REFINE_PROTO_FLD ( DEL , IPV4_SRC ) ; } } else { hdr -> field_selector = 0 ; } break ; case VIRTCHNL_PROTO_HDR_IPV6 : if ( rss_type & ( ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_NONFRAG_IPV6_SCTP ) ) { if ( rss_type & ETH_RSS_L3_SRC_ONLY ) { REFINE_PROTO_FLD ( DEL , IPV6_DST ) ; } else if ( rss_type & ETH_RSS_L3_DST_ONLY ) { REFINE_PROTO_FLD ( DEL , IPV6_SRC ) ; } else if ( rss_type & ( ETH_RSS_L4_SRC_ONLY | ETH_RSS_L4_DST_ONLY ) ) { REFINE_PROTO_FLD ( DEL , IPV6_DST ) ; REFINE_PROTO_FLD ( DEL , IPV6_SRC ) ; } } else { hdr -> field_selector = 0 ; } if ( rss_type & RTE_ETH_RSS_L3_PRE64 ) { if ( REFINE_PROTO_FLD ( TEST , IPV6_SRC ) ) REPALCE_PROTO_FLD ( IPV6_SRC , IPV6_PREFIX64_SRC ) ; if ( REFINE_PROTO_FLD ( TEST , IPV6_DST ) ) REPALCE_PROTO_FLD ( IPV6_DST , IPV6_PREFIX64_DST ) ; } break ; case VIRTCHNL_PROTO_HDR_UDP : if ( rss_type & ( ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP ) ) { if ( rss_type & ETH_RSS_L4_SRC_ONLY ) REFINE_PROTO_FLD ( DEL , UDP_DST_PORT ) ; else if ( rss_type & ETH_RSS_L4_DST_ONLY ) REFINE_PROTO_FLD ( DEL , UDP_SRC_PORT ) ; else if ( rss_type & ( ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY ) ) hdr -> field_selector = 0 ; } else { hdr -> field_selector = 0 ; } break ; case VIRTCHNL_PROTO_HDR_TCP : if ( rss_type & ( ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP ) ) { if ( rss_type & ETH_RSS_L4_SRC_ONLY ) REFINE_PROTO_FLD ( DEL , TCP_DST_PORT ) ; else if ( rss_type & ETH_RSS_L4_DST_ONLY ) REFINE_PROTO_FLD ( DEL , TCP_SRC_PORT ) ; else if ( rss_type & ( ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY ) ) hdr -> field_selector = 0 ; } else { hdr -> field_selector = 0 ; } break ; case VIRTCHNL_PROTO_HDR_SCTP : if ( rss_type & ( ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP ) ) { if ( rss_type & ETH_RSS_L4_SRC_ONLY ) REFINE_PROTO_FLD ( DEL , SCTP_DST_PORT ) ; else if ( rss_type & ETH_RSS_L4_DST_ONLY ) REFINE_PROTO_FLD ( DEL , SCTP_SRC_PORT ) ; else if ( rss_type & ( ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY ) ) hdr -> field_selector = 0 ; } else { hdr -> field_selector = 0 ; } break ; case VIRTCHNL_PROTO_HDR_S_VLAN : if ( ! ( rss_type & ETH_RSS_S_VLAN ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_C_VLAN : if ( ! ( rss_type & ETH_RSS_C_VLAN ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_L2TPV3 : if ( ! ( rss_type & ETH_RSS_L2TPV3 ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_ESP : if ( ! ( rss_type & ETH_RSS_ESP ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_AH : if ( ! ( rss_type & ETH_RSS_AH ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_PFCP : if ( ! ( rss_type & ETH_RSS_PFCP ) ) hdr -> field_selector = 0 ; break ; case VIRTCHNL_PROTO_HDR_ECPRI : if ( ! ( rss_type & ETH_RSS_ECPRI ) ) hdr -> field_selector = 0 ; break ; default : break ; } } }
refine proto hdrs base on l2, l3, l4 rss type
refine proto hdrs base on l2 l3 l4 rss type