X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fice%2Fice_hash.c;h=d891538bd480bbbbb3e4cf7000b35f969257a2b9;hb=dc36bd5dfdeb;hp=57e7d553d61dd5a3e2147bb28e5eab0494ab232f;hpb=db6730a809c44abc4c2760d777ddc732b6f69373;p=dpdk.git diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index 57e7d553d6..d891538bd4 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -41,6 +41,11 @@ struct rss_meta { uint8_t hash_function; }; +struct ice_hash_flow_cfg { + bool simple_xor; + struct ice_rss_cfg rss_cfg; +}; + static int ice_hash_init(struct ice_adapter *ad); @@ -115,22 +120,22 @@ static struct ice_pattern_match_item ice_hash_pattern_list_os[] = { /* Supported pattern for comms package. */ static struct ice_pattern_match_item ice_hash_pattern_list_comms[] = { - {pattern_eth_ipv4, ICE_INSET_NONE, &hint_1}, - {pattern_eth_ipv4_udp, ICE_INSET_NONE, &hint_2}, - {pattern_eth_ipv4_tcp, ICE_INSET_NONE, &hint_3}, - {pattern_eth_ipv4_sctp, ICE_INSET_NONE, &hint_4}, - {pattern_eth_ipv6, ICE_INSET_NONE, &hint_5}, - {pattern_eth_ipv6_udp, ICE_INSET_NONE, &hint_6}, - {pattern_eth_ipv6_tcp, ICE_INSET_NONE, &hint_7}, - {pattern_eth_ipv6_sctp, ICE_INSET_NONE, &hint_8}, - {pattern_empty, ICE_INSET_NONE, &hint_0}, - {pattern_eth_ipv4_gtpu_ipv4, ICE_INSET_NONE, &hint_9}, - {pattern_eth_ipv4_gtpu_ipv4_udp, ICE_INSET_NONE, &hint_9}, - {pattern_eth_ipv4_gtpu_ipv4_tcp, ICE_INSET_NONE, &hint_9}, - {pattern_eth_pppoes_ipv4, ICE_INSET_NONE, &hint_10}, - {pattern_eth_pppoes_ipv4_udp, ICE_INSET_NONE, &hint_11}, - {pattern_eth_pppoes_ipv4_tcp, ICE_INSET_NONE, &hint_12}, - {pattern_eth_pppoes_ipv4_sctp, ICE_INSET_NONE, &hint_13}, + {pattern_eth_ipv4, ICE_INSET_NONE, &hint_1}, + {pattern_eth_ipv4_udp, ICE_INSET_NONE, &hint_2}, + {pattern_eth_ipv4_tcp, ICE_INSET_NONE, &hint_3}, + {pattern_eth_ipv4_sctp, ICE_INSET_NONE, &hint_4}, + {pattern_eth_ipv6, ICE_INSET_NONE, &hint_5}, + {pattern_eth_ipv6_udp, ICE_INSET_NONE, &hint_6}, + {pattern_eth_ipv6_tcp, ICE_INSET_NONE, &hint_7}, + {pattern_eth_ipv6_sctp, ICE_INSET_NONE, &hint_8}, + {pattern_empty, ICE_INSET_NONE, &hint_0}, + {pattern_eth_ipv4_gtpu_eh_ipv4, ICE_INSET_NONE, &hint_9}, + {pattern_eth_ipv4_gtpu_eh_ipv4_udp, ICE_INSET_NONE, &hint_9}, + {pattern_eth_ipv4_gtpu_eh_ipv4_tcp, ICE_INSET_NONE, &hint_9}, + {pattern_eth_pppoes_ipv4, ICE_INSET_NONE, &hint_10}, + {pattern_eth_pppoes_ipv4_udp, ICE_INSET_NONE, &hint_11}, + {pattern_eth_pppoes_ipv4_tcp, ICE_INSET_NONE, &hint_12}, + {pattern_eth_pppoes_ipv4_sctp, ICE_INSET_NONE, &hint_13}, }; /** @@ -404,7 +409,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, void **meta, struct rte_flow_error *error) { - int ret = 0; + int ret = -rte_errno; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -420,11 +425,11 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); if (!pattern_match_item) - return -rte_errno; + goto error; ret = ice_hash_check_inset(pattern, error); if (ret) - return -rte_errno; + goto error; /* Save protocol header to rss_meta. */ *meta = rss_meta_ptr; @@ -433,12 +438,12 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss action. */ ret = ice_hash_parse_action(pattern_match_item, actions, meta, error); +error: if (ret) - return -rte_errno; - + rte_free(rss_meta_ptr); rte_free(pattern_match_item); - return 0; + return ret; } static int @@ -452,14 +457,14 @@ ice_hash_create(struct ice_adapter *ad, struct ice_vsi *vsi = pf->main_vsi; int ret; uint32_t reg; - struct ice_rss_cfg *filter_ptr; + struct ice_hash_flow_cfg *filter_ptr; uint32_t headermask = ((struct rss_meta *)meta)->pkt_hdr; uint64_t hash_field = ((struct rss_meta *)meta)->hash_flds; uint8_t hash_function = ((struct rss_meta *)meta)->hash_function; filter_ptr = rte_zmalloc("ice_rss_filter", - sizeof(struct ice_rss_cfg), 0); + sizeof(struct ice_hash_flow_cfg), 0); if (!filter_ptr) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, @@ -474,19 +479,20 @@ ice_hash_create(struct ice_adapter *ad, (2 << VSIQF_HASH_CTL_HASH_SCHEME_S); ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg); - filter_ptr->symm = 0; + filter_ptr->simple_xor = 1; goto out; - } else if (hash_function == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) { - ret = ice_add_rss_cfg(hw, vsi->idx, hash_field, headermask, 1); - if (ret) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "rss flow create fail"); - goto error; - } } else { - ret = ice_add_rss_cfg(hw, vsi->idx, hash_field, headermask, 0); + filter_ptr->rss_cfg.packet_hdr = headermask; + filter_ptr->rss_cfg.hashed_flds = hash_field; + filter_ptr->rss_cfg.symm = + (hash_function == + RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ); + + ret = ice_add_rss_cfg(hw, vsi->idx, + filter_ptr->rss_cfg.hashed_flds, + filter_ptr->rss_cfg.packet_hdr, + filter_ptr->rss_cfg.symm); if (ret) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, @@ -495,9 +501,6 @@ ice_hash_create(struct ice_adapter *ad, } } - filter_ptr->packet_hdr = headermask; - filter_ptr->hashed_flds = hash_field; - out: flow->rule = filter_ptr; rte_free(meta); @@ -519,11 +522,11 @@ ice_hash_destroy(struct ice_adapter *ad, struct ice_vsi *vsi = pf->main_vsi; int ret; uint32_t reg; - struct ice_rss_cfg *filter_ptr; + struct ice_hash_flow_cfg *filter_ptr; - filter_ptr = (struct ice_rss_cfg *)flow->rule; + filter_ptr = (struct ice_hash_flow_cfg *)flow->rule; - if (filter_ptr->symm == 0) { + if (filter_ptr->simple_xor == 1) { /* Return to symmetric_toeplitz state. */ reg = ICE_READ_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id)); reg = (reg & (~VSIQF_HASH_CTL_HASH_SCHEME_M)) | @@ -531,8 +534,14 @@ ice_hash_destroy(struct ice_adapter *ad, ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg); } else { ret = ice_rem_rss_cfg(hw, vsi->idx, - filter_ptr->hashed_flds, filter_ptr->packet_hdr); - if (ret) { + filter_ptr->rss_cfg.hashed_flds, + filter_ptr->rss_cfg.packet_hdr); + /* Fixme: Ignore the error if a rule does not exist. + * Currently a rule for inputset change or symm turn on/off + * will overwrite an exist rule, while application still + * have 2 rte_flow handles. + **/ + if (ret && ret != ICE_ERR_DOES_NOT_EXIST) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "rss flow destroy fail");