From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by mail.toke.dk (Postfix) with ESMTPS id D34F9A17E00 for ; Fri, 7 Jul 2023 21:30:23 +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=yhEMjNag Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-666e87eff0eso3593125b3a.3 for ; Fri, 07 Jul 2023 12:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688758222; x=1691350222; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2BGiqgbrDyKLhwoMHCwnPJoUQz2wNa2y6goRcd3J+cs=; b=yhEMjNagmmrLmOyJIXf+GcVs/r/FLDht6NRolf4Io140nmc1zROztzx7zC6soHLmur QttelemzHbtFZS5G4ZUAcAPJrij8o23uNOzqZIiwF5PgBmio2S9yDnQkt/vgT9mNr2/o RJXkN1+K4nPSh14wkBaXxorFzvG7PYBJ/4kn8cHBUKz9Y359oKKCAodqg9iJDPHqIasc dDjo39FWkFej4GN9Q5YuGs03IGD2oflAHB2TaWVy/iKxhVn5uW0cCie0ly+nkJbEohGp ZEvGH8Rn2cpIS3mzniLZFDN5mV0ApFOm8GA+8B1fX0XL9WeHQna5yBUAMSYoK8Z14mTr mr0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688758222; x=1691350222; 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=2BGiqgbrDyKLhwoMHCwnPJoUQz2wNa2y6goRcd3J+cs=; b=lrE/QYY3DLTWazVmNkDvpEYAoAMYqIJD64REECYx1+S5o0bDKN/APuNHHTkQuHr496 A/cu+D3G7xM4fgGcBsNPGwj4FTng3xv+PYNrmhSkhdy28YXey0QCRIKWYkdsaTvGMWlF pGDb6T9a7wVz47DUZCT4yU59W6Bd2mLQPHBtFpYc/QA5P2b/Sy4XJBSNYqozMqjqDVxJ LmRu6im6mmwKJt013CSGFM4k+iwOpeQZn24ZMjnaI5WAmsDvZ5jvDZmLmp7jIkZWr30F 8ICAqNBlGLWQDzHb+uO1nrJiyHkiaDZx96Ofy+VOv4BJU0+2re8TnNxi+x7mZpjtyKzk EJ/w== X-Gm-Message-State: ABy/qLZ/hHzcSDP2B7T8VGh57oT9RqHLio51N+R559EfZcvCQ5PemQEu PzlxywQ9xPM9+uHDqPDgFz5fYPw= X-Google-Smtp-Source: APBJJlE1V2C1sYD7EMBUp/7vClIOTGCd6NsbSDTFDjXHYOlh+hp5b0zqxGQgzgcVakjTeyFl2UQG+e0= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a05:6a00:b51:b0:66e:4df5:6c15 with SMTP id p17-20020a056a000b5100b0066e4df56c15mr8488242pfo.4.1688758222376; Fri, 07 Jul 2023 12:30:22 -0700 (PDT) Date: Fri, 7 Jul 2023 12:30:00 -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-9-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 6TR4U5OQLNRXUPC3ZV4IRB4424LCKV5D X-Message-ID-Hash: 6TR4U5OQLNRXUPC3ZV4IRB4424LCKV5D X-MailFrom: 3zmeoZAMKCWsbMOPXXPUN.LXVgMY-QRWcbgMY-YaXSNLc.WNc@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 08/14] net: veth: Implement devtx tx checksum List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Implement tx checksum kfunc for veth by checksumming the packet in software (since there is nothing to offload). The change mostly exists to make it possible to have software-based selftest. Probably should instead set csum_start/csum_offset on the skb itself? Signed-off-by: Stanislav Fomichev --- drivers/net/veth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 5af4b15e107c..6f97511a545b 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1814,6 +1814,34 @@ static int veth_devtx_tx_timestamp(const struct devtx_ctx *_ctx, u64 *timestamp) return 0; } +static int veth_devtx_request_l4_csum(const struct devtx_ctx *_ctx, + u16 csum_start, u16 csum_offset) +{ + struct veth_devtx_ctx *ctx = (struct veth_devtx_ctx *)_ctx; + struct sk_buff *skb = ctx->skb; + __wsum csum; + int ret; + + if (!skb) + return -EINVAL; + + if (skb_transport_header_was_set(skb)) + return -EINVAL; + + if (csum_start >= skb->len) + return -EINVAL; + + ret = skb_ensure_writable(skb, csum_offset + sizeof(__sum16)); + if (ret) + return ret; + + csum = csum_partial(skb->data + csum_start, skb->len - csum_start, 0); + *(__sum16 *)(skb->data + csum_offset) = csum_fold(csum) ?: CSUM_MANGLED_0; + skb->ip_summed = CHECKSUM_UNNECESSARY; + + return 0; +} + static const struct net_device_ops veth_netdev_ops = { .ndo_init = veth_dev_init, .ndo_open = veth_open, @@ -1840,6 +1868,7 @@ static const struct xdp_metadata_ops veth_xdp_metadata_ops = { .xmo_rx_hash = veth_xdp_rx_hash, .xmo_request_tx_timestamp = veth_devtx_request_tx_timestamp, .xmo_tx_timestamp = veth_devtx_tx_timestamp, + .xmo_request_l4_checksum = veth_devtx_request_l4_csum, }; #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ -- 2.41.0.255.g8b1d071c50-goog