Skip to contentSkip to conversation

net/virtio: add mtu set in virtio

PATCH Superseded souvikdey33 3 participants 19 messages Sep 7, 2016 – Sep 21, 2016 Network drivers

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 net/virtio: add mtu set in virtio

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

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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +12 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,
 static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 static void virtio_mac_addr_set(struct rte_eth_dev *dev,
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev,
@@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");
+		return -EINVAL;
+	}
+	return 0;
+}
+
 /*
  * dev_ops for virtio, bare necessities for basic operation

*/
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {

 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,

Signature · 1 line
2.9.3.windows.1
#1 lore raw

Hi Liu,
Submitted the version 4 of the patch as you suggested , and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for other eth_dev_ops.

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

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

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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,  static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);  static void virtio_mac_addr_set(struct rte_eth_dev *dev,
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 

+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+ struct virtio_hw *hw = dev->data->dev_private;
+ if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+ PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
/*
* dev_ops for virtio, bare necessities for basic operation */
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {

 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--
2.9.3.windows.1

#2 lore raw
Quoted 2 lines · Souvik

Hi Liu,
Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 2 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 12 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 5 lines

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

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply. In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 10 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,  static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);  static void virtio_mac_addr_set(struct rte_eth_dev *dev,
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

	--yliu
#3 lore raw

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed patch. Thanks for the help though.

---
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+ if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+ PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
/*
* dev_ops for virtio, bare necessities for basic operation */
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {

 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--

--
Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 2 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 5 lines

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

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply. In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 11 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,  static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);  static void virtio_mac_addr_set(struct rte_eth_dev *dev,
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

	--yliu
#4 lore raw
Quoted 17 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed patch. Thanks for the help though.

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +6 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Why hardcode the values in the PMD_INIT_LOG?

Why not do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

							 VIRTIO_MIN_RX_BUFSIZE,
					            VIRTIO_MAX_RX_PKTLEN);

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 106 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+		return -EINVAL;
+	}
+	return 0;
+}
+

/*
* dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--
 
--

Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 2 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 1 line

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply. In another word, we don't like to see those change log in git history, but we'd like to see them while review.

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void

Quoted 9 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void · line 96

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void

Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

	--yliu
#5 lore raw

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU. Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud environments.

---
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set(
__rte_unused struct rte_eth_dev *eth_dev,
@@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
}

+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+ if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+ PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and VIRTIO_MAX_RX_PKTLEN \n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
/*
* dev_ops for virtio, bare necessities for basic operation */
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {

 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--

--
Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 18 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it
is not really required.
So the latest patch will look like this . Yes I did rush a bit to
submit the patch last will correct my suite. So sending the patch in a
reply if we have more comments we can take a look and they re-submit the final reviewed patch. Thanks for the help though.

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Why hardcode the values in the PMD_INIT_LOG?

Why not do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

							 VIRTIO_MIN_RX_BUFSIZE,
					            VIRTIO_MAX_RX_PKTLEN);

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 109 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+		return -EINVAL;
+	}
+	return 0;
+}
+

/*
* dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--
 
--

Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply. In another word, we don't like to see those change log in git history,
but we'd like to see them while review.

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev · line 92

Quoted 10 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev 
 *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev · line 97

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev

Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

	--yliu
#6 lore raw
Quoted 17 lines · Souvik

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU. Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud environments.

---
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set(

drivers/net/virtio/virtio_ethdev.c +0 -0
 	__rte_unused struct rte_eth_dev *eth_dev,

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 661

Quoted 9 lines
drivers/net/virtio/virtio_ethdev.c +6 -0
@@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and VIRTIO_MAX_RX_PKTLEN \n");

Unfortunately, that is still broken, in two ways:

- we should avoid long lines over 80 chars

- the range will not be correctly showed in the message, because ... (well, you know it).

	--yliu
#7 lore raw
In reply to Dey, Souvik
Quoted 21 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU. Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud environments.

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set(
__rte_unused struct rte_eth_dev *eth_dev,

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 660

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
@@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account of L2 overhead before performing the comparison above.
Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size is L2_HDR_LEN + 9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 662

Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
+		PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and
 VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all caps) </micronit>

Hope this helps,
Mark

Quoted 176 lines
drivers/net/virtio/virtio_ethdev.c +6 -2
+		return -EINVAL;
+	}
+	return 0;
+}
+
 /*
 * dev_ops for virtio, bare necessities for basic operation
 */
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--
 
--

Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 8 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to
submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Why hardcode the values in the PMD_INIT_LOG?

Why not do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

							 VIRTIO_MIN_RX_BUFSIZE,
					            VIRTIO_MAX_RX_PKTLEN);

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 109 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+		return -EINVAL;
+	}
+	return 0;
+}
+

/*
* dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.promiscuous_disable     = virtio_dev_promiscuous_disable,
 	.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,
--
 
--

Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply. In another word, we don't like to see those change log in git history,
but we'd like to see them while review.

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev · line 92

Quoted 10 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev
 *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev · line 97

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
 				struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static int virtio_dev_queue_stats_mapping_set(
 	__rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev

Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 		PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+	struct virtio_hw *hw = dev->data->dev_private;
+	if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+		PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

	--yliu
#8 lore raw

Hi Mark/Liu,

Thanks to both of you for being so patient with a series of silly errors. I have tried to make it better this time. Also there were some un-used variable in the function which I have removed. Please check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

One doubt though,

"9728 is the largest L2 frame size allowed by the NIC" -- this 9728 size is some constrain due to DPDK as the virtio driver in the kernel can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to 9728.

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

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

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_LEN 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_LEN;

+ uint32_t frame_size = mtu + ether_hdr_len;

+

+ virtio_dev_info_get(dev, &dev_info);

+

+ if (mtu < dev_info.min_rx_bufsize || frame_size > dev_info.max_rx_pktlen) {

+ PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",

+ dev_info.min_rx_bufsize,

+ (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,

--

Regards,

Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 48 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it .

Thanks.

The MTU here is L3 MTU. Setting this will help in reducing the

fragmented/multi-segmented packets and also in case we want to reduce

the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud environments.

---

drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

static int virtio_dev_queue_stats_mapping_set(

           __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

                          PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

Review

Quoted 7 lines
(quoted diff) +4 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+          struct virtio_hw *hw = dev->data->dev_private;
 
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account of L2 overhead before performing the comparison above.

Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size is L2_HDR_LEN + 9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

Quoted 3 lines

+ PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and

VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:

1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines

2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all caps) </micronit>

Hope this helps,

Mark

Quoted 355 lines
(quoted diff) +5 -0
+                        return -EINVAL;
 
+          }
 
+          return 0;
 
+}
 
+

/*

* dev_ops for virtio, bare necessities for basic operation

*/

(quoted diff) +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 
           .promiscuous_disable     = virtio_dev_promiscuous_disable,
 
           .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,
 
--
 
 
 
--

Regards,

Souvik

-----Original Message-----

From: Kavanagh, Mark B [mailto:[email protected]]

Sent: Friday, September 9, 2016 11:05 AM

To: Dey, Souvik <[email protected]<mailto:[email protected]>>; Yuanhan Liu

<[email protected]<mailto:[email protected]>>

Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 10 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as

it is not really required.

Quoted 7 lines

So the latest patch will look like this . Yes I did rush a bit to

submit the patch last will correct my suite. So sending the patch in a

reply if we have more comments we can take a look and they re-submit

the final reviewed

patch. Thanks for the help though.

Quoted 22 lines

---

drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

Review

Quoted 9 lines
(quoted diff) +5 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+        struct virtio_hw *hw = dev->data->dev_private;
 
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
 
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Why hardcode the values in the PMD_INIT_LOG?

Why not do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

                                                                                                  VIRTIO_MIN_RX_BUFSIZE,

                                                                                 VIRTIO_MAX_RX_PKTLEN);

That way, if the values that the macros evaluate to change, the log

will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 217 lines
(quoted diff) +5 -0
+                      return -EINVAL;
 
+        }
 
+        return 0;
 
+}
 
+

/*

* dev_ops for virtio, bare necessities for basic operation

*/

(quoted diff) +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 
         .promiscuous_disable     = virtio_dev_promiscuous_disable,
 
         .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,
 
--
 
 
 
--

Regards,

Souvik

-----Original Message-----

From: Yuanhan Liu [mailto:[email protected]]

Sent: Friday, September 9, 2016 3:00 AM

To: Dey, Souvik <[email protected]<mailto:[email protected]>>

Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 3 lines · Souvik

Hi Liu,

Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 5 lines

and have removed the Reviewed by line.

I have still kept the function definition as to follow the same suit

as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the

reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree

with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 26 lines

--

Regards,

Souvik

-----Original Message-----

From: Dey, Souvik

Sent: Wednesday, September 7, 2016 12:19 AM

To: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>;

[email protected]<mailto:[email protected]>

Cc Dey, Souvik <[email protected]<mailto:[email protected]>>

Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 3 lines

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

Quoted 7 lines

Changes in v4: Incorporated review comments.

Changes in v3: Corrected few style errors as reported by sys-stv.

Changes in v2: Incorporated review comments.

DPDK prefers to put the change log to ...

Quoted 7 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply.

In another word, we don't like to see those change log in git history,

but we'd like to see them while review.

Quoted 17 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

Review static void virtio_mac_addr_add(struct rte_eth_dev · line 93

Quoted 2 lines
(quoted diff) +0 -0
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev
 
 *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);

static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 9 lines
(quoted diff) +1 -0
                                                  struct ether_addr *mac_addr);
 
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 

static int virtio_dev_queue_stats_mapping_set(

       __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

Review

Quoted 13 lines
                     PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
(quoted diff) +5 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+     struct virtio_hw *hw = dev->data->dev_private;
 
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
 
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

         --yliu
#9 lore raw

Hi All,
Any further comments or updates to be made in the below patch else I will go ahead a submit the v5 for the same.

--
Regards,
Souvik

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Dey, Souvik
Sent: Friday, September 9, 2016 2:16 PM
To: Kavanagh, Mark B <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4]net/virtio: add mtu set in virtio

Hi Mark/Liu,

Thanks to both of you for being so patient with a series of silly errors. I have tried to make it better this time. Also there were some un-used variable in the function which I have removed. Please check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

One doubt though,

"9728 is the largest L2 frame size allowed by the NIC" -- this 9728 size is some constrain due to DPDK as the virtio driver in the kernel can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to 9728.

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

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

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_LEN 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_LEN;

+ uint32_t frame_size = mtu + ether_hdr_len;

+

+ virtio_dev_info_get(dev, &dev_info);

+

+ if (mtu < dev_info.min_rx_bufsize || frame_size > dev_info.max_rx_pktlen) {

+ PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",

+ dev_info.min_rx_bufsize,

+ (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,

--

Regards,

Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 48 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it .

Thanks.

The MTU here is L3 MTU. Setting this will help in reducing the

fragmented/multi-segmented packets and also in case we want to reduce

the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud environments.

---

drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

static int virtio_dev_queue_stats_mapping_set(

           __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

                          PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

Review

Quoted 7 lines
(quoted diff) +4 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+          struct virtio_hw *hw = dev->data->dev_private;
 
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account of L2 overhead before performing the comparison above.

Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size is L2_HDR_LEN + 9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

Quoted 3 lines

+ PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and

VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:

1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines

2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all caps) </micronit>

Hope this helps,

Mark

Quoted 355 lines
(quoted diff) +5 -0
+                        return -EINVAL;
 
+          }
 
+          return 0;
 
+}
 
+

/*

* dev_ops for virtio, bare necessities for basic operation

*/

(quoted diff) +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 
           .promiscuous_disable     = virtio_dev_promiscuous_disable,
 
           .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,
 
--
 
 
 
--

Regards,

Souvik

-----Original Message-----

From: Kavanagh, Mark B [mailto:[email protected]]

Sent: Friday, September 9, 2016 11:05 AM

To: Dey, Souvik <[email protected]<mailto:[email protected]>>; Yuanhan Liu

<[email protected]<mailto:[email protected]>>

Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 10 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as

it is not really required.

Quoted 7 lines

So the latest patch will look like this . Yes I did rush a bit to

submit the patch last will correct my suite. So sending the patch in a

reply if we have more comments we can take a look and they re-submit

the final reviewed

patch. Thanks for the help though.

Quoted 22 lines

---

drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

Review

Quoted 9 lines
(quoted diff) +5 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+        struct virtio_hw *hw = dev->data->dev_private;
 
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
 
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Why hardcode the values in the PMD_INIT_LOG?

Why not do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

                                                                                                  VIRTIO_MIN_RX_BUFSIZE,

                                                                                 VIRTIO_MAX_RX_PKTLEN);

That way, if the values that the macros evaluate to change, the log

will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 217 lines
(quoted diff) +5 -0
+                      return -EINVAL;
 
+        }
 
+        return 0;
 
+}
 
+

/*

* dev_ops for virtio, bare necessities for basic operation

*/

(quoted diff) +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 
         .promiscuous_disable     = virtio_dev_promiscuous_disable,
 
         .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,
 
--
 
 
 
--

Regards,

Souvik

-----Original Message-----

From: Yuanhan Liu [mailto:[email protected]]

Sent: Friday, September 9, 2016 3:00 AM

To: Dey, Souvik <[email protected]<mailto:[email protected]>>

Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 3 lines · Souvik

Hi Liu,

Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 5 lines

and have removed the Reviewed by line.

I have still kept the function definition as to follow the same suit

as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the

reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree

with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 26 lines

--

Regards,

Souvik

-----Original Message-----

From: Dey, Souvik

Sent: Wednesday, September 7, 2016 12:19 AM

To: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>;

[email protected]<mailto:[email protected]>

Cc Dey, Souvik <[email protected]<mailto:[email protected]>>

Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 3 lines

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

Quoted 7 lines

Changes in v4: Incorporated review comments.

Changes in v3: Corrected few style errors as reported by sys-stv.

Changes in v2: Incorporated review comments.

DPDK prefers to put the change log to ...

Quoted 7 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after apply.

In another word, we don't like to see those change log in git history,

but we'd like to see them while review.

Quoted 17 lines
 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

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

Review static void virtio_mac_addr_add(struct rte_eth_dev · line 93

Quoted 2 lines
(quoted diff) +0 -0
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev
 
 *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);

static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 9 lines
(quoted diff) +1 -0
                                                  struct ether_addr *mac_addr);
 
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 

static int virtio_dev_queue_stats_mapping_set(

       __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

Review

Quoted 13 lines
                     PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }
(quoted diff) +5 -0
+static int
 
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
 
+     struct virtio_hw *hw = dev->data->dev_private;
 
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
 
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

         --yliu
#10 lore raw
In reply to Dey, Souvik
Quoted 11 lines

Hi Mark/Liu,
              Thanks to both of you for being so patient with a series of silly errors. I have tried to make it better this time. Also there were some un-used variable in the function which I have removed. Please check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

One doubt though,
"9728 is the largest L2 frame size allowed by the NIC" -- this 9728 size is some constrain due to DPDK as the virtio driver in the kernel can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to 9728.

Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was implicit, given the context of this discussion). I'll be more explicit in future mails though.

Quoted 9 lines

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 658

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
                 PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }
 
+#define VLAN_TAG_LEN           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

One thing on this function: it doesn't actually set any fields, but rather just sanitizes 'mtu'. Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_mtu) sets rte_eth_dev->data->mtu?

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 666

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +8 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size > dev_info.max_rx_pktlen) {

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize. Any thoughts?

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) · line 668

Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +2 -0
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               dev_info.min_rx_bufsize,

As above.

Quoted 255 lines
drivers/net/virtio/virtio_ethdev.c +6 -1
+                               (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,
 
 
--

Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 8 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU.  Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce
the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud

environments.

Quoted 16 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set(
           __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c

Quoted 4 lines
drivers/net/virtio/virtio_ethdev.c +4 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+          struct virtio_hw *hw = dev->data->dev_private;
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account of L2 overhead before performing the comparison above.
Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size is L2_HDR_LEN + 9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

Quoted 2 lines

+                        PMD_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all caps) </micronit>

Hope this helps,
Mark

Quoted 58 lines

+                        return -EINVAL;
+          }
+          return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
            .promiscuous_disable     = virtio_dev_promiscuous_disable,
            .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,
--
 
--

Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+        struct virtio_hw *hw = dev->data->dev_private;
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

Hi Souvik,

Quoted 4 lines

Why hardcode the values in the PMD_INIT_LOG?

Why not  do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

       VIRTIO_MIN_RX_BUFSIZE,

Quoted 1 line

                                                                                  VIRTIO_MAX

_RX_PKTLEN);

Quoted 83 lines

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 77 lines

+                      return -EINVAL;
+        }
+        return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -2
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
          .promiscuous_disable     = virtio_dev_promiscuous_disable,
          .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,
--
 
--

Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
       Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after

apply.

Quoted 32 lines
Quoted 32 lines

In another word, we don't like to see those change log in git history, but we'd like to see them while review.

drivers/net/virtio/virtio_ethdev.c static void virtio_mac_addr_add(struct rte_eth_dev · line 92

Quoted 10 lines

  drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev
 *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
                                                    struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 

  static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c

Quoted 7 lines

                      PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c +5 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+     struct virtio_hw *hw = dev->data->dev_private;
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) {
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and 9728\n");

I still saw those numbers.

          --yliu

#11 lore raw

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Monday, September 12, 2016 10:48 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 11 lines

Hi Mark/Liu,
              Thanks to both of you for being so patient with a series
of silly errors. I have tried to make it better this time. Also there
were some un-used variable in the function which I have removed. Please
check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

One doubt though,
"9728 is the largest L2 frame size allowed by the NIC" -- this 9728
size is some constrain due to DPDK as the virtio driver in the kernel
can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to 9728.

Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was implicit, given the context of this discussion). I'll be more explicit in future mails though.

Quoted 10 lines

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 658

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct 
 rte_eth_dev *dev)
                 PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); }
 
+#define VLAN_TAG_LEN           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

One thing on this function: it doesn't actually set any fields, but rather just sanitizes 'mtu'.
Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_mtu) sets rte_eth_dev->data->mtu?
[Dey, Souvik] Yes , only the sanity check for the mtu is required here and the setting of the call back, else the rte_eth_dev_set_mtu() just returns without setting the MTU in the rte_eth_dev->data->mtu.

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 668

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + 
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size > 
+dev_info.max_rx_pktlen) {

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize. Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as
If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 670

Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +2 -0
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               dev_info.min_rx_bufsize,

As above.

Quoted 278 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
+                               (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,

--
Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU.  Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce
the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud

environments.

Quoted 17 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+          struct virtio_hw *hw = dev->data->dev_private;
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > 
+VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account
of L2 overhead before performing the comparison above.
Say the user supplies 'mtu' as 9728 - the corresponding minimum frame
size is L2_HDR_LEN +
9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can
accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

Quoted 3 lines

+                        PMD_INIT_LOG(ERR, "Mtu should be between +VIRTIO_MIN_RX_BUFSIZE and
VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all
caps) </micronit>

Hope this helps,
Mark

Quoted 62 lines

+                        return -EINVAL;
+          }
+          return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +0 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops 
 = {
            .promiscuous_disable     = virtio_dev_promiscuous_disable,
            .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, --

--
Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+        struct virtio_hw *hw = dev->data->dev_private;
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > 
+VIRTIO_MAX_RX_PKTLEN) {
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 
+and 9728\n");

Hi Souvik,

Quoted 5 lines

Why hardcode the values in the PMD_INIT_LOG?

Why not  do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

       VIRTIO_MIN_RX_BUFSIZE,

Quoted 2 lines


VIRTIO_MAX

_RX_PKTLEN);

Quoted 85 lines

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 79 lines

+                      return -EINVAL;
+        }
+        return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops 
 virtio_eth_dev_ops = {
          .promiscuous_disable     = virtio_dev_promiscuous_disable,
          .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, --

--
Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
       Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after

apply.

Quoted 37 lines
Quoted 37 lines

In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 10 lines

  drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct 

rte_eth_dev *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 7 lines

                                                   struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

  static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c

Quoted 10 lines

                      PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c +7 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+     struct virtio_hw *hw = dev->data->dev_private;
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > 
+VIRTIO_MAX_RX_PKTLEN) {
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and 
+9728\n");

I still saw those numbers.

          --yliu

#12 lore raw

Hi Mark/Liu,
Is there any further comments to the below patch ? Should I submit it as v5 of the patch ?

--
Regards,
Souvik

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Dey, Souvik
Sent: Monday, September 12, 2016 11:12 AM
To: Kavanagh, Mark B <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4]net/virtio: add mtu set in virtio

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Monday, September 12, 2016 10:48 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 11 lines

Hi Mark/Liu,
              Thanks to both of you for being so patient with a series
of silly errors. I have tried to make it better this time. Also there
were some un-used variable in the function which I have removed. Please
check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

One doubt though,
"9728 is the largest L2 frame size allowed by the NIC" -- this 9728
size is some constrain due to DPDK as the virtio driver in the kernel
can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to 9728.

Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was implicit, given the context of this discussion). I'll be more explicit in future mails though.

Quoted 10 lines

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 658

Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct
 rte_eth_dev *dev)
                 PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); }
 
+#define VLAN_TAG_LEN           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

One thing on this function: it doesn't actually set any fields, but rather just sanitizes 'mtu'.
Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_mtu) sets rte_eth_dev->data->mtu?
[Dey, Souvik] Yes , only the sanity check for the mtu is required here and the setting of the call back, else the rte_eth_dev_set_mtu() just returns without setting the MTU in the rte_eth_dev->data->mtu.

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 668

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + 
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize.
Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 670

Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +2 -0
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               dev_info.min_rx_bufsize,

As above.

Quoted 278 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
+                               (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,

--
Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU.  Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce
the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud

environments.

Quoted 17 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+          struct virtio_hw *hw = dev->data->dev_private;
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account
of L2 overhead before performing the comparison above.
Say the user supplies 'mtu' as 9728 - the corresponding minimum frame
size is L2_HDR_LEN +
9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can
accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest IP packet size).

Quoted 3 lines

+                        PMD_INIT_LOG(ERR, "Mtu should be between +VIRTIO_MIN_RX_BUFSIZE and
VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all
caps) </micronit>

Hope this helps,
Mark

Quoted 62 lines

+                        return -EINVAL;
+          }
+          return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +0 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops 
 = {
            .promiscuous_disable     = virtio_dev_promiscuous_disable,
            .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, --

--
Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+        struct virtio_hw *hw = dev->data->dev_private;
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 
+and 9728\n");

Hi Souvik,

Quoted 5 lines

Why hardcode the values in the PMD_INIT_LOG?

Why not  do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

       VIRTIO_MIN_RX_BUFSIZE,

Quoted 2 lines


VIRTIO_MAX

_RX_PKTLEN);

Quoted 85 lines

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 79 lines

+                      return -EINVAL;
+        }
+        return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops 
 virtio_eth_dev_ops = {
          .promiscuous_disable     = virtio_dev_promiscuous_disable,
          .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, --

--
Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
       Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after

apply.

Quoted 37 lines
Quoted 37 lines

In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 10 lines

  drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct 

rte_eth_dev *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 7 lines

                                                   struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

  static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c

Quoted 10 lines

                      PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c +7 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+     struct virtio_hw *hw = dev->data->dev_private;
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and 
+9728\n");

I still saw those numbers.

          --yliu

#13 lore raw
Quoted 2 lines · Souvik

Hi Mark/Liu,
Is there any further comments to the below patch ? Should I submit it as v5 of the patch ?

I think I'm okay with the patch now. But I got one more ask for you :)

In commit log, you stated:

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

What would go wrong if the expectation is not achieved? I think you should have met some issue and you meant to fix it, right? If so, you should state that here.

	--yliu
#14 lore raw
In reply to Dey, Souvik
Quoted 31 lines
Quoted 7 lines

Hi Mark/Liu,
              Thanks to both of you for being so patient with a series
of silly errors. I have tried to make it better this time. Also there
were some un-used variable in the function which I have removed. Please check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and

L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

Quoted 5 lines

One doubt though,
"9728 is the largest L2 frame size allowed by the NIC" -- this 9728
size is some constrain due to DPDK as the virtio driver in the kernel
can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to

9728.

Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was implicit, given the context of this discussion). I'll be more explicit in future mails though.

Quoted 13 lines

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct
 rte_eth_dev *dev)
                 PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); }
 
Quoted 11 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 658

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
+#define VLAN_TAG_LEN           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

One thing on this function: it doesn't actually set any fields, but rather just sanitizes 'mtu'.
Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_mtu) sets rte_eth_dev->data->mtu?
[Dey, Souvik] Yes , only the sanity check for the mtu is required here and the setting of the call back, else the rte_eth_dev_set_mtu() just returns without setting the MTU in the rte_eth_dev->data->mtu.

Hi Souvik, apologies for the delayed response.

That's what I thought, just wanted to verify that no additional structures should be updated here.

Quoted 12 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 668

Quoted 11 lines
drivers/net/virtio/virtio_ethdev.c +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN +
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {
Quoted 8 lines

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize.
Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as
If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

Again, this all depends on what 'mtu' means in this context.

Since you mentioned previously that it relates to the packet (i.e. L3) length, and not the frame (i.e. L2) length, I would suggest that the comparison should be:

	if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)

Yuanhan, any thoughts on this?

Quoted 284 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 670

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.c +2 -0
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               dev_info.min_rx_bufsize,

As above.

Quoted 55 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
+                               (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,

--
Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU.  Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce
the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud

environments.

Quoted 17 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

Quoted 12 lines

drivers/net/virtio/virtio_ethdev.c

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+          struct virtio_hw *hw = dev->data->dev_private;
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account
of L2 overhead before performing the comparison above.
Say the user supplies 'mtu' as 9728 - the corresponding minimum frame
size is L2_HDR_LEN +
9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can
accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest

IP packet size).

Quoted 211 lines
Quoted 4 lines

+                        PMD_INIT_LOG(ERR, "Mtu should be between +VIRTIO_MIN_RX_BUFSIZE and
VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all
caps) </micronit>

Hope this helps,
Mark

Quoted 62 lines

+                        return -EINVAL;
+          }
+          return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +0 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops
 = {
            .promiscuous_disable     = virtio_dev_promiscuous_disable,
            .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, --

--
Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+        struct virtio_hw *hw = dev->data->dev_private;
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64
+and 9728\n");

Hi Souvik,

Quoted 5 lines

Why hardcode the values in the PMD_INIT_LOG?

Why not  do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

       VIRTIO_MIN_RX_BUFSIZE,

Quoted 2 lines

VIRTIO_MAX

_RX_PKTLEN);

Quoted 85 lines

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 79 lines

+                      return -EINVAL;
+        }
+        return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +1 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops
 virtio_eth_dev_ops = {
          .promiscuous_disable     = virtio_dev_promiscuous_disable,
          .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, --

--
Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
       Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after

apply.

Quoted 37 lines
Quoted 37 lines

In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 10 lines

  drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct

rte_eth_dev *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 7 lines

                                                   struct ether_addr *mac_addr);
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

  static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c

Quoted 10 lines

                      PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c +7 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+     struct virtio_hw *hw = dev->data->dev_private;
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 and
+9728\n");

I still saw those numbers.

          --yliu

#15 lore raw

Hi Mark/Liu,
I know this might be a redundant question, but should I put your names in the Reviewed-by section in v5 ?

--
Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Wednesday, September 14, 2016 8:16 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 33 lines
Quoted 8 lines

Hi Mark/Liu,
              Thanks to both of you for being so patient with a series of silly errors. I have tried to make it better this time. Also there were some un-used variable in the function which I have removed. Please check the new patch with all your comments incorporated. Also along with the L2_HDR_LEN and

L2_CRC_LEN, I have taken in consideration the VLAN_LEN too.

Quoted 6 lines

One doubt though,
"9728 is the largest L2 frame size allowed by the NIC" -- this 9728 size is some constrain due to DPDK as the virtio driver in the kernel can support till mtu size of 68 to 65535, where as in DPDK pmd we are trying with 64 to

9728.

Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was
implicit, given the context of this discussion). I'll be more explicit in future mails though.

Quoted 13 lines

drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct
 rte_eth_dev *dev)
                 PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); }
 
Quoted 11 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 658

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
+#define VLAN_TAG_LEN           4    /* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

One thing on this function: it doesn't actually set any fields, but rather just sanitizes 'mtu'.
Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_mtu) sets rte_eth_dev->data->mtu?
[Dey, Souvik] Yes , only the sanity check for the mtu is required here and the setting of the call back, else the rte_eth_dev_set_mtu() just returns without setting the MTU in the rte_eth_dev->data->mtu.

Hi Souvik, apologies for the delayed response.

That's what I thought, just wanted to verify that no additional structures should be updated here.

Quoted 12 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 668

Quoted 11 lines
drivers/net/virtio/virtio_ethdev.c +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + 
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {
Quoted 8 lines

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize. Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

Again, this all depends on what 'mtu' means in this context.

Since you mentioned previously that it relates to the packet (i.e. L3) length, and not the frame (i.e. L2) length, I would suggest that the comparison should be:

	if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)

Yuanhan, any thoughts on this?

Quoted 289 lines

drivers/net/virtio/virtio_ethdev.c virtio_dev_allmulticast_disable(struct · line 670

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.c +2 -0
+               PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+                               dev_info.min_rx_bufsize,

As above.

Quoted 55 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
+                               (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,

--
Regards,
Souvik

-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:44 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Mark,

Yes I thought I did that change. Sorry once again.. making too many mistakes. Changed it . Thanks.
The MTU here is L3 MTU.  Setting this will help in reducing the fragmented/multi-segmented packets and also in case we want to reduce
the MTU below 1500, to support VXLAN or GRE tunnel for the packets in openstack and cloud

environments.

Quoted 17 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

Quoted 13 lines

drivers/net/virtio/virtio_ethdev.c

Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+          struct virtio_hw *hw = dev->data->dev_private;
+          if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {

If MTU is the L3 MTU as you've indicated, then you need to take account of L2 overhead before performing the comparison above. Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size is L2_HDR_LEN +
9728 + L2_CRC_LEN = 9746 bytes, which is larger than the NIC can accommodate (note that 9728 is the largest L2 frame size allowed by the NIC, not the largest

IP packet size).

Quoted 215 lines
Quoted 4 lines

+                        PMD_INIT_LOG(ERR, "Mtu should be between +VIRTIO_MIN_RX_BUFSIZE and
VIRTIO_MAX_RX_PKTLEN \n");

Two things on this statement:
1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely means very little, and as such is not helpful. I suggest going with the format that I included in my earlier mail, which prints the numeric value of the min and max rx defines
2) <micronit> MTU is an initialization, and should be printed as such in a log (i.e. all
caps) </micronit>

Hope this helps,
Mark

Quoted 64 lines

+                        return -EINVAL;
+          }
+          return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +0 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops 
 virtio_eth_dev_ops = {

           .promiscuous_disable     = virtio_dev_promiscuous_disable, .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, --

--
Regards,
Souvik
-----Original Message-----
From: Kavanagh, Mark B [mailto:[email protected]]
Sent: Friday, September 9, 2016 11:05 AM
To: Dey, Souvik <[email protected]>; Yuanhan Liu <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 9 lines

Hi Liu,

Yes agreed your comment. I will definitely remove the declaration as it is not really required.
So the latest patch will look like this . Yes I did rush a bit to submit the patch last will correct my suite. So sending the patch in a reply if we have more comments we can take a look and they re-submit the final reviewed

patch. Thanks for the help though.

Quoted 10 lines

---
drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644

drivers/net/virtio/virtio_ethdev.c

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +7 -0
 
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+        struct virtio_hw *hw = dev->data->dev_private;
+        if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                      PMD_INIT_LOG(ERR, "Mtu should be between 64 
+and 9728\n");

Hi Souvik,

Quoted 5 lines

Why hardcode the values in the PMD_INIT_LOG?

Why not  do the following: PMD_INIT_LOG(ERR, "MTU should be between %d and %d",

       VIRTIO_MIN_RX_BUFSIZE,

Quoted 2 lines

VIRTIO_MAX

_RX_PKTLEN);

Quoted 86 lines

That way, if the values that the macros evaluate to change, the log will update correspondingly.

Also, does 'MTU' in this context relate to the L2 or L3 MTU?

Quoted 80 lines

+                      return -EINVAL;
+        }
+        return 0;

drivers/net/virtio/virtio_ethdev.c +2 -0
+}
+

/*
  * dev_ops for virtio, bare necessities for basic operation */

drivers/net/virtio/virtio_ethdev.c +0 -0
@@ -664,6 +675,7 @@ static const struct eth_dev_ops 
 virtio_eth_dev_ops = {
          .promiscuous_disable     = virtio_dev_promiscuous_disable,
          .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, --

--
Regards,
Souvik

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Friday, September 9, 2016 3:00 AM
To: Dey, Souvik <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines · Souvik

Hi Liu,
       Submitted the version 4 of the patch as you suggested ,

Your patch is looking much better. But not really, you ignored few of my comments.

Quoted 3 lines

and have removed the Reviewed by line.
I have still kept the function definition as to follow the same suit as we have done for

other eth_dev_ops.

That's because most of the method implementions are after the reference, thus the declaration is needed.

For your case, I see no good reason to do that. BTW, if you disagree with my comment, you shoud made a reply, instead of rushing to sending a new version.

Quoted 13 lines

--
Regards,
Souvik

-----Original Message-----
From: Dey, Souvik
Sent: Wednesday, September 7, 2016 12:19 AM
To: [email protected]; [email protected]; [email protected]
Cc: Dey, Souvik <[email protected]>
Subject: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 2 lines

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

Quoted 4 lines

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

DPDK prefers to put the change log to ...

Quoted 4 lines

---

... here.

So that they will be showed in mailing list (for review), but they will be gone after

apply.

Quoted 38 lines
Quoted 38 lines

In another word, we don't like to see those change log in git history, but we'd like to see them while review.

Quoted 10 lines

  drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 07d6449..da16ad4 100644
@@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct 

rte_eth_dev *dev,  static void

virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); static void virtio_mac_addr_set(struct rte_eth_dev *dev,

Quoted 8 lines

                                                   struct ether_addr *mac_addr);

drivers/net/virtio/virtio_ethdev.c +2 -0
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t 
+mtu);

  static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@

virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)

drivers/net/virtio/virtio_ethdev.c

Quoted 10 lines

                      PMD_INIT_LOG(ERR, "Failed to disable allmulticast");  }

drivers/net/virtio/virtio_ethdev.c +7 -0
+static int
+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
+     struct virtio_hw *hw = dev->data->dev_private;
+     if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu >
+VIRTIO_MAX_RX_PKTLEN) {
+                   PMD_INIT_LOG(ERR, "Mtu should be between 64 
+and 9728\n");

I still saw those numbers.

          --yliu

#16 lore raw
In reply to Kavanagh, Mark B
Quoted 21 lines · Mark B
Quoted 12 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN +
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {
Quoted 8 lines

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize.
Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as
If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

Quoted 7 lines

Again, this all depends on what 'mtu' means in this context.

Since you mentioned previously that it relates to the packet (i.e. L3) length, and not the frame (i.e. L2) length, I would suggest that the comparison should be:

	if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)

Yuanhan, any thoughts on this?

I think you are right. At least, that's how the ixgbe PMD driver code looks like.

	--yliu
#17 lore raw

I have already taken care of this in v5 of the patch , If possible please review the same .

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Tuesday, September 20, 2016 3:12 AM
To: Kavanagh, Mark B <[email protected]>
Cc: Dey, Souvik <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 21 lines · Mark B
Quoted 12 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + 
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {
Quoted 8 lines

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize. Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

Quoted 7 lines

Again, this all depends on what 'mtu' means in this context.

Since you mentioned previously that it relates to the packet (i.e. L3) length, and not the frame (i.e. L2) length, I would suggest that the comparison should be:

	if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)

Yuanhan, any thoughts on this?

I think you are right. At least, that's how the ixgbe PMD driver code looks like.

	--yliu
#18 lore raw
Quoted 1 line · Souvik

I have already taken care of this in v5 of the patch , If possible please review the same .

I don't think so, otherwise I would not comment here.

BTW, there is a format error: you used white space instead of TAB for indention.

You might want to send another version, to fix above two issues. Or, if you don't mind, I could fix them for you and apply it.

	--yliu
Quoted 41 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Tuesday, September 20, 2016 3:12 AM
To: Kavanagh, Mark B <[email protected]>
Cc: Dey, Souvik <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio

Quoted 21 lines · Mark B
Quoted 12 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+{
+       struct rte_eth_dev_info dev_info;
+       uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + 
+VLAN_TAG_LEN;
+       uint32_t frame_size = mtu + ether_hdr_len;
+
+       virtio_dev_info_get(dev, &dev_info);
+
+       if (mtu < dev_info.min_rx_bufsize || frame_size >
+dev_info.max_rx_pktlen) {
Quoted 8 lines

It's not clear to me whether 'mtu' in this case should be compared with ETHER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size' should be compared with dev_info.min_rx_bufsize. Any thoughts?
[Dey, Souvik] I am not sure why virtio min_rx_bufsize is less than ETHER_MIN_MTU, i think it will be good to have the compare statement as If(frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) , then error. What do you suggest ?

Quoted 7 lines

Again, this all depends on what 'mtu' means in this context.

Since you mentioned previously that it relates to the packet (i.e. L3) length, and not the frame (i.e. L2) length, I would suggest that the comparison should be:

	if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)

Yuanhan, any thoughts on this?

I think you are right. At least, that's how the ixgbe PMD driver code looks like.

	--yliu