From patchwork Tue Jun 13 15:10:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fijalkowski, Maciej" X-Patchwork-Id: 13278971 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0760B23DB for ; Tue, 13 Jun 2023 15:10:14 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD98CA for ; Tue, 13 Jun 2023 08:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686669013; x=1718205013; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wJHHcNgaMX0oYvDrU2aakU5zXPurfwpvSyXv0As7+4E=; b=RLq5JYBVJ3gUxhNCSV4tGoS+GrVTdIl6+sDatu8PN0BvFgY8dhZ4Ck+h lcDZl+eM+Km6AgTvllCYozNZweJHAOHNL5YhTQ0/gAnY1NFmd4jbKLyW4 6jb4/6KC1oMl0oERHxXeO1euQPuqfnhHszIVkU02OAk+zHjw38x4GIjzI ycYgao03S34T7ood9UNT7j8aK0n2rrLxXLT8ZCcEiAa0vXnysRhM0JuWI +xB1Brc0P3FR/R3y4NTZULX79NDofqu3w5wnVfzodw79vxs7K13if+5Ep EKSAnt3rD5A14lU/GXu4wdNVYK1KCDAGubIEuQGx3HytGskJNqial7ZDI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="338000007" X-IronPort-AV: E=Sophos;i="6.00,240,1681196400"; d="scan'208";a="338000007" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 08:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="1041802186" X-IronPort-AV: E=Sophos;i="6.00,240,1681196400"; d="scan'208";a="1041802186" Received: from boxer.igk.intel.com ([10.102.20.173]) by fmsmga005.fm.intel.com with ESMTP; 13 Jun 2023 08:10:11 -0700 From: Maciej Fijalkowski To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, magnus.karlsson@intel.com, fred@cloudflare.com, Maciej Fijalkowski Subject: [PATCH iwl-next] ice: allow hot-swapping XDP programs Date: Tue, 13 Jun 2023 17:10:05 +0200 Message-Id: <20230613151005.337462-1-maciej.fijalkowski@intel.com> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Currently ice driver's .ndo_bpf callback brings the interface down and up independently of the presence of XDP resources. This is only needed when either these resources have to be configured or removed. It means that if one is switching XDP programs on-the-fly with running traffic, packets will be dropped. To avoid this, compare early on ice_xdp_setup_prog() state of incoming bpf_prog pointer vs the bpf_prog pointer that is already assigned to VSI. Do the swap in case VSI has bpf_prog and incoming one are non-NULL. Signed-off-by: Maciej Fijalkowski --- drivers/net/ethernet/intel/ice/ice_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a1f7c8edc22f..8940ee505811 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2922,6 +2922,11 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog, "MTU is too large for linear frames and XDP prog does not support frags"); return -EOPNOTSUPP; } + + /* hot swap progs and avoid toggling link */ + if (ice_is_xdp_ena_vsi(vsi) == !!prog) { + ice_vsi_assign_bpf_prog(vsi, prog); + return 0; } /* need to stop netdev while setting up the program for Rx rings */ @@ -2956,13 +2961,6 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog, xdp_ring_err = ice_realloc_zc_buf(vsi, false); if (xdp_ring_err) NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Rx resources failed"); - } else { - /* safe to call even when prog == vsi->xdp_prog as - * dev_xdp_install in net/core/dev.c incremented prog's - * refcount so corresponding bpf_prog_put won't cause - * underflow - */ - ice_vsi_assign_bpf_prog(vsi, prog); } if (if_running)