Reuse netif_tx_lock for EoE TX synchronization
ndo_start_xmit callback is protected by __netif_tx_lock by the network stack, so we no not need our own locks.
This commit is contained in:
parent
a54fac3090
commit
eb44f82a91
|
|
@ -117,7 +117,6 @@ int ec_eoe_init(
|
|||
eoe->tx_queue_size = EC_EOE_TX_QUEUE_SIZE;
|
||||
eoe->tx_queued_frames = 0;
|
||||
|
||||
sema_init(&eoe->tx_queue_sem, 1);
|
||||
eoe->tx_frame_number = 0xFF;
|
||||
memset(&eoe->stats, 0, sizeof(struct net_device_stats));
|
||||
|
||||
|
|
@ -233,17 +232,20 @@ void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */)
|
|||
void ec_eoe_flush(ec_eoe_t *eoe /**< EoE handler */)
|
||||
{
|
||||
ec_eoe_frame_t *frame, *next;
|
||||
struct list_head tx_queue;
|
||||
|
||||
down(&eoe->tx_queue_sem);
|
||||
netif_tx_lock_bh(eoe->dev);
|
||||
|
||||
list_for_each_entry_safe(frame, next, &eoe->tx_queue, queue) {
|
||||
list_replace_init(&eoe->tx_queue, &tx_queue);
|
||||
eoe->tx_queued_frames = 0;
|
||||
|
||||
netif_tx_unlock_bh(eoe->dev);
|
||||
|
||||
list_for_each_entry_safe(frame, next, &tx_queue, queue) {
|
||||
list_del(&frame->queue);
|
||||
dev_kfree_skb(frame->skb);
|
||||
kfree(frame);
|
||||
}
|
||||
eoe->tx_queued_frames = 0;
|
||||
|
||||
up(&eoe->tx_queue_sem);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -635,10 +637,10 @@ void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
|
|||
return;
|
||||
}
|
||||
|
||||
down(&eoe->tx_queue_sem);
|
||||
netif_tx_lock_bh(eoe->dev);
|
||||
|
||||
if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) {
|
||||
up(&eoe->tx_queue_sem);
|
||||
netif_tx_unlock_bh(eoe->dev);
|
||||
eoe->tx_idle = 1;
|
||||
// no data available.
|
||||
// start a new receive immediately.
|
||||
|
|
@ -659,7 +661,7 @@ void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
|
|||
}
|
||||
|
||||
eoe->tx_queued_frames--;
|
||||
up(&eoe->tx_queue_sem);
|
||||
netif_tx_unlock_bh(eoe->dev);
|
||||
|
||||
eoe->tx_idle = 0;
|
||||
|
||||
|
|
@ -833,14 +835,12 @@ int ec_eoedev_tx(struct sk_buff *skb, /**< transmit socket buffer */
|
|||
|
||||
frame->skb = skb;
|
||||
|
||||
down(&eoe->tx_queue_sem);
|
||||
list_add_tail(&frame->queue, &eoe->tx_queue);
|
||||
eoe->tx_queued_frames++;
|
||||
if (eoe->tx_queued_frames == eoe->tx_queue_size) {
|
||||
netif_stop_queue(dev);
|
||||
eoe->tx_queue_active = 0;
|
||||
}
|
||||
up(&eoe->tx_queue_sem);
|
||||
|
||||
#if EOE_DEBUG_LEVEL >= 2
|
||||
EC_SLAVE_DBG(eoe->slave, 0, "EoE %s TX queued frame"
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@
|
|||
#include <linux/list.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#include <linux/semaphore.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "slave.h"
|
||||
#include "datagram.h"
|
||||
|
|
@ -87,7 +85,6 @@ struct ec_eoe
|
|||
unsigned int tx_queue_size; /**< Transmit queue size. */
|
||||
unsigned int tx_queue_active; /**< kernel netif queue started */
|
||||
unsigned int tx_queued_frames; /**< number of frames in the queue */
|
||||
struct semaphore tx_queue_sem; /**< Semaphore for the send queue. */
|
||||
ec_eoe_frame_t *tx_frame; /**< current TX frame */
|
||||
uint8_t tx_frame_number; /**< number of the transmitted frame */
|
||||
uint8_t tx_fragment_number; /**< number of the fragment */
|
||||
|
|
|
|||
Loading…
Reference in New Issue