From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mail.toke.dk (Postfix) with ESMTPS id 09A1BA24C1A for ; Thu, 24 Aug 2023 21:34:42 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=C+ERzTaR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692905683; x=1724441683; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v/9+YLj8PObvke9lo18PPjjZWs72+cBmo3t7jVTPzqc=; b=C+ERzTaRyqrp/NVMKB+hi5Bn6NvglE9yGcOKlOqv/FMUTCgOQphe106e 05zhtaEMQXlY3i0KCUkHRZxeJLNpkDTk9ShW2CmKiV5AW/Yf6WKhBTLTR btvj1U/FUiyqux7+lQV4h4rHwJf6rgXF7REbmnzhkzaE0f8GnrLyqaw3A 4SongBPvgQqwjOoARPNFHMvDs5qFqWLR68vPat6MmNcY/i/cqKABWLTfb vQbIfE5Z7e3yaCcosXq/D8+aTHyXKitok/6LDHg/c3LIfCx1A+YbKOE1F iFj64HzchyBwA+KkLsCqZ1aHl2v91uhZyiq5J1C8G2MyL0HgLxGMOfEV5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="354865517" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="354865517" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 12:34:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="860830592" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="860830592" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga004.jf.intel.com with ESMTP; 24 Aug 2023 12:34:36 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 347183491F; Thu, 24 Aug 2023 20:34:34 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Thu, 24 Aug 2023 21:27:01 +0200 Message-ID: <20230824192703.712881-23-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824192703.712881-1-larysa.zaremba@intel.com> References: <20230824192703.712881-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: H5YCPBSJ7OYTNOG3CAGL43VCWZNLPHQH X-Message-ID-Hash: H5YCPBSJ7OYTNOG3CAGL43VCWZNLPHQH X-MailFrom: larysa.zaremba@intel.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address CC: Larysa Zaremba , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, Willem de Bruijn , Alexei Starovoitov , Simon Horman , Tariq Toukan , Saeed Mahameed X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next 22/23] mlx5: implement VLAN tag XDP hint List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Implement the newly added .xmo_rx_vlan_tag() hint function. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 15 +++++++++++++++ include/linux/mlx5/device.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c index 12f56d0db0af..e8319ab0fa85 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c @@ -256,9 +256,24 @@ static int mlx5e_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash, return 0; } +static int mlx5e_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tci, + __be16 *vlan_proto) +{ + const struct mlx5e_xdp_buff *_ctx = (void *)ctx; + const struct mlx5_cqe64 *cqe = _ctx->cqe; + + if (!cqe_has_vlan(cqe)) + return -ENODATA; + + *vlan_proto = htons(ETH_P_8021Q); + *vlan_tci = be16_to_cpu(cqe->vlan_info); + return 0; +} + const struct xdp_metadata_ops mlx5e_xdp_metadata_ops = { .xmo_rx_timestamp = mlx5e_xdp_rx_timestamp, .xmo_rx_hash = mlx5e_xdp_rx_hash, + .xmo_rx_vlan_tag = mlx5e_xdp_rx_vlan_tag, }; /* returns true if packet was consumed by xdp */ diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 93399802ba77..95ffd78546a7 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -913,7 +913,7 @@ static inline u8 get_cqe_tls_offload(struct mlx5_cqe64 *cqe) return (cqe->tls_outer_l3_tunneled >> 3) & 0x3; } -static inline bool cqe_has_vlan(struct mlx5_cqe64 *cqe) +static inline bool cqe_has_vlan(const struct mlx5_cqe64 *cqe) { return cqe->l4_l3_hdr_type & 0x1; } -- 2.41.0