Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1187904rdb; Fri, 22 Dec 2023 19:11:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHk6ljyTgNueEKfB27/BfJpUQj7RD12MMhYdZ9ntNjtgu+JqQmlZHgIlGDCJK6FMzzUbw7f X-Received: by 2002:a17:902:7588:b0:1d4:11b1:11b7 with SMTP id j8-20020a170902758800b001d411b111b7mr2207863pll.62.1703301100245; Fri, 22 Dec 2023 19:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703301100; cv=none; d=google.com; s=arc-20160816; b=tVNjvxtSGE4u4wpWxHXQ0WJ3lqPpKJxSIEDMqDFvAs5TwQCBsrRzwY3VjWlBuPZ3r1 0Aillc3iuTmUV6kndUU0R7PRPUhNe2b68g9vANde5nqTWWiEt+l/TSfQUZqI4dW4htJ8 1IJ247YroQAUUtD8l1MPDkxOMJqER2XpTURzebGfMpRL/m/2bUYTvCbcsbgnPjhgIgpY CFaO6h8sd57wRGdZM2zDY1KGK/UiU74ACXAHm/TcqG2l81h2n8phDbazjuBuEhoP98i7 1vuzZ5gCCN7ZMaCShDXaffHqTBqfjNScAh8Y96pQF75oMcTKSy0m9EIWf/B0/s1nZpFV awkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nIcsvuKxYT2g3KK/5eN1W4MzaarxFmqakEhBdm5/1vA=; fh=J3H3jkZRTdH/CD0R7uXO8r43FYFiJ1FqB2ouoqeBxmQ=; b=mbw/ESpOwz5dWQJVIbclFGARHiusTrEkL3YiUI7xjyZgGx5OFRCrnmZVFkCSw3GFPf T2TvclZHsvEpPxyAwAaCSEYLY0AjO1jDmt1fsAYSLNVzauVYhWOXnpm4wg7S4pDUaEHh QbJTRVjw7sRlAVlJtpSYPw9GOQiIH/ea7iPY75WsASuN9P7ba/ZsKB76eViVFJRSjNN7 SbWEJBSsg7zn53wWegQKXAzGCSW+R4lsBi5Gz4WfFbS4JJlq8rXi1ULX472VQmdyOwuQ 0lqxz8LyQAp5ugnSk/Pz4LCGXZkuyjWrknRs8nccJ2KOp5r+yYig1ubQVtjDWwj7ndaK oWLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JJD26Wo8; spf=pass (google.com: domain of linux-kernel+bounces-10250-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10250-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x20-20020a170902ea9400b001d3aa3328a7si4129579plb.614.2023.12.22.19.11.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 19:11:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10250-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JJD26Wo8; spf=pass (google.com: domain of linux-kernel+bounces-10250-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10250-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 67E1DB2451B for ; Sat, 23 Dec 2023 03:10:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 976E43FB0E; Sat, 23 Dec 2023 03:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JJD26Wo8" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) (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 73E893F8D3; Sat, 23 Dec 2023 03:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703300417; x=1734836417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B3hwJC99k6mjwP2SBzKX/gmp6IEmR5LqHfeVCYUgddI=; b=JJD26Wo8zJLaN5p3PfSjSGnO77Lulozu/LpPpGUpcA+L+sH6yd3bBgjE Ghg3cWD0qZ0YP4F2Kkd9aKC468RHQoWXuI09v7J2c1yTIrAW9OkVI9iGU bRTP3JwKP3J9iq3PH4YSXutjMm9IX+fPTi8yCDUHi8cV2T+kRGNeMc3GR +3MuNUJa/yO9IZFzWyogXOd7d44G/RmOK4eUba/9VogpFZ5TfGPpy5BFM 4EWFYMdxMLxuYB31pjkhcRuZRGoodVUNuA16pgg+zh/RgPPUSRhkOGmoI Tj5fCA69m4oqUu+iipcgXk+Dn+j5Tiq20tZqeb+dw3YT64sf+BqlFmrhe A==; X-IronPort-AV: E=McAfee;i="6600,9927,10932"; a="386611122" X-IronPort-AV: E=Sophos;i="6.04,298,1695711600"; d="scan'208";a="386611122" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 19:00:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,298,1695711600"; d="scan'208";a="25537692" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa001.jf.intel.com with ESMTP; 22 Dec 2023 19:00:13 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Maciej Fijalkowski , Michal Kubiak , Larysa Zaremba , Alexei Starovoitov , Daniel Borkmann , Willem de Bruijn , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next 34/34] idpf: enable XSk features and ndo_xsk_wakeup Date: Sat, 23 Dec 2023 03:55:54 +0100 Message-ID: <20231223025554.2316836-35-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223025554.2316836-1-aleksander.lobakin@intel.com> References: <20231223025554.2316836-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Michal Kubiak Now that AF_XDP functionality is fully implemented, advertise XSk XDP feature and add .ndo_xsk_wakeup() callback to be able to use it with this driver. Signed-off-by: Michal Kubiak Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/idpf/idpf_lib.c | 5 ++- drivers/net/ethernet/intel/idpf/idpf_xsk.c | 42 ++++++++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_xsk.h | 2 ++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c index 7c3d45f84e1b..af4f708b82f3 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c @@ -3,6 +3,7 @@ #include "idpf.h" #include "idpf_xdp.h" +#include "idpf_xsk.h" static const struct net_device_ops idpf_netdev_ops_splitq; static const struct net_device_ops idpf_netdev_ops_singleq; @@ -844,7 +845,8 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) if (idpf_is_queue_model_split(vport->rxq_model)) xdp_set_features_flag(netdev, NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | - NETDEV_XDP_ACT_RX_SG); + NETDEV_XDP_ACT_RX_SG | + NETDEV_XDP_ACT_XSK_ZEROCOPY); idpf_set_ethtool_ops(netdev); SET_NETDEV_DEV(netdev, &adapter->pdev->dev); @@ -2452,6 +2454,7 @@ static const struct net_device_ops idpf_netdev_ops_splitq = { .ndo_tx_timeout = idpf_tx_timeout, .ndo_bpf = idpf_xdp, .ndo_xdp_xmit = idpf_xdp_xmit, + .ndo_xsk_wakeup = idpf_xsk_wakeup, }; static const struct net_device_ops idpf_netdev_ops_singleq = { diff --git a/drivers/net/ethernet/intel/idpf/idpf_xsk.c b/drivers/net/ethernet/intel/idpf/idpf_xsk.c index 01231e828f6a..aff37c6a5adb 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_xsk.c +++ b/drivers/net/ethernet/intel/idpf/idpf_xsk.c @@ -1137,3 +1137,45 @@ bool idpf_xmit_zc(struct idpf_queue *complq) return result; } + +/** + * idpf_xsk_wakeup - Implements ndo_xsk_wakeup + * @netdev: net_device + * @queue_id: queue to wake up + * @flags: ignored in our case, since we have Rx and Tx in the same NAPI + * + * Returns negative on error, zero otherwise. + */ +int idpf_xsk_wakeup(struct net_device *netdev, u32 qid, u32 flags) +{ + struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_vport *vport = np->vport; + struct idpf_q_vector *q_vector; + struct idpf_queue *q; + int idx; + + if (idpf_vport_ctrl_is_locked(netdev)) + return -EBUSY; + + if (unlikely(!vport->link_up)) + return -ENETDOWN; + + if (unlikely(!idpf_xdp_is_prog_ena(vport))) + return -ENXIO; + + idx = qid + vport->xdp_txq_offset; + + if (unlikely(idx >= vport->num_txq)) + return -ENXIO; + + if (unlikely(!test_bit(__IDPF_Q_XSK, vport->txqs[idx]->flags))) + return -ENXIO; + + q = vport->txqs[idx]; + q_vector = q->txq_grp->complq->q_vector; + + if (!napi_if_scheduled_mark_missed(&q_vector->napi)) + idpf_trigger_sw_intr(&vport->adapter->hw, q_vector); + + return 0; +} diff --git a/drivers/net/ethernet/intel/idpf/idpf_xsk.h b/drivers/net/ethernet/intel/idpf/idpf_xsk.h index 51ddf2e36577..446ca971f37e 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_xsk.h +++ b/drivers/net/ethernet/intel/idpf/idpf_xsk.h @@ -10,6 +10,7 @@ enum virtchnl2_queue_type; struct idpf_queue; struct idpf_vport; +struct net_device; struct xsk_buff_pool; void idpf_xsk_setup_queue(struct idpf_queue *q, enum virtchnl2_queue_type t); @@ -24,5 +25,6 @@ bool idpf_xmit_zc(struct idpf_queue *complq); int idpf_xsk_pool_setup(struct idpf_vport *vport, struct xsk_buff_pool *pool, u32 qid); +int idpf_xsk_wakeup(struct net_device *netdev, u32 qid, u32 flags); #endif /* !_IDPF_XSK_H_ */ -- 2.43.0