Skip to contentSkip to conversation

ixgbe: allow to increase MTU to some extent with XDP enalbed

PATCH Superseded Jason Xing 4 participants 7 messages Jan 21, 2023 – Jan 27, 2023

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jason Xing

author
#0 lore raw

PATCH 1/1 ixgbe: allow to increase MTU to some extent with XDP enalbed

From: Jason Xing <[email protected]>

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
index ab8370c413f3..dc016582f91e 100644
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
 		if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
 		    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
 			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+		if (ixgbe_enabled_xdp_adapter(adapter))
+			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
 #endif
 	}
 }
Signature · 1 line
2.37.3
#1 lore raw

Dear Jason,

Thank you for your patch.

Am 21.01.23 um 09:55 schrieb Jason Xing:

Quoted 1 line

From: Jason Xing <[email protected]>

There is a small typo in the summary: ena*bl*ed

Quoted 3 lines

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and

That’s included since Linux 4.19-rc1.

Quoted 14 lines

added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

Quoted 6 lines

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

What card did you test with exactly?

Quoted 3 lines

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

I’d say to not break the line in references.

Quoted 10 lines
---
  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index ab8370c413f3..dc016582f91e 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · line 4321

Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
  		if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
  		    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
  			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+		if (ixgbe_enabled_xdp_adapter(adapter))
+			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
  #endif
  	}
  }

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

author
#2 lore raw
Quoted 5 lines · Paul Menzel

Dear Jason,

Thank you for your patch.

Hello Paul,

Thanks for the review.

Quoted 6 lines

Am 21.01.23 um 09:55 schrieb Jason Xing:

Quoted 1 line

From: Jason Xing <[email protected]>

There is a small typo in the summary: ena*bl*ed

Sure it is. That's my fault.

Quoted 20 lines
Quoted 3 lines

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and

That’s included since Linux 4.19-rc1.

Quoted 14 lines

added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

Quoted 9 lines
Quoted 6 lines

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

What card did you test with exactly?

It is the IXGBE driver that has such an issue. The I40E driver I mentioned here is only for contrast. It's not that proper from my point of view if the IXGBE driver cannot directly adjust to 2000. Thus I would like more reviews and suggestions.

Thanks,
Jason

Quoted 30 lines
Quoted 3 lines

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

I’d say to not break the line in references.

Quoted 10 lines
---
  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index ab8370c413f3..dc016582f91e 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · line 4321

Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
              if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
                  (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
                      set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+             if (ixgbe_enabled_xdp_adapter(adapter))
+                     set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
  #endif
      }
  }

Kind regards,

Paul

author
#3 lore raw
In reply to Jason Xing

I'm sorry. I just noticed that I sent it to the wrong email address of john.fastabend previously. So I corrected it here.

Thanks,
Jason

Quoted 53 lines · Jason Xing

From: Jason Xing <[email protected]>

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -1
index ab8370c413f3..dc016582f91e 100644
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
                if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
                    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
                        set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+               if (ixgbe_enabled_xdp_adapter(adapter))
+                       set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
 #endif
        }
 }
--

2.37.3

#4 lore raw
In reply to Jason Xing
Quoted 40 lines · Jason Xing

From: Jason Xing <[email protected]>

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index ab8370c413f3..dc016582f91e 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · line 4318

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
 		if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
 		    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
 			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+		if (ixgbe_enabled_xdp_adapter(adapter))
+			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);

This will result with unnecessary overhead for 1500 MTU because you will be working on order-1 pages. Instead I would focus on fixing ixgbe_change_mtu() and stop relying on ixgbe_rx_bufsz() in there. You can check what we do on ice/i40e sides.

I'm not looking actively into ixgbe internals but I don't think that there is anything that stops us from using 3k buffers with XDP.

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
 #endif
 	}
 }
Signature · 1 line
2.37.3

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw

From: Maciej Fijalkowski <[email protected]>
Date: Thu, 26 Jan 2023 13:17:20 +0100

Quoted 53 lines · Jason Xing
Quoted 40 lines

From: Jason Xing <[email protected]>

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index ab8370c413f3..dc016582f91e 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · line 4318

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
 		if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
 		    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
 			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+		if (ixgbe_enabled_xdp_adapter(adapter))
+			set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);

This will result with unnecessary overhead for 1500 MTU because you will be working on order-1 pages. Instead I would focus on fixing ixgbe_change_mtu() and stop relying on ixgbe_rx_bufsz() in there. You can check what we do on ice/i40e sides.

Quoted 2 lines

I'm not looking actively into ixgbe internals but I don't think that there is anything that stops us from using 3k buffers with XDP.

I think it uses the same logics as the rest of drivers: splits a 4k page into two 2k buffers when MTU is <= 1536, otherwise uses order-1 pages and uses 3k buffers.

OTOH ixgbe is not fully correct in terms how it calculates Rx headroom, but the main problem is how it calculates the maximum MTU available when XDP is on. Our usual MTU supported when XDP is on is 3046 bytes. For MTU <= 1536, 2k buffers are used even for XDP, so the fix is not correct. Maciej is right that i40e and ice do that way better and don't have such issue.

Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
 #endif
 	}
 }
Signature · 1 line
2.37.3

Thanks,
Olek

author
#6 lore raw
Quoted 56 lines · Alexander Lobakin

From: Maciej Fijalkowski <[email protected]>
Date: Thu, 26 Jan 2023 13:17:20 +0100

Quoted 52 lines · Jason Xing
Quoted 40 lines

From: Jason Xing <[email protected]>

I encountered one case where I cannot increase the MTU size with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers. I noticed it was prohibited from 2017[1] and added size checks[2] if allowed soon after the previous patch.

Interesting part goes like this:
1) Changing MTU directly from 1500 (default value) to 2000 doesn't work because the driver finds out that 'new_frame_size > ixgbe_rx_bufsz(ring)' in ixgbe_change_mtu() function.
2) However, if we change MTU to 1501 then change from 1501 to 2000, it does work, because the driver sets __IXGBE_RX_3K_BUFFER when MTU size is converted to 1501, which later size check policy allows.

The default MTU value for most servers is 1500 which cannot be adjusted directly to the value larger than IXGBE_MAX_2K_FRAME_BUILD_SKB (1534 or 1536) if it loads XDP.

After I do a quick study on the manner of i40E driver allowing two kinds of buffer size (one is 2048 while another is 3072) to support XDP mode in i40e_max_xdp_frame_size(), I believe the default MTU size is possibly not satisfied in XDP mode when IXGBE driver is in use, we sometimes need to insert a new header, say, vxlan header. So setting the 3K-buffer flag could solve the issue.

[1] commit 38b7e7f8ae82 ("ixgbe: Do not allow LRO or MTU change with XDP")
[2] commit fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP")

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index ab8370c413f3..dc016582f91e 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · line 4318

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -0
@@ -4313,6 +4313,9 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
             if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
                 (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
                     set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
+
+            if (ixgbe_enabled_xdp_adapter(adapter))
+                    set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);

This will result with unnecessary overhead for 1500 MTU because you will be working on order-1 pages. Instead I would focus on fixing ixgbe_change_mtu() and stop relying on ixgbe_rx_bufsz() in there. You can check what we do on ice/i40e sides.

Well, now I see the commit 23b44513c3e6f in 2019. Thanks, Maciej.

Quoted 8 lines
Quoted 3 lines

I'm not looking actively into ixgbe internals but I don't think that there is anything that stops us from using 3k buffers with XDP.

I think it uses the same logics as the rest of drivers: splits a 4k page into two 2k buffers when MTU is <= 1536, otherwise uses order-1 pages and uses 3k buffers.

Quoted 6 lines

OTOH ixgbe is not fully correct in terms how it calculates Rx headroom, but the main problem is how it calculates the maximum MTU available when XDP is on. Our usual MTU supported when XDP is on is 3046 bytes. For MTU <= 1536, 2k buffers are used even for XDP, so the fix is not correct. Maciej is right that i40e and ice do that way better and don't have such issue.

Thank you for the detailed explanation. And yes, I checked this part in the ice/i40e driver which introduces ice/i40e_max_xdp_frame_size() to test if we can change MTU size when the driver is loading the XDP program.
I will rewrite the patch as the i40e/ice does in the next submission.

Thanks,
Jason

Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -1
 #endif
     }
 }
--

2.37.3

Thanks,
Olek