[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca0ffcae-a82b-f81f-7702-410650e4677c@gmail.com>
Date: Thu, 30 Sep 2021 01:55:36 +0100
From: Edward Cree <ecree.xilinx@...il.com>
To: Jian Shen <shenjian15@...wei.com>, davem@...emloft.net,
kuba@...nel.org, andrew@...n.ch, hkallweit1@...il.com
Cc: netdev@...r.kernel.org, linuxarm@...neuler.org
Subject: Re: [RFCv2 net-next 000/167] net: extend the netdev_features_t
On 29/09/2021 16:50, Jian Shen wrote:
> This patchset try to solve it by change the prototype of
> netdev_features_t from u64 to bitmap. With this change,
> it's necessary to introduce a set of bitmap operation helpers
> for netdev features. Meanwhile, the functions which use
> netdev_features_t as return value are also need to be changed,
> return the result as an output parameter.
This might be a terrible idea, but could you not do something like
typedef struct {
DECLARE_BITMAP(bits, NETDEV_FEATURE_COUNT);
} netdev_features_t;
thereby allowing functions to carry on returning it directly?
The compiler would still likely turn it into an output parameter
at an ABI level (at least once NETDEV_FEATURE_COUNT goes above
64), but the amount of code churn might be significantly reduced.
Another advantage is that, whereas bitwise ops (&, |, ^) on a
pointer (such as unsigned long *) are legal (meaning something
like "if (features & NETIF_F_GSO_MASK)" may still compile, at
best with a warning, despite having nonsensical semantics), they
aren't possible on a struct; so there's less risk of unpatched
code (perhaps merged in from another subsystem, or in out-of-tree
modules) silently breaking — instead, any mix of new and old code
will be caught at build time.
WDYT?
-ed
Powered by blists - more mailing lists