diff mbox

[ovs-dev] netdev-dpdk: use rte_eth_dev_set_mtu

Message ID 1497009266-154494-1-git-send-email-mark.b.kavanagh@intel.com
State Superseded
Headers show

Commit Message

Mark Kavanagh June 9, 2017, 11:54 a.m. UTC
DPDK provides an API to set the MTU of compatible physical devices -
rte_eth_dev_set_mtu(). Prior to DPDK v16.07 however, this API was not
implemented in some DPDK PMDs (i40e, specifically). To allow the use
of jumbo frames with affected NICs in OvS-DPDK, MTU configuration was
achieved by setting the jumbo frame flag, and corresponding maximum
permitted Rx frame size, in an rte_eth_conf structure for the NIC
port, and subsequently invoking rte_eth_dev_configure() with that
configuration.

However, that method does not set the MTU field of the underlying DPDK
structure (rte_eth_dev) for the corresponding physical device;
consequently, rte_eth_dev_get_mtu() reports the incorrect MTU for an
OvS-DPDK phy device with non-standard MTU.

Resolve this issue by invoking rte_eth_dev_set_mtu() when setting up
or modifying the MTU of a DPDK phy port.

Fixes: 0072e93 ("netdev-dpdk: add support for jumbo frames")
Reported-by: Vipin Varghese <vipin.varghese@intel.com>
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
---
 lib/netdev-dpdk.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Aaron Conole June 9, 2017, 7:25 p.m. UTC | #1
Hi Mark,

Mark Kavanagh <mark.b.kavanagh@intel.com> writes:

> DPDK provides an API to set the MTU of compatible physical devices -
> rte_eth_dev_set_mtu(). Prior to DPDK v16.07 however, this API was not
> implemented in some DPDK PMDs (i40e, specifically). To allow the use
> of jumbo frames with affected NICs in OvS-DPDK, MTU configuration was
> achieved by setting the jumbo frame flag, and corresponding maximum
> permitted Rx frame size, in an rte_eth_conf structure for the NIC
> port, and subsequently invoking rte_eth_dev_configure() with that
> configuration.
>
> However, that method does not set the MTU field of the underlying DPDK
> structure (rte_eth_dev) for the corresponding physical device;
> consequently, rte_eth_dev_get_mtu() reports the incorrect MTU for an
> OvS-DPDK phy device with non-standard MTU.
>
> Resolve this issue by invoking rte_eth_dev_set_mtu() when setting up
> or modifying the MTU of a DPDK phy port.
>
> Fixes: 0072e93 ("netdev-dpdk: add support for jumbo frames")
> Reported-by: Vipin Varghese <vipin.varghese@intel.com>
> Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
> ---

I think I should also get a reported-by tag for this ;) :

https://mail.openvswitch.org/pipermail/ovs-dev/2016-January/308828.html

I should have probably not claimed that it wasn't a show-stopper.  I
also don't see the comment I requested you to add that would warn us to
revisit this in the future :(

I will carve out some time to apply and test this.  Thanks Mark.

-Aaron
Mark Kavanagh June 12, 2017, 9:48 a.m. UTC | #2
>From: Aaron Conole [mailto:aconole@redhat.com]
>Sent: Friday, June 9, 2017 8:26 PM
>To: Kavanagh, Mark B <mark.b.kavanagh@intel.com>
>Cc: ovs-dev@openvswitch.org; Varghese, Vipin <vipin.varghese@intel.com>
>Subject: Re: [ovs-dev] [PATCH] netdev-dpdk: use rte_eth_dev_set_mtu
>
>Hi Mark,
>
>Mark Kavanagh <mark.b.kavanagh@intel.com> writes:
>
>> DPDK provides an API to set the MTU of compatible physical devices -
>> rte_eth_dev_set_mtu(). Prior to DPDK v16.07 however, this API was not
>> implemented in some DPDK PMDs (i40e, specifically). To allow the use
>> of jumbo frames with affected NICs in OvS-DPDK, MTU configuration was
>> achieved by setting the jumbo frame flag, and corresponding maximum
>> permitted Rx frame size, in an rte_eth_conf structure for the NIC
>> port, and subsequently invoking rte_eth_dev_configure() with that
>> configuration.
>>
>> However, that method does not set the MTU field of the underlying DPDK
>> structure (rte_eth_dev) for the corresponding physical device;
>> consequently, rte_eth_dev_get_mtu() reports the incorrect MTU for an
>> OvS-DPDK phy device with non-standard MTU.
>>
>> Resolve this issue by invoking rte_eth_dev_set_mtu() when setting up
>> or modifying the MTU of a DPDK phy port.
>>
>> Fixes: 0072e93 ("netdev-dpdk: add support for jumbo frames")
>> Reported-by: Vipin Varghese <vipin.varghese@intel.com>
>> Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
>> ---
>
>I think I should also get a reported-by tag for this ;) :

Hey Aaron,

You definitely have a much better memory than me ;)

I pushed this patch in response to a request from Vipin, who flagged an issue he encountered with rte_eth_dev_get_mtu() last week.
You're completely right though, you did point it out way back in January of last year - apologies for the oversight, I'll add a reported-by tag for you in v2.

>
>https://mail.openvswitch.org/pipermail/ovs-dev/2016-January/308828.html
>
>I should have probably not claimed that it wasn't a show-stopper.  I
>also don't see the comment I requested you to add that would warn us to
>revisit this in the future :(

I did add that comment in V3 of the patch, but removed it again in V4: https://mail.openvswitch.org/pipermail/ovs-dev/2016-February/309599.html.

In V4, the implementation of dpdk_buf_size changed completely:

	== V3 ==
	static uint32_t
	dpdk_buf_size(struct netdev_dpdk *netdev, int frame_len)
	{
	    struct rte_eth_dev_info info;
	    uint32_t buf_size;
	    /* XXX: This is a workaround for DPDK v2.2, and needs to be refactored with a
	     * future DPDK release. */
	    uint32_t len = frame_len + (2 * DPDK_VLAN_TAG_LEN);
	
	    if(netdev->type == DPDK_DEV_ETH) {
	        rte_eth_dev_info_get(netdev->port_id, &info);
	        buf_size = (info.min_rx_bufsize == 0) ?
	                   NETDEV_DPDK_DEFAULT_RX_BUFSIZE :
	                   info.min_rx_bufsize;
	    } else {
	        buf_size = NETDEV_DPDK_DEFAULT_RX_BUFSIZE;
	    }
	
	    if(len % buf_size) {
	        len = buf_size * ((len/buf_size) + 1);
	    }
	
	    return len;
	}
	
	== V4 ==
	static uint32_t
	dpdk_buf_size(int mtu)
	{
	    return ROUND_UP((MTU_TO_MAX_FRAME_LEN(mtu) + RTE_PKTMBUF_HEADROOM),
		                     NETDEV_DPDK_MBUF_ALIGN);
	}

In replacing the function body, I omitted to include the comment, which is on me - sorry about that... :( 

Thanks,
Mark

>
>I will carve out some time to apply and test this.  Thanks Mark.
>
>-Aaron
diff mbox

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 810800e..fbf6aa6 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -649,13 +649,6 @@  dpdk_eth_dev_queue_setup(struct netdev_dpdk *dev, int n_rxq, int n_txq)
     int i;
     struct rte_eth_conf conf = port_conf;
 
-    if (dev->mtu > ETHER_MTU) {
-        conf.rxmode.jumbo_frame = 1;
-        conf.rxmode.max_rx_pkt_len = dev->max_packet_len;
-    } else {
-        conf.rxmode.jumbo_frame = 0;
-        conf.rxmode.max_rx_pkt_len = 0;
-    }
     conf.rxmode.hw_ip_checksum = (dev->hw_ol_features &
                                   NETDEV_RX_CHECKSUM_OFFLOAD) != 0;
     /* A device may report more queues than it makes available (this has
@@ -675,6 +668,13 @@  dpdk_eth_dev_queue_setup(struct netdev_dpdk *dev, int n_rxq, int n_txq)
             break;
         }
 
+        diag = rte_eth_dev_set_mtu(dev->port_id, dev->mtu);
+        if (diag) {
+            VLOG_INFO("Interface %s MTU (%d) setup error: %s",
+                    dev->up.name, dev->mtu, rte_strerror(-diag));
+            break;
+        }
+
         for (i = 0; i < n_txq; i++) {
             diag = rte_eth_tx_queue_setup(dev->port_id, i, dev->txq_size,
                                           dev->socket_id, NULL);