diff mbox series

[net] virtio-net: unify notifications coalescing structs

Message ID 20230305154942.1770925-1-alvaro.karsz@solid-run.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] virtio-net: unify notifications coalescing structs | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 22 this patch: 22
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 22 this patch: 22
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns WARNING: line length of 91 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alvaro Karsz March 5, 2023, 3:49 p.m. UTC
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

Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
---
 drivers/net/virtio_net.c        | 15 +++++++--------
 include/uapi/linux/virtio_net.h | 24 +++++++-----------------
 2 files changed, 14 insertions(+), 25 deletions(-)

Comments

Jason Wang March 6, 2023, 3:39 a.m. UTC | #1
On Sun, Mar 5, 2023 at 11:49 PM Alvaro Karsz <alvaro.karsz@solid-run.com> wrote:
>
> 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
>
> Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
> ---
>  drivers/net/virtio_net.c        | 15 +++++++--------
>  include/uapi/linux/virtio_net.h | 24 +++++++-----------------
>  2 files changed, 14 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fb5e68ed3ec..86b6b3e0257 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -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,
> diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
> index b4062bed186..ce044260e02 100644
> --- a/include/uapi/linux/virtio_net.h
> +++ b/include/uapi/linux/virtio_net.h
> @@ -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;
> -};

Is this too late to be changed?

Thanks

> -
> -#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 */
> --
> 2.34.1
>
Alvaro Karsz March 6, 2023, 7:48 a.m. UTC | #2
> 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?
Jason Wang March 7, 2023, 7:26 a.m. UTC | #3
On Mon, Mar 6, 2023 at 3:48 PM Alvaro Karsz <alvaro.karsz@solid-run.com> wrote:
>
> > 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

>
>
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fb5e68ed3ec..86b6b3e0257 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -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,
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index b4062bed186..ce044260e02 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -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 */