Skip to content

Commit

Permalink
netdev-dpdk: Acquire dev->stats_lock only once.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
Acked-by: Aaron Conole <[email protected]>
Tested-by: Aaron Conole <[email protected]>
  • Loading branch information
ddiproietto committed Oct 12, 2016
1 parent 78bd47c commit 819f13b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,9 +1261,13 @@ netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq)
rte_free(rx);
}

static inline void
/* Tries to transmit 'pkts' to txq 'qid' of device 'dev'. Takes ownership of
* 'pkts', even in case of failure.
*
* Returns the number of packets that weren't transmitted. */
static inline int
netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid,
struct rte_mbuf **pkts, int cnt)
struct rte_mbuf **pkts, int cnt)
{
uint32_t nb_tx = 0;

Expand All @@ -1279,17 +1283,16 @@ netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid,
}

if (OVS_UNLIKELY(nb_tx != cnt)) {
/* free buffers, which we couldn't transmit, one at a time (each
/* Free buffers, which we couldn't transmit, one at a time (each
* packet could come from a different mempool) */
int i;

for (i = nb_tx; i < cnt; i++) {
rte_pktmbuf_free(pkts[i]);
}
rte_spinlock_lock(&dev->stats_lock);
dev->stats.tx_dropped += cnt - nb_tx;
rte_spinlock_unlock(&dev->stats_lock);
}

return cnt - nb_tx;
}

static inline bool
Expand Down Expand Up @@ -1666,7 +1669,7 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
newcnt = netdev_dpdk_qos_run(dev, pkts, newcnt);

dropped += qos_pkts - newcnt;
netdev_dpdk_eth_tx_burst(dev, qid, pkts, newcnt);
dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, newcnt);
}

if (OVS_UNLIKELY(dropped)) {
Expand Down Expand Up @@ -1723,7 +1726,7 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
cnt = netdev_dpdk_qos_run(dev, pkts, cnt);
dropped = batch->count - cnt;

netdev_dpdk_eth_tx_burst(dev, qid, pkts, cnt);
dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, cnt);

if (OVS_UNLIKELY(dropped)) {
rte_spinlock_lock(&dev->stats_lock);
Expand Down

0 comments on commit 819f13b

Please sign in to comment.