From patchwork Fri Apr 2 09:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 414841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2DF7C433B4 for ; Fri, 2 Apr 2021 09:57:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B67E6113A for ; Fri, 2 Apr 2021 09:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234316AbhDBJ5M (ORCPT ); Fri, 2 Apr 2021 05:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234275AbhDBJ5G (ORCPT ); Fri, 2 Apr 2021 05:57:06 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D863C0613E6 for ; Fri, 2 Apr 2021 02:57:04 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id l123so1793348pfl.8 for ; Fri, 02 Apr 2021 02:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q8fZ6bXiBKdKxq6WTnwN2X3L/4J4BXa/QeiEAL+Oam0=; b=klGSRr7XIkSCU/bXbFaNIPohrtOBM2CUwkeUtEHEBbz6jM3iMgaZhRdYZNxa8z+CQ2 KyB+6F1VaWsTKG9w5CDuuS4JgyaPYI4OwDnVwUJnwmMx94u2R5zITVe1eQ1/pgjAa/0k hVqqcKd02gJf2Ry0my6LLC0R2jdlZE85y6k4Hfmb7Ho/BT7jPymScV0V0DXql2h5460x NSSrzRMqjKq6zbP4c4O4fqgCYKwi1nqkE61kHH6zZBxcamu24M+7JPcWXYlrg8u3f5ec Sk9ZMp2HqRvDEUp/D19mPf43Y/P55yq4Tvs3KzB6+0a/ieJODq7zEnqSTxy189rTWwhy OkhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q8fZ6bXiBKdKxq6WTnwN2X3L/4J4BXa/QeiEAL+Oam0=; b=h2zw4Kt2KxLjcG+Rdfb5yDDkdIbg8LUtFGL2HkRVt70rP0nJd/2hT46odUEiJrWCMj CGWKoRTwTguqOyUYveAy+LhUPfYvzM3KnbMMGhcfvWmD4yZEG/yyfTUWpauIPQV19YBA LCtc9blvKVof6tqUqmKCykU7ypGMxkGVeUB0nE1ilet/zvT0cuWztmei6K8kLx9Ksd9K KK3u00jhZ3f2HDC3ypOBoX6rO5RFVTO9bA7Z9pxPW19La10E5PtWtwrJq/GxCZ8i2IOQ /6lTGQWrVf0oLBVl5hv4I2OB6ZiKJwkjNL/7MIDW+mlf1f7letac1duxH+Tn6OAwhMjD o3Tg== X-Gm-Message-State: AOAM532qMcfNyb30CHMyFtg5tSfxY1BSX2FpL8QFHpaKmiJmL16PzkNC ETsRpePE/UnCyMDM53CypFA= X-Google-Smtp-Source: ABdhPJzCU0kFs4rul6fRrBftHIV5W1PfGYPucuYpa2maEuHMIaIXDYPupXt7RtqB4FkfetPPFXc5lA== X-Received: by 2002:aa7:8b0f:0:b029:20d:1b60:e823 with SMTP id f15-20020aa78b0f0000b029020d1b60e823mr11534138pfd.16.1617357423816; Fri, 02 Apr 2021 02:57:03 -0700 (PDT) Received: from yoga-910.localhost (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id d13sm8009505pgb.6.2021.04.02.02.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 02:57:03 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Ioana Ciornei , Andrew Lunn Subject: [PATCH net-next v2 1/3] dpaa2-eth: rename dpaa2_eth_xdp_release_buf into dpaa2_eth_recycle_buf Date: Fri, 2 Apr 2021 12:55:30 +0300 Message-Id: <20210402095532.925929-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210402095532.925929-1-ciorneiioana@gmail.com> References: <20210402095532.925929-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Rename the dpaa2_eth_xdp_release_buf function into dpaa2_eth_recycle_buf since in the next patches we'll be using the same recycle mechanism for the normal stack path beside for XDP_DROP. Also, rename the array which holds the buffers to be recycled so that it does not have any reference to XDP. Signed-off-by: Ioana Ciornei Reviewed-by: Andrew Lunn --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 26 +++++++++---------- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 6 +++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index fc0eb82cdd6a..f545cb99388a 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -223,31 +223,31 @@ static void dpaa2_eth_free_bufs(struct dpaa2_eth_priv *priv, u64 *buf_array, } } -static void dpaa2_eth_xdp_release_buf(struct dpaa2_eth_priv *priv, - struct dpaa2_eth_channel *ch, - dma_addr_t addr) +static void dpaa2_eth_recycle_buf(struct dpaa2_eth_priv *priv, + struct dpaa2_eth_channel *ch, + dma_addr_t addr) { int retries = 0; int err; - ch->xdp.drop_bufs[ch->xdp.drop_cnt++] = addr; - if (ch->xdp.drop_cnt < DPAA2_ETH_BUFS_PER_CMD) + ch->recycled_bufs[ch->recycled_bufs_cnt++] = addr; + if (ch->recycled_bufs_cnt < DPAA2_ETH_BUFS_PER_CMD) return; while ((err = dpaa2_io_service_release(ch->dpio, priv->bpid, - ch->xdp.drop_bufs, - ch->xdp.drop_cnt)) == -EBUSY) { + ch->recycled_bufs, + ch->recycled_bufs_cnt)) == -EBUSY) { if (retries++ >= DPAA2_ETH_SWP_BUSY_RETRIES) break; cpu_relax(); } if (err) { - dpaa2_eth_free_bufs(priv, ch->xdp.drop_bufs, ch->xdp.drop_cnt); - ch->buf_count -= ch->xdp.drop_cnt; + dpaa2_eth_free_bufs(priv, ch->recycled_bufs, ch->recycled_bufs_cnt); + ch->buf_count -= ch->recycled_bufs_cnt; } - ch->xdp.drop_cnt = 0; + ch->recycled_bufs_cnt = 0; } static int dpaa2_eth_xdp_flush(struct dpaa2_eth_priv *priv, @@ -300,7 +300,7 @@ static void dpaa2_eth_xdp_tx_flush(struct dpaa2_eth_priv *priv, ch->stats.xdp_tx++; } for (i = enqueued; i < fq->xdp_tx_fds.num; i++) { - dpaa2_eth_xdp_release_buf(priv, ch, dpaa2_fd_get_addr(&fds[i])); + dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(&fds[i])); percpu_stats->tx_errors++; ch->stats.xdp_tx_err++; } @@ -382,7 +382,7 @@ static u32 dpaa2_eth_run_xdp(struct dpaa2_eth_priv *priv, trace_xdp_exception(priv->net_dev, xdp_prog, xdp_act); fallthrough; case XDP_DROP: - dpaa2_eth_xdp_release_buf(priv, ch, addr); + dpaa2_eth_recycle_buf(priv, ch, addr); ch->stats.xdp_drop++; break; case XDP_REDIRECT: @@ -403,7 +403,7 @@ static u32 dpaa2_eth_run_xdp(struct dpaa2_eth_priv *priv, free_pages((unsigned long)vaddr, 0); } else { ch->buf_count++; - dpaa2_eth_xdp_release_buf(priv, ch, addr); + dpaa2_eth_recycle_buf(priv, ch, addr); } ch->stats.xdp_drop++; } else { diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 9b6a89709ce1..9ba31c2706bb 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -438,8 +438,6 @@ struct dpaa2_eth_fq { struct dpaa2_eth_ch_xdp { struct bpf_prog *prog; - u64 drop_bufs[DPAA2_ETH_BUFS_PER_CMD]; - int drop_cnt; unsigned int res; }; @@ -457,6 +455,10 @@ struct dpaa2_eth_channel { struct dpaa2_eth_ch_xdp xdp; struct xdp_rxq_info xdp_rxq; struct list_head *rx_list; + + /* Buffers to be recycled back in the buffer pool */ + u64 recycled_bufs[DPAA2_ETH_BUFS_PER_CMD]; + int recycled_bufs_cnt; }; struct dpaa2_eth_dist_fields { From patchwork Fri Apr 2 09:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 415155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53B8DC43460 for ; Fri, 2 Apr 2021 09:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A6AC610D1 for ; Fri, 2 Apr 2021 09:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234463AbhDBJ5N (ORCPT ); Fri, 2 Apr 2021 05:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234361AbhDBJ5K (ORCPT ); Fri, 2 Apr 2021 05:57:10 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6B29C0613E6 for ; Fri, 2 Apr 2021 02:57:09 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso2352187pjb.3 for ; Fri, 02 Apr 2021 02:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KTZN4TM0TtROVLYP2klLnJVfOC45nICO3UWfC7ev+zU=; b=XNT1bSxlIUNaRPeHtXBIX5hNP25AOvni9Idw4/A51N/m8QWjzwaSLSUGFGNocQ+Rrz 7+Td2Fga982RNfYUan8EVrmvewlNBzAtqKNAGOYIrgI8fsRjZD9Lf6/d9xTM4ufOONjw asO/SXe5KgIkhABI7wTGRCzyM8+H39sqrSvO5GKBnE6V2aAIBOxkvvztVbz/lxtqLPm/ dpWRkDtcOSq76COf5qzf+VPMIjqVAud0jXX6v03Yoi8jJBYLuMa0GpI2+Pc2+RzVuZxz WIcoZIG0X9qOI/n3QECdIh/X+dx9uq6AJypHnzzcm984g5fBgRDQfyLJ+KCmnN9gvLt8 NcTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KTZN4TM0TtROVLYP2klLnJVfOC45nICO3UWfC7ev+zU=; b=Tt5+yt1mIeQSH5FAfhH85GWSvIkxHEoluOF5TssiJ75Yj3gZHKKlQwEZWaZs8BI3bD fRM3uSwzhHdlbQ/OrUYNtf5GC8bvs7480fz6Msc5yXXEE3KlkbKoh+7czJUHjNRYh19k fVuM2ksVdmT5ejMywMdS/um1PjXbo+7WgnEcYkcjTLHlBKw4M1qsDSc8Usa4xdwp5Utk H/yf6nS3ddPCa8rRp0qtWnXoCuD8fvRMjg2ZAI1Aay+dY4K7L0Z6xJT9Zzmak7KUseZc LvwbOlbkazxigF2lNebEIkcROaI4LvYrVBCr/0mzzTMQ6Tk9mkFJRebwPQ8+po4usAvI 8TgA== X-Gm-Message-State: AOAM531g2wdjZseZemK0b6yyvsbeRJGqoDMSiDM/JXCdWEOhbu8bi8c7 9hXxh4V5dtjkVsHMrTX/eyo= X-Google-Smtp-Source: ABdhPJwPlLwLlLSinwrCSPB8n4fgTBhMHTQAhhgq59N7E9DLxFL1i9X1pwBuer1Z/131z3Y30Lvg1w== X-Received: by 2002:a17:90b:ed0:: with SMTP id gz16mr13180749pjb.106.1617357429343; Fri, 02 Apr 2021 02:57:09 -0700 (PDT) Received: from yoga-910.localhost (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id d13sm8009505pgb.6.2021.04.02.02.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 02:57:08 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 2/3] dpaa2-eth: add rx copybreak support Date: Fri, 2 Apr 2021 12:55:31 +0300 Message-Id: <20210402095532.925929-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210402095532.925929-1-ciorneiioana@gmail.com> References: <20210402095532.925929-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei DMA unmapping, allocating a new buffer and DMA mapping it back on the refill path is really not that efficient. Proper buffer recycling (page pool, flipping the page and using the other half) cannot be done for DPAA2 since it's not a ring based controller but it rather deals with multiple queues which all get their buffers from the same buffer pool on Rx. To circumvent these limitations, add support for Rx copybreak. For small sized packets instead of creating a skb around the buffer in which the frame was received, allocate a new sk buffer altogether, copy the contents of the frame and release the initial page back into the buffer pool. Signed-off-by: Ioana Ciornei --- Changes in v2: - properly marked dpaa2_eth_copybreak as static .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 37 +++++++++++++++++-- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index f545cb99388a..535b9079943c 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -418,6 +418,34 @@ static u32 dpaa2_eth_run_xdp(struct dpaa2_eth_priv *priv, return xdp_act; } +static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch, + const struct dpaa2_fd *fd, + void *fd_vaddr) +{ + u16 fd_offset = dpaa2_fd_get_offset(fd); + u32 fd_length = dpaa2_fd_get_len(fd); + struct sk_buff *skb = NULL; + unsigned int skb_len; + + if (fd_length > DPAA2_ETH_DEFAULT_COPYBREAK) + return NULL; + + skb_len = fd_length + dpaa2_eth_needed_headroom(NULL); + + skb = napi_alloc_skb(&ch->napi, skb_len); + if (!skb) + return NULL; + + skb_reserve(skb, dpaa2_eth_needed_headroom(NULL)); + skb_put(skb, fd_length); + + memcpy(skb->data, fd_vaddr + fd_offset, fd_length); + + dpaa2_eth_recycle_buf(ch->priv, ch, dpaa2_fd_get_addr(fd)); + + return skb; +} + /* Main Rx frame processing routine */ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, struct dpaa2_eth_channel *ch, @@ -459,9 +487,12 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, return; } - dma_unmap_page(dev, addr, priv->rx_buf_size, - DMA_BIDIRECTIONAL); - skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr); + skb = dpaa2_eth_copybreak(ch, fd, vaddr); + if (!skb) { + dma_unmap_page(dev, addr, priv->rx_buf_size, + DMA_BIDIRECTIONAL); + skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr); + } } else if (fd_format == dpaa2_fd_sg) { WARN_ON(priv->xdp_prog); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 9ba31c2706bb..f8d2b4769983 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -489,6 +489,8 @@ struct dpaa2_eth_trap_data { struct dpaa2_eth_priv *priv; }; +#define DPAA2_ETH_DEFAULT_COPYBREAK 512 + /* Driver private data */ struct dpaa2_eth_priv { struct net_device *net_dev; From patchwork Fri Apr 2 09:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 414840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E096DC433B4 for ; Fri, 2 Apr 2021 09:57:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6EC1610D1 for ; Fri, 2 Apr 2021 09:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234548AbhDBJ5T (ORCPT ); Fri, 2 Apr 2021 05:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234361AbhDBJ5S (ORCPT ); Fri, 2 Apr 2021 05:57:18 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43ABFC06178A for ; Fri, 2 Apr 2021 02:57:16 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id j25so3319981pfe.2 for ; Fri, 02 Apr 2021 02:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R025QGe++ldrNnNDz/NuwITmuuEJjJwstiIZlcwZwPI=; b=nsxxLtXW6FAF3rO4o1w2iRtqoTStyGzxzw/axa1SySrMUwhWJwPlrf13qfCsh7MHyW lJ9aNl490D7j4AG+SA23Wa1HwNxDLiaqnRrj22j2hD0xkXvt4R91XqtUJVNinSsa3Cnc l/wvAhxYkUv8BJRYMCLMg9RRoRTLet1uyHEv2cbw5BYcJ+ayPQTRXjS/W3sbXz1ES2hv iNkiaGHwboZ6j203v0A4TdJwC2btBRJuUF8bVK3IFoT3CXpWnAndpyIfM29SzhkKUDWP 8qxO7LpcolfWUEBBomRW2bzUcrcCFvQfETCV4YITEkvA6Cj85mHVTx8bvWepseM3FV1r ESMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R025QGe++ldrNnNDz/NuwITmuuEJjJwstiIZlcwZwPI=; b=Xq8U+CnFVke0TjFBgI51KbpreVZD5ZIS3lbujpPebXFUM0sfztKBTojmrMhCcBJLBH a8Gf65henZei8wR7a9cMkLxRpau4ygzKhOTo1t0aDEVwQkzH9DWIDlyjVOdPryjPHyjq 3Zwa9VFqoKFLY6PWeTO2G9eg+J2wigWN6J+0dg/ZRW1iqqahjxbsbQ4SwjHWu5sb+p94 OEg0NucXIM5QsTa4nkGR8WbHdT9lZ0hO61KP5kvtvIpT7U9h8h1SlU7hSCTI+VOrozU6 uj3Pa33kLDrFBwpawoi9Wh14fnYissBzdQC7FMDwtCmECEAiQc4KY7lcjTm34dA0CWx5 y7qw== X-Gm-Message-State: AOAM531Rhq/7hdjyMySX2uzpjcm8yINDsqkUd0jZmFfzYRaQMdVlnNq5 JmHQ60vfWL/ZhKB0JZOqh07uuKmhmSqzmQ== X-Google-Smtp-Source: ABdhPJyphBvLInxlubuO78dmDpEe9TRBpna5kJUalU4rFa5Ksx/gUfTSOiaXFL4N0exIM7eAKPbXlw== X-Received: by 2002:a65:4243:: with SMTP id d3mr11586191pgq.180.1617357435763; Fri, 02 Apr 2021 02:57:15 -0700 (PDT) Received: from yoga-910.localhost (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id d13sm8009505pgb.6.2021.04.02.02.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 02:57:15 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Ioana Ciornei , Andrew Lunn Subject: [PATCH net-next v2 3/3] dpaa2-eth: export the rx copybreak value as an ethtool tunable Date: Fri, 2 Apr 2021 12:55:32 +0300 Message-Id: <20210402095532.925929-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210402095532.925929-1-ciorneiioana@gmail.com> References: <20210402095532.925929-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei It's useful, especially for debugging purposes, to have the Rx copybreak value changeable at runtime. Export it as an ethtool tunable. Signed-off-by: Ioana Ciornei Reviewed-by: Andrew Lunn --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 7 +++- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 + .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 40 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 535b9079943c..e0c3c58e2ac7 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -423,11 +423,12 @@ static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch, void *fd_vaddr) { u16 fd_offset = dpaa2_fd_get_offset(fd); + struct dpaa2_eth_priv *priv = ch->priv; u32 fd_length = dpaa2_fd_get_len(fd); struct sk_buff *skb = NULL; unsigned int skb_len; - if (fd_length > DPAA2_ETH_DEFAULT_COPYBREAK) + if (fd_length > priv->rx_copybreak) return NULL; skb_len = fd_length + dpaa2_eth_needed_headroom(NULL); @@ -441,7 +442,7 @@ static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch, memcpy(skb->data, fd_vaddr + fd_offset, fd_length); - dpaa2_eth_recycle_buf(ch->priv, ch, dpaa2_fd_get_addr(fd)); + dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd)); return skb; } @@ -4333,6 +4334,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) skb_queue_head_init(&priv->tx_skbs); + priv->rx_copybreak = DPAA2_ETH_DEFAULT_COPYBREAK; + /* Obtain a MC portal */ err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, &priv->mc_io); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index f8d2b4769983..cdb623d5f2c1 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -571,6 +571,8 @@ struct dpaa2_eth_priv { struct devlink *devlink; struct dpaa2_eth_trap_data *trap_data; struct devlink_port devlink_port; + + u32 rx_copybreak; }; struct dpaa2_eth_devlink_priv { diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index bf59708b869e..ad5e374eeccf 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -782,6 +782,44 @@ static int dpaa2_eth_get_ts_info(struct net_device *dev, return 0; } +static int dpaa2_eth_get_tunable(struct net_device *net_dev, + const struct ethtool_tunable *tuna, + void *data) +{ + struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + int err = 0; + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + *(u32 *)data = priv->rx_copybreak; + break; + default: + err = -EOPNOTSUPP; + break; + } + + return err; +} + +static int dpaa2_eth_set_tunable(struct net_device *net_dev, + const struct ethtool_tunable *tuna, + const void *data) +{ + struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + int err = 0; + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + priv->rx_copybreak = *(u32 *)data; + break; + default: + err = -EOPNOTSUPP; + break; + } + + return err; +} + const struct ethtool_ops dpaa2_ethtool_ops = { .get_drvinfo = dpaa2_eth_get_drvinfo, .nway_reset = dpaa2_eth_nway_reset, @@ -796,4 +834,6 @@ const struct ethtool_ops dpaa2_ethtool_ops = { .get_rxnfc = dpaa2_eth_get_rxnfc, .set_rxnfc = dpaa2_eth_set_rxnfc, .get_ts_info = dpaa2_eth_get_ts_info, + .get_tunable = dpaa2_eth_get_tunable, + .set_tunable = dpaa2_eth_set_tunable, };