* Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
@ 2022-11-15 14:00 Lanhao (Lan)
0 siblings, 0 replies; 7+ messages in thread
From: Lanhao (Lan) @ 2022-11-15 14:00 UTC (permalink / raw)
To: Leon Romanovsky, huangguangbin (A)
Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, shenjian (K)
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@huawei.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@huawei.com>
>> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.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@kernel.org>
发送时间: 2022年9月28日 18:29
收件人: huangguangbin (A) <huangguangbin2@huawei.com>
抄送: davem@davemloft.net; kuba@kernel.org; edumazet@google.com; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; shenjian (K) <shenjian15@huawei.com>; Lanhao (Lan) <lanhao@huawei.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@huawei.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@huawei.com>
> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.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
>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver
@ 2023-05-15 13:46 Hao Lan
2023-05-15 13:46 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Hao Lan
0 siblings, 1 reply; 7+ messages in thread
From: Hao Lan @ 2023-05-15 13:46 UTC (permalink / raw)
To: netdev
Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng
There are some cleanup for the HNS3 ethernet driver.
Hao Chen (2):
net: hns3: fix hns3 driver header file not self-contained issue
net: hns3: fix strncpy() not using dest-buf length as length issue
Jian Shen (1):
net: hns3: refine the tcam key convert handle
Peiyang Wang (1):
net: hns3: clear hns unused parameter alarm
.../net/ethernet/hisilicon/hns3/hclge_mbx.h | 4 +-
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 +-
.../hns3/hns3_common/hclge_comm_rss.c | 3 +-
.../hns3/hns3_common/hclge_comm_rss.h | 3 +-
.../hns3/hns3_common/hclge_comm_tqp_stats.h | 2 +
.../ethernet/hisilicon/hns3/hns3_debugfs.c | 36 ++++++++++----
.../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
.../net/ethernet/hisilicon/hns3/hns3_enet.h | 5 +-
.../ethernet/hisilicon/hns3/hns3_ethtool.c | 7 ++-
.../hisilicon/hns3/hns3pf/hclge_debugfs.c | 29 ++++++++++--
.../hisilicon/hns3/hns3pf/hclge_main.c | 47 ++++++++-----------
.../hisilicon/hns3/hns3pf/hclge_main.h | 11 ++---
.../hisilicon/hns3/hns3pf/hclge_ptp.h | 5 +-
.../hisilicon/hns3/hns3vf/hclgevf_main.c | 14 ++----
14 files changed, 97 insertions(+), 74 deletions(-)
--
2.30.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2023-05-15 13:46 [PATCH net-next 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
@ 2023-05-15 13:46 ` Hao Lan
2023-05-15 15:51 ` Simon Horman
0 siblings, 1 reply; 7+ messages in thread
From: Hao Lan @ 2023-05-15 13:46 UTC (permalink / raw)
To: netdev
Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng
From: Jian Shen <shenjian15@huawei.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.
(k ^ ~v) & k == (k & v) & k == k & k & v == k & v
It also add necessary brackets for them.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Hao Lan <lanhao@huawei.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 81aa6b0facf5..6a43d1515585 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -835,15 +835,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))
#define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
#define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
--
2.30.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2023-05-15 13:46 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Hao Lan
@ 2023-05-15 15:51 ` Simon Horman
2023-05-15 20:04 ` Simon Horman
0 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2023-05-15 15:51 UTC (permalink / raw)
To: Hao Lan
Cc: netdev, yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
richardcochran, wangpeiyang1, shenjian15, chenhao418, wangjie125,
yuanjilin, cai.huoqing, xiujianfeng
On Mon, May 15, 2023 at 09:46:40PM +0800, Hao Lan wrote:
> From: Jian Shen <shenjian15@huawei.com>
>
> The expression '(k ^ ~v)' is exaclty '(k & v)', and
This part doesn't seem correct to me.
Suppose both k and v are 0.
For simplicity, consider only one bit.
Then: (k ^ ~v) == (0 ^ ~0) == (0 ^ 1) = 1
But (k & v) == (0 & 0) == 0
> '(k & v) & k' is exaclty 'k & v'. So simplify the
> expression for tcam key convert.
This I follow.
> (k ^ ~v) & k == (k & v) & k == k & k & v == k & v
Looking at the truth table (in non table form), this seems correct.
k == 0, v == 0:
(k ^ ~v) & k == (0 ^ ~0) & 0 == (0 ^ 1) & 0 == 1 & 0 == 0
k & v == 0 & 0 == 0
Good!
k == 0, v == 1:
(k ^ ~v) & k == (0 ^ ~1) & 0 == (0 ^ 0) & 0 == 1 & 0 == 0
k & v == 0 & 1 == 0
Good!
k == 1, v == 0:
(k ^ ~v) & k == (1 ^ ~0) & 1 == (1 ^ 1) & 1 == 0 & 1 == 0
k & v == 1 & 0 == 0
Good!
k == 1, v == 1:
(k ^ ~v) & k == (1 ^ ~1) & 1 == (1 ^ 0) & 1 == 1 & 1 == 1
k & v == 1 & 1 == 1
Good!
>
> It also add necessary brackets for them.
>
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Hao Lan <lanhao@huawei.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 81aa6b0facf5..6a43d1515585 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> @@ -835,15 +835,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))
This also looks good to me.
>
> #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
> #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2023-05-15 15:51 ` Simon Horman
@ 2023-05-15 20:04 ` Simon Horman
0 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2023-05-15 20:04 UTC (permalink / raw)
To: Hao Lan
Cc: netdev, yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
richardcochran, wangpeiyang1, shenjian15, chenhao418, wangjie125,
yuanjilin, cai.huoqing, xiujianfeng
On Mon, May 15, 2023 at 05:51:03PM +0200, Simon Horman wrote:
> On Mon, May 15, 2023 at 09:46:40PM +0800, Hao Lan wrote:
> > From: Jian Shen <shenjian15@huawei.com>
> >
> > The expression '(k ^ ~v)' is exaclty '(k & v)', and
Sorry, one more thing: s/exaclty/exactly/
Also one more time below.
>
> This part doesn't seem correct to me.
>
> Suppose both k and v are 0.
> For simplicity, consider only one bit.
>
> Then: (k ^ ~v) == (0 ^ ~0) == (0 ^ 1) = 1
> But (k & v) == (0 & 0) == 0
>
> > '(k & v) & k' is exaclty 'k & v'. So simplify the
> > expression for tcam key convert.
>
> This I follow.
>
> > (k ^ ~v) & k == (k & v) & k == k & k & v == k & v
>
> Looking at the truth table (in non table form), this seems correct.
>
> k == 0, v == 0:
>
> (k ^ ~v) & k == (0 ^ ~0) & 0 == (0 ^ 1) & 0 == 1 & 0 == 0
> k & v == 0 & 0 == 0
> Good!
>
> k == 0, v == 1:
>
> (k ^ ~v) & k == (0 ^ ~1) & 0 == (0 ^ 0) & 0 == 1 & 0 == 0
> k & v == 0 & 1 == 0
> Good!
>
> k == 1, v == 0:
>
> (k ^ ~v) & k == (1 ^ ~0) & 1 == (1 ^ 1) & 1 == 0 & 1 == 0
> k & v == 1 & 0 == 0
> Good!
>
> k == 1, v == 1:
>
> (k ^ ~v) & k == (1 ^ ~1) & 1 == (1 ^ 0) & 1 == 1 & 1 == 1
> k & v == 1 & 1 == 1
> Good!
>
> >
> > It also add necessary brackets for them.
> >
> > Signed-off-by: Jian Shen <shenjian15@huawei.com>
> > Signed-off-by: Hao Lan <lanhao@huawei.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 81aa6b0facf5..6a43d1515585 100644
> > --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > @@ -835,15 +835,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))
>
> This also looks good to me.
>
> >
> > #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
> > #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 0/4] net: hns3: cleanup and optimization
@ 2022-09-27 11:12 Guangbin Huang
2022-09-27 11:12 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Guangbin Huang
0 siblings, 1 reply; 7+ messages in thread
From: Guangbin Huang @ 2022-09-27 11:12 UTC (permalink / raw)
To: davem, kuba
Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
shenjian15, lanhao
This serial includes some cleanup and one optimization patches for
HNS3 driver.
Guangbin Huang (1):
net: hns3: delete unnecessary vf value judgement when get vport id
Hao Chen (2):
net: hns3: fix hns3 driver header file not self-contained issue
net: hns3: replace magic numbers with macro for IPv4/v6
Jian Shen (1):
net: hns3: refine the tcam key convert handle
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 4 +++-
.../hns3/hns3_common/hclge_comm_tqp_stats.h | 2 ++
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 ++++++------
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 6 ++++++
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +---
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +++--------
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h | 5 ++++-
7 files changed, 25 insertions(+), 19 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2022-09-27 11:12 [PATCH net-next 0/4] net: hns3: cleanup and optimization Guangbin Huang
@ 2022-09-27 11:12 ` Guangbin Huang
2022-09-28 10:28 ` Leon Romanovsky
0 siblings, 1 reply; 7+ messages in thread
From: Guangbin Huang @ 2022-09-27 11:12 UTC (permalink / raw)
To: davem, kuba
Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
shenjian15, lanhao
From: Jian Shen <shenjian15@huawei.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@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.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))
#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
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2022-09-27 11:12 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Guangbin Huang
@ 2022-09-28 10:28 ` Leon Romanovsky
2022-11-15 14:12 ` Hao Lan
0 siblings, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2022-09-28 10:28 UTC (permalink / raw)
To: Guangbin Huang
Cc: davem, kuba, edumazet, pabeni, netdev, linux-kernel, shenjian15,
lanhao
On Tue, Sep 27, 2022 at 07:12:02PM +0800, Guangbin Huang wrote:
> From: Jian Shen <shenjian15@huawei.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@huawei.com>
> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.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
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
2022-09-28 10:28 ` Leon Romanovsky
@ 2022-11-15 14:12 ` Hao Lan
0 siblings, 0 replies; 7+ messages in thread
From: Hao Lan @ 2022-11-15 14:12 UTC (permalink / raw)
To: Leon Romanovsky, Guangbin Huang
Cc: davem, kuba, edumazet, pabeni, netdev, linux-kernel, shenjian15
> Can you please explain why do you need special define for boolean AND?
we use '&', just define a bitwise AND, not define boolean AND.
Thanks.
On 2022/9/28 18:28, Leon Romanovsky wrote:
> On Tue, Sep 27, 2022 at 07:12:02PM +0800, Guangbin Huang wrote:
>> From: Jian Shen <shenjian15@huawei.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@huawei.com>
>> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.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?
we use '&', just define a bitwise AND, not define 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
>>
> .
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-15 20:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 14:00 [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Lanhao (Lan)
-- strict thread matches above, loose matches on Subject: below --
2023-05-15 13:46 [PATCH net-next 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
2023-05-15 13:46 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Hao Lan
2023-05-15 15:51 ` Simon Horman
2023-05-15 20:04 ` Simon Horman
2022-09-27 11:12 [PATCH net-next 0/4] net: hns3: cleanup and optimization Guangbin Huang
2022-09-27 11:12 ` [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Guangbin Huang
2022-09-28 10:28 ` Leon Romanovsky
2022-11-15 14:12 ` Hao Lan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).