From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by mail.toke.dk (Postfix) with ESMTPS id AD62AA17DF7 for ; Fri, 7 Jul 2023 21:30:22 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=vVc7haj5 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b8a7e21f15so35952775ad.0 for ; Fri, 07 Jul 2023 12:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688758221; x=1691350221; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=t8deO8YK9QH1JyxmBLifMsUSraGfEWt+GK3LbNEDBRc=; b=vVc7haj5CuY5xwGeuuKW7XMtVU6n0Gal3hAnUKhqyLbsNiD3yqBTgzjSxXC8eONZNY qz8diAF0WdtSD1L1na+e3+6Z2UHaa5HfH4w9q5jGkrP+NeCQjNOGWwJr1I/JM5SxtJdV g8L0perqeh/rce+xOmT9yzep67oeqIP3ftYRSFb1zb64IdSHj+E8a4Ir+ULrfj1DOJLt y1U/rqmUJtfA4VmJoDHYEjysC8LMkNw9NCvtVo6eXxtvt0oK0BjAhWz4nNiZ1RtLzchB SVBgKaFo0FSjp44ePSIEsxkACcCHD4u+KDS7Mh7+edqvnjZgxoDQthTHlOwvZCLCLMK/ vA/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688758221; x=1691350221; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t8deO8YK9QH1JyxmBLifMsUSraGfEWt+GK3LbNEDBRc=; b=iOfGClM5xIVgywFad7sbV4IGP10sT0cfkVDtLT6d1Nclex//oY7gqghDhD3/VL/12i ykJAIn/2Ev5wcbxUpt1hPrvmE/oJjNhr+SxVtEgdkNImr+kDOUIbO1ZGmpjKvO5a+ah4 lv7+eYf3CkMrslyCLpUBYN8Y589bZdWqtcgATvsMAO8sbJ10b/8+UfAtVFIkyxWKDFPC IyekkbRt/jr2TLv2zbVcKkzWE/NBPT4EklALdI/2d64FZ7lDgm/WRNz84xBR0Xm+9Hla ZmRNZXYXvqIsYlBQ0CL0BezkUOzdDBnnt0m/p7xZlkcQwn8TjlN9IadeOhOhY4hCpQpj KuuQ== X-Gm-Message-State: ABy/qLYT546is+/p7+9j78wqsp8V/g54NXot+IVc8RciEJ4oXNnIWJTZ SjeUq02mTsYVGzrRYn0YQLnyUKw= X-Google-Smtp-Source: APBJJlHXBiX0HUdUvRUVZbgJrogX4uLuV9nnqFz6lq3o9UNjG7zRePCrTBStAIhguoDyo5W5TPAUMn8= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:8f83:b0:1b5:2607:3256 with SMTP id z3-20020a1709028f8300b001b526073256mr5121265plo.6.1688758220937; Fri, 07 Jul 2023 12:30:20 -0700 (PDT) Date: Fri, 7 Jul 2023 12:29:59 -0700 In-Reply-To: <20230707193006.1309662-1-sdf@google.com> Mime-Version: 1.0 References: <20230707193006.1309662-1-sdf@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230707193006.1309662-8-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: EZWAUAKEKI4UNBLYQB72L6NDEWWMOG4E X-Message-ID-Hash: EZWAUAKEKI4UNBLYQB72L6NDEWWMOG4E X-MailFrom: 3zGeoZAMKCWkZKMNVVNSL.JVTeKW-OPUaZeKW-WYVQLJa.ULa@flex--sdf.bounces.google.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: 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, 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] [RFC bpf-next v3 07/14] bpf: Introduce tx checksum devtx kfuncs List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add new kfunc that will be used for tx checksum offloading. The API mirrors existing one from sk_buff: - csum_start - checksum the packet starting from this position - csum_offset - put checksum at this offset Signed-off-by: Stanislav Fomichev --- include/linux/netdevice.h | 2 ++ include/net/offload.h | 5 ++++- net/core/devtx.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5be6649ea3fa..aeb1fa024d65 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1662,6 +1662,8 @@ struct xdp_metadata_ops { enum xdp_rss_hash_type *rss_type); int (*xmo_request_tx_timestamp)(const struct devtx_ctx *ctx); int (*xmo_tx_timestamp)(const struct devtx_ctx *ctx, u64 *timestamp); + int (*xmo_request_l4_checksum)(const struct devtx_ctx *ctx, + u16 csum_start, u16 csum_offset); }; /** diff --git a/include/net/offload.h b/include/net/offload.h index 7e2c19c5aaef..d8f908af9e59 100644 --- a/include/net/offload.h +++ b/include/net/offload.h @@ -15,7 +15,10 @@ #define DEVTX_SUBMIT_KFUNC_xxx \ NETDEV_METADATA_KFUNC(DEVTX_KFUNC_REQUEST_TX_TIMESTAMP, \ bpf_devtx_request_tx_timestamp, \ - xmo_request_tx_timestamp) + xmo_request_tx_timestamp) \ + NETDEV_METADATA_KFUNC(DEVTX_KFUNC_REQUEST_L4_CHECKSUM, \ + bpf_devtx_request_l4_csum, \ + xmo_request_l4_checksum) #define DEVTX_COMPLETE_KFUNC_xxx \ NETDEV_METADATA_KFUNC(DEVTX_KFUNC_TX_TIMESTAMP, \ diff --git a/net/core/devtx.c b/net/core/devtx.c index 991a52fe81a3..fd8a9ea125db 100644 --- a/net/core/devtx.c +++ b/net/core/devtx.c @@ -106,6 +106,23 @@ __bpf_kfunc int bpf_devtx_tx_timestamp(const struct devtx_ctx *ctx, __u64 *times return -EOPNOTSUPP; } +/** + * bpf_devtx_request_l4_csum - Request TX checksum offload on the packet. + * Callable only from the devtx-submit hook. + * @ctx: devtx context pointer. + * @csum_start: start checksumming from given position + * @csum_offset: add resulting checksum at given offset + * + * Note, this checksum offload doesn't calculate pseudo-header part. + * + * Returns 0 on success or ``-errno`` on error. + */ +__bpf_kfunc int bpf_devtx_request_l4_csum(const struct devtx_ctx *ctx, + u16 csum_start, u16 csum_offset) +{ + return -EOPNOTSUPP; +} + __diag_pop(); BTF_SET8_START(devtx_sb_kfunc_ids) -- 2.41.0.255.g8b1d071c50-goog