From: Adham Masarwah <adham@nvidia.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <matan@nvidia.com>, <idanhac@nvidia.com>,
<tamerh@nvidia.com>, <talshn@nvidia.com>,
<viacheslavo@nvidia.com>
Subject: [PATCH 2/2] net/mlx5: add support for set and get MTU in Windows
Date: Sun, 10 Apr 2022 13:31:07 +0300 [thread overview]
Message-ID: <20220410103107.66964-3-adham@nvidia.com> (raw)
In-Reply-To: <20220410103107.66964-2-adham@nvidia.com>
Mlx5Devx library has new API's for setting and getting MTU.
Added new glue functions that wrap the new mlx5devx lib API's.
Implemented the os_ethdev callbacks to use the new glue
functions in Windows.
Signed-off-by: Adham Masarwah <adham@nvidia.com>
Tested-by: Idan Hackmon <idanhac@nvidia.com>
Acked-by: Matan Azard <matan@nvidia.com>
---
drivers/common/mlx5/windows/mlx5_glue.c | 55 +++++++++++++++++++++++++++++++
drivers/common/mlx5/windows/mlx5_glue.h | 2 ++
drivers/net/mlx5/windows/mlx5_ethdev_os.c | 31 ++++++++++++++---
3 files changed, 84 insertions(+), 4 deletions(-)
diff --git a/drivers/common/mlx5/windows/mlx5_glue.c b/drivers/common/mlx5/windows/mlx5_glue.c
index 73d63ffd98..6935811bf4 100644
--- a/drivers/common/mlx5/windows/mlx5_glue.c
+++ b/drivers/common/mlx5/windows/mlx5_glue.c
@@ -358,6 +358,59 @@ mlx5_glue_devx_set_promisc_vport(void *ctx, uint32_t promisc_type, uint8_t f_ena
#endif
}
+static int
+mlx5_glue_devx_get_mtu(void *ctx, uint32_t *mtu)
+{
+ int err = 0;
+ struct mlx5_context *mlx5_ctx;
+
+ if (!ctx) {
+ errno = EINVAL;
+ return errno;
+ }
+ mlx5_ctx = (struct mlx5_context *)ctx;
+#ifdef HAVE_DEVX_SET_GET_MTU_SUPPORT
+ err = devx_get_mtu(mlx5_ctx->devx_ctx, mtu);
+ if (err) {
+ errno = err;
+ return errno;
+ }
+#else
+ *mtu = mlx5_ctx->mlx5_dev.mtu_bytes;
+#endif
+
+ return err;
+}
+
+static int
+mlx5_glue_devx_set_mtu(void *ctx, uint32_t mtu)
+{
+#ifdef HAVE_DEVX_SET_GET_MTU_SUPPORT
+ struct mlx5_context *mlx5_ctx;
+ int err;
+
+ if (!ctx) {
+ errno = EINVAL;
+ return errno;
+ }
+ mlx5_ctx = (struct mlx5_context *)ctx;
+ err = devx_set_mtu(mlx5_ctx->devx_ctx, mtu);
+ if (err) {
+ errno = err;
+ return errno;
+ }
+ return 0;
+#else
+ (void)mtu;
+ (void)ctx;
+ DRV_LOG(WARNING, "%s: is not supported", __func__);
+ return -ENOTSUP;
+#endif
+
+}
+
+
+
alignas(RTE_CACHE_LINE_SIZE)
const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
.version = MLX5_GLUE_VERSION,
@@ -382,4 +435,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
.query_rt_values = mlx5_glue_query_rt_values,
.devx_init_showdown_event = mlx5_glue_devx_init_showdown_event,
.devx_set_promisc_vport = mlx5_glue_devx_set_promisc_vport,
+ .devx_get_mtu = mlx5_glue_devx_get_mtu,
+ .devx_set_mtu = mlx5_glue_devx_set_mtu,
};
diff --git a/drivers/common/mlx5/windows/mlx5_glue.h b/drivers/common/mlx5/windows/mlx5_glue.h
index eae8070b3f..5ba324ebc4 100644
--- a/drivers/common/mlx5/windows/mlx5_glue.h
+++ b/drivers/common/mlx5/windows/mlx5_glue.h
@@ -93,6 +93,8 @@ struct mlx5_glue {
int (*query_rt_values)(void *ctx, void *devx_clock);
int (*devx_init_showdown_event)(void *ctx);
int (*devx_set_promisc_vport)(void *ctx, uint32_t promisc_type, uint8_t f_enable);
+ int (*devx_get_mtu)(void *ctx, uint32_t *mtu);
+ int (*devx_set_mtu)(void *ctx, uint32_t mtu);
};
extern const struct mlx5_glue *mlx5_glue;
diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
index c6315ce368..f97526580d 100644
--- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -85,6 +85,8 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[MLX5_NAMESIZE])
int
mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu)
{
+ int err;
+ uint32_t curr_mtu;
struct mlx5_priv *priv;
mlx5_context_st *context_obj;
@@ -94,7 +96,14 @@ mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu)
}
priv = dev->data->dev_private;
context_obj = (mlx5_context_st *)priv->sh->cdev->ctx;
- *mtu = context_obj->mlx5_dev.mtu_bytes;
+
+ err = mlx5_glue->devx_get_mtu(context_obj, &curr_mtu);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not get the MTU!");
+ return err;
+ }
+ *mtu = (uint16_t)curr_mtu;
+
return 0;
}
@@ -112,9 +121,23 @@ mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu)
int
mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
{
- RTE_SET_USED(dev);
- RTE_SET_USED(mtu);
- return -ENOTSUP;
+ int err;
+ struct mlx5_priv *priv;
+ mlx5_context_st *context_obj;
+
+ if (!dev) {
+ rte_errno = EINVAL;
+ return -rte_errno;
+ }
+ priv = dev->data->dev_private;
+ context_obj = (mlx5_context_st *)priv->sh->cdev->ctx;
+
+ err = mlx5_glue->devx_set_mtu(context_obj, mtu);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not set the MTU!");
+ return err;
+ }
+ return 0;
}
/*
--
2.16.1.windows.4
prev parent reply other threads:[~2022-04-10 10:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-10 10:31 [PATCH 1/2] net/mlx5: add support for set promiscuous modes " Adham Masarwah
2022-04-10 10:31 ` Adham Masarwah [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=20220410103107.66964-3-adham@nvidia.com \
--to=adham@nvidia.com \
--cc=dev@dpdk.org \
--cc=idanhac@nvidia.com \
--cc=matan@nvidia.com \
--cc=talshn@nvidia.com \
--cc=tamerh@nvidia.com \
--cc=thomas@monjalon.net \
--cc=viacheslavo@nvidia.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).