From: Allen Pais <allen.lkml@gmail.com>
To: netdev@vger.kernel.org
Cc: Allen Pais <allen.lkml@gmail.com>
Subject: [PATCH 09/15] net: sundance: Convert tasklet API to new bottom half workqueue mechanism
Date: Fri, 21 Jun 2024 11:39:41 -0700 [thread overview]
Message-ID: <20240621183947.4105278-10-allen.lkml@gmail.com> (raw)
In-Reply-To: <20240621183947.4105278-1-allen.lkml@gmail.com>
Migrate tasklet APIs to the new bottom half workqueue mechanism. It
replaces all occurrences of tasklet usage with the appropriate workqueue
APIs throughout the dlink sundance driver. This transition ensures
compatibility with the latest design and enhances performance.
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
drivers/net/ethernet/dlink/sundance.c | 41 ++++++++++++++-------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
index 8af5ecec7d61..65dfd32a9656 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -86,6 +86,7 @@ static char *media[MAX_UNITS];
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
+#include <linux/workqueue.h>
#include <linux/init.h>
#include <linux/bitops.h>
#include <linux/uaccess.h>
@@ -395,8 +396,8 @@ struct netdev_private {
unsigned int an_enable:1;
unsigned int speed;
unsigned int wol_enabled:1; /* Wake on LAN enabled */
- struct tasklet_struct rx_tasklet;
- struct tasklet_struct tx_tasklet;
+ struct work_struct rx_bh_work;
+ struct work_struct tx_bh_work;
int budget;
int cur_task;
/* Multicast and receive mode. */
@@ -430,8 +431,8 @@ static void init_ring(struct net_device *dev);
static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev);
static int reset_tx (struct net_device *dev);
static irqreturn_t intr_handler(int irq, void *dev_instance);
-static void rx_poll(struct tasklet_struct *t);
-static void tx_poll(struct tasklet_struct *t);
+static void rx_poll(struct work_struct *work);
+static void tx_poll(struct work_struct *work);
static void refill_rx (struct net_device *dev);
static void netdev_error(struct net_device *dev, int intr_status);
static void netdev_error(struct net_device *dev, int intr_status);
@@ -541,8 +542,8 @@ static int sundance_probe1(struct pci_dev *pdev,
np->msg_enable = (1 << debug) - 1;
spin_lock_init(&np->lock);
spin_lock_init(&np->statlock);
- tasklet_setup(&np->rx_tasklet, rx_poll);
- tasklet_setup(&np->tx_tasklet, tx_poll);
+ INIT_WORK(&np->rx_bh_work, rx_poll);
+ INIT_WORK(&np->tx_bh_work, tx_poll);
ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE,
&ring_dma, GFP_KERNEL);
@@ -965,7 +966,7 @@ static void tx_timeout(struct net_device *dev, unsigned int txqueue)
unsigned long flag;
netif_stop_queue(dev);
- tasklet_disable_in_atomic(&np->tx_tasklet);
+ disable_work_sync(&np->tx_bh_work);
iowrite16(0, ioaddr + IntrEnable);
printk(KERN_WARNING "%s: Transmit timed out, TxStatus %2.2x "
"TxFrameId %2.2x,"
@@ -1006,7 +1007,7 @@ static void tx_timeout(struct net_device *dev, unsigned int txqueue)
netif_wake_queue(dev);
}
iowrite16(DEFAULT_INTR, ioaddr + IntrEnable);
- tasklet_enable(&np->tx_tasklet);
+ enable_and_queue_work(system_bh_wq, &np->tx_bh_work);
}
@@ -1058,9 +1059,9 @@ static void init_ring(struct net_device *dev)
}
}
-static void tx_poll(struct tasklet_struct *t)
+static void tx_poll(struct work_struct *work)
{
- struct netdev_private *np = from_tasklet(np, t, tx_tasklet);
+ struct netdev_private *np = from_work(np, work, tx_bh_work);
unsigned head = np->cur_task % TX_RING_SIZE;
struct netdev_desc *txdesc =
&np->tx_ring[(np->cur_tx - 1) % TX_RING_SIZE];
@@ -1104,11 +1105,11 @@ start_tx (struct sk_buff *skb, struct net_device *dev)
goto drop_frame;
txdesc->frag.length = cpu_to_le32 (skb->len | LastFrag);
- /* Increment cur_tx before tasklet_schedule() */
+ /* Increment cur_tx before bh_work is queued */
np->cur_tx++;
mb();
- /* Schedule a tx_poll() task */
- tasklet_schedule(&np->tx_tasklet);
+ /* Queue a tx_poll() bh work */
+ queue_work(system_bh_wq, &np->tx_bh_work);
/* On some architectures: explicitly flush cache lines here. */
if (np->cur_tx - np->dirty_tx < TX_QUEUE_LEN - 1 &&
@@ -1199,7 +1200,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
ioaddr + IntrEnable);
if (np->budget < 0)
np->budget = RX_BUDGET;
- tasklet_schedule(&np->rx_tasklet);
+ queue_work(system_bh_wq, &np->rx_bh_work);
}
if (intr_status & (IntrTxDone | IntrDrvRqst)) {
tx_status = ioread16 (ioaddr + TxStatus);
@@ -1315,9 +1316,9 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
return IRQ_RETVAL(handled);
}
-static void rx_poll(struct tasklet_struct *t)
+static void rx_poll(struct work_struct *work)
{
- struct netdev_private *np = from_tasklet(np, t, rx_tasklet);
+ struct netdev_private *np = from_work(np, work, rx_bh_work);
struct net_device *dev = np->ndev;
int entry = np->cur_rx % RX_RING_SIZE;
int boguscnt = np->budget;
@@ -1407,7 +1408,7 @@ static void rx_poll(struct tasklet_struct *t)
np->budget -= received;
if (np->budget <= 0)
np->budget = RX_BUDGET;
- tasklet_schedule(&np->rx_tasklet);
+ queue_work(system_bh_wq, &np->rx_bh_work);
}
static void refill_rx (struct net_device *dev)
@@ -1819,9 +1820,9 @@ static int netdev_close(struct net_device *dev)
struct sk_buff *skb;
int i;
- /* Wait and kill tasklet */
- tasklet_kill(&np->rx_tasklet);
- tasklet_kill(&np->tx_tasklet);
+ /* Wait and cancel bh work */
+ cancel_work_sync(&np->rx_bh_work);
+ cancel_work_sync(&np->tx_bh_work);
np->cur_tx = 0;
np->dirty_tx = 0;
np->cur_task = 0;
--
2.34.1
next prev parent reply other threads:[~2024-06-21 18:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 18:39 [PATCH 00/15] ethernet: Convert from tasklet to BH workqueue Allen Pais
2024-06-21 18:39 ` [PATCH 01/15] net: alteon: Convert tasklet API to new bottom half workqueue mechanism Allen Pais
2024-06-21 18:39 ` [PATCH 02/15] net: xgbe: " Allen Pais
2024-06-21 18:39 ` [PATCH 03/15] net: cnic: " Allen Pais
2024-06-21 18:39 ` [PATCH 04/15] net: macb: " Allen Pais
2024-06-21 18:39 ` [PATCH 05/15] net: cavium/liquidio: " Allen Pais
2024-06-21 18:39 ` [PATCH 06/15] net: octeon: " Allen Pais
2024-06-21 18:39 ` [PATCH 07/15] net: thunderx: " Allen Pais
2024-06-21 18:39 ` [PATCH 08/15] net: chelsio: " Allen Pais
2024-06-21 18:39 ` Allen Pais [this message]
2024-06-21 18:39 ` [PATCH 10/15] net: hinic: " Allen Pais
2024-06-21 18:39 ` [PATCH 11/15] net: ehea: " Allen Pais
2024-06-21 18:39 ` [PATCH 12/15] net: ibmvnic: " Allen Pais
2024-06-21 18:39 ` [PATCH 13/15] net: jme: " Allen Pais
2024-06-21 18:39 ` [PATCH 14/15] net: marvell: " Allen Pais
2024-06-21 20:19 ` Andrew Lunn
2024-06-21 18:39 ` [PATCH 15/15] net: mtk-wed: " Allen Pais
[not found] <20240621050525.3720069-1-allen.lkml@gmail.com>
2024-06-21 5:05 ` [PATCH 09/15] net: sundance: " Allen Pais
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=20240621183947.4105278-10-allen.lkml@gmail.com \
--to=allen.lkml@gmail.com \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).