ice: do not bring the VSI up, if it was down before the XDP setup

[ Upstream commit 04c7e14e5b ]

After XDP configuration is completed, we bring the interface up
unconditionally, regardless of its state before the call to .ndo_bpf().

Preserve the information whether the interface had to be brought down and
later bring it up only in such case.

Fixes: efc2214b60 ("ice: Add support for XDP")
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Larysa Zaremba 2024-08-23 11:59:31 +02:00 committed by Greg Kroah-Hartman
parent 2f057db2fb
commit 81e5622c05

View File

@ -2931,8 +2931,8 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
unsigned int frame_size = vsi->netdev->mtu + ICE_ETH_PKT_HDR_PAD; unsigned int frame_size = vsi->netdev->mtu + ICE_ETH_PKT_HDR_PAD;
bool if_running = netif_running(vsi->netdev);
int ret = 0, xdp_ring_err = 0; int ret = 0, xdp_ring_err = 0;
bool if_running;
if (prog && !prog->aux->xdp_has_frags) { if (prog && !prog->aux->xdp_has_frags) {
if (frame_size > ice_max_xdp_frame_size(vsi)) { if (frame_size > ice_max_xdp_frame_size(vsi)) {
@ -2949,8 +2949,11 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
return 0; return 0;
} }
if_running = netif_running(vsi->netdev) &&
!test_and_set_bit(ICE_VSI_DOWN, vsi->state);
/* need to stop netdev while setting up the program for Rx rings */ /* need to stop netdev while setting up the program for Rx rings */
if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { if (if_running) {
ret = ice_down(vsi); ret = ice_down(vsi);
if (ret) { if (ret) {
NL_SET_ERR_MSG_MOD(extack, "Preparing device for XDP attach failed"); NL_SET_ERR_MSG_MOD(extack, "Preparing device for XDP attach failed");