From: Zaiyu Wang <zaiyuwang@trustnetic.com>
To: dev@dpdk.org
Cc: Zaiyu Wang <zaiyuwang@trustnetic.com>,
Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [PATCH 05/15] net/ngbe: add set MTU ops for VF device
Date: Thu, 9 Jan 2025 12:02:15 +0800 [thread overview]
Message-ID: <20250109040227.1016-6-zaiyuwang@trustnetic.com> (raw)
In-Reply-To: <20250109040227.1016-1-zaiyuwang@trustnetic.com>
Support to update MTU for VF device.
Signed-off-by: Zaiyu Wang <zaiyuwang@trustnetic.com>
---
doc/guides/nics/features/ngbe_vf.ini | 1 +
drivers/net/ngbe/base/ngbe_type.h | 1 +
drivers/net/ngbe/base/ngbe_vf.c | 24 +++++++++++++++++++
drivers/net/ngbe/base/ngbe_vf.h | 1 +
drivers/net/ngbe/ngbe_ethdev_vf.c | 36 ++++++++++++++++++++++++++++
5 files changed, 63 insertions(+)
diff --git a/doc/guides/nics/features/ngbe_vf.ini b/doc/guides/nics/features/ngbe_vf.ini
index aa628dfa97..333f02c854 100644
--- a/doc/guides/nics/features/ngbe_vf.ini
+++ b/doc/guides/nics/features/ngbe_vf.ini
@@ -4,6 +4,7 @@
; Refer to default.ini for the full list of available PMD features.
;
[Features]
+MTU update = Y
Promiscuous mode = Y
Allmulticast mode = Y
CRC offload = P
diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h
index 29dcd5f912..f780b92efa 100644
--- a/drivers/net/ngbe/base/ngbe_type.h
+++ b/drivers/net/ngbe/base/ngbe_type.h
@@ -352,6 +352,7 @@ struct ngbe_mac_info {
void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
bool enable, int vf);
s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
+ s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size);
/* Flow Control */
s32 (*fc_enable)(struct ngbe_hw *hw);
diff --git a/drivers/net/ngbe/base/ngbe_vf.c b/drivers/net/ngbe/base/ngbe_vf.c
index 918df6f0dc..2d00d5998d 100644
--- a/drivers/net/ngbe/base/ngbe_vf.c
+++ b/drivers/net/ngbe/base/ngbe_vf.c
@@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
return 0;
}
+/**
+ * ngbevf_rlpml_set_vf - Set the maximum receive packet length
+ * @hw: pointer to the HW structure
+ * @max_size: value to assign to max frame size
+ **/
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size)
+{
+ u32 msgbuf[2];
+ s32 retval;
+
+ msgbuf[0] = NGBE_VF_SET_LPE;
+ msgbuf[1] = max_size;
+
+ retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+ if (retval)
+ return retval;
+ if ((msgbuf[0] & NGBE_VF_SET_LPE) &&
+ (msgbuf[0] & NGBE_VT_MSGTYPE_NACK))
+ return NGBE_ERR_MBX;
+
+ return 0;
+}
+
/**
* ngbevf_negotiate_api_version - Negotiate supported API version
* @hw: pointer to the HW structure
@@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
mac->negotiate_api_version = ngbevf_negotiate_api_version;
mac->update_xcast_mode = ngbevf_update_xcast_mode;
+ mac->set_rlpml = ngbevf_rlpml_set_vf;
mac->max_tx_queues = 1;
mac->max_rx_queues = 1;
diff --git a/drivers/net/ngbe/base/ngbe_vf.h b/drivers/net/ngbe/base/ngbe_vf.h
index 79891e8389..a64de9d332 100644
--- a/drivers/net/ngbe/base/ngbe_vf.h
+++ b/drivers/net/ngbe/base/ngbe_vf.h
@@ -17,6 +17,7 @@ s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
s32 ngbe_reset_hw_vf(struct ngbe_hw *hw);
s32 ngbe_stop_hw_vf(struct ngbe_hw *hw);
s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
unsigned int *default_tc);
diff --git a/drivers/net/ngbe/ngbe_ethdev_vf.c b/drivers/net/ngbe/ngbe_ethdev_vf.c
index d8ece38b00..5ce0c2df98 100644
--- a/drivers/net/ngbe/ngbe_ethdev_vf.c
+++ b/drivers/net/ngbe/ngbe_ethdev_vf.c
@@ -272,6 +272,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
return 0;
}
+static int
+ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+ struct ngbe_hw *hw;
+ uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+ struct rte_eth_dev_data *dev_data = dev->data;
+
+ hw = ngbe_dev_hw(dev);
+
+ if (mtu < RTE_ETHER_MIN_MTU ||
+ max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+ return -EINVAL;
+
+ /* If device is started, refuse mtu that requires the support of
+ * scattered packets when this feature has not been enabled before.
+ */
+ if (dev_data->dev_started && !dev_data->scattered_rx &&
+ (max_frame + 2 * RTE_VLAN_HLEN >
+ dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+ PMD_INIT_LOG(ERR, "Stop port first.");
+ return -EINVAL;
+ }
+
+ /*
+ * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU
+ * request of the version 2.0 of the mailbox API.
+ * For now, use the NGBE_VF_SET_LPE request of the version 1.0
+ * of the mailbox API.
+ */
+ if (ngbevf_rlpml_set_vf(hw, max_frame))
+ return -EINVAL;
+
+ return 0;
+}
+
static int
ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
{
@@ -369,6 +404,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
.allmulticast_enable = ngbevf_dev_allmulticast_enable,
.allmulticast_disable = ngbevf_dev_allmulticast_disable,
.dev_infos_get = ngbevf_dev_info_get,
+ .mtu_set = ngbevf_dev_set_mtu,
};
RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
--
2.21.0.windows.1
next prev parent reply other threads:[~2025-01-09 4:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 4:02 [PATCH 00/15] net/ngbe: add VF driver support Zaiyu Wang
2025-01-09 4:02 ` [PATCH 01/15] net/ngbe: add ethdev probe and remove for VF device Zaiyu Wang
2025-01-09 4:02 ` [PATCH 02/15] net/ngbe: add support for PF-VF mailbox interface Zaiyu Wang
2025-01-09 4:02 ` [PATCH 03/15] net/ngbe: add hardware configuration code for VF device Zaiyu Wang
2025-01-09 4:02 ` [PATCH 04/15] net/ngbe: add promiscuous and allmulticast ops " Zaiyu Wang
2025-01-09 4:02 ` Zaiyu Wang [this message]
2025-01-09 4:02 ` [PATCH 06/15] net/ngbe: add add/remove/set mac addr " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 07/15] net/ngbe: add datapath init code " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 08/15] net/ngbe: add vlan related ops " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 09/15] net/ngbe: add interrupt support " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 10/15] net/ngbe: add link update ops " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 11/15] net/ngbe: add stats and xstats " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 12/15] net/ngbe: add start/stop/reset/close " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 13/15] net/ngbe: add multicast MAC filter " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 14/15] net/ngbe: add dump registers " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 15/15] net/ngbe: add some ops which PF has implemented Zaiyu Wang
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=20250109040227.1016-6-zaiyuwang@trustnetic.com \
--to=zaiyuwang@trustnetic.com \
--cc=dev@dpdk.org \
--cc=jiawenwu@trustnetic.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).