[<prev] [next>] [day] [month] [year] [list]
Message-ID: <fc3431dc55be4968909fb746e4c1d454@huawei.com>
Date: Tue, 15 Nov 2022 14:00:37 +0000
From: "Lanhao (Lan)" <lanhao@...wei.com>
To: Leon Romanovsky <leon@...nel.org>,
"huangguangbin (A)" <huangguangbin2@...wei.com>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"kuba@...nel.org" <kuba@...nel.org>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"shenjian (K)" <shenjian15@...wei.com>
Subject: Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert
handle
Can you please explain why do you need special define for boolean AND?
we use '&', just define a bitwise AND, not define boolean AND.
On Tue, Sep 28, 2022 at 10:28:02AM +0800, Leon Romanovsky wrote:
>On Tue, Sep 27, 2022 at 07:12:02PM +0800, Guangbin Huang wrote:
>> From: Jian Shen <shenjian15@...wei.com>
>>
>> The expression '(k ^ ~v)' is exaclty '(k & v)', and '(k & v) & k' is
>> exaclty 'k & v'. So simplify the expression for tcam key convert.
>>
>> It also add necessary brackets for them.
>>
>> Signed-off-by: Jian Shen <shenjian15@...wei.com>
>> Signed-off-by: Guangbin Huang <huangguangbin2@...wei.com>
>> ---
>> .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> index 495b639b0dc2..59bfacc687c9 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> @@ -827,15 +827,10 @@ struct hclge_vf_vlan_cfg {
>> * Then for input key(k) and mask(v), we can calculate the value by
>> * the formulae:
>> * x = (~k) & v
>> - * y = (k ^ ~v) & k
>> + * y = k & v
>> */
>> -#define calc_x(x, k, v) (x = ~(k) & (v)) -#define calc_y(y, k, v) \
>> - do { \
>> - const typeof(k) _k_ = (k); \
>> - const typeof(v) _v_ = (v); \
>> - (y) = (_k_ ^ ~_v_) & (_k_); \
>> - } while (0)
>> +#define calc_x(x, k, v) ((x) = ~(k) & (v)) #define calc_y(y, k, v)
>> +((y) = (k) & (v))
>
>Can you please explain why do you need special define for boolean AND?
>
>Thanks
we use '&', just define a bitwise AND, not define boolean AND.
>
>>
>> #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct
>> hclge_mac_stats, f)) #define HCLGE_STATS_READ(p, offset) (*(u64
>> *)((u8 *)(p) + (offset)))
>> --
>> 2.33.0
>>
>
-----邮件原件-----
发件人: Leon Romanovsky <leon@...nel.org>
发送时间: 2022年9月28日 18:29
收件人: huangguangbin (A) <huangguangbin2@...wei.com>
抄送: davem@...emloft.net; kuba@...nel.org; edumazet@...gle.com; pabeni@...hat.com; netdev@...r.kernel.org; linux-kernel@...r.kernel.org; shenjian (K) <shenjian15@...wei.com>; Lanhao (Lan) <lanhao@...wei.com>
主题: Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
On Tue, Sep 27, 2022 at 07:12:02PM +0800, Guangbin Huang wrote:
> From: Jian Shen <shenjian15@...wei.com>
>
> The expression '(k ^ ~v)' is exaclty '(k & v)', and '(k & v) & k' is
> exaclty 'k & v'. So simplify the expression for tcam key convert.
>
> It also add necessary brackets for them.
>
> Signed-off-by: Jian Shen <shenjian15@...wei.com>
> Signed-off-by: Guangbin Huang <huangguangbin2@...wei.com>
> ---
> .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> index 495b639b0dc2..59bfacc687c9 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> @@ -827,15 +827,10 @@ struct hclge_vf_vlan_cfg {
> * Then for input key(k) and mask(v), we can calculate the value by
> * the formulae:
> * x = (~k) & v
> - * y = (k ^ ~v) & k
> + * y = k & v
> */
> -#define calc_x(x, k, v) (x = ~(k) & (v)) -#define calc_y(y, k, v) \
> - do { \
> - const typeof(k) _k_ = (k); \
> - const typeof(v) _v_ = (v); \
> - (y) = (_k_ ^ ~_v_) & (_k_); \
> - } while (0)
> +#define calc_x(x, k, v) ((x) = ~(k) & (v)) #define calc_y(y, k, v)
> +((y) = (k) & (v))
Can you please explain why do you need special define for boolean AND?
Thanks
>
> #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct
> hclge_mac_stats, f)) #define HCLGE_STATS_READ(p, offset) (*(u64
> *)((u8 *)(p) + (offset)))
> --
> 2.33.0
>
Powered by blists - more mailing lists