From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by mail.toke.dk (Postfix) with ESMTPS id A88E7A18D6D for ; Wed, 12 Jul 2023 00:57:04 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=EKLeOSrM Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-55ba5bb0bf3so87646a12.1 for ; Tue, 11 Jul 2023 15:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689116222; x=1691708222; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CfgWvCSpj+DnZbG1Qs16+JDRZWOQUcuTeLj26an4Qb4=; b=EKLeOSrMbEdpdXS5iI5K4XUsy+PK7ZSQEjEsd2EvVXWQOxssw6gy1bPGaRgT7/GNBG ox0FHFiiJJF3BfzaofDW/MqJ47WhJ6IgrxYR9gMcaKI2vHj2RJ2O+bUmU+4MgAjy7NQL vccQlQtWOTWYwQIo9rLBiMIYFgfv5d/vHUQ5Rl7BLo2CAucMMv+B5m+uPvDy+49GEu3w P7aHpwGOH8OOkkLYtdMG5XBnKtuX1wORDmMMbfwmBhCp8LOaQQAbpd6LwWLVtqCbo0t2 XnN6FJr/ts3U9SsznT4bUZwLENRAvh3MkbfDXhMN6Tw1qImI0UAaqwCZsCIC7gKt6sJN qFJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689116222; x=1691708222; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CfgWvCSpj+DnZbG1Qs16+JDRZWOQUcuTeLj26an4Qb4=; b=fYWJPfOV0Yo/UpW3+e1ThvWUqbRcuM71F4SUvb5NrILH4nfjhXf5UpAIZlSJ9Rc4hY Vy7dJ7AP6RYgVSHBROYp8rCONP/P4ex2PYRKsqOFfjubN5k1XuFNNRF0Etk8RzoQzxr8 ndsLuym+wWS/KL8vtirLYgpUOayG9a1nfJY21DaOei1Gd8yBNN+3NwoRguXKUUN29154 8Z9tGzhj+D/RLLXgFkTxzTHuTmKT8YrJZIxTAKtg26BBZKBdTbCTmrjsNdwh7VJ77X59 ITj6Aq11pc/m87MA/WYmxCJjU7heiZng+coBcfvMgFYcKtEVBBOiDyKoqvRtGbuvsnFE iK0w== X-Gm-Message-State: ABy/qLbQYqAbSDRRw6XtcWy5xOf/4g085JswF2OHbLYAvLd+4IgjEeZp drcxMK6fmrqxDg8fPB6SBa0= X-Google-Smtp-Source: APBJJlFkylwSDW71IOV/B8MI99JwzyWyjeYA9e6v1H+tWWxuQvNREarIGbloXFKxpKL8mcsiGhVMNA== X-Received: by 2002:a17:90a:b30d:b0:262:d8e7:abfc with SMTP id d13-20020a17090ab30d00b00262d8e7abfcmr156063pjr.17.1689116221988; Tue, 11 Jul 2023 15:57:01 -0700 (PDT) Received: from MacBook-Pro-8.local ([2620:10d:c090:400::5:f81]) by smtp.gmail.com with ESMTPSA id i3-20020a17090a7e0300b0026358dfd2a3sm8617227pjl.24.2023.07.11.15.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 15:57:01 -0700 (PDT) Date: Tue, 11 Jul 2023 15:56:57 -0700 From: Alexei Starovoitov To: Stanislav Fomichev Message-ID: <20230711225657.kuvkil776fajonl5@MacBook-Pro-8.local> References: <20230707193006.1309662-1-sdf@google.com> <20230707193006.1309662-10-sdf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230707193006.1309662-10-sdf@google.com> Message-ID-Hash: LKLQWLEPNDFGDJQALFE2OL6HHITA3DJ2 X-Message-ID-Hash: LKLQWLEPNDFGDJQALFE2OL6HHITA3DJ2 X-MailFrom: alexei.starovoitov@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, 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, haoluo@google.com, jolsa@kernel.org, kuba@kernel.org, toke@kernel.org, willemb@google.com, dsahern@kernel.org, magnus.karlsson@intel.com, bjorn@kernel.org, maciej.fijalkowski@intel.com, hawk@kernel.org, netdev@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [RFC bpf-next v3 09/14] net/mlx5e: Implement devtx kfuncs List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, Jul 07, 2023 at 12:30:01PM -0700, Stanislav Fomichev wrote: > + > +static int mlx5e_devtx_request_l4_checksum(const struct devtx_ctx *_ctx, > + u16 csum_start, u16 csum_offset) > +{ > + const struct mlx5e_devtx_ctx *ctx = (void *)_ctx; > + struct mlx5_wqe_eth_seg *eseg; > + > + if (unlikely(!ctx->wqe)) > + return -ENODATA; > + > + eseg = &ctx->wqe->eth; > + > + switch (csum_offset) { > + case sizeof(struct ethhdr) + sizeof(struct iphdr) + offsetof(struct udphdr, check): > + case sizeof(struct ethhdr) + sizeof(struct ipv6hdr) + offsetof(struct udphdr, check): > + /* Looks like HW/FW is doing parsing, so offsets are largely ignored. */ > + eseg->cs_flags = MLX5_ETH_WQE_L3_CSUM | MLX5_ETH_WQE_L4_CSUM; > + break; > + default: > + return -EINVAL; > + } I think this proves my point: csum is not generalizable even across veth and mlx5. Above is a square peg that tries to fit csum_start/offset api (that makes sense from SW pov) into HW that has different ideas about csum-ing. Here is what mlx5 does: mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct mlx5e_accel_tx_state *accel, struct mlx5_wqe_eth_seg *eseg) { if (unlikely(mlx5e_ipsec_txwqe_build_eseg_csum(sq, skb, eseg))) return; if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { eseg->cs_flags = MLX5_ETH_WQE_L3_CSUM; if (skb->encapsulation) { eseg->cs_flags |= MLX5_ETH_WQE_L3_INNER_CSUM | MLX5_ETH_WQE_L4_INNER_CSUM; sq->stats->csum_partial_inner++; } else { eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM; sq->stats->csum_partial++; } How would you generalize that into csum api that will work across NICs ? My answer stands: you cannot. My proposal again: add driver specifc kfuncs and hooks for things like csum. Kuba, since you nacked driver specific stuff please suggest a way to unblock this stalemate.