RE: [PATCH v4 net-next 01/14] net: enetc: add initial netc-lib driver to support NTMP
From: Wei Fang
Date: Mon Mar 17 2025 - 07:40:03 EST
> On Mon, Mar 17, 2025 at 11:55:26AM +0200, Wei Fang wrote:
> > Actually I did this is the original version, I mean in downstream kernel 6.6
> > tree. I add a "ntmp_mfe" in ntmp.h like below
> >
> > struct ntmp_mfe {
> > u8 mac[ETH_ALEN];
> > u16 si_bitmap;
> > };
> >
> > And the conversion was done by the NTMP driver. But then I found that this
> was
> > very troublesome. We get data from kernel "struct A,B,C", then the enetc
> driver
> > converts them to "struct D", and finally the ntmp driver converts it to "struct
> E".
> > So I thought why don't we convert "struct A,B,C" to "struct E" from the
> beginning?
> > After all, these data structures are only used by enetc and netc switch drivers,
> so
> > in kernel 6.12, I changed it to the current way.
>
> I understand. With pack_fields(), "struct E" (the packed representation
> of "struct D") doesn't explicitly exist, just an abstract type
> representing the u8 *buffer, and the struct packed_field_u8 array[]
> which is hidden inside the NTMP layer.
Yes, "struct E" will not exist, but we need to pack every member in
"struct D" to convert them to the hardware structure, so there are
still two conversions ("struct A,B,C" -> "struct "D" --> hardware
structure).