Skip to content

Commit dab86af

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
i40e/i40evf: Change the way we limit the maximum frame size for Rx
This patch changes the way we handle the maximum frame size for the Rx path. Previously we were rounding up to 2K for a 1500 MTU and then brining the max frame size down to MTU plus a fixed amount. With this patch applied what we now do is limit the maximum frame to 1.5K minus the value for NET_IP_ALIGN for standard MTU, and for any MTU greater than 1500 we allow up to the maximum frame size. This makes the behavior more consistent with the other drivers such as igb which had similar logic. In addition it reduces the test matrix for MTU since we only have two max frame sizes that are handled for Rx now. Change-ID: I23a9d3c857e7df04b0ef28c64df63e659c013f3f Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent c424d4a commit dab86af

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,7 +2995,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
29952995

29962996
ring->rx_buf_len = vsi->rx_buf_len;
29972997

2998-
rx_ctx.dbuff = ring->rx_buf_len >> I40E_RXQ_CTX_DBUFF_SHIFT;
2998+
rx_ctx.dbuff = DIV_ROUND_UP(ring->rx_buf_len,
2999+
BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
29993000

30003001
rx_ctx.base = (ring->dma / 128);
30013002
rx_ctx.qlen = ring->count;
@@ -3075,17 +3076,18 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)
30753076
int err = 0;
30763077
u16 i;
30773078

3078-
if (vsi->netdev && (vsi->netdev->mtu > ETH_DATA_LEN))
3079-
vsi->max_frame = vsi->netdev->mtu + ETH_HLEN
3080-
+ ETH_FCS_LEN + VLAN_HLEN;
3081-
else
3082-
vsi->max_frame = I40E_RXBUFFER_2048;
3083-
3084-
vsi->rx_buf_len = I40E_RXBUFFER_2048;
3085-
3086-
/* round up for the chip's needs */
3087-
vsi->rx_buf_len = ALIGN(vsi->rx_buf_len,
3088-
BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
3079+
if (!vsi->netdev || (vsi->back->flags & I40E_FLAG_LEGACY_RX)) {
3080+
vsi->max_frame = I40E_MAX_RXBUFFER;
3081+
vsi->rx_buf_len = I40E_RXBUFFER_2048;
3082+
#if (PAGE_SIZE < 8192)
3083+
} else if (vsi->netdev->mtu <= ETH_DATA_LEN) {
3084+
vsi->max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
3085+
vsi->rx_buf_len = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
3086+
#endif
3087+
} else {
3088+
vsi->max_frame = I40E_MAX_RXBUFFER;
3089+
vsi->rx_buf_len = I40E_RXBUFFER_2048;
3090+
}
30893091

30903092
/* set up individual rings */
30913093
for (i = 0; i < vsi->num_queue_pairs && !err; i++)

drivers/net/ethernet/intel/i40e/i40e_txrx.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ enum i40e_dyn_idx_t {
117117

118118
/* Supported Rx Buffer Sizes (a multiple of 128) */
119119
#define I40E_RXBUFFER_256 256
120+
#define I40E_RXBUFFER_1536 1536 /* 128B aligned standard Ethernet frame */
120121
#define I40E_RXBUFFER_2048 2048
121-
#define I40E_RXBUFFER_3072 3072 /* For FCoE MTU of 2158 */
122-
#define I40E_RXBUFFER_4096 4096
123-
#define I40E_RXBUFFER_8192 8192
124122
#define I40E_MAX_RXBUFFER 9728 /* largest size for single descriptor */
125123

126124
/* NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we

drivers/net/ethernet/intel/i40evf/i40e_txrx.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ enum i40e_dyn_idx_t {
104104

105105
/* Supported Rx Buffer Sizes (a multiple of 128) */
106106
#define I40E_RXBUFFER_256 256
107+
#define I40E_RXBUFFER_1536 1536 /* 128B aligned standard Ethernet frame */
107108
#define I40E_RXBUFFER_2048 2048
108-
#define I40E_RXBUFFER_3072 3072 /* For FCoE MTU of 2158 */
109-
#define I40E_RXBUFFER_4096 4096
110-
#define I40E_RXBUFFER_8192 8192
111109
#define I40E_MAX_RXBUFFER 9728 /* largest size for single descriptor */
112110

113111
/* NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we

drivers/net/ethernet/intel/i40evf/i40evf.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ struct i40e_vsi {
7272
#define I40EVF_MAX_RXD 4096
7373
#define I40EVF_MIN_RXD 64
7474
#define I40EVF_REQ_DESCRIPTOR_MULTIPLE 32
75-
76-
/* Supported Rx Buffer Sizes */
77-
#define I40EVF_RXBUFFER_2048 2048
78-
#define I40EVF_MAX_RXBUFFER 16384 /* largest size for single descriptor */
7975
#define I40EVF_MAX_AQ_BUF_SIZE 4096
8076
#define I40EVF_AQ_LEN 32
8177
#define I40EVF_AQ_MAX_ERR 20 /* times to try before resetting AQ */

drivers/net/ethernet/intel/i40evf/i40evf_main.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,26 @@ static void i40evf_configure_tx(struct i40evf_adapter *adapter)
686686
**/
687687
static void i40evf_configure_rx(struct i40evf_adapter *adapter)
688688
{
689+
unsigned int rx_buf_len = I40E_RXBUFFER_2048;
690+
struct net_device *netdev = adapter->netdev;
689691
struct i40e_hw *hw = &adapter->hw;
690692
int i;
691693

694+
/* Legacy Rx will always default to a 2048 buffer size. */
695+
#if (PAGE_SIZE < 8192)
696+
if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX)) {
697+
/* We use a 1536 buffer size for configurations with
698+
* standard Ethernet mtu. On x86 this gives us enough room
699+
* for shared info and 192 bytes of padding.
700+
*/
701+
if (netdev->mtu <= ETH_DATA_LEN)
702+
rx_buf_len = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
703+
}
704+
#endif
705+
692706
for (i = 0; i < adapter->num_active_queues; i++) {
693707
adapter->rx_rings[i].tail = hw->hw_addr + I40E_QRX_TAIL1(i);
694-
adapter->rx_rings[i].rx_buf_len = I40EVF_RXBUFFER_2048;
708+
adapter->rx_rings[i].rx_buf_len = rx_buf_len;
695709
}
696710
}
697711

drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void i40evf_configure_queues(struct i40evf_adapter *adapter)
234234
struct i40e_virtchnl_vsi_queue_config_info *vqci;
235235
struct i40e_virtchnl_queue_pair_info *vqpi;
236236
int pairs = adapter->num_active_queues;
237-
int i, len;
237+
int i, len, max_frame = I40E_MAX_RXBUFFER;
238238

239239
if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) {
240240
/* bail because we already have a command pending */
@@ -249,6 +249,11 @@ void i40evf_configure_queues(struct i40evf_adapter *adapter)
249249
if (!vqci)
250250
return;
251251

252+
/* Limit maximum frame size when jumbo frames is not enabled */
253+
if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX) &&
254+
(adapter->netdev->mtu <= ETH_DATA_LEN))
255+
max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
256+
252257
vqci->vsi_id = adapter->vsi_res->vsi_id;
253258
vqci->num_queue_pairs = pairs;
254259
vqpi = vqci->qpair;
@@ -264,9 +269,10 @@ void i40evf_configure_queues(struct i40evf_adapter *adapter)
264269
vqpi->rxq.queue_id = i;
265270
vqpi->rxq.ring_len = adapter->rx_rings[i].count;
266271
vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
267-
vqpi->rxq.max_pkt_size = adapter->netdev->mtu
268-
+ ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
269-
vqpi->rxq.databuffer_size = adapter->rx_rings[i].rx_buf_len;
272+
vqpi->rxq.max_pkt_size = max_frame;
273+
vqpi->rxq.databuffer_size =
274+
ALIGN(adapter->rx_rings[i].rx_buf_len,
275+
BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
270276
vqpi++;
271277
}
272278

0 commit comments

Comments
 (0)