Skip to content

Instantly share code, notes, and snippets.

@syuu1228
Created June 16, 2014 09:13
Show Gist options
  • Save syuu1228/68d9bff11ac978aa8d1d to your computer and use it in GitHub Desktop.
Save syuu1228/68d9bff11ac978aa8d1d to your computer and use it in GitHub Desktop.
From 928dc899128ac9b6d0b0cc63b20889e56f7d32ee Mon Sep 17 00:00:00 2001
From: Takuya ASADA <syuu@cloudius-systems.com>
Date: Sun, 15 Jun 2014 03:35:25 +0900
Subject: [PATCH 2/3] vmxnet3: pending kick
---
drivers/vmxnet3.cc | 31 ++++++++++++-------------------
drivers/vmxnet3.hh | 8 ++------
2 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/vmxnet3.cc b/drivers/vmxnet3.cc
index fda9611..7f7c035 100644
--- a/drivers/vmxnet3.cc
+++ b/drivers/vmxnet3.cc
@@ -292,7 +292,6 @@ vmxnet3::vmxnet3(pci::device &dev)
, _mcast_list(VMXNET3_MULTICAST_MAX * VMXNET3_ETH_ALEN, VMXNET3_MULTICAST_ALIGN)
, _receive_task([&] { receive_work(); }, sched::thread::attr().name("vmxnet3-receive"))
, _xmit_it(this)
- , _kick_thresh(512)
, _xmitter(this)
, _worker([this] { _xmitter.poll_until([] { return false; }, _xmit_it); })
{
@@ -550,19 +549,26 @@ void vmxnet3::xmit_one_locked(void *req)
// It was a good packet - increase the counter of a "pending for a kick"
// packets.
//
- _pkts_to_kick++;
+ ++_txq[0].layout->npending;
}
-void vmxnet3::kick_pending(u16 thresh)
+void vmxnet3::kick_pending()
{
- if (_pkts_to_kick >= thresh) {
- _pkts_to_kick = 0;
+ kick_hw();
+}
+
+void vmxnet3::kick_pending_with_thresh()
+{
+ if (_txq[0].layout->npending >= _txq[0].layout->intr_threshold)
kick_hw();
- }
}
bool vmxnet3::kick_hw()
{
+ auto &txr = _txq[0].cmd_ring;
+
+ _txq[0].layout->npending = 0;
+ _bar0->writel(VMXNET3_BAR0_TXH, txr.head);
return true;
}
@@ -591,7 +597,6 @@ int vmxnet3::txq_encap(vmxnet3_txqueue &txq, struct mbuf *m_head)
auto txd = txr.get_desc(txr.head);
auto sop = txr.get_desc(txr.head);
auto gen = txr.gen ^ 1; // Owned by cpu (yet)
- auto tx = 0;
u64 tx_bytes = 0;
int etype, proto, start;
@@ -629,7 +634,6 @@ int vmxnet3::txq_encap(vmxnet3_txqueue &txq, struct mbuf *m_head)
txr.gen ^= 1;
}
gen = txr.gen;
- tx++;
}
txd->layout->eop = 1;
txd->layout->compreq = 1;
@@ -653,17 +657,6 @@ int vmxnet3::txq_encap(vmxnet3_txqueue &txq, struct mbuf *m_head)
wmb();
sop->layout->gen ^= 1;
- if (++txq.layout->npending >= txq.layout->intr_threshold) {
- txq.layout->npending = 0;
- _bar0->writel(VMXNET3_BAR0_TXH, txr.head);
- }
- if (tx > 0) {
- if (txq.layout->npending > 0) {
- txq.layout->npending = 0;
- _bar0->writel(VMXNET3_BAR0_TXH, txr.head);
- }
- }
-
_txq_stats.tx_bytes += tx_bytes;
_txq_stats.tx_packets++;
diff --git a/drivers/vmxnet3.hh b/drivers/vmxnet3.hh
index a0ec32a..46fe5ad 100644
--- a/drivers/vmxnet3.hh
+++ b/drivers/vmxnet3.hh
@@ -126,10 +126,8 @@ public:
int transmit(struct mbuf* m_head);
void receive_work();
int xmit_prep(mbuf* m_head, void*& cooky);
- void kick_pending(u16 thresh = 1);
- void kick_pending_with_thresh() {
- kick_pending(_kick_thresh);
- }
+ void kick_pending();
+ void kick_pending_with_thresh();
bool kick_hw();
void wake_worker();
int try_xmit_one_locked(void* cooky);
@@ -287,8 +285,6 @@ private:
sched::thread _receive_task;
tx_xmit_iterator<vmxnet3> _xmit_it;
- const int _kick_thresh;
- u16 _pkts_to_kick = 0;
osv::xmitter<vmxnet3, 4096> _xmitter;
sched::thread _worker;
};
--
1.9.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment