DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v6] net/virtio: add set_mtu in virtio
@ 2016-09-21 23:11 Dey
  2016-09-21 23:22 ` Stephen Hemminger
  0 siblings, 1 reply; 17+ messages in thread
From: Dey @ 2016-09-21 23:11 UTC (permalink / raw)
  To: mark.b.kavanagh, yuanhan.liu, stephen, dev; +Cc: souvikdey33

From: souvikdey33 <sodey@sonusnet.com>


Virtio interfaces do not currently allow the user to specify a particular 
Maximum Transmission Unit (MTU).Consequently, the MTU of Virtio interfaces 
is typically set to the Ethernet default value of 1500.
This is problematic in the case of cloud deployments, in which a specific
(and potentially non-standard) MTU needs to be set by a DHCP server, which 
needs to be honored by all interfaces across the traffic path.To acheive 
this Virtio interfaces should support setting of MTU.
In case when GRE/VXLAN tunneling is used for internal communication, there 
will be an overhead added by the infrastructure in the packet over and 
above the ETHER MTU of 1518. So to take care of this overhead in these 
cases the DHCP server corrects the L3 MTU to 1454. But since virtio 
interfaces was not having the MTU set functionality that MTU sent by the 
DHCP server was ignored and the instance will still send packets with 1500 
MTU which after encapsulation will become more than 1518 and eventually 
gets dropped in the infrastructure. 
By adding an additional 'set_mtu' function to the Virtio driver, we can 
honor the MTU sent by the DHCP server. The dhcp server/controller can 
then leverage this 'set_mtu' functionality to resolve the above 
mentioned issue of packets getting dropped due to incorrect size.


Signed-off-by: Souvik Dey <sodey@sonusnet.com>

---
Changes in v6:
- Description of change corrected
- Corrected the identations
- Corrected the subject line too
- The From line was also not correct
Changes in v5: 
- Fix log message for out-of-bounds MTU parameter in virtio_mtu_set
- Calculate frame size, based on 'mtu' parameter
- Corrected the upper bound and lower bound checks in virtio_mtu_set
Changes in v4: Incorporated review comments.
Changes in v3: Corrected few style errors as reported by sys-stv.
Changes in v2: Incorporated review comments.

 drivers/net/virtio/virtio_ethdev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 423c597..1dbfea6 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
 
+
+#define VLAN_TAG_SIZE           4    /* 802.3ac tag (not DMA'd) */
+
+static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) {
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               ETHER_MIN_MTU,
+                               (dev_info.max_rx_pktlen - ether_hdr_len));
+               return -EINVAL;
+       }
+       return 0;
+}

 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
@@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.allmulticast_enable     = virtio_dev_allmulticast_enable,
 	.allmulticast_disable    = virtio_dev_allmulticast_disable,
+	.mtu_set                 = virtio_mtu_set,
 	.dev_infos_get           = virtio_dev_info_get,
 	.stats_get               = virtio_dev_stats_get,
 	.xstats_get              = virtio_dev_xstats_get,
-- 
2.9.3.windows.1

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v6] net/virtio: add set_mtu in virtio
@ 2016-09-21 21:10 Dey
  0 siblings, 0 replies; 17+ messages in thread
From: Dey @ 2016-09-21 21:10 UTC (permalink / raw)
  To: mark.b.kavanagh, yuanhan.liu, stephen, dev; +Cc: souvikdey33

From: souvikdey33 <sodey@sonusnet.com>


Virtio interfaces do not currently allow the user to specify a particular 
Maximum Transmission Unit (MTU).Consequently, the MTU of Virtio interfaces 
is typically set to the Ethernet default value of 1500.
This is problematic in the case of cloud deployments, in which a specific
(and potentially non-standard) MTU needs to be set by a DHCP server, which 
needs to be honored by all interfaces across the traffic path.To acheive 
this Virtio interfaces should support setting of MTU.
In case when GRE/VXLAN tunneling is used for internal communication, there 
will be an overhead added by the infrastructure in the packet over and 
above the ETHER MTU of 1518. So to take care of this overhead in these 
cases the DHCP server corrects the L3 MTU to 1454. But since virtio 
interfaces was not having the MTU set functionality that MTU sent by the 
DHCP server was ignored and the instance will still send packets with 1500 
MTU which after encapsulation will become more than 1518 and eventually 
gets dropped in the infrastructure. 
By adding an additional 'set_mtu' function to the Virtio driver, we can 
honor the MTU sent by the DHCP server. The dhcp server/controller can 
then leverage this 'set_mtu' functionality to resolve the above 
mentioned issue of packets getting dropped due to incorrect size.


Signed-off-by: Souvik Dey <sodey@sonusnet.com>

---
Changes in v6:
- Description of change corrected
- Corrected the identations
- Corrected the subject line too
- The From line was also not correct
Changes in v5: 
- Fix log message for out-of-bounds MTU parameter in virtio_mtu_set
- Calculate frame size, based on 'mtu' parameter
- Corrected the upper bound and lower bound checks in virtio_mtu_set
Changes in v4: Incorporated review comments.
Changes in v3: Corrected few style errors as reported by sys-stv.
Changes in v2: Incorporated review comments.

 drivers/net/virtio/virtio_ethdev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 423c597..1dbfea6 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
 
+
+#define VLAN_TAG_SIZE           4    /* 802.3ac tag (not DMA'd) */
+
+static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) {
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               ETHER_MIN_MTU,
+                               (dev_info.max_rx_pktlen - ether_hdr_len));
+               return -EINVAL;
+       }
+       return 0;
+}

 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
@@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.allmulticast_enable     = virtio_dev_allmulticast_enable,
 	.allmulticast_disable    = virtio_dev_allmulticast_disable,
+	.mtu_set                 = virtio_mtu_set,
 	.dev_infos_get           = virtio_dev_info_get,
 	.stats_get               = virtio_dev_stats_get,
 	.xstats_get              = virtio_dev_xstats_get,
-- 
2.9.3.windows.1

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v5]net/virtio: add mtu set in virtio
@ 2016-09-16 17:13 souvikdey33
  2016-09-22 13:56 ` [dpdk-dev] [PATCH v6] net/virtio: add set_mtu " Dey
  0 siblings, 1 reply; 17+ messages in thread
From: souvikdey33 @ 2016-09-16 17:13 UTC (permalink / raw)
  To: dev, stephen, yuanhan.liu, mark.b.kavanagh; +Cc: souvikdey33


Virtio interfaces should also support setting of mtu, as in case of cloud
it is expected to have the consistent mtu across the infrastructure that
the dhcp server sends and not hardcoded to 1500(default).
In case when GRE/VXLAN tunneling is used, it adds overheads to the total
size of 1518, and in that cases the DHCP server corrects the L3 MTU to 1454
to take care of the overhead. BUt since virtio interfaces was not having the 
mtu set that mtu sent by dhcp was ignored and teh instance will still send
packets with 1500 mtu which afetr encapsulation will become more than 1518 
and eventually gets dropped in the infrastructure. This issue can be solved
by honoring the mtu 1454 sent by dhcp server, which this below patch will
take care.


Changes in v5: Incorporated review comments.
Changes in v4: Incorporated review comments.
Changes in v3: Corrected few style errors as reported by sys-stv.
Changes in v2: Incorporated review comments.

Signed-off-by: Souvik Dey <sodey@sonusnet.com>

---
 drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 07d6449..da16ad4 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
                PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }

+#define VLAN_TAG_SIZE           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) {
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               (ETHER_MIN_MTU - ether_hdr_len),
+                               (dev_info.max_rx_pktlen - ether_hdr_len));
+               return -EINVAL;
+       }
+       return 0;
+}
@@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
        .allmulticast_enable     = virtio_dev_allmulticast_enable,
        .allmulticast_disable    = virtio_dev_allmulticast_disable,
+       .mtu_set                 = virtio_mtu_set,
        .dev_infos_get           = virtio_dev_info_get,
        .stats_get               = virtio_dev_stats_get,
        .xstats_get              = virtio_dev_xstats_get,
-- 
2.9.3.windows.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-09-28 15:31 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 23:11 [dpdk-dev] [PATCH v6] net/virtio: add set_mtu in virtio Dey
2016-09-21 23:22 ` Stephen Hemminger
2016-09-22  0:08   ` Dey, Souvik
2016-09-22  1:45     ` Stephen Hemminger
2016-09-22  2:29       ` Dey, Souvik
2016-09-23  7:53       ` Yuanhan Liu
2016-09-23  9:07         ` Kavanagh, Mark B
2016-09-23 15:17           ` Dey, Souvik
2016-09-26  3:21             ` Yuanhan Liu
2016-09-27 15:41               ` Dey, Souvik
2016-09-27 18:56             ` Stephen Hemminger
2016-09-27 20:44               ` Dey, Souvik
2016-09-27 23:11                 ` Yuanhan Liu
2016-09-28 15:31                   ` Dey, Souvik
2016-09-22 15:57     ` Stephen Hemminger
  -- strict thread matches above, loose matches on Subject: below --
2016-09-21 21:10 Dey
2016-09-16 17:13 [dpdk-dev] [PATCH v5]net/virtio: add mtu set " souvikdey33
2016-09-22 13:56 ` [dpdk-dev] [PATCH v6] net/virtio: add set_mtu " Dey

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).