X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fiavf%2Fiavf_hash.c;h=d8d22f80091d3ff29b8b39841549dc8a0b2a493c;hb=31d7c6f7d424c533b0a4dd9b4408b814ac7852f1;hp=a20c33e7fb370192411d31bcb9fbe56ef8f76645;hpb=f57ebdae3cd09f6aa60390ee45d958aea349074f;p=dpdk.git diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index a20c33e7fb..d8d22f8009 100644 --- a/drivers/net/iavf/iavf_hash.c +++ b/drivers/net/iavf/iavf_hash.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -443,17 +443,6 @@ static struct iavf_pattern_match_item iavf_hash_pattern_list[] = { {iavf_pattern_eth_ipv6_gtpc, ETH_RSS_IPV6, &ipv6_udp_gtpc_tmplt}, }; -struct virtchnl_proto_hdrs *iavf_hash_default_hdrs[] = { - &inner_ipv4_tmplt, - &inner_ipv4_udp_tmplt, - &inner_ipv4_tcp_tmplt, - &inner_ipv4_sctp_tmplt, - &inner_ipv6_tmplt, - &inner_ipv6_udp_tmplt, - &inner_ipv6_tcp_tmplt, - &inner_ipv6_sctp_tmplt, -}; - static struct iavf_flow_engine iavf_hash_engine = { .init = iavf_hash_init, .create = iavf_hash_create, @@ -472,24 +461,64 @@ static struct iavf_flow_parser iavf_hash_parser = { .stage = IAVF_FLOW_STAGE_RSS, }; -static int -iavf_hash_default_set(struct iavf_adapter *ad, bool add) +int +iavf_rss_hash_set(struct iavf_adapter *ad, uint64_t rss_hf, bool add) { - struct virtchnl_rss_cfg *rss_cfg; - uint16_t i; + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); + struct virtchnl_rss_cfg rss_cfg; + +#define IAVF_RSS_HF_ALL ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_NONFRAG_IPV6_UDP | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV4_SCTP | \ + ETH_RSS_NONFRAG_IPV6_SCTP) + + rss_cfg.rss_algorithm = VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC; + if (rss_hf & ETH_RSS_IPV4) { + rss_cfg.proto_hdrs = inner_ipv4_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } - rss_cfg = rte_zmalloc("iavf rss rule", - sizeof(struct virtchnl_rss_cfg), 0); - if (!rss_cfg) - return -ENOMEM; + if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) { + rss_cfg.proto_hdrs = inner_ipv4_udp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } + + if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) { + rss_cfg.proto_hdrs = inner_ipv4_tcp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } - for (i = 0; i < RTE_DIM(iavf_hash_default_hdrs); i++) { - rss_cfg->proto_hdrs = *iavf_hash_default_hdrs[i]; - rss_cfg->rss_algorithm = VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC; + if (rss_hf & ETH_RSS_NONFRAG_IPV4_SCTP) { + rss_cfg.proto_hdrs = inner_ipv4_sctp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } - iavf_add_del_rss_cfg(ad, rss_cfg, add); + if (rss_hf & ETH_RSS_IPV6) { + rss_cfg.proto_hdrs = inner_ipv6_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); } + if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) { + rss_cfg.proto_hdrs = inner_ipv6_udp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } + + if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) { + rss_cfg.proto_hdrs = inner_ipv6_tcp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } + + if (rss_hf & ETH_RSS_NONFRAG_IPV6_SCTP) { + rss_cfg.proto_hdrs = inner_ipv6_sctp_tmplt; + iavf_add_del_rss_cfg(ad, &rss_cfg, add); + } + + vf->rss_hf = rss_hf & IAVF_RSS_HF_ALL; return 0; } @@ -524,12 +553,6 @@ iavf_hash_init(struct iavf_adapter *ad) return ret; } - ret = iavf_hash_default_set(ad, true); - if (ret) { - PMD_DRV_LOG(ERR, "fail to set default RSS"); - iavf_unregister_parser(parser, ad); - } - return ret; } @@ -574,11 +597,12 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint, break; case RTE_FLOW_ITEM_TYPE_ECPRI: ecpri = item->spec; - ecpri_common.u32 = rte_be_to_cpu_32( - ecpri->hdr.common.u32); if (!ecpri) break; - else if (ecpri_common.type != + + ecpri_common.u32 = rte_be_to_cpu_32(ecpri->hdr.common.u32); + + if (ecpri_common.type != RTE_ECPRI_MSG_TYPE_IQ_DATA) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -840,7 +864,9 @@ static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs *proto_hdrs, static uint64_t invalid_rss_comb[] = { ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP, + ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_TCP, ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP, + ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_L3_PRE32 | RTE_ETH_RSS_L3_PRE40 | RTE_ETH_RSS_L3_PRE48 | RTE_ETH_RSS_L3_PRE56 | RTE_ETH_RSS_L3_PRE96 @@ -901,6 +927,13 @@ iavf_any_invalid_rss_type(enum rte_eth_hash_function rss_func, if (rss_type & (ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY | ETH_RSS_L4_DST_ONLY)) return true; + + if (!(rss_type & + (ETH_RSS_IPV4 | ETH_RSS_IPV6 | + ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP | + ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP | + ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP))) + return true; } /* check invalid combination */ @@ -1123,6 +1156,7 @@ static void iavf_hash_uninit(struct iavf_adapter *ad) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); + struct rte_eth_rss_conf *rss_conf; if (vf->vf_reset) return; @@ -1133,7 +1167,8 @@ iavf_hash_uninit(struct iavf_adapter *ad) if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)) return; - if (iavf_hash_default_set(ad, false)) + rss_conf = &ad->eth_dev->data->dev_conf.rx_adv_conf.rss_conf; + if (iavf_rss_hash_set(ad, rss_conf->rss_hf, false)) PMD_DRV_LOG(ERR, "fail to delete default RSS"); iavf_unregister_parser(&iavf_hash_parser, ad);