Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10473795rwr; Fri, 12 May 2023 08:34:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tR+KI3rpuYwVNljdw1wLnxo2Oc19bgayKQBlVv6dZNtyKtCYSq6leJIjY3OY8RIcLcPMc X-Received: by 2002:a05:6a21:3396:b0:100:74c5:f916 with SMTP id yy22-20020a056a21339600b0010074c5f916mr24103528pzb.40.1683905661829; Fri, 12 May 2023 08:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683905661; cv=none; d=google.com; s=arc-20160816; b=zbkfv/MxOJUoc8baLeGR4CCFMCjMWjTTuLhhHSbGdZAtpq+2B5DUGPLQ87H+RkGh9h EKstLbA6dBTppvl/bm/rCFHcaBnZeIxm6a3LJaSwdLA9kC90iiXxrJQmRca/GgTCAA9u h+Y/eK8X/Sm23YDAeQRwHRBOHK6ifnewW6jtPS0JO+8wce8/YweU3HX/9N80AgFigsjm VLHzUNxbzv4EKN0Ok8ZuG0nTVoMBUDkE6iZVLSH5Bw44Zjyy/Aj+XkwmqSgxI+JFjtZY z1AjQfPBQR2tLQ8o28rY0O/4v/3/3XM9tpJGM+4zXduWbRBRkuiLMrbOM640u1snLzzv Hw+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jzNhturUU417f0tArT7o0RXLZvj24MyHNhnn7GVo4p0=; b=Ln7drSBzmwR2qi4MYljLirVgx+RIeWEk8Moe0uHZm7y9XvM+fuH6rtjRNuWIyLvnko QXm295ML2CJD+DZVkrr2urJ3Gz8JVmYZzPA1tDF4soxFk1p9pRnVJgybKW6uimcYKIlO DIAsPABBmuh+JQhF5/FvjNqiiuNG82zH6mG9ENn52hhKCOut9aI3OcHMJ6LGM9vgAE/w 65qf5ixENTeWSi00riZYoOCJsn2nYTu/Nc+IRbGLZi/6CvPYh38K8rRGfkYnABfx1g7q TourzzXX1tBtoA3VGzNai/462DyPAxTA8eacqWn9FCT9JwcMPJXVxHadusP1iv72/OIy 4TFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Z/CCJFYs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b0052c7aa64058si9656375pgb.323.2023.05.12.08.34.05; Fri, 12 May 2023 08:34:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Z/CCJFYs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241786AbjELPVW (ORCPT + 99 others); Fri, 12 May 2023 11:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241801AbjELPVR (ORCPT ); Fri, 12 May 2023 11:21:17 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6674DD864; Fri, 12 May 2023 08:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683904855; x=1715440855; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RxAZyfKvmCeKRbEnyC2VNCiFTtwsPxlmLEsjOF/q5aQ=; b=Z/CCJFYsB9xa3wFQqHs4CWUBe7yf3E7Y4mFmcWgo8fCIVLlvbsUhSeGD xamPRk5Xd5YOFQM5zcx72ZWdYDPCHJODsWaF8g9y540EtuxfYUhsnAAv2 btqUoPodSlyD4rsmImMrmT7RsGPbG1coZuq8OEatnuK87kAlhIu+UUKGY hqx2GqXSntXiBpJbdi/Roo4VJ8Nd0JwJ92f0vW6FAIQkId9eFlrqWoMH8 nl3jRPHosIdTqaYyrRV4IFGs8NU00vWHiJbep1R9rR+ikXzJ4BiAdcMjT wRzeXEFC3+xGtWLN3wMQX9uL57SgND7FkZPkBGjLKLEE1TkQrbUwuezMW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="353061098" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="353061098" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 08:20:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812114254" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812114254" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga002.fm.intel.com with ESMTP; 12 May 2023 08:20:28 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 8D5BD35FB7; Fri, 12 May 2023 16:20:24 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Cc: Larysa Zaremba , Stanislav Fomichev , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jakub Kicinski , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa , Jesse Brandeburg , Tony Nguyen , Anatoly Burakov , Jesper Dangaard Brouer , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/15] ice: Support XDP hints in AF_XDP ZC mode Date: Fri, 12 May 2023 17:16:32 +0200 Message-Id: <20230512151639.992033-9-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230512151639.992033-1-larysa.zaremba@intel.com> References: <20230512151639.992033-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In AF_XDP ZC, xdp_buff is not stored on ring, instead it is provided by xsk_pool. Space for metadata sources right after such buffers was already reserved in commit 94ecc5ca4dbf ("xsk: Add cb area to struct xdp_buff_xsk"). This makes the implementation rather straightforward. Update AF_XDP ZC packet processing to support XDP hints. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_xsk.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 3b80aed5d47a..7f5ce3529666 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -708,16 +708,25 @@ static int ice_xmit_xdp_tx_zc(struct xdp_buff *xdp, * @xdp: xdp_buff used as input to the XDP program * @xdp_prog: XDP program to run * @xdp_ring: ring to be used for XDP_TX action + * @rx_desc: packet descriptor * * Returns any of ICE_XDP_{PASS, CONSUMED, TX, REDIR} */ static int ice_run_xdp_zc(struct ice_rx_ring *rx_ring, struct xdp_buff *xdp, - struct bpf_prog *xdp_prog, struct ice_tx_ring *xdp_ring) + struct bpf_prog *xdp_prog, struct ice_tx_ring *xdp_ring, + union ice_32b_rx_flex_desc *rx_desc) { int err, result = ICE_XDP_PASS; u32 act; + /* We can safely convert xdp_buff_xsk to ice_xdp_buff, + * because there are XSK_PRIV_MAX bytes reserved in xdp_buff_xsk + * right after xdp_buff, for our private use. + * Macro insures we do not go above the limit. + */ + XSK_CHECK_PRIV_TYPE(struct ice_xdp_buff); + ice_xdp_set_meta_srcs(xdp, rx_desc, rx_ring); act = bpf_prog_run_xdp(xdp_prog, xdp); if (likely(act == XDP_REDIRECT)) { @@ -816,7 +825,8 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget) xsk_buff_set_size(xdp, size); xsk_buff_dma_sync_for_cpu(xdp, rx_ring->xsk_pool); - xdp_res = ice_run_xdp_zc(rx_ring, xdp, xdp_prog, xdp_ring); + xdp_res = ice_run_xdp_zc(rx_ring, xdp, xdp_prog, xdp_ring, + rx_desc); if (likely(xdp_res & (ICE_XDP_TX | ICE_XDP_REDIR))) { xdp_xmit |= xdp_res; } else if (xdp_res == ICE_XDP_EXIT) { -- 2.35.3