net: hns3: refine the tcam key convert handle
Subsystems (2)
Can you please explain why do you need special define for boolean AND? we use '&', just define a bitwise AND, not define boolean AND.
Quoted 37 lines · Leon Romanovsky
Quoted 23 lines · Guangbin Huang
From: Jian Shen <[email protected]>
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 <[email protected]>Signed-off-by Guangbin Huang <[email protected]>--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0
-1@@ -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 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h struct hclge_vf_vlan_cfg { · line 833
Quoted 10 lines
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +3
-6+* 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?
Quoted 1 line
Thanks
we use '&', just define a bitwise AND, not define boolean AND.
Quoted 9 lines
Quoted 8 lines
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0
-0#define HCLGE_MAC_STATS_FIELD_OFF (f) (offsetof(struct
hclge_mac_stats, f)) #defineHCLGE_STATS_READ(p, offset)(*(u64 *)((u8 *)(p) + (offset)))
--
2.33.0
-----邮件原件-----
发件人: Leon Romanovsky <[email protected]>
发送时间: 2022年9月28日 18:29
收件人: huangguangbin (A) <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; shenjian (K) <[email protected]>; Lanhao (Lan) <[email protected]> 主题: Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
Quoted 23 lines · Guangbin Huang
From: Jian Shen <[email protected]>
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 <[email protected]>Signed-off-by Guangbin Huang <[email protected]>--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0
-1@@ -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
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h struct hclge_vf_vlan_cfg { · line 833
Quoted 10 lines
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +3
-6+* 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
Quoted 7 lines
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0
-0#define HCLGE_MAC_STATS_FIELD_OFF (f) (offsetof(struct
hclge_mac_stats, f)) #defineHCLGE_STATS_READ(p, offset)(*(u64 *)((u8 *)(p) + (offset)))
--
2.33.0