[dpdk-dev] i40e: cannot change mtu to enable jumbo frame

Julien Meunier julien.meunier at 6wind.com
Fri Feb 12 15:08:09 CET 2016


On 02/10/2016 04:20 PM, Zhang, Helin wrote:
>
>
>> -----Original Message-----
>> From: Julien Meunier [mailto:julien.meunier at 6wind.com]
>> Sent: Wednesday, February 10, 2016 12:36 AM
>> To: Zhang, Helin <helin.zhang at intel.com>; dev at dpdk.org
>> Subject: i40e: cannot change mtu to enable jumbo frame
>> [...]
>> Does a mtu_set function will be developed soon in order to support jumbo
>> frame ?
> Yes, we will implement soon later.
> Could you help to try with max_pkt_len in port config for now?
>
> Regards,
> Helin
>

Hi,

When I stop ports, change max_pkt_len and restart ports, jumbo frame are 
accepted. I was able to forward 9k frames on a i40e card.

I wrote a quick and dirty patch in order to add minimal support of MTU 
for my test. I did not carefully study the impacts... Please advice.

---
i40e: add support of mtu configuration

Add support of MTU configuration.
Ports are stopped and then started in order to force
re-initialization of RX queues.

NOTE: This patch is still experimental.

Signed-off-by: Julien Meunier <julien.meunier at 6wind.com>
---
  drivers/net/i40e/i40e_ethdev.c | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 750206b..b4d6912 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -296,6 +296,7 @@ static int i40e_dev_queue_stats_mapping_set(struct 
rte_eth_dev *dev,
  					    uint8_t is_rx);
  static void i40e_dev_info_get(struct rte_eth_dev *dev,
  			      struct rte_eth_dev_info *dev_info);
+static int i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
  static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
  				uint16_t vlan_id,
  				int on);
@@ -439,6 +440,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
  	.xstats_reset                 = i40e_dev_stats_reset,
  	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
  	.dev_infos_get                = i40e_dev_info_get,
+	.mtu_set                      = i40e_dev_mtu_set,
  	.vlan_filter_set              = i40e_vlan_filter_set,
  	.vlan_tpid_set                = i40e_vlan_tpid_set,
  	.vlan_offload_set             = i40e_vlan_offload_set,
@@ -4681,6 +4683,37 @@ i40e_dev_rxtx_init(struct i40e_pf *pf)
  }

  static int
+i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct rte_eth_dev_info dev_info;
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	i40e_dev_info_get(dev, &dev_info);
+
+	if ((frame_size < ETHER_MIN_MTU) || (frame_size > 
dev_info.max_rx_pktlen)) {
+		PMD_DRV_LOG(ERR, "Invalid MTU\n");
+		return I40E_ERR_PARAM;
+	}
+
+	i40e_dev_stop(dev);
+	hw->adapter_stopped = 1;
+
+	/* switch to jumbo mode if needed */
+	if (frame_size > ETHER_MAX_LEN)
+		dev->data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	i40e_dev_start(dev);
+	hw->adapter_stopped = 0;
+
+	return 0;
+}
+
+static int
  i40e_vmdq_setup(struct rte_eth_dev *dev)
  {
  	struct rte_eth_conf *conf = &dev->data->dev_conf;
-- 

Regards,
-- 
Julien MEUNIER
6WIND


More information about the dev mailing list