From: Leon Romanovsky <leon@kernel.org>
To: Guangbin Huang <huangguangbin2@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, shenjian15@huawei.com,
lanhao@huawei.com
Subject: Re: [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle
Date: Wed, 28 Sep 2022 13:28:49 +0300 [thread overview]
Message-ID: <YzQh4Zu3Md1+Npeo@unreal> (raw)
In-Reply-To: <20220927111205.18060-2-huangguangbin2@huawei.com>
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
>
next prev parent reply other threads:[~2022-09-28 10:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-11-15 14:12 ` Hao Lan
2022-09-27 11:12 ` [PATCH net-next 2/4] net: hns3: fix hns3 driver header file not self-contained issue Guangbin Huang
2022-09-27 11:12 ` [PATCH net-next 3/4] net: hns3: replace magic numbers with macro for IPv4/v6 Guangbin Huang
2022-09-28 10:34 ` Leon Romanovsky
2022-09-27 11:12 ` [PATCH net-next 4/4] net: hns3: delete unnecessary vf value judgement when get vport id Guangbin Huang
-- strict thread matches above, loose matches on Subject: below --
2022-11-15 14:00 [PATCH net-next 1/4] net: hns3: refine the tcam key convert handle Lanhao (Lan)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YzQh4Zu3Md1+Npeo@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=huangguangbin2@huawei.com \
--cc=kuba@kernel.org \
--cc=lanhao@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenjian15@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox