virtio-net: unify notifications coalescing structs
Subsystems (4)
PATCH 1/1 virtio-net: unify notifications coalescing structs
Unify virtio_net_ctrl_coal_tx and virtio_net_ctrl_coal_rx structs into a single struct, virtio_net_ctrl_coal, as they are identical.
This patch follows the VirtIO spec patch:
https://lists.oasis-open.org/archives/virtio-comment/202302/msg00431.html
--- drivers/net/virtio_net.c | 15 +++++++-------- include/uapi/linux/virtio_net.h | 24 +++++++----------------- 2 files changed, 14 insertions(+), 25 deletions(-)
drivers/net/virtio_net.c +7 -8
@@ -2883,12 +2883,11 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { struct scatterlist sgs_tx, sgs_rx; - struct virtio_net_ctrl_coal_tx coal_tx; - struct virtio_net_ctrl_coal_rx coal_rx; + struct virtio_net_ctrl_coal coal_params; - coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); - coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); - sg_init_one(&sgs_tx, &coal_tx, sizeof(coal_tx)); + coal_params.max_usecs = cpu_to_le32(ec->tx_coalesce_usecs); + coal_params.max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); + sg_init_one(&sgs_tx, &coal_params, sizeof(coal_params)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_TX_SET,
@@ -2899,9 +2898,9 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, vi->tx_usecs = ec->tx_coalesce_usecs; vi->tx_max_packets = ec->tx_max_coalesced_frames; - coal_rx.rx_usecs =cpu_to_le32 (ec->rx_coalesce_usecs); - coal_rx.rx_max_packets =cpu_to_le32 (ec->rx_max_coalesced_frames); -sg_init_one (&sgs_rx, &coal_rx,sizeof (coal_rx)); + coal_params.max_usecs =cpu_to_le32 (ec->rx_coalesce_usecs); + coal_params.max_packets =cpu_to_le32 (ec->rx_max_coalesced_frames); +sg_init_one (&sgs_rx, &coal_params,sizeof (coal_params)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_RX_SET,
include/uapi/linux/virtio_net.h +7 -17
@@ -367,28 +367,18 @@ struct virtio_net_hash_config {* Available with the VIRTIO_NET_F_NOTF_COAL feature bit. */ #define VIRTIO_NET_CTRL_NOTF_COAL 6 -/* -* Set the tx-usecs/tx-max-packets parameters. -*/ -struct virtio_net_ctrl_coal_tx { -/* Maximum number of packets to send before a TX notification */ -__le32 tx_max_packets; -/* Maximum number of usecs to delay a TX notification */ -__le32 tx_usecs; -}; - -#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0/* -* Set the rx-usecs/rx-max-packets parameters. +* Set the max_usecs/max_packets coalescing parameters for all transmit/receive virtqueues. */ -struct virtio_net_ctrl_coal_rx { -/* Maximum number of packets to receive before a RX notification */ -__le32 rx_max_packets; -/* Maximum number of usecs to delay a RX notification */ -__le32 rx_usecs; +struct virtio_net_ctrl_coal { +/* Maximum number of packets to send/receive before a TX/RX notification */ +__le32 max_packets; +/* Maximum number of microseconds to delay a TX/RX notification */ +__le32 max_usecs; }; +#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1#endif /* _UAPI_LINUX_VIRTIO_NET_H */
Signature · 6 lines
2.34.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 54 lines · Alvaro Karsz
Unify
virtio_net_ctrl_coal_txandvirtio_net_ctrl_coal_rxstructs into a single struct,virtio_net_ctrl_coal, as they are identical.This patch follows the VirtIO spec patch:
https://lists.oasis-open.org/archives/virtio-comment/202302/msg00431.htmlSigned-off-by Alvaro Karsz <[email protected]>--- drivers/net/virtio_net.c | 15 +++++++-------- include/uapi/linux/virtio_net.h | 24 +++++++----------------- 2 files changed, 14 insertions(+), 25 deletions(-)drivers/net/virtio_net.c +7
-8@@ -2883,12 +2883,11 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { struct scatterlist sgs_tx, sgs_rx; - struct virtio_net_ctrl_coal_tx coal_tx; - struct virtio_net_ctrl_coal_rx coal_rx; + struct virtio_net_ctrl_coal coal_params; - coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); - coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); - sg_init_one(&sgs_tx, &coal_tx, sizeof(coal_tx)); + coal_params.max_usecs = cpu_to_le32(ec->tx_coalesce_usecs); + coal_params.max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); + sg_init_one(&sgs_tx, &coal_params, sizeof(coal_params)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_TX_SET,@@ -2899,9 +2898,9 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, vi->tx_usecs = ec->tx_coalesce_usecs; vi->tx_max_packets = ec->tx_max_coalesced_frames; - coal_rx.rx_usecs =cpu_to_le32 (ec->rx_coalesce_usecs); - coal_rx.rx_max_packets =cpu_to_le32 (ec->rx_max_coalesced_frames); -sg_init_one (&sgs_rx, &coal_rx,sizeof (coal_rx)); + coal_params.max_usecs =cpu_to_le32 (ec->rx_coalesce_usecs); + coal_params.max_packets =cpu_to_le32 (ec->rx_max_coalesced_frames); +sg_init_one (&sgs_rx, &coal_params,sizeof (coal_params)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_RX_SET,include/uapi/linux/virtio_net.h +0
-0@@ -367,28 +367,18 @@ struct virtio_net_hash_config {* Available with the VIRTIO_NET_F_NOTF_COAL feature bit. */
include/uapi/linux/virtio_net.h struct virtio_net_hash_config { · line 378
Quoted 10 lines
include/uapi/linux/virtio_net.h +0
-9#define VIRTIO_NET_CTRL_NOTF_COAL 6 -/* -* Set the tx-usecs/tx-max-packets parameters. -*/ -struct virtio_net_ctrl_coal_tx { -/* Maximum number of packets to send before a TX notification */ -__le32 tx_max_packets; -/* Maximum number of usecs to delay a TX notification */ -__le32 tx_usecs; -};
Is this too late to be changed?
Thanks
Quoted 24 lines
include/uapi/linux/virtio_net.h +7
-9- -#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0/* -* Set the rx-usecs/rx-max-packets parameters. +* Set the max_usecs/max_packets coalescing parameters for all transmit/receive virtqueues. */ -struct virtio_net_ctrl_coal_rx { -/* Maximum number of packets to receive before a RX notification */ -__le32 rx_max_packets; -/* Maximum number of usecs to delay a RX notification */ -__le32 rx_usecs; +struct virtio_net_ctrl_coal { +/* Maximum number of packets to send/receive before a TX/RX notification */ +__le32 max_packets; +/* Maximum number of microseconds to delay a TX/RX notification */ +__le32 max_usecs; }; +#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1#endif /* _UAPI_LINUX_VIRTIO_NET_H */ --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 3 lines
Is this too late to be changed?
Thanks
You're right.
What do you suggest, dropping the patch or adding the unified struct without deleting the existing ones?
Quoted 7 lines · Alvaro Karsz
Quoted 4 lines
Is this too late to be changed?
Thanks
You're right.
What do you suggest, dropping the patch or adding the unified struct without deleting the existing ones?
At least we need to avoid touching existing uAPI structures.
I think we can leave the code as is but we can hear from others.
Thanks
Quoted 2 lines
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization