Re: [PATCH net-next v7 1/5] rust: core abstractions for network PHY drivers

Andrew Lunn
2023-11-10T13:26:15Z

On Wed, Nov 08, 2023 at 07:46:47PM +0900, FUJITA Tomonori wrote:
> On Mon, 30 Oct 2023 16:45:38 +0000
> Benno Lossin <benno.lossin@proton.me> wrote:
>
> >>> But I would wait until we see a response from the bindgen devs on the issue.
> >>
> >> You meant that they might have a different option on this?
> >
> > No, before you implement the workaround that Boqun posted you
> > should wait until the bindgen devs say how long/if they will
> > implement it.
>
> It has been 10 days but no response from bindgen developpers. I guess
> that unlikely bindgen will support the feature until the next merge
> window.

I just took a look around the kernel includes. Here are a few examples
i found, there are many many more.

include/target/iscsi/iscsi_target_core.h: unsigned int conn_tx_reset_cpumask:1;
include/media/videobuf2-core.h: unsigned int synced:1;
include/media/v4l2-ctrls.h: unsigned int done:1;
include/drm/bridge/samsung-dsim.h: unsigned int has_freqband:1;
include/net/sock_reuseport.h: unsigned int bind_inany:1;
include/net/sock.h: unsigned char skc_ipv6only:1;
include/sound/simple_card_utils.h: unsigned int force_dpcm:1;
include/sound/soc.h: unsigned int autodisable:1;
include/linux/pci.h: unsigned int imm_ready:1; /* Supports Immediate Readiness */
include/linux/regmap.h: unsigned int use_ack:1;
include/linux/cpuidle.h: unsigned int registered:1;
include/linux/regulator/gpio-regulator.h: unsigned enabled_at_boot:1;
include/linux/phy.h: unsigned link:1;
include/linux/pm.h: unsigned int irq_safe:1;
include/linux/nfs_xdr.h: unsigned char renew:1;
include/linux/iio/iio.h: unsigned output:1;
include/linux/drbd.h: unsigned user_isp:1 ;
include/linux/sched.h: unsigned sched_migrated:1;
include/linux/writeback.h: unsigned no_cgroup_owner:1;
include/linux/tty_port.h: unsigned char console:1;
include/linux/mpi.h: unsigned int two_inv_p:1;
include/linux/mmc/host.h: unsigned int use_spi_crc:1;
include/linux/netdevice.h: unsigned wol_enabled:1;
include/linux/serial_8250.h: unsigned int tx_stopped:1;
include/linux/usb.h: unsigned can_submit:1;
include/linux/firewire.h: unsigned is_local:1;
include/linux/phylink.h: unsigned int link:1;
include/linux/gpio_keys.h: unsigned int rep:1;
include/linux/spi/spi.h: unsigned cs_change:1;
include/linux/i2c-mux.h: unsigned int arbitrator:1;
include/linux/kobject.h: unsigned int state_in_sysfs:1;
include/linux/kbd_kern.h: unsigned char ledmode:1;
include/linux/bpf_verifier.h: unsigned int fit_for_inline:1;
include/linux/rtc.h: unsigned int uie_irq_active:1;
include/linux/usb/usbnet.h: unsigned can_dma_sg:1;
include/linux/usb/serial.h: unsigned char attached:1;
include/linux/usb/gadget.h: unsigned dir_out:1;
include/linux/comedi/comedidev.h: unsigned int attached:1;
include/scsi/sg.h: unsigned int twelve_byte:1;
include/scsi/scsi_host.h: unsigned emulated:1;
include/scsi/scsi_device.h: unsigned removable:1;
include/rdma/ib_verbs.h: unsigned int ip_gids:1;

And thats just bitfields used as binary values. There are more with
:2, :3, :4, :8, :16.

The point i'm trying to make is that they are used in many
subsystems. Not having bindgen support for them seems like its going
to be a problem.

Isn't this also an unsoundness problem? Is there existing Rust code
which people think is sound but is actually not?

> I prefer adding accessors in the C side rather than the workaround if
> it's fine by Andrew because we have no idea when bindgen will support
> the feature.

Maybe we need a better understanding of the kernel wide implications
of this. It could be this is actually a big issue, and rust-for-linux
can then apply either pressure, or human resources, to get it
implemented.

Andrew