From: Simon Horman <horms@kernel.org>
To: Heng Qi <hengqi@linux.alibaba.com>
Cc: netdev@vger.kernel.org, virtualization@lists.linux.dev,
Jakub Kicinski <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Jason Wang <jasowang@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Brett Creeley <bcreeley@amd.com>,
Ratheesh Kannoth <rkannoth@marvell.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Subject: Re: [PATCH net-next v7 2/4] ethtool: provide customized dim profile management
Date: Mon, 15 Apr 2024 21:03:43 +0100 [thread overview]
Message-ID: <20240415200343.GG2320920@kernel.org> (raw)
In-Reply-To: <20240415093638.123962-3-hengqi@linux.alibaba.com>
On Mon, Apr 15, 2024 at 05:36:36PM +0800, Heng Qi wrote:
...
> @@ -10229,6 +10230,61 @@ static void netdev_do_free_pcpu_stats(struct net_device *dev)
> }
> }
>
> +static int dev_dim_profile_init(struct net_device *dev)
> +{
> +#if IS_ENABLED(CONFIG_DIMLIB)
> + u32 supported = dev->ethtool_ops->supported_coalesce_params;
> + struct netdev_profile_moder *moder;
> + int length;
> +
> + dev->moderation = kzalloc(sizeof(*dev->moderation), GFP_KERNEL);
> + if (!dev->moderation)
> + goto err_moder;
> +
> + moder = dev->moderation;
> + length = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*moder->rx_eqe_profile);
> +
> + if (supported & ETHTOOL_COALESCE_RX_EQE_PROFILE) {
> + moder->rx_eqe_profile = kzalloc(length, GFP_KERNEL);
> + if (!moder->rx_eqe_profile)
> + goto err_rx_eqe;
> + memcpy(moder->rx_eqe_profile, rx_profile[0], length);
> + }
> + if (supported & ETHTOOL_COALESCE_RX_CQE_PROFILE) {
> + moder->rx_cqe_profile = kzalloc(length, GFP_KERNEL);
> + if (!moder->rx_cqe_profile)
> + goto err_rx_cqe;
> + memcpy(moder->rx_cqe_profile, rx_profile[1], length);
> + }
> + if (supported & ETHTOOL_COALESCE_TX_EQE_PROFILE) {
> + moder->tx_eqe_profile = kzalloc(length, GFP_KERNEL);
> + if (!moder->tx_eqe_profile)
> + goto err_tx_eqe;
> + memcpy(moder->tx_eqe_profile, tx_profile[0], length);
> + }
> + if (supported & ETHTOOL_COALESCE_TX_CQE_PROFILE) {
> + moder->tx_cqe_profile = kzalloc(length, GFP_KERNEL);
> + if (!moder->tx_cqe_profile)
> + goto err_tx_cqe;
> + memcpy(moder->tx_cqe_profile, tx_profile[1], length);
> + }
nit: Coccinelle suggests that the kzalloc()/memcpy() pattern above
could be replaced with calls to kmemdup()
> +#endif
> + return 0;
> +
> +#if IS_ENABLED(CONFIG_DIMLIB)
> +err_tx_cqe:
> + kfree(moder->tx_eqe_profile);
> +err_tx_eqe:
> + kfree(moder->rx_cqe_profile);
> +err_rx_cqe:
> + kfree(moder->rx_eqe_profile);
> +err_rx_eqe:
> + kfree(moder);
> +err_moder:
> + return -ENOMEM;
> +#endif
> +}
> +
> /**
> * register_netdevice() - register a network device
> * @dev: device to register
...
next prev parent reply other threads:[~2024-04-15 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 9:36 [PATCH net-next v7 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi
2024-04-15 9:36 ` [PATCH net-next v7 1/4] linux/dim: move useful macros to .h file Heng Qi
2024-04-15 9:36 ` [PATCH net-next v7 2/4] ethtool: provide customized dim profile management Heng Qi
2024-04-15 12:19 ` kernel test robot
2024-04-15 12:51 ` kernel test robot
2024-04-15 20:03 ` Simon Horman [this message]
2024-04-16 2:27 ` Heng Qi
2024-04-15 9:36 ` [PATCH net-next v7 3/4] virtio-net: refactor dim initialization/destruction Heng Qi
2024-04-15 9:36 ` [PATCH net-next v7 4/4] virtio-net: support dim profile fine-tuning Heng Qi
2024-04-15 13:35 ` [PATCH net-next v7 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi
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=20240415200343.GG2320920@kernel.org \
--to=horms@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=bcreeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hengqi@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.