i40e: fix xdp_redirect logs error message when testing with MTU=1500
Subsystems (2)
PATCH 1/1 i40e: fix xdp_redirect logs error message when testing with MTU=1500
From: Bartosz Staszewski <[email protected]>
The driver is currently logging an error message "MTU too large to enable XDP" when trying to enable XDP on totally normal MTU.
This was caused by whenever the interface was down, function i40e_xdp was passing vsi->rx_buf_len field to i40e_xdp_setup() which was equal 0. i40e_open() then calls i40e_vsi_configure_rx() which configures that field, but that only happens when interface is up. When it is down, i40e_open() is not being called, thusvsi->rx_buf_len which causes the bug is not set.
Solution for this is calculate buffer length in newly created function - i40e_calculate_vsi_rx_buf_len() that return actual buffer length. Buffer length is being calculated based on the same rules applied previously in i40e_vsi_configure_rx() function.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +30 -12
@@ -3693,6 +3693,30 @@ static int i40e_vsi_configure_tx(struct i40e_vsi *vsi)return err; } +/** +* i40e_calculate_vsi_rx_buf_len - Calculates buffer length +* +* @vsi: VSI to calculate rx_buf_len from +*/ +static u16 i40e_calculate_vsi_rx_buf_len (struct i40e_vsi *vsi) +{ +u16 ret; + +if (!vsi->netdev || (vsi->back->flags &I40E_FLAG_LEGACY_RX )) { + ret =I40E_RXBUFFER_2048 ; +#if (PAGE_SIZE <8192 ) + } else if (!I40E_2K_TOO_SMALL_WITH_PADDING && + (vsi->netdev->mtu <=ETH_DATA_LEN )) { + ret =I40E_RXBUFFER_1536 -NET_IP_ALIGN ; +#endif + }else { + ret = (PAGE_SIZE <8192 ) ?I40E_RXBUFFER_3072 : +I40E_RXBUFFER_2048 ; + } + +return ret; +} +/** * i40e_vsi_configure_rx - Configure the VSI for Rx * @vsi: the VSI being configured
@@ -3704,20 +3728,14 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)int err =0 ;u16 i; -if (!vsi->netdev || (vsi->back->flags &I40E_FLAG_LEGACY_RX )) { - vsi->max_frame =I40E_MAX_RXBUFFER ; - vsi->rx_buf_len =I40E_RXBUFFER_2048 ; + vsi->max_frame =I40E_MAX_RXBUFFER ; + vsi->rx_buf_len =i40e_calculate_vsi_rx_buf_len (vsi); +#if (PAGE_SIZE <8192 ) - } else if (!I40E_2K_TOO_SMALL_WITH_PADDING && - (vsi->netdev->mtu <=ETH_DATA_LEN )) { +if (vsi->netdev && !I40E_2K_TOO_SMALL_WITH_PADDING && + (vsi->netdev->mtu <=ETH_DATA_LEN )) vsi->max_frame =I40E_RXBUFFER_1536 -NET_IP_ALIGN ; - vsi->rx_buf_len =I40E_RXBUFFER_1536 -NET_IP_ALIGN ;#endif - }else { - vsi->max_frame =I40E_MAX_RXBUFFER ; - vsi->rx_buf_len = (PAGE_SIZE <8192 ) ?I40E_RXBUFFER_3072 : -I40E_RXBUFFER_2048 ; - }/* set up individual rings */ for (i =0 ; i < vsi->num_queue_pairs && !err; i++)
@@ -13265,7 +13283,7 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog,int i;/* Don't allow frames that span over multiple buffers */ -if (frame_size > vsi->rx_buf_len) { +if (frame_size >i40e_calculate_vsi_rx_buf_len (vsi)) {NL_SET_ERR_MSG_MOD (extack,"MTU too large to enable XDP" );return -EINVAL ; }
Signature · 6 lines
2.31.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 36 lines · Mateusz Palczewski
From: Bartosz Staszewski <[email protected]>
The driver is currently logging an error message "MTU too large to enable XDP" when trying to enable XDP on totally normal MTU.
This was caused by whenever the interface was down, function
i40e_xdpwas passingvsi->rx_buf_lenfield toi40e_xdp_setup()which was equal 0.i40e_open()then callsi40e_vsi_configure_rx()which configures that field, but that only happens when interface is up. When it is down,i40e_open()is not being called,thusvsi->rx_buf_lenwhich causes the bug is not set.Solution for this is calculate buffer length in newly created function -
i40e_calculate_vsi_rx_buf_len()that return actual buffer length. Buffer length is being calculated based on the same rules applied previously ini40e_vsi_configure_rx()function.Fixes 613142b0bb88 ("i40e: Log error for oversized MTU on device")Signed-off-by Bartosz Staszewski <[email protected]>Signed-off-by Mateusz Palczewski <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/i40e/i40e_main.c +4
-0@@ -3693,6 +3693,30 @@ static int i40e_vsi_configure_tx(struct i40e_vsi *vsi)return err; } +/** +* i40e_calculate_vsi_rx_buf_len - Calculates buffer length +* +* @vsi: VSI to calculate rx_buf_len from
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_vsi_configure_tx(struct i40e_vsi *vsi) · line 3709
Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +10
-0+*/ +static u16 i40e_calculate_vsi_rx_buf_len (struct i40e_vsi *vsi) +{ +u16 ret; + +if (!vsi->netdev || (vsi->back->flags &I40E_FLAG_LEGACY_RX )) { + ret =I40E_RXBUFFER_2048 ; +#if (PAGE_SIZE <8192 ) + } else if (!I40E_2K_TOO_SMALL_WITH_PADDING && + (vsi->netdev->mtu <=ETH_DATA_LEN )) {
This has a checkpatch error here because of the unnecessary parenthesis.
I can fix this up locally when applying the patch to net-queue.
Thanks,
Jake
Quoted 40 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +15
-11+ ret =I40E_RXBUFFER_1536 -NET_IP_ALIGN ; +#endif + }else { + ret = (PAGE_SIZE <8192 ) ?I40E_RXBUFFER_3072 : +I40E_RXBUFFER_2048 ; + } + +return ret; +} +/** * i40e_vsi_configure_rx - Configure the VSI for Rx * @vsi: the VSI being configured @@ -3704,20 +3728,14 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)int err =0 ;u16 i; -if (!vsi->netdev || (vsi->back->flags &I40E_FLAG_LEGACY_RX )) { - vsi->max_frame =I40E_MAX_RXBUFFER ; - vsi->rx_buf_len =I40E_RXBUFFER_2048 ; + vsi->max_frame =I40E_MAX_RXBUFFER ; + vsi->rx_buf_len =i40e_calculate_vsi_rx_buf_len (vsi); +#if (PAGE_SIZE <8192 ) - } else if (!I40E_2K_TOO_SMALL_WITH_PADDING && - (vsi->netdev->mtu <=ETH_DATA_LEN )) { +if (vsi->netdev && !I40E_2K_TOO_SMALL_WITH_PADDING && + (vsi->netdev->mtu <=ETH_DATA_LEN )) vsi->max_frame =I40E_RXBUFFER_1536 -NET_IP_ALIGN ; - vsi->rx_buf_len =I40E_RXBUFFER_1536 -NET_IP_ALIGN ;#endif - }else { - vsi->max_frame =I40E_MAX_RXBUFFER ; - vsi->rx_buf_len = (PAGE_SIZE <8192 ) ?I40E_RXBUFFER_3072 : -I40E_RXBUFFER_2048 ; - }/* set up individual rings */ for (i =0 ; i < vsi->num_queue_pairs && !err; i++)
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog, · line 13289
Quoted 8 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1
-1@@ -13265,7 +13283,7 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog,int i;/* Don't allow frames that span over multiple buffers */ -if (frame_size > vsi->rx_buf_len) { +if (frame_size >i40e_calculate_vsi_rx_buf_len (vsi)) {NL_SET_ERR_MSG_MOD (extack,"MTU too large to enable XDP" );return -EINVAL ; }
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Mateusz Palczewski
Sent: Friday, October 14, 2022 3:33 PM
To: [email protected]
Cc: Staszewski, BartoszX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v1] i40e: fixxdp_redirectlogs error message when testing with MTU=1500From: Bartosz Staszewski <[email protected]>
The driver is currently logging an error message "MTU too large to enable XDP"
when trying to enable XDP on totally normal MTU.This was caused by whenever the interface was down, function
i40e_xdpwas passingvsi->rx_buf_lenfield toi40e_xdp_setup()which was equal 0.i40e_open()then callsi40e_vsi_configure_rx()which configures that field, but that only happens when interface is up.
When it is down,i40e_open()is not being called,thusvsi->rx_buf_lenwhich causes the bug is not set.Solution for this is calculate buffer length in newly created function -
i40e_calculate_vsi_rx_buf_len()that return actual buffer length. Buffer length is being calculated based on the same rules applied previously ini40e_vsi_configure_rx()function.
Quoted 7 lines
Fixes 613142b0bb88 ("i40e: Log error for oversized MTU on device")Signed-off-by Bartosz Staszewski <[email protected]>Signed-off-by Mateusz Palczewski <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan