[v2,1/2] ethdev: add new symmetric hash function

Message ID 20230827081745.31906-1-xuemingl@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2,1/2] ethdev: add new symmetric hash function |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Xueming Li Aug. 27, 2023, 8:17 a.m. UTC
  The new symmetric hash function swap src/dst L3 address and
L4 ports automatically by sorting.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/ethdev/rte_flow.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Ori Kam Aug. 30, 2023, 6:55 a.m. UTC | #1
Hi Xueming,

> -----Original Message-----
> From: Xueming(Steven) Li <xuemingl@nvidia.com>
> Sent: Sunday, August 27, 2023 11:18 AM
> 
> The new symmetric hash function swap src/dst L3 address and
> L4 ports automatically by sorting.
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
>  lib/ethdev/rte_flow.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
> index 2ebb76dbc0..4f4421ca50 100644
> --- a/lib/ethdev/rte_flow.h
> +++ b/lib/ethdev/rte_flow.h
> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
>  	 * src or dst address will xor with zero pair.
>  	 */
>  	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
> +	/**
> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
> +	 * the hash function.
> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
> +	 *  If src_port > dst_port, swap src_port and dst_port.
> +	 */
> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
>  	RTE_ETH_HASH_FUNCTION_MAX,
>  };
> 
> --
> 2.25.1

Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
  
lihuisong (C) Aug. 30, 2023, 7:50 a.m. UTC | #2
Hi Xueming,

在 2023/8/27 16:17, Xueming Li 写道:
> The new symmetric hash function swap src/dst L3 address and
> L4 ports automatically by sorting.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
>   lib/ethdev/rte_flow.h | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
> index 2ebb76dbc0..4f4421ca50 100644
> --- a/lib/ethdev/rte_flow.h
> +++ b/lib/ethdev/rte_flow.h
> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
>   	 * src or dst address will xor with zero pair.
>   	 */
>   	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
> +	/**
> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
> +	 * the hash function.
> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
> +	 *  If src_port > dst_port, swap src_port and dst_port.
> +	 */
If hash result are computed by the order: "src_ip+dst_ip+src_port+dst_port"
How to obtain the value of every L3 and L4 field obove?
I still cannot understand how to swap and set these values for these 
fields?
> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
>   	RTE_ETH_HASH_FUNCTION_MAX,
>   };
>
  
Xueming Li Aug. 30, 2023, 8:38 a.m. UTC | #3
> -----Original Message-----
> From: lihuisong (C) <lihuisong@huawei.com>
> Sent: 8/30/2023 15:51
> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> <ivan.malov@arknetworks.am>
> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> 
> Hi Xueming,
> 
> 在 2023/8/27 16:17, Xueming Li 写道:
> > The new symmetric hash function swap src/dst L3 address and
> > L4 ports automatically by sorting.
> >
> > Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> > ---
> >   lib/ethdev/rte_flow.h | 7 +++++++
> >   1 file changed, 7 insertions(+)
> >
> > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
> > 2ebb76dbc0..4f4421ca50 100644
> > --- a/lib/ethdev/rte_flow.h
> > +++ b/lib/ethdev/rte_flow.h
> > @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
> >   	 * src or dst address will xor with zero pair.
> >   	 */
> >   	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
> > +	/**
> > +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
> > +	 * the hash function.
> > +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
> > +	 *  If src_port > dst_port, swap src_port and dst_port.
> > +	 */
> If hash result are computed by the order: "src_ip+dst_ip+src_port+dst_port"
> How to obtain the value of every L3 and L4 field obove?
> I still cannot understand how to swap and set these values for these fields?

Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
Here is a detailed explanation of standard hash and symmetric hash by key:
  https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf

If src_ip > dst_ip, swap them, then the input becomes:
  "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP are swapped.
Same for L4 ports.

> > +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
> >   	RTE_ETH_HASH_FUNCTION_MAX,
> >   };
> >
  
lihuisong (C) Aug. 30, 2023, 12:42 p.m. UTC | #4
在 2023/8/30 16:38, Xueming(Steven) Li 写道:
>
>> -----Original Message-----
>> From: lihuisong (C) <lihuisong@huawei.com>
>> Sent: 8/30/2023 15:51
>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>> <ivan.malov@arknetworks.am>
>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>
>> Hi Xueming,
>>
>> 在 2023/8/27 16:17, Xueming Li 写道:
>>> The new symmetric hash function swap src/dst L3 address and
>>> L4 ports automatically by sorting.
>>>
>>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>>> ---
>>>    lib/ethdev/rte_flow.h | 7 +++++++
>>>    1 file changed, 7 insertions(+)
>>>
>>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>> 2ebb76dbc0..4f4421ca50 100644
>>> --- a/lib/ethdev/rte_flow.h
>>> +++ b/lib/ethdev/rte_flow.h
>>> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
>>>    	 * src or dst address will xor with zero pair.
>>>    	 */
>>>    	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
>>> +	/**
>>> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
>>> +	 * the hash function.
>>> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
>>> +	 *  If src_port > dst_port, swap src_port and dst_port.
>>> +	 */
>> If hash result are computed by the order: "src_ip+dst_ip+src_port+dst_port"
>> How to obtain the value of every L3 and L4 field obove?
>> I still cannot understand how to swap and set these values for these fields?
> Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
> Here is a detailed explanation of standard hash and symmetric hash by key:
>    https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf
>
> If src_ip > dst_ip, swap them, then the input becomes:
>    "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP are swapped.
> Same for L4 ports.
get it.
What are the advantages of the symmetric toeplitz sort?
Or why swap here?
>
>>> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
>>>    	RTE_ETH_HASH_FUNCTION_MAX,
>>>    };
>>>
  
Xueming Li Aug. 30, 2023, 1:09 p.m. UTC | #5
> -----Original Message-----
> From: lihuisong (C) <lihuisong@huawei.com>
> Sent: 8/30/2023 20:42
> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> <ivan.malov@arknetworks.am>
> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> 
> 
> 在 2023/8/30 16:38, Xueming(Steven) Li 写道:
> >
> >> -----Original Message-----
> >> From: lihuisong (C) <lihuisong@huawei.com>
> >> Sent: 8/30/2023 15:51
> >> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
> >> <orika@nvidia.com>
> >> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> >> <ivan.malov@arknetworks.am>
> >> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> >>
> >> Hi Xueming,
> >>
> >> 在 2023/8/27 16:17, Xueming Li 写道:
> >>> The new symmetric hash function swap src/dst L3 address and
> >>> L4 ports automatically by sorting.
> >>>
> >>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> >>> ---
> >>>    lib/ethdev/rte_flow.h | 7 +++++++
> >>>    1 file changed, 7 insertions(+)
> >>>
> >>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
> >>> 2ebb76dbc0..4f4421ca50 100644
> >>> --- a/lib/ethdev/rte_flow.h
> >>> +++ b/lib/ethdev/rte_flow.h
> >>> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
> >>>    	 * src or dst address will xor with zero pair.
> >>>    	 */
> >>>    	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
> >>> +	/**
> >>> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
> >>> +	 * the hash function.
> >>> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
> >>> +	 *  If src_port > dst_port, swap src_port and dst_port.
> >>> +	 */
> >> If hash result are computed by the order:
> "src_ip+dst_ip+src_port+dst_port"
> >> How to obtain the value of every L3 and L4 field obove?
> >> I still cannot understand how to swap and set these values for these fields?
> > Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
> > Here is a detailed explanation of standard hash and symmetric hash by key:
> >    https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf
> >
> > If src_ip > dst_ip, swap them, then the input becomes:
> >    "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP are
> swapped.
> > Same for L4 ports.
> get it.
> What are the advantages of the symmetric toeplitz sort?
> Or why swap here?

It's a different symmetric hash calculation, hardware can support either/all of them.

From calculation perspective, the hash result distribution is better, the result is more
suitable to be used as hash table key.

> >
> >>> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
> >>>    	RTE_ETH_HASH_FUNCTION_MAX,
> >>>    };
> >>>
  
lihuisong (C) Aug. 31, 2023, 1:23 a.m. UTC | #6
在 2023/8/30 21:09, Xueming(Steven) Li 写道:
>
>> -----Original Message-----
>> From: lihuisong (C) <lihuisong@huawei.com>
>> Sent: 8/30/2023 20:42
>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>> <ivan.malov@arknetworks.am>
>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>
>>
>> 在 2023/8/30 16:38, Xueming(Steven) Li 写道:
>>>> -----Original Message-----
>>>> From: lihuisong (C) <lihuisong@huawei.com>
>>>> Sent: 8/30/2023 15:51
>>>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
>>>> <orika@nvidia.com>
>>>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>>>> <ivan.malov@arknetworks.am>
>>>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>>>
>>>> Hi Xueming,
>>>>
>>>> 在 2023/8/27 16:17, Xueming Li 写道:
>>>>> The new symmetric hash function swap src/dst L3 address and
>>>>> L4 ports automatically by sorting.
>>>>>
>>>>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>>>>> ---
>>>>>     lib/ethdev/rte_flow.h | 7 +++++++
>>>>>     1 file changed, 7 insertions(+)
>>>>>
>>>>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>>>> 2ebb76dbc0..4f4421ca50 100644
>>>>> --- a/lib/ethdev/rte_flow.h
>>>>> +++ b/lib/ethdev/rte_flow.h
>>>>> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
>>>>>     	 * src or dst address will xor with zero pair.
>>>>>     	 */
>>>>>     	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
>>>>> +	/**
>>>>> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
>>>>> +	 * the hash function.
>>>>> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
>>>>> +	 *  If src_port > dst_port, swap src_port and dst_port.
>>>>> +	 */
>>>> If hash result are computed by the order:
>> "src_ip+dst_ip+src_port+dst_port"
>>>> How to obtain the value of every L3 and L4 field obove?
>>>> I still cannot understand how to swap and set these values for these fields?
>>> Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
>>> Here is a detailed explanation of standard hash and symmetric hash by key:
>>>     https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf
>>>
>>> If src_ip > dst_ip, swap them, then the input becomes:
>>>     "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP are
>> swapped.
>>> Same for L4 ports.
>> get it.
>> What are the advantages of the symmetric toeplitz sort?
>> Or why swap here?
> It's a different symmetric hash calculation, hardware can support either/all of them.
>
>  From calculation perspective, the hash result distribution is better, the result is more
> suitable to be used as hash table key.
I get it now.
but I have a question.
why not is that if src_ip < dst_ip, then swap src_ip and dst_ip?
I guess this is going to have the same effect as you said, right?
The symmetric toeplitz sort is not a standard algorithm, is just to 
enhance the hash result distribution.
If what I understand is right,
it is better that the new RSS algorithm should works on the one of them 
("src_ip > dst_ip" or "src_ip < dst_ip").
>
>>>>> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
>>>>>     	RTE_ETH_HASH_FUNCTION_MAX,
>>>>>     };
>>>>>
  
Xueming Li Aug. 31, 2023, 6:25 a.m. UTC | #7
> -----Original Message-----
> From: lihuisong (C) <lihuisong@huawei.com>
> Sent: 8/31/2023 9:24
> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> <ivan.malov@arknetworks.am>
> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> 
> 
> 在 2023/8/30 21:09, Xueming(Steven) Li 写道:
> >
> >> -----Original Message-----
> >> From: lihuisong (C) <lihuisong@huawei.com>
> >> Sent: 8/30/2023 20:42
> >> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
> >> <orika@nvidia.com>
> >> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> >> <ivan.malov@arknetworks.am>
> >> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> >>
> >>
> >> 在 2023/8/30 16:38, Xueming(Steven) Li 写道:
> >>>> -----Original Message-----
> >>>> From: lihuisong (C) <lihuisong@huawei.com>
> >>>> Sent: 8/30/2023 15:51
> >>>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
> >>>> <orika@nvidia.com>
> >>>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> >>>> <ivan.malov@arknetworks.am>
> >>>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> >>>>
> >>>> Hi Xueming,
> >>>>
> >>>> 在 2023/8/27 16:17, Xueming Li 写道:
> >>>>> The new symmetric hash function swap src/dst L3 address and
> >>>>> L4 ports automatically by sorting.
> >>>>>
> >>>>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> >>>>> ---
> >>>>>     lib/ethdev/rte_flow.h | 7 +++++++
> >>>>>     1 file changed, 7 insertions(+)
> >>>>>
> >>>>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
> >>>>> 2ebb76dbc0..4f4421ca50 100644
> >>>>> --- a/lib/ethdev/rte_flow.h
> >>>>> +++ b/lib/ethdev/rte_flow.h
> >>>>> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
> >>>>>     	 * src or dst address will xor with zero pair.
> >>>>>     	 */
> >>>>>     	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
> >>>>> +	/**
> >>>>> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
> >>>>> +	 * the hash function.
> >>>>> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
> >>>>> +	 *  If src_port > dst_port, swap src_port and dst_port.
> >>>>> +	 */
> >>>> If hash result are computed by the order:
> >> "src_ip+dst_ip+src_port+dst_port"
> >>>> How to obtain the value of every L3 and L4 field obove?
> >>>> I still cannot understand how to swap and set these values for these
> fields?
> >>> Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
> >>> Here is a detailed explanation of standard hash and symmetric hash by
> key:
> >>>     https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf
> >>>
> >>> If src_ip > dst_ip, swap them, then the input becomes:
> >>>     "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP
> >>> are
> >> swapped.
> >>> Same for L4 ports.
> >> get it.
> >> What are the advantages of the symmetric toeplitz sort?
> >> Or why swap here?
> > It's a different symmetric hash calculation, hardware can support either/all
> of them.
> >
> >  From calculation perspective, the hash result distribution is better,
> > the result is more suitable to be used as hash table key.
> I get it now.
> but I have a question.
> why not is that if src_ip < dst_ip, then swap src_ip and dst_ip?
> I guess this is going to have the same effect as you said, right?
> The symmetric toeplitz sort is not a standard algorithm, is just to enhance the
> hash result distribution.
> If what I understand is right,
> it is better that the new RSS algorithm should works on the one of them
> ("src_ip > dst_ip" or "src_ip < dst_ip").

Any special reason to introduce the descending sort?
I personally prefer to keep the enum clean unless some new hw or new algorithm introduced.

> >
> >>>>> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
> >>>>>     	RTE_ETH_HASH_FUNCTION_MAX,
> >>>>>     };
> >>>>>
  
lihuisong (C) Aug. 31, 2023, 11:29 a.m. UTC | #8
在 2023/8/31 14:25, Xueming(Steven) Li 写道:
>
>> -----Original Message-----
>> From: lihuisong (C) <lihuisong@huawei.com>
>> Sent: 8/31/2023 9:24
>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam <orika@nvidia.com>
>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>> <ivan.malov@arknetworks.am>
>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>
>>
>> 在 2023/8/30 21:09, Xueming(Steven) Li 写道:
>>>> -----Original Message-----
>>>> From: lihuisong (C) <lihuisong@huawei.com>
>>>> Sent: 8/30/2023 20:42
>>>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
>>>> <orika@nvidia.com>
>>>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>>>> <ivan.malov@arknetworks.am>
>>>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>>>
>>>>
>>>> 在 2023/8/30 16:38, Xueming(Steven) Li 写道:
>>>>>> -----Original Message-----
>>>>>> From: lihuisong (C) <lihuisong@huawei.com>
>>>>>> Sent: 8/30/2023 15:51
>>>>>> To: Xueming(Steven) Li <xuemingl@nvidia.com>; Ori Kam
>>>>>> <orika@nvidia.com>
>>>>>> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
>>>>>> <ivan.malov@arknetworks.am>
>>>>>> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
>>>>>>
>>>>>> Hi Xueming,
>>>>>>
>>>>>> 在 2023/8/27 16:17, Xueming Li 写道:
>>>>>>> The new symmetric hash function swap src/dst L3 address and
>>>>>>> L4 ports automatically by sorting.
>>>>>>>
>>>>>>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>>>>>>> ---
>>>>>>>      lib/ethdev/rte_flow.h | 7 +++++++
>>>>>>>      1 file changed, 7 insertions(+)
>>>>>>>
>>>>>>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>>>>>> 2ebb76dbc0..4f4421ca50 100644
>>>>>>> --- a/lib/ethdev/rte_flow.h
>>>>>>> +++ b/lib/ethdev/rte_flow.h
>>>>>>> @@ -3196,6 +3196,13 @@ enum rte_eth_hash_function {
>>>>>>>      	 * src or dst address will xor with zero pair.
>>>>>>>      	 */
>>>>>>>      	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
>>>>>>> +	/**
>>>>>>> +	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
>>>>>>> +	 * the hash function.
>>>>>>> +	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
>>>>>>> +	 *  If src_port > dst_port, swap src_port and dst_port.
>>>>>>> +	 */
>>>>>> If hash result are computed by the order:
>>>> "src_ip+dst_ip+src_port+dst_port"
>>>>>> How to obtain the value of every L3 and L4 field obove?
>>>>>> I still cannot understand how to swap and set these values for these
>> fields?
>>>>> Hash result is computed by order ""src_ip+dst_ip+src_port+dst_port"
>>>>> Here is a detailed explanation of standard hash and symmetric hash by
>> key:
>>>>>      https://www.ndsl.kaist.edu/~kyoungsoo/papers/TR-symRSS.pdf
>>>>>
>>>>> If src_ip > dst_ip, swap them, then the input becomes:
>>>>>      "dst_ip+src_ip+src_port+dst_port" // please note src and dst IP
>>>>> are
>>>> swapped.
>>>>> Same for L4 ports.
>>>> get it.
>>>> What are the advantages of the symmetric toeplitz sort?
>>>> Or why swap here?
>>> It's a different symmetric hash calculation, hardware can support either/all
>> of them.
>>>   From calculation perspective, the hash result distribution is better,
>>> the result is more suitable to be used as hash table key.
>> I get it now.
>> but I have a question.
>> why not is that if src_ip < dst_ip, then swap src_ip and dst_ip?
>> I guess this is going to have the same effect as you said, right?
>> The symmetric toeplitz sort is not a standard algorithm, is just to enhance the
>> hash result distribution.
>> If what I understand is right,
>> it is better that the new RSS algorithm should works on the one of them
>> ("src_ip > dst_ip" or "src_ip < dst_ip").
> Any special reason to introduce the descending sort?
Because the descending sort also can achieve the goal.
After all, this doesn't seem like a standard algorithm.

> I personally prefer to keep the enum clean unless some new hw or new algorithm introduced.

Agree with you. But this new enum cannot reveal ascending or descending 
sort.

>
>>>>>>> +	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
>>>>>>>      	RTE_ETH_HASH_FUNCTION_MAX,
>>>>>>>      };
>>>>>>>
  
Ferruh Yigit Sept. 21, 2023, 3:49 p.m. UTC | #9
On 8/30/2023 7:55 AM, Ori Kam wrote:
>> -----Original Message-----
>> From: Xueming(Steven) Li <xuemingl@nvidia.com>
>> Sent: Sunday, August 27, 2023 11:18 AM
>>
>> The new symmetric hash function swap src/dst L3 address and
>> L4 ports automatically by sorting.
>>
>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> 
> Acked-by: Ori Kam <orika@nvidia.com>
> 

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

Updated commit log with information provided in this mail thread.

Applied to dpdk-next-net/main, thanks.


Note only ethdev patch applied, not series, mlx5 patch delegated to Raslan.
  
Xueming Li Sept. 22, 2023, 6:57 a.m. UTC | #10
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: 9/21/2023 23:50
> To: Ori Kam <orika@nvidia.com>; Xueming(Steven) Li <xuemingl@nvidia.com>
> Cc: dev@dpdk.org; fengchengwen@huawei.com; Ivan Malov
> <ivan.malov@arknetworks.am>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: Re: [PATCH v2 1/2] ethdev: add new symmetric hash function
> 
> On 8/30/2023 7:55 AM, Ori Kam wrote:
> >> -----Original Message-----
> >> From: Xueming(Steven) Li <xuemingl@nvidia.com>
> >> Sent: Sunday, August 27, 2023 11:18 AM
> >>
> >> The new symmetric hash function swap src/dst L3 address and
> >> L4 ports automatically by sorting.
> >>
> >> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> >
> > Acked-by: Ori Kam <orika@nvidia.com>
> >
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
> 
> Updated commit log with information provided in this mail thread.

Thanks very much!

> 
> Applied to dpdk-next-net/main, thanks.
> 
> 
> Note only ethdev patch applied, not series, mlx5 patch delegated to Raslan.
  

Patch

diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 2ebb76dbc0..4f4421ca50 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3196,6 +3196,13 @@  enum rte_eth_hash_function {
 	 * src or dst address will xor with zero pair.
 	 */
 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+	/**
+	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
+	 * the hash function.
+	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
+	 *  If src_port > dst_port, swap src_port and dst_port.
+	 */
+	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
 	RTE_ETH_HASH_FUNCTION_MAX,
 };