qemu-e2k/hw/net
Daniil Tatianin d74c30c811 virtio: introduce VirtIOConfigSizeParams & virtio_get_config_size
This is the first step towards moving all device config size calculation
logic into the virtio core code. In particular, this adds a struct that
contains all the necessary information for common virtio code to be able
to calculate the final config size for a device. This is expected to be
used with the new virtio_get_config_size helper, which calculates the
final length based on the provided host features.

This builds on top of already existing code like VirtIOFeature and
virtio_feature_get_config_size(), but adds additional fields, as well as
sanity checking so that device-specifc code doesn't have to duplicate it.

An example usage would be:

    static const VirtIOFeature dev_features[] = {
        {.flags = 1ULL << FEATURE_1_BIT,
         .end = endof(struct virtio_dev_config, feature_1)},
        {.flags = 1ULL << FEATURE_2_BIT,
         .end = endof(struct virtio_dev_config, feature_2)},
        {}
    };

    static const VirtIOConfigSizeParams dev_cfg_size_params = {
        .min_size = DEV_BASE_CONFIG_SIZE,
        .max_size = sizeof(struct virtio_dev_config),
        .feature_sizes = dev_features
    };

    // code inside my_dev_device_realize()
    size_t config_size = virtio_get_config_size(&dev_cfg_size_params,
                                                host_features);
    virtio_init(vdev, VIRTIO_ID_MYDEV, config_size);

Currently every device is expected to write its own boilerplate from the
example above in device_realize(), however, the next step of this
transition is moving VirtIOConfigSizeParams into VirtioDeviceClass,
so that it can be done automatically by the virtio initialization code.

All of the users of virtio_feature_get_config_size have been converted
to use virtio_get_config_size so it's no longer needed and is removed
with this commit.

Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Message-Id: <20220906073111.353245-2-d-tatianin@yandex-team.ru>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-10-07 09:41:51 -04:00
..
can hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic 2022-09-22 16:38:26 +01:00
fsl_etsec
rocker hw/net/rocker: Avoid undefined shifts with more than 31 ports 2022-08-09 17:02:18 +08:00
allwinner_emac.c
allwinner-sun8i-emac.c
cadence_gem.c
dp8393x.c
e1000_regs.h
e1000.c e1000: set RX descriptor status in a separate operation 2022-07-06 11:39:09 +08:00
e1000e_core.c e1000e: set RX desc status with DD flag in a separate operation 2022-09-27 15:12:08 +08:00
e1000e_core.h
e1000e.c
e1000x_common.c
e1000x_common.h
eepro100.c
etraxfs_eth.c
ftgmac100.c
i82596.c
i82596.h
imx_fec.c Trivial: 3 char repeat typos 2022-06-28 11:06:02 +02:00
Kconfig
lan9118.c hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level 2022-09-22 16:38:28 +01:00
lance.c
lasi_i82596.c
mcf_fec.c
meson.build
mipsnet.c
msf2-emac.c
mv88w8618_eth.c
ne2000-isa.c
ne2000-pci.c
ne2000.c
ne2000.h
net_rx_pkt.c
net_rx_pkt.h
net_tx_pkt.c
net_tx_pkt.h
npcm7xx_emc.c
opencores_eth.c
pcnet-pci.c
pcnet.c
pcnet.h
rtl8139.c
smc91c111.c
spapr_llan.c
stellaris_enet.c
sungem.c
sunhme.c
trace-events
trace.h
tulip.c net: tulip: Restrict DMA engine to memories 2022-09-02 10:22:39 +08:00
tulip.h
vhost_net-stub.c
vhost_net.c vhost_net: add NetClientState->load() callback 2022-09-02 10:22:39 +08:00
virtio-net.c virtio: introduce VirtIOConfigSizeParams & virtio_get_config_size 2022-10-07 09:41:51 -04:00
vmware_utils.h
vmxnet3_defs.h
vmxnet3.c
vmxnet3.h
vmxnet_debug.h
xen_nic.c
xgmac.c
xilinx_axienet.c
xilinx_ethlite.c