From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
To: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>
Cc: stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2 2/2] net/mlx5: improve stack usage during link update
Date: Wed, 30 Aug 2017 16:47:07 +0200 [thread overview]
Message-ID: <dcead09edd852da04c04b4c16fae5768234cbab9.1504104367.git.nelio.laranjeiro@6wind.com> (raw)
In-Reply-To: <7b005e17d5b2a1221e6d7237e3d36fea57a33c6a.1504104367.git.nelio.laranjeiro@6wind.com>
In-Reply-To: <20f8cf112084a36f203b80e212a9f08463bd3c91.1504020810.git.nelio.laranjeiro@6wind.com>
Allocate no more memory than necessary for the second call to
ETHTOOL_GLINKSETTINGS.
Cc: stable@dpdk.org
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
--
Changes in v2:
Fix the memory space, link_mode_mask_nwords has the size for the three
expected arrays.
---
drivers/net/mlx5/mlx5_ethdev.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 0d2dae4..53a23ab 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -113,7 +113,6 @@ struct ethtool_link_settings {
#define ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT 38
#define ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT 39
#endif
-#define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
/**
* Return private structure associated with an Ethernet device.
@@ -805,11 +804,7 @@ static int
mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
{
struct priv *priv = mlx5_get_priv(dev);
- alignas(struct ethtool_link_settings)
- uint8_t data[offsetof(struct ethtool_link_settings, link_mode_masks) +
- sizeof(uint32_t) *
- ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 * 3];
- struct ethtool_link_settings *ecmd = (void *)data;
+ struct ethtool_link_settings gcmd = { .cmd = ETHTOOL_GLINKSETTINGS };
struct ifreq ifr;
struct rte_eth_link dev_link;
uint64_t sc;
@@ -822,15 +817,21 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
memset(&dev_link, 0, sizeof(dev_link));
dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
(ifr.ifr_flags & IFF_RUNNING));
- memset(ecmd, 0, sizeof(*ecmd));
- ecmd->cmd = ETHTOOL_GLINKSETTINGS;
- ifr.ifr_data = (void *)ecmd;
+ ifr.ifr_data = (void *)&gcmd;
if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
DEBUG("ioctl(SIOCETHTOOL, ETHTOOL_GLINKSETTINGS) failed: %s",
strerror(errno));
return -1;
}
- ecmd->link_mode_masks_nwords = -ecmd->link_mode_masks_nwords;
+ gcmd.link_mode_masks_nwords = -gcmd.link_mode_masks_nwords;
+
+ alignas(struct ethtool_link_settings)
+ uint8_t data[offsetof(struct ethtool_link_settings, link_mode_masks) +
+ sizeof(uint32_t) * gcmd.link_mode_masks_nwords * 3];
+ struct ethtool_link_settings *ecmd = (void *)data;
+
+ *ecmd = gcmd;
+ ifr.ifr_data = (void *)ecmd;
if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
DEBUG("ioctl(SIOCETHTOOL, ETHTOOL_GLINKSETTINGS) failed: %s",
strerror(errno));
--
2.1.4
prev parent reply other threads:[~2017-08-30 14:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 15:35 [dpdk-stable] [PATCH 1/2] net/mlx5: fix clang compilation Nelio Laranjeiro
2017-08-29 15:35 ` [dpdk-stable] [PATCH 2/2] net/mlx5: improve stack usage during link update Nelio Laranjeiro
2017-08-30 13:56 ` [dpdk-stable] [PATCH 1/2] net/mlx5: fix clang compilation Ferruh Yigit
2017-08-30 14:47 ` [dpdk-stable] [PATCH v2 " Nelio Laranjeiro
2017-08-31 15:33 ` Ferruh Yigit
2017-08-30 14:47 ` Nelio Laranjeiro [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=dcead09edd852da04c04b4c16fae5768234cbab9.1504104367.git.nelio.laranjeiro@6wind.com \
--to=nelio.laranjeiro@6wind.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=stable@dpdk.org \
/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).