From: Andrew Lunn <andrew@lunn.ch>
To: Yibo Dong <dong100@mucse.com>
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
corbet@lwn.net, gur.stavi@huawei.com, maddy@linux.ibm.com,
mpe@ellerman.id.au, danishanwar@ti.com, lee@trager.us,
gongfan1@huawei.com, lorenzo@kernel.org, geert+renesas@glider.be,
Parthiban.Veerasooran@microchip.com, lukas.bulwahn@redhat.com,
alexanderduyck@fb.com, richardcochran@gmail.com,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/5] net: rnpgbe: Add basic mbx_fw support
Date: Fri, 15 Aug 2025 15:21:33 +0200 [thread overview]
Message-ID: <0890f9e0-1115-4fa3-8c1c-0f2e8e5625de@lunn.ch> (raw)
In-Reply-To: <3A381A779EB97B74+20250815063656.GA1148411@nic-Precision-5820-Tower>
> > Using struct_size() makes me think this is supposed to be a flexible
> > array? I've never used them myself, but shouldn't be some markup so
> > the compiler knows priv_len is the len of priv?
> >
>
> Maybe link this?
> struct mbx_req_cookie {
> ....
> int priv_len;
> char priv[] __counted_by(priv_len);
> }
Yes, that looks correct.
> > > + return err;
> > > + }
> > > + do {
> > > + err = wait_event_interruptible_timeout(cookie->wait,
> > > + cookie->done == 1,
> > > + cookie->timeout_jiffes);
> > > + } while (err == -ERESTARTSYS);
> >
> > This needs a comment, because i don't understand it.
> >
> >
>
> wait_event_interruptible_timeout return -ERESTARTSYS if it was interrupted
> by a signal, which will cause misjudgement about cookie->done is timeout.
> In this case, just wait for timeout.
> Maybe comment link this?
> /* If it was interrupted by a signal (-ERESTARTSYS), it is not true timeout,
> * just wait again.
> */
But why use wait_event_interruptible_timout() if you are going to
ignore all interrupts, a.k.a. signals? Why not use
wait_event_timeout()?
> > > + if ((1 << lane) & le32_to_cpu(reply.mac_addr.lanes))
> >
> > BIT(). And normally the & would be the other way around.
> >
>
> Maybe changed link this?
> ...
> if (le32_to_cpu(reply.mac_addr.ports) & BIT(lane))
Yes, that is better.
> > What exactly is a lane here? Normally we would think of a lane is
> > -KR4, 4 SERDES lanes making one port. But the MAC address is a
> > property of the port, not the lane within a port.
> >
>
> lane is the valid bit in 'reply.mac_addr.ports'.
> Maybe change it to 'port', that is more appropriate.
You need to be careful with your terms. I read in another patch, that
there is a dual version and a quad version. I've not yet seen how you
handle this, but i assume they are identical, and appear on the PCI
bus X number of times, and this driver will probe X times, once per
instance. We would normally refer to each instance as an
interface. But this driver also mentions PF, so i assume you also have
VFs? And if you have VF, i assume you have an embedded switch which
each of the VFs are connected to. Each VF would normally be connected
to a port of the switch.
So even though you don't have VF support yet, you should be thinking
forward. In the big picture architecture, what does this lane/port
represent? What do other drivers call it?
> > Another example of a bad structure layout. It would of been much
> > better to put the two u8 after speed.
> >
> > > +} __packed;
> >
> > And because this is packed, and badly aligned, you are forcing the
> > compiler to do a lot more work accessing these members.
> >
>
> Yes, It is bad. But FW use this define, I can only follow the define...
> Maybe I can add comment here?
> /* Must follow FW define here */
No need. When somebody sees __packed, it becomes obvious this is ABI
and cannot be changed. Just think about it for any future extensions
to the firmware ABI.
>
> > > +
> > > +static inline void ability_update_host_endian(struct hw_abilities *abi)
> > > +{
> > > + u32 host_val = le32_to_cpu(abi->ext_ability);
> > > +
> > > + abi->e_host = *(typeof(abi->e_host) *)&host_val;
> > > +}
> >
> > Please add a comment what this is doing, it is not obvious.
> >
> >
>
> Maybe link this?
> /* Converts the little-endian ext_ability field to host byte order,
> * then copies the value into the e_host field by reinterpreting the
> * memory as the type of e_host (likely a bitfield or structure that
> * represents the extended abilities in a host-friendly format).
> */
This explains what you are doing, but why? Why do you do this only to
this field? What about all the others?
Andrew
next prev parent reply other threads:[~2025-08-15 13:22 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 7:38 [PATCH v4 0/5] Add driver for 1Gbe network chips from MUCSE Dong Yibo
2025-08-14 7:38 ` [PATCH v4 1/5] net: rnpgbe: Add build support for rnpgbe Dong Yibo
2025-08-15 1:58 ` Andrew Lunn
2025-08-14 7:38 ` [PATCH v4 2/5] net: rnpgbe: Add n500/n210 chip support Dong Yibo
2025-08-14 12:07 ` MD Danish Anwar
2025-08-14 13:52 ` Yibo Dong
2025-08-15 2:07 ` Andrew Lunn
2025-08-15 2:05 ` Andrew Lunn
2025-08-15 2:38 ` Yibo Dong
2025-08-15 3:56 ` Andrew Lunn
2025-08-15 7:21 ` Yibo Dong
2025-08-15 13:36 ` Andrew Lunn
2025-08-18 1:14 ` Yibo Dong
2025-08-14 7:38 ` [PATCH v4 3/5] net: rnpgbe: Add basic mbx ops support Dong Yibo
2025-08-15 2:13 ` Andrew Lunn
2025-08-15 2:43 ` Yibo Dong
2025-08-15 3:59 ` Andrew Lunn
2025-08-15 7:22 ` Yibo Dong
2025-08-15 2:29 ` Andrew Lunn
2025-08-15 3:15 ` Yibo Dong
2025-08-14 7:38 ` [PATCH v4 4/5] net: rnpgbe: Add basic mbx_fw support Dong Yibo
2025-08-14 12:10 ` MD Danish Anwar
2025-08-14 13:54 ` Yibo Dong
2025-08-15 3:27 ` Andrew Lunn
2025-08-15 6:36 ` Yibo Dong
2025-08-15 13:21 ` Andrew Lunn [this message]
2025-08-18 2:14 ` Yibo Dong
2025-08-14 7:38 ` [PATCH v4 5/5] net: rnpgbe: Add register_netdev Dong Yibo
2025-08-14 12:14 ` MD Danish Anwar
2025-08-14 13:59 ` Yibo Dong
2025-08-15 2:28 ` Yibo Dong
2025-08-15 3:42 ` Andrew Lunn
2025-08-15 6:44 ` Yibo Dong
2025-08-15 18:06 ` Andrew Lunn
2025-08-18 1:21 ` Yibo Dong
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=0890f9e0-1115-4fa3-8c1c-0f2e8e5625de@lunn.ch \
--to=andrew@lunn.ch \
--cc=Parthiban.Veerasooran@microchip.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=gongfan1@huawei.com \
--cc=gur.stavi@huawei.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@trager.us \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.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
all inboxes | Powered by JetHome®