From: Daniel Machon <daniel.machon@microchip.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
<UNGLinuxDriver@microchip.com>, <rdunlap@infradead.org>,
<horms@kernel.org>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Jens Emil Schulz Østergaard"
<jensemil.schulzostergaard@microchip.com>
Subject: [PATCH net-next 05/12] net: sparx5: use FDMA library for adding DCB's in the rx path
Date: Mon, 2 Sep 2024 16:54:10 +0200 [thread overview]
Message-ID: <20240902-fdma-sparx5-v1-5-1e7d5e5a9f34@microchip.com> (raw)
In-Reply-To: <20240902-fdma-sparx5-v1-0-1e7d5e5a9f34@microchip.com>
Use the fdma_dcb_add() function to add DCB's in the rx path. This gets
rid of the open-coding of nextptr and dataptr handling and leaves it to
the library.
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Reviewed-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
.../net/ethernet/microchip/sparx5/sparx5_fdma.c | 49 ++--------------------
1 file changed, 3 insertions(+), 46 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 675f8d5faa74..122876136f75 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -50,26 +50,6 @@ static int sparx5_fdma_rx_dataptr_cb(struct fdma *fdma, int dcb, int db,
return 0;
}
-static void sparx5_fdma_rx_add_dcb(struct sparx5_rx *rx,
- struct fdma_dcb *dcb,
- u64 nextptr)
-{
- struct fdma *fdma = &rx->fdma;
- int idx = 0;
-
- /* Reset the status of the DB */
- for (idx = 0; idx < fdma->n_dbs; ++idx) {
- struct fdma_db *db = &dcb->db[idx];
-
- db->status = FDMA_DCB_STATUS_INTR;
- }
- dcb->nextptr = FDMA_DCB_INVALID_DATA;
- dcb->info = FDMA_DCB_INFO_DATAL(FDMA_XTR_BUFFER_SIZE);
-
- fdma->last_dcb->nextptr = nextptr;
- fdma->last_dcb = dcb;
-}
-
static void sparx5_fdma_tx_add_dcb(struct sparx5_tx *tx,
struct sparx5_tx_dcb_hw *dcb,
u64 nextptr)
@@ -179,36 +159,20 @@ static void sparx5_fdma_tx_reload(struct sparx5 *sparx5, struct sparx5_tx *tx)
spx5_wr(BIT(tx->fdma.channel_id), sparx5, FDMA_CH_RELOAD);
}
-static struct sk_buff *sparx5_fdma_rx_alloc_skb(struct sparx5_rx *rx)
-{
- return __netdev_alloc_skb(rx->ndev, FDMA_XTR_BUFFER_SIZE,
- GFP_ATOMIC);
-}
-
static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx)
{
struct fdma *fdma = &rx->fdma;
unsigned int packet_size;
struct sparx5_port *port;
- struct sk_buff *new_skb;
struct fdma_db *db_hw;
struct frame_info fi;
struct sk_buff *skb;
- dma_addr_t dma_addr;
/* Check if the DCB is done */
db_hw = &fdma->dcbs[fdma->dcb_index].db[fdma->db_index];
if (unlikely(!(db_hw->status & FDMA_DCB_STATUS_DONE)))
return false;
skb = rx->skb[fdma->dcb_index][fdma->db_index];
- /* Replace the DB entry with a new SKB */
- new_skb = sparx5_fdma_rx_alloc_skb(rx);
- if (unlikely(!new_skb))
- return false;
- /* Map the new skb data and set the new skb */
- dma_addr = virt_to_phys(new_skb->data);
- rx->skb[fdma->dcb_index][fdma->db_index] = new_skb;
- db_hw->dataptr = dma_addr;
packet_size = FDMA_DCB_STATUS_BLOCKL(db_hw->status);
skb_put(skb, packet_size);
/* Now do the normal processing of the skb */
@@ -247,24 +211,17 @@ static int sparx5_fdma_napi_callback(struct napi_struct *napi, int weight)
int counter = 0;
while (counter < weight && sparx5_fdma_rx_get_frame(sparx5, rx)) {
- struct fdma_dcb *old_dcb;
-
fdma->db_index++;
counter++;
/* Check if the DCB can be reused */
if (fdma->db_index != fdma->n_dbs)
continue;
- /* As the DCB can be reused, just advance the dcb_index
- * pointer and set the nextptr in the DCB
- */
+ fdma_dcb_add(fdma, fdma->dcb_index,
+ FDMA_DCB_INFO_DATAL(fdma->db_size),
+ FDMA_DCB_STATUS_INTR);
fdma->db_index = 0;
- old_dcb = &fdma->dcbs[fdma->dcb_index];
fdma->dcb_index++;
fdma->dcb_index &= fdma->n_dcbs - 1;
- sparx5_fdma_rx_add_dcb(rx, old_dcb,
- fdma->dma +
- ((unsigned long)old_dcb -
- (unsigned long)fdma->dcbs));
}
if (counter < weight) {
napi_complete_done(&rx->napi, counter);
--
2.34.1
next prev parent reply other threads:[~2024-09-02 14:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 14:54 [PATCH net-next 00/12] net: microchip: add FDMA library and use it for Sparx5 Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 01/12] net: microchip: add FDMA library Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 02/12] net: sparx5: use FDMA library symbols Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 03/12] net: sparx5: replace a few variables with new equivalent ones Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 04/12] net: sparx5: use the FDMA library for allocation of rx buffers Daniel Machon
2024-09-02 14:54 ` Daniel Machon [this message]
2024-09-02 14:54 ` [PATCH net-next 06/12] net: sparx5: use library helper for freeing " Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 07/12] net: sparx5: use a few FDMA helpers in the rx path Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 08/12] net: sparx5: use the FDMA library for allocation of tx buffers Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 09/12] net: sparx5: use FDMA library for adding DCB's in the tx path Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 10/12] net: sparx5: use library helper for freeing tx buffers Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 11/12] net: sparx5: use contiguous memory for " Daniel Machon
2024-09-02 14:54 ` [PATCH net-next 12/12] net: sparx5: ditch sparx5_fdma_rx/tx_reload() functions Daniel Machon
2024-09-04 11:00 ` [PATCH net-next 00/12] net: microchip: add FDMA library and use it for Sparx5 patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240902-fdma-sparx5-v1-5-1e7d5e5a9f34@microchip.com \
--to=daniel.machon@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horatiu.vultur@microchip.com \
--cc=horms@kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®