DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawen Wu <jiawenwu@trustnetic.com>
To: dev@dpdk.org
Cc: Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [dpdk-dev] [PATCH v2 13/17] net/txgbe: support to update MTU on VF device
Date: Fri,  5 Feb 2021 11:34:45 +0800	[thread overview]
Message-ID: <20210205033449.3813939-14-jiawenwu@trustnetic.com> (raw)
In-Reply-To: <20210205033449.3813939-1-jiawenwu@trustnetic.com>

Add MTU set operation for VF device.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 doc/guides/nics/features/txgbe_vf.ini |  1 +
 drivers/net/txgbe/txgbe_ethdev_vf.c   | 36 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/doc/guides/nics/features/txgbe_vf.ini b/doc/guides/nics/features/txgbe_vf.ini
index 14040070e..4c072b4a5 100644
--- a/doc/guides/nics/features/txgbe_vf.ini
+++ b/doc/guides/nics/features/txgbe_vf.ini
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Rx interrupt         = Y
+MTU update           = Y
 Jumbo frame          = Y
 Scattered Rx         = Y
 LRO                  = Y
diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c
index d5f7b21cd..8839b610d 100644
--- a/drivers/net/txgbe/txgbe_ethdev_vf.c
+++ b/drivers/net/txgbe/txgbe_ethdev_vf.c
@@ -911,6 +911,41 @@ txgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+txgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct txgbe_hw *hw;
+	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+	struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
+
+	hw = TXGBE_DEV_HW(dev);
+
+	if (mtu < RTE_ETHER_MIN_MTU ||
+			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+		return -EINVAL;
+
+	/* refuse mtu that requires the support of scattered packets when this
+	 * feature has not been enabled before.
+	 */
+	if (!(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) &&
+	    (max_frame + 2 * TXGBE_VLAN_TAG_SIZE >
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
+		return -EINVAL;
+
+	/*
+	 * When supported by the underlying PF driver, use the TXGBE_VF_SET_MTU
+	 * request of the version 2.0 of the mailbox API.
+	 * For now, use the TXGBE_VF_SET_LPE request of the version 1.0
+	 * of the mailbox API.
+	 */
+	if (txgbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
+
+	/* update max frame size */
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
+	return 0;
+}
+
 static int
 txgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
@@ -1074,6 +1109,7 @@ static const struct eth_dev_ops txgbevf_eth_dev_ops = {
 	.allmulticast_enable  = txgbevf_dev_allmulticast_enable,
 	.allmulticast_disable = txgbevf_dev_allmulticast_disable,
 	.dev_infos_get        = txgbevf_dev_info_get,
+	.mtu_set              = txgbevf_dev_set_mtu,
 	.vlan_filter_set      = txgbevf_vlan_filter_set,
 	.vlan_strip_queue_set = txgbevf_vlan_strip_queue_set,
 	.vlan_offload_set     = txgbevf_vlan_offload_set,
-- 
2.27.0




  parent reply	other threads:[~2021-02-05  3:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05  3:34 [dpdk-dev] [PATCH v2 00/17] net/txgbe: add VF driver support Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 01/17] net/txgbe: add ethdev probe and remove for VF device Jiawen Wu
2021-02-24 11:39   ` Ferruh Yigit
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 02/17] net/txgbe: add base code for VF driver Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 03/17] net/txgbe: support add and remove VF device MAC address Jiawen Wu
2021-02-24 11:40   ` Ferruh Yigit
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 04/17] net/txgbe: get VF device information Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 05/17] net/txgbe: add interrupt operation for VF device Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 06/17] net/txgbe: get link status of " Jiawen Wu
2021-02-24 11:40   ` Ferruh Yigit
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 07/17] net/txgbe: add Rx and Tx unit init for " Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 08/17] net/txgbe: add VF device stats and xstats get operation Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 09/17] net/txgbe: add VLAN handle support to VF driver Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 10/17] net/txgbe: add RSS support for VF device Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 11/17] net/txgbe: add VF device promiscuous and allmulticast mode Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 12/17] net/txgbe: support multicast MAC filter for VF driver Jiawen Wu
2021-02-05  3:34 ` Jiawen Wu [this message]
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 14/17] net/txgbe: support register dump on VF device Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 15/17] net/txgbe: start and stop " Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 16/17] net/txgbe: add some supports as PF driver implemented Jiawen Wu
2021-02-05  3:34 ` [dpdk-dev] [PATCH v2 17/17] doc: update release note for txgbe Jiawen Wu
2021-02-24 11:41   ` Ferruh Yigit

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=20210205033449.3813939-14-jiawenwu@trustnetic.com \
    --to=jiawenwu@trustnetic.com \
    --cc=dev@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).