From: Heng Qi <hengqi@linux.alibaba.com>
To: netdev@vger.kernel.org, virtualization@lists.linux.dev
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Ratheesh Kannoth <rkannoth@marvell.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Subject: [PATCH net-next v4 4/4] virtio-net: support dim profile fine-tuning
Date: Mon, 8 Apr 2024 11:44:30 +0800 [thread overview]
Message-ID: <1712547870-112976-5-git-send-email-hengqi@linux.alibaba.com> (raw)
In-Reply-To: <1712547870-112976-1-git-send-email-hengqi@linux.alibaba.com>
Virtio-net has different types of back-end device
implementations. In order to effectively optimize
the dim library's gains for different device
implementations, let's use the new interface params
to fine-tune the profile list.
Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
---
drivers/net/virtio_net.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cc3a281..24e8a59 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -57,6 +57,8 @@
#define VIRTNET_DRIVER_VERSION "1.0.0"
+static const struct dim_cq_moder rx_eqe_conf[] = NET_DIM_RX_EQE_PROFILES;
+
static const unsigned long guest_offloads[] = {
VIRTIO_NET_F_GUEST_TSO4,
VIRTIO_NET_F_GUEST_TSO6,
@@ -330,6 +332,12 @@ struct virtnet_info {
struct virtnet_interrupt_coalesce intr_coal_tx;
struct virtnet_interrupt_coalesce intr_coal_rx;
+ /* DIM profile list for different queue mode */
+ struct dim_cq_moder rx_eqe_conf[NET_DIM_PARAMS_NUM_PROFILES];
+ struct dim_cq_moder rx_cqe_conf[NET_DIM_PARAMS_NUM_PROFILES];
+ struct dim_cq_moder tx_eqe_conf[NET_DIM_PARAMS_NUM_PROFILES];
+ struct dim_cq_moder tx_cqe_conf[NET_DIM_PARAMS_NUM_PROFILES];
+
unsigned long guest_offloads;
unsigned long guest_offloads_capable;
@@ -3588,7 +3596,7 @@ static void virtnet_rx_dim_work(struct work_struct *work)
if (!rq->dim_enabled)
continue;
- update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
+ update_moder = vi->rx_eqe_conf[dim->profile_ix];
if (update_moder.usec != rq->intr_coal.max_usecs ||
update_moder.pkts != rq->intr_coal.max_packets) {
err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum,
@@ -3631,6 +3639,27 @@ static int virtnet_should_update_vq_weight(int dev_flags, int weight,
return 0;
}
+static int virtnet_update_profile(struct virtnet_info *vi,
+ struct kernel_ethtool_coalesce *kc)
+{
+ int i;
+
+ if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) {
+ for (i = 0; i < NET_DIM_PARAMS_NUM_PROFILES; i++)
+ if (kc->rx_eqe_profs[i].comps)
+ return -EINVAL;
+ } else {
+ return -EOPNOTSUPP;
+ }
+
+ for (i = 0; i < NET_DIM_PARAMS_NUM_PROFILES; i++) {
+ vi->rx_eqe_conf[i].usec = kc->rx_eqe_profs[i].usec;
+ vi->rx_eqe_conf[i].pkts = kc->rx_eqe_profs[i].pkts;
+ }
+
+ return 0;
+}
+
static int virtnet_set_coalesce(struct net_device *dev,
struct ethtool_coalesce *ec,
struct kernel_ethtool_coalesce *kernel_coal,
@@ -3657,6 +3686,10 @@ static int virtnet_set_coalesce(struct net_device *dev,
}
}
+ ret = virtnet_update_profile(vi, kernel_coal);
+ if (ret)
+ return ret;
+
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL))
ret = virtnet_send_notf_coal_cmds(vi, ec);
else
@@ -3693,6 +3726,10 @@ static int virtnet_get_coalesce(struct net_device *dev,
ec->tx_max_coalesced_frames = 1;
}
+ if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL))
+ memcpy(kernel_coal->rx_eqe_profs, vi->rx_eqe_conf,
+ sizeof(vi->rx_eqe_conf));
+
return 0;
}
@@ -3872,7 +3909,8 @@ static int virtnet_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
static const struct ethtool_ops virtnet_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_MAX_FRAMES |
- ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
+ ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX |
+ ETHTOOL_COALESCE_RX_EQE_PROFILE,
.get_drvinfo = virtnet_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_ringparam = virtnet_get_ringparam,
@@ -4437,6 +4475,8 @@ static void virtnet_dim_init(struct virtnet_info *vi)
INIT_WORK(&vi->rq[i].dim.work, virtnet_rx_dim_work);
vi->rq[i].dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
}
+
+ memcpy(vi->rx_eqe_conf, rx_eqe_conf, sizeof(vi->rx_eqe_conf));
}
static int virtnet_alloc_queues(struct virtnet_info *vi)
--
1.8.3.1
prev parent reply other threads:[~2024-04-08 3:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 3:44 [PATCH net-next v4 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi
2024-04-08 3:44 ` [PATCH net-next v4 1/4] ethtool: provide customized dim profile management Heng Qi
2024-04-08 19:09 ` Jakub Kicinski
2024-04-08 19:13 ` Jakub Kicinski
2024-04-09 8:38 ` Heng Qi
2024-04-08 3:44 ` [PATCH net-next v4 2/4] linux/dim: move profiles from .c to .h file Heng Qi
2024-04-08 3:44 ` [PATCH net-next v4 3/4] virtio-net: refactor dim initialization/destruction Heng Qi
2024-04-08 3:44 ` Heng Qi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1712547870-112976-5-git-send-email-hengqi@linux.alibaba.com \
--to=hengqi@linux.alibaba.com \
--cc=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).