From: Dimon Zhao <dimon.zhao@nebula-matrix.com>
To: dimon.zhao@nebula-matrix.com, dev@dpdk.org
Cc: Kyo Liu <kyo.liu@nebula-matrix.com>,
Leon Yu <leon.yu@nebula-matrix.com>,
Sam Chen <sam.chen@nebula-matrix.com>
Subject: [PATCH v4 16/16] net/nbl: nbl device support set MTU and promisc
Date: Tue, 12 Aug 2025 23:44:10 -0700 [thread overview]
Message-ID: <20250813064410.3894506-17-dimon.zhao@nebula-matrix.com> (raw)
In-Reply-To: <20250813064410.3894506-1-dimon.zhao@nebula-matrix.com>
Implement NBL device set MTU and promisc functions
Signed-off-by: Dimon Zhao <dimon.zhao@nebula-matrix.com>
---
drivers/net/nbl/nbl_core.h | 2 +
drivers/net/nbl/nbl_dev/nbl_dev.c | 57 ++++++++++++++
drivers/net/nbl/nbl_dev/nbl_dev.h | 7 +-
drivers/net/nbl/nbl_dispatch.c | 77 +++++++++++++++++++
drivers/net/nbl/nbl_dispatch.h | 2 +
drivers/net/nbl/nbl_ethdev.c | 3 +
drivers/net/nbl/nbl_include/nbl_def_channel.h | 10 +++
.../net/nbl/nbl_include/nbl_def_dispatch.h | 1 +
.../net/nbl/nbl_include/nbl_def_resource.h | 2 +
9 files changed, 160 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nbl/nbl_core.h b/drivers/net/nbl/nbl_core.h
index 997544b112..d3fe1d02d2 100644
--- a/drivers/net/nbl/nbl_core.h
+++ b/drivers/net/nbl/nbl_core.h
@@ -51,6 +51,8 @@
#define NBL_IS_NOT_COEXISTENCE(common) ({ typeof(common) _common = (common); \
_common->nl_socket_route < 0 || \
_common->ifindex < 0; })
+#define NBL_IS_COEXISTENCE(common) ((common)->devfd != -1)
+
struct nbl_core {
void *phy_mgt;
void *res_mgt;
diff --git a/drivers/net/nbl/nbl_dev/nbl_dev.c b/drivers/net/nbl/nbl_dev/nbl_dev.c
index bab89c707f..8d1423bc14 100644
--- a/drivers/net/nbl/nbl_dev/nbl_dev.c
+++ b/drivers/net/nbl/nbl_dev/nbl_dev.c
@@ -501,6 +501,63 @@ int nbl_xstats_reset(struct rte_eth_dev *eth_dev)
return 0;
}
+int nbl_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
+{
+ struct rte_eth_dev_data *dev_data = eth_dev->data;
+ struct nbl_adapter *adapter = ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
+ struct nbl_dev_mgt *dev_mgt = NBL_ADAPTER_TO_DEV_MGT(adapter);
+ struct nbl_dispatch_ops *disp_ops = NBL_DEV_MGT_TO_DISP_OPS(dev_mgt);
+ uint32_t frame_size = mtu + NBL_ETH_OVERHEAD;
+ int ret;
+
+ /* check if mtu is within the allowed range */
+ if (mtu < RTE_ETHER_MIN_MTU || frame_size > NBL_FRAME_SIZE_MAX)
+ return -EINVAL;
+
+ /* mtu setting is forbidden if port is start */
+ if (dev_data->dev_started) {
+ NBL_LOG(ERR, "port %d must be stopped before configuration", dev_data->port_id);
+ return -EBUSY;
+ }
+
+ dev_data->dev_conf.rxmode.mtu = frame_size;
+ ret = disp_ops->set_mtu(NBL_DEV_MGT_TO_DISP_PRIV(dev_mgt), dev_mgt->net_dev->vsi_id, mtu);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+int nbl_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+ struct nbl_adapter *adapter = ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
+ struct nbl_dev_mgt *dev_mgt = NBL_ADAPTER_TO_DEV_MGT(adapter);
+ struct nbl_dispatch_ops *disp_ops = NBL_DEV_MGT_TO_DISP_OPS(dev_mgt);
+ struct nbl_common_info *common = &adapter->common;
+
+ if (!common->is_vf)
+ disp_ops->set_promisc_mode(NBL_DEV_MGT_TO_DISP_PRIV(dev_mgt),
+ dev_mgt->net_dev->vsi_id, 1);
+ dev_mgt->net_dev->promisc = 1;
+
+ return 0;
+}
+
+int nbl_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+ struct nbl_adapter *adapter = ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
+ struct nbl_dev_mgt *dev_mgt = NBL_ADAPTER_TO_DEV_MGT(adapter);
+ struct nbl_dispatch_ops *disp_ops = NBL_DEV_MGT_TO_DISP_OPS(dev_mgt);
+ struct nbl_common_info *common = &adapter->common;
+
+ if (!common->is_vf)
+ disp_ops->set_promisc_mode(NBL_DEV_MGT_TO_DISP_PRIV(dev_mgt),
+ dev_mgt->net_dev->vsi_id, 0);
+ dev_mgt->net_dev->promisc = 0;
+
+ return 0;
+}
+
struct nbl_dev_ops dev_ops = {
};
diff --git a/drivers/net/nbl/nbl_dev/nbl_dev.h b/drivers/net/nbl/nbl_dev/nbl_dev.h
index 1500a782a5..e3a7a098a5 100644
--- a/drivers/net/nbl/nbl_dev/nbl_dev.h
+++ b/drivers/net/nbl/nbl_dev/nbl_dev.h
@@ -47,7 +47,9 @@ struct nbl_dev_net_mgt {
u8 eth_mode;
u8 eth_id;
u16 max_mac_num;
- bool trust;
+ u8 trust:1;
+ u8 promisc:1;
+ u8 rsv:6;
};
struct nbl_dev_mgt {
@@ -79,5 +81,8 @@ int nbl_xstats_get_names(struct rte_eth_dev *eth_dev,
struct rte_eth_xstat_name *xstats_names,
__rte_unused unsigned int limit);
int nbl_xstats_reset(struct rte_eth_dev *eth_dev);
+int nbl_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
+int nbl_promiscuous_enable(struct rte_eth_dev *eth_dev);
+int nbl_promiscuous_disable(struct rte_eth_dev *eth_dev);
#endif
diff --git a/drivers/net/nbl/nbl_dispatch.c b/drivers/net/nbl/nbl_dispatch.c
index 15ea61d8e4..8d805e2ee6 100644
--- a/drivers/net/nbl/nbl_dispatch.c
+++ b/drivers/net/nbl/nbl_dispatch.c
@@ -897,6 +897,74 @@ static void nbl_disp_get_private_stat_data_req(void *priv, u32 eth_id, u64 *data
chan_ops->send_msg(NBL_DISP_MGT_TO_CHAN_PRIV(disp_mgt), &chan_send);
}
+static int nbl_disp_set_mtu(void *priv, u16 vsi_id, u16 mtu)
+{
+ struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv;
+ struct nbl_resource_ops *res_ops;
+ int ret = 0;
+
+ res_ops = NBL_DISP_MGT_TO_RES_OPS(disp_mgt);
+ ret = NBL_OPS_CALL(res_ops->set_mtu, (NBL_DISP_MGT_TO_RES_PRIV(disp_mgt), vsi_id, mtu));
+ return ret;
+}
+
+static int nbl_disp_chan_set_mtu_req(void *priv, u16 vsi_id, u16 mtu)
+{
+ struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv;
+ struct nbl_channel_ops *chan_ops = NBL_DISP_MGT_TO_CHAN_OPS(disp_mgt);
+ struct nbl_chan_send_info chan_send = {0};
+ struct nbl_chan_param_set_mtu param = {0};
+
+ param.mtu = mtu;
+ param.vsi_id = vsi_id;
+
+ NBL_CHAN_SEND(chan_send, 0, NBL_CHAN_MSG_MTU_SET,
+ ¶m, sizeof(param), NULL, 0, 1);
+ return chan_ops->send_msg(NBL_DISP_MGT_TO_CHAN_PRIV(disp_mgt),
+ &chan_send);
+}
+
+static int nbl_disp_set_promisc_mode(void *priv, u16 vsi_id, u16 mode)
+{
+ struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv;
+ struct nbl_resource_ops *res_ops;
+ int ret = 0;
+
+ res_ops = NBL_DISP_MGT_TO_RES_OPS(disp_mgt);
+ ret = NBL_OPS_CALL(res_ops->set_promisc_mode,
+ (NBL_DISP_MGT_TO_RES_PRIV(disp_mgt), vsi_id, mode));
+ return ret;
+}
+
+static int nbl_disp_chan_set_promisc_mode_req(void *priv, u16 vsi_id, u16 mode)
+{
+ struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv;
+ struct nbl_common_info *common;
+ struct nbl_channel_ops *chan_ops;
+ struct nbl_chan_param_set_promisc_mode param = {0};
+ struct nbl_chan_send_info chan_send = {0};
+ int ret = 0;
+
+ common = NBL_DISP_MGT_TO_COMMON(disp_mgt);
+ if (NBL_IS_COEXISTENCE(common)) {
+ ret = ioctl(common->devfd, NBL_DEV_USER_SET_PROMISC_MODE, &mode);
+ if (ret) {
+ NBL_LOG(ERR, "userspace send set_promisc_mode ioctl msg failed ret %d",
+ ret);
+ return ret;
+ }
+ return 0;
+ }
+
+ chan_ops = NBL_DISP_MGT_TO_CHAN_OPS(disp_mgt);
+ param.vsi_id = vsi_id;
+ param.mode = mode;
+ NBL_CHAN_SEND(chan_send, 0, NBL_CHAN_MSG_SET_PROSISC_MODE,
+ ¶m, sizeof(param), NULL, 0, 1);
+ return chan_ops->send_msg(NBL_DISP_MGT_TO_CHAN_PRIV(disp_mgt),
+ &chan_send);
+}
+
#define NBL_DISP_OPS_TBL \
do { \
NBL_DISP_SET_OPS(configure_msix_map, nbl_disp_configure_msix_map, \
@@ -1067,6 +1135,14 @@ do { \
NBL_DISP_CTRL_LVL_MGT, \
NBL_CHAN_MSG_GET_ETH_STATS, \
nbl_disp_get_private_stat_data_req, NULL); \
+ NBL_DISP_SET_OPS(set_promisc_mode, nbl_disp_set_promisc_mode, \
+ NBL_DISP_CTRL_LVL_MGT, \
+ NBL_CHAN_MSG_SET_PROSISC_MODE, \
+ nbl_disp_chan_set_promisc_mode_req, NULL); \
+ NBL_DISP_SET_OPS(set_mtu, nbl_disp_set_mtu, \
+ NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_MTU_SET, \
+ nbl_disp_chan_set_mtu_req, \
+ NULL); \
} while (0)
/* Structure starts here, adding an op should not modify anything below */
@@ -1182,6 +1258,7 @@ int nbl_disp_init(void *p)
NBL_DISP_MGT_TO_RES_OPS_TBL(*disp_mgt) = res_ops_tbl;
NBL_DISP_MGT_TO_CHAN_OPS_TBL(*disp_mgt) = chan_ops_tbl;
NBL_DISP_MGT_TO_DISP_OPS_TBL(*disp_mgt) = *disp_ops_tbl;
+ NBL_DISP_MGT_TO_COMMON(*disp_mgt) = NBL_ADAPTER_TO_COMMON(adapter);
if (disp_product_ops->dispatch_init) {
ret = disp_product_ops->dispatch_init(*disp_mgt);
diff --git a/drivers/net/nbl/nbl_dispatch.h b/drivers/net/nbl/nbl_dispatch.h
index dcdf87576a..d1572769fe 100644
--- a/drivers/net/nbl/nbl_dispatch.h
+++ b/drivers/net/nbl/nbl_dispatch.h
@@ -16,11 +16,13 @@
#define NBL_DISP_MGT_TO_DISP_OPS_TBL(disp_mgt) ((disp_mgt)->disp_ops_tbl)
#define NBL_DISP_MGT_TO_DISP_OPS(disp_mgt) (NBL_DISP_MGT_TO_DISP_OPS_TBL(disp_mgt)->ops)
#define NBL_DISP_MGT_TO_DISP_PRIV(disp_mgt) (NBL_DISP_MGT_TO_DISP_OPS_TBL(disp_mgt)->priv)
+#define NBL_DISP_MGT_TO_COMMON(disp_mgt) ((disp_mgt)->common)
struct nbl_dispatch_mgt {
struct nbl_resource_ops_tbl *res_ops_tbl;
struct nbl_channel_ops_tbl *chan_ops_tbl;
struct nbl_dispatch_ops_tbl *disp_ops_tbl;
+ struct nbl_common_info *common;
uint32_t ctrl_lvl;
};
diff --git a/drivers/net/nbl/nbl_ethdev.c b/drivers/net/nbl/nbl_ethdev.c
index 81b8946acc..d1c5f898b7 100644
--- a/drivers/net/nbl/nbl_ethdev.c
+++ b/drivers/net/nbl/nbl_ethdev.c
@@ -45,6 +45,9 @@ const struct eth_dev_ops nbl_eth_dev_ops = {
.xstats_get = nbl_xstats_get,
.xstats_get_names = nbl_xstats_get_names,
.xstats_reset = nbl_xstats_reset,
+ .mtu_set = nbl_mtu_set,
+ .promiscuous_enable = nbl_promiscuous_enable,
+ .promiscuous_disable = nbl_promiscuous_disable,
};
static int nbl_eth_dev_init(struct rte_eth_dev *eth_dev)
diff --git a/drivers/net/nbl/nbl_include/nbl_def_channel.h b/drivers/net/nbl/nbl_include/nbl_def_channel.h
index 39050a3999..86726177ed 100644
--- a/drivers/net/nbl/nbl_include/nbl_def_channel.h
+++ b/drivers/net/nbl/nbl_include/nbl_def_channel.h
@@ -422,6 +422,16 @@ enum nbl_chan_queue_state {
NBL_CHAN_STATE_NBITS
};
+struct nbl_chan_param_set_promisc_mode {
+ u16 vsi_id;
+ u16 mode;
+};
+
+struct nbl_chan_param_set_mtu {
+ u16 vsi_id;
+ u16 mtu;
+};
+
struct nbl_channel_ops {
int (*send_msg)(void *priv, struct nbl_chan_send_info *chan_send);
int (*send_ack)(void *priv, struct nbl_chan_ack_info *chan_ack);
diff --git a/drivers/net/nbl/nbl_include/nbl_def_dispatch.h b/drivers/net/nbl/nbl_include/nbl_def_dispatch.h
index f38a10e5f4..717b92ac8f 100644
--- a/drivers/net/nbl/nbl_include/nbl_def_dispatch.h
+++ b/drivers/net/nbl/nbl_include/nbl_def_dispatch.h
@@ -37,6 +37,7 @@ struct nbl_dispatch_ops {
void (*clear_flow)(void *priv, u16 vsi_id);
void (*get_firmware_version)(void *priv, char *firmware_version, u8 max_len);
int (*set_promisc_mode)(void *priv, u16 vsi_id, u16 mode);
+ int (*set_mtu)(void *priv, u16 vsi_id, u16 mtu);
int (*alloc_txrx_queues)(void *priv, u16 vsi_id, u16 queue_num);
void (*free_txrx_queues)(void *priv, u16 vsi_id);
u16 (*get_vsi_id)(void *priv);
diff --git a/drivers/net/nbl/nbl_include/nbl_def_resource.h b/drivers/net/nbl/nbl_include/nbl_def_resource.h
index 5b32506be1..a7794f314c 100644
--- a/drivers/net/nbl/nbl_include/nbl_def_resource.h
+++ b/drivers/net/nbl/nbl_include/nbl_def_resource.h
@@ -76,6 +76,8 @@ struct nbl_resource_ops {
int (*setup_cqs)(void *priv, u16 vsi_id, u16 real_qps, bool rss_indir_set);
void (*remove_cqs)(void *priv, u16 vsi_id);
void (*get_link_state)(void *priv, u8 eth_id, struct nbl_eth_link_info *eth_link_info);
+ int (*set_promisc_mode)(void *priv, u16 vsi_id, u16 mode);
+ int (*set_mtu)(void *priv, u16 vsi_id, u16 mtu);
};
struct nbl_resource_ops_tbl {
--
2.34.1
next prev parent reply other threads:[~2025-08-13 6:46 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 1:40 [PATCH v3 00/16] NBL PMD for Nebulamatrix NICs dimon.zhao
2025-06-27 1:40 ` [PATCH v3 01/16] net/nbl: add doc and minimum nbl build framework dimon.zhao
2025-06-27 1:40 ` [PATCH v3 02/16] net/nbl: add simple probe/remove and log module dimon.zhao
2025-06-27 1:40 ` [PATCH v3 03/16] net/nbl: add PHY layer definitions and implementation dimon.zhao
2025-06-27 1:40 ` [PATCH v3 04/16] net/nbl: add Channel " dimon.zhao
2025-06-27 1:40 ` [PATCH v3 05/16] net/nbl: add Resource " dimon.zhao
2025-06-27 1:40 ` [PATCH v3 06/16] net/nbl: add Dispatch " dimon.zhao
2025-06-27 1:40 ` [PATCH v3 07/16] net/nbl: add Dev " dimon.zhao
2025-06-27 1:40 ` [PATCH v3 08/16] net/nbl: add complete device init and uninit functionality dimon.zhao
2025-06-27 1:40 ` [PATCH v3 09/16] net/nbl: add UIO and VFIO mode for nbl dimon.zhao
2025-06-27 1:40 ` [PATCH v3 10/16] net/nbl: add nbl coexistence " dimon.zhao
2025-06-27 1:40 ` [PATCH v3 11/16] net/nbl: add nbl ethdev configuration dimon.zhao
2025-06-27 1:40 ` [PATCH v3 12/16] net/nbl: add nbl device rxtx queue setup and release ops dimon.zhao
2025-06-27 1:40 ` [PATCH v3 13/16] net/nbl: add nbl device start and stop ops dimon.zhao
2025-06-27 1:40 ` [PATCH v3 14/16] net/nbl: add nbl device Tx and Rx burst dimon.zhao
2025-06-27 1:40 ` [PATCH v3 15/16] net/nbl: add nbl device xstats and stats dimon.zhao
2025-06-27 1:40 ` [PATCH v3 16/16] net/nbl: nbl device support set MTU and promisc dimon.zhao
2025-06-27 21:07 ` [PATCH v3 00/16] NBL PMD for Nebulamatrix NICs Stephen Hemminger
2025-06-27 21:40 ` Thomas Monjalon
2025-08-13 6:43 ` [PATCH v4 " Dimon Zhao
2025-08-13 6:43 ` [PATCH v4 01/16] net/nbl: add doc and minimum nbl build framework Dimon Zhao
2025-08-13 14:43 ` Stephen Hemminger
2025-08-13 6:43 ` [PATCH v4 02/16] net/nbl: add simple probe/remove and log module Dimon Zhao
2025-08-13 6:43 ` [PATCH v4 03/16] net/nbl: add PHY layer definitions and implementation Dimon Zhao
2025-08-13 9:30 ` Ivan Malov
2025-08-13 14:19 ` Stephen Hemminger
2025-08-13 6:43 ` [PATCH v4 04/16] net/nbl: add Channel " Dimon Zhao
2025-08-13 9:54 ` Ivan Malov
2025-08-13 14:21 ` Stephen Hemminger
2025-08-13 14:22 ` Stephen Hemminger
2025-08-13 14:25 ` Stephen Hemminger
2025-08-13 14:28 ` Stephen Hemminger
2025-08-13 6:43 ` [PATCH v4 05/16] net/nbl: add Resource " Dimon Zhao
2025-08-13 6:44 ` [PATCH v4 06/16] net/nbl: add Dispatch " Dimon Zhao
2025-08-13 6:44 ` [PATCH v4 07/16] net/nbl: add Dev " Dimon Zhao
2025-08-13 10:12 ` Ivan Malov
2025-08-13 6:44 ` [PATCH v4 08/16] net/nbl: add complete device init and uninit functionality Dimon Zhao
2025-08-13 6:44 ` [PATCH v4 09/16] net/nbl: add UIO and VFIO mode for nbl Dimon Zhao
2025-08-13 6:44 ` [PATCH v4 10/16] net/nbl: add nbl coexistence " Dimon Zhao
2025-08-13 10:35 ` Ivan Malov
2025-08-13 6:44 ` [PATCH v4 11/16] net/nbl: add nbl ethdev configuration Dimon Zhao
2025-08-13 10:40 ` Ivan Malov
2025-08-13 6:44 ` [PATCH v4 12/16] net/nbl: add nbl device rxtx queue setup and release ops Dimon Zhao
2025-08-13 12:00 ` Ivan Malov
2025-08-13 6:44 ` [PATCH v4 13/16] net/nbl: add nbl device start and stop ops Dimon Zhao
2025-08-13 6:44 ` [PATCH v4 14/16] net/nbl: add nbl device Tx and Rx burst Dimon Zhao
2025-08-13 11:31 ` Ivan Malov
2025-08-13 6:44 ` [PATCH v4 15/16] net/nbl: add nbl device xstats and stats Dimon Zhao
2025-08-13 11:48 ` Ivan Malov
2025-08-13 14:27 ` Stephen Hemminger
2025-08-13 6:44 ` Dimon Zhao [this message]
2025-08-13 12:06 ` [PATCH v4 16/16] net/nbl: nbl device support set MTU and promisc Ivan Malov
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=20250813064410.3894506-17-dimon.zhao@nebula-matrix.com \
--to=dimon.zhao@nebula-matrix.com \
--cc=dev@dpdk.org \
--cc=kyo.liu@nebula-matrix.com \
--cc=leon.yu@nebula-matrix.com \
--cc=sam.chen@nebula-matrix.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).