Re: [PATCH net-next v3 1/2] hinic: add generating mailbox random index support

From: Jakub Kicinski
Date: Mon Aug 03 2020 - 18:05:49 EST


On Sat, 1 Aug 2020 10:49:34 +0800 Luo bin wrote:
> add support to generate mailbox random id of VF to ensure that
> mailbox messages PF received are from the correct VF.
>
> Signed-off-by: Luo bin <luobin9@xxxxxxxxxx>
> ---
> V2~V3 fix review opinions pointed out by Jakub

In the future please specify what was changed, e.g.:

- use get_random_u32()
- remove unnecessary parenthesis

etc.

> +int hinic_vf_mbox_random_id_init(struct hinic_hwdev *hwdev)
> +{
> + u8 vf_in_pf;
> + int err = 0;
> +
> + if (HINIC_IS_VF(hwdev->hwif))
> + return 0;
> +
> + for (vf_in_pf = 1; vf_in_pf <= hwdev->nic_cap.max_vf; vf_in_pf++) {
> + err = set_vf_mbox_random_id(hwdev, hinic_glb_pf_vf_offset
> + (hwdev->hwif) + vf_in_pf);

I'm sorry but you must put the call to hinic_glb_pf_vf_offset() on a
separate line. Perhaps take this call out of the for loop entirely?

The way it's written with the parenthesis on the next line is hard to
read.

> + if (err)
> + break;
> + }