Commit 224b06ce authored by eddietwo's avatar eddietwo

re-regressed back to the modified device handling elements

parent 90da2a56
...@@ -15,7 +15,8 @@ extern "C" { ...@@ -15,7 +15,8 @@ extern "C" {
#define INPUT_BATCH 8 #define INPUT_BATCH 8
#define OUTPUT_BATCH 16 #define OUTPUT_BATCH 16
// #define CLICK_DEVICE_STATS 1 // #define CLICK_DEVICE_CYCLES 1
// #define CLICK_DEVICE_PRFCTR 1
// #define CLICK_DEVICE_THESIS_STATS 1 // #define CLICK_DEVICE_THESIS_STATS 1
// #define _DEV_OVRN_STATS_ 1 // #define _DEV_OVRN_STATS_ 1
#define CLICK_CYCLE_COMPENSATION 54 #define CLICK_CYCLE_COMPENSATION 54
...@@ -24,37 +25,37 @@ extern "C" { ...@@ -24,37 +25,37 @@ extern "C" {
# define CLICK_DEVICE_ADJUST_TICKETS 1 # define CLICK_DEVICE_ADJUST_TICKETS 1
#endif #endif
#if CLICK_DEVICE_STATS > 1 #if CLICK_DEVICE_PRFCTR
#define CLICK_DEVICE_STATS 1
#define SET_STATS(p0mark, p1mark, time_mark) \ #define SET_STATS(p0mark, p1mark, time_mark) \
{ \ { \
unsigned high; \ unsigned high; \
rdpmc(0, p0mark, high); \ rdpmc(0, p0mark, high); \
rdpmc(1, p1mark, high); \ rdpmc(1, p1mark, high); \
time_mark = get_cycles(); \ time_mark = click_get_cycles(); \
} }
#define GET_STATS_RESET(p0mark, p1mark, time_mark, pctr0, pctr1, tctr) \ #define GET_STATS_RESET(p0mark, p1mark, time_mark, pctr0, pctr1, tctr) \
{ \ { \
unsigned high; \ unsigned high; \
unsigned low01, low11; \ unsigned low01, low11; \
tctr += get_cycles() - time_mark - CLICK_CYCLE_COMPENSATION; \ tctr += click_get_cycles() - time_mark - CLICK_CYCLE_COMPENSATION; \
rdpmc(0, low01, high); \ rdpmc(0, low01, high); \
rdpmc(1, low11, high); \ rdpmc(1, low11, high); \
pctr0 += (low01 >= p0mark) ? low01-p0mark : (UINT_MAX-p0mark+low01); \ pctr0 += (low01 >= p0mark) ? low01-p0mark : (UINT_MAX-p0mark+low01); \
pctr1 += (low11 >= p1mark) ? low11-p1mark : (UINT_MAX-p1mark+low11); \ pctr1 += (low11 >= p1mark) ? low11-p1mark : (UINT_MAX-p1mark+low11); \
rdpmc(0, p0mark, high); \ rdpmc(0, p0mark, high); \
rdpmc(1, p1mark, high); \ rdpmc(1, p1mark, high); \
time_mark = get_cycles(); \ time_mark = click_get_cycles(); \
} }
#elif CLICK_DEVICE_STATS #elif CLICK_DEVICE_CYCLES
#define CLICK_DEVICE_STATS 1
#define SET_STATS(p0mark, p1mark, time_mark) \ #define SET_STATS(p0mark, p1mark, time_mark) \
{ \ { \
time_mark = click_get_cycles(); \ time_mark = click_get_cycles(); \
} }
#define GET_STATS_RESET(p0mark, p1mark, time_mark, pctr0, pctr1, tctr) \ #define GET_STATS_RESET(p0mark, p1mark, time_mark, pctr0, pctr1, tctr) \
{ \ { \
unsigned long long __now = click_get_cycles(); \ unsigned long long __now = click_get_cycles(); \
...@@ -74,6 +75,8 @@ class AnyDevice : public Element { protected: ...@@ -74,6 +75,8 @@ class AnyDevice : public Element { protected:
String _devname; String _devname;
struct device *_dev; struct device *_dev;
AnyDevice *_next; AnyDevice *_next;
void adjust_tickets(int work);
public: public:
...@@ -87,6 +90,21 @@ class AnyDevice : public Element { protected: ...@@ -87,6 +90,21 @@ class AnyDevice : public Element { protected:
}; };
inline void
AnyDevice::adjust_tickets(int work)
{
#if CLICK_DEVICE_ADJUST_TICKETS
// simple additive increase multiplicative decrease scheme
int adj = 0;
if (work > 2)
adj = work;
else if (work == 0)
adj = 0-(tickets()>>4);
adj_tickets(adj);
#endif
}
class AnyDeviceMap { class AnyDeviceMap {
AnyDevice *_map[MAX_DEVICES]; AnyDevice *_map[MAX_DEVICES];
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
extern "C" { extern "C" {
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/sched.h>
#include <unistd.h> #include <unistd.h>
} }
...@@ -132,6 +133,8 @@ PollDevice::initialize(ErrorHandler *errh) ...@@ -132,6 +133,8 @@ PollDevice::initialize(ErrorHandler *errh)
if (l->next() == 0) { if (l->next() == 0) {
/* turn off interrupt if interrupts weren't already off */ /* turn off interrupt if interrupts weren't already off */
_dev->poll_on(_dev); _dev->poll_on(_dev);
if (_dev->polling != 1)
return errh->error("PollDevice detected wrong version of polling patch");
} }
if (_promisc) dev_set_promiscuity(_dev, 1); if (_promisc) dev_set_promiscuity(_dev, 1);
...@@ -143,10 +146,6 @@ PollDevice::initialize(ErrorHandler *errh) ...@@ -143,10 +146,6 @@ PollDevice::initialize(ErrorHandler *errh)
set_tickets(ScheduleInfo::DEFAULT); set_tickets(ScheduleInfo::DEFAULT);
#endif #endif
#if CLICK_DEVICE_ADJUST_TICKETS
_last_rx = 0;
#endif
join_scheduler(); join_scheduler();
reset_counts(); reset_counts();
...@@ -164,7 +163,6 @@ PollDevice::reset_counts() ...@@ -164,7 +163,6 @@ PollDevice::reset_counts()
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
_activations = 0; _activations = 0;
_idle_calls = 0;
_time_poll = 0; _time_poll = 0;
_time_refill = 0; _time_refill = 0;
_perfcnt1_poll = 0; _perfcnt1_poll = 0;
...@@ -217,8 +215,6 @@ PollDevice::run_scheduled() ...@@ -217,8 +215,6 @@ PollDevice::run_scheduled()
_perfcnt1_poll, _perfcnt2_poll, _time_poll); _perfcnt1_poll, _perfcnt2_poll, _time_poll);
if (got > 0) if (got > 0)
_activations++; _activations++;
else
_idle_calls++;
#endif #endif
_dev->rx_refill(_dev); _dev->rx_refill(_dev);
...@@ -266,32 +262,7 @@ PollDevice::run_scheduled() ...@@ -266,32 +262,7 @@ PollDevice::run_scheduled()
} }
#endif #endif
#if CLICK_DEVICE_ADJUST_TICKETS adjust_tickets(got);
int base = tickets() / 4;
if (base < 2) base = 2;
int adj = 0;
/*
* bursty traffic: sent substantially more packets this time than last time,
* so increase our tickets a lot to adapt.
*/
if (got == INPUT_BATCH && _last_rx <= INPUT_BATCH/8)
adj = base * 2;
/*
* was able to get many packets, so increase our ticket some to adapt.
*/
else if (got == INPUT_BATCH)
adj = base;
/*
* no packets, decrease tickets by some
*/
else if (got < INPUT_BATCH/4)
adj = -base;
adj_tickets(adj);
_last_rx = got;
#endif
reschedule(); reschedule();
#endif /* HAVE_POLLING */ #endif /* HAVE_POLLING */
...@@ -304,7 +275,6 @@ PollDevice_read_calls(Element *f, void *) ...@@ -304,7 +275,6 @@ PollDevice_read_calls(Element *f, void *)
return return
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
String(kw->_npackets) + " packets received\n" + String(kw->_npackets) + " packets received\n" +
String(kw->_idle_calls) + " idle calls\n" +
String(kw->_time_poll) + " cycles poll\n" + String(kw->_time_poll) + " cycles poll\n" +
String(kw->_time_refill) + " cycles refill\n" + String(kw->_time_refill) + " cycles refill\n" +
String(kw->_push_cycles) + " cycles pushing\n" + String(kw->_push_cycles) + " cycles pushing\n" +
......
...@@ -58,7 +58,6 @@ class PollDevice : public AnyDevice { ...@@ -58,7 +58,6 @@ class PollDevice : public AnyDevice {
unsigned long _npackets; unsigned long _npackets;
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
unsigned long long _idle_calls;
unsigned long long _time_poll; unsigned long long _time_poll;
unsigned long long _time_refill; unsigned long long _time_refill;
unsigned long long _perfcnt1_poll; unsigned long long _perfcnt1_poll;
...@@ -78,10 +77,6 @@ class PollDevice : public AnyDevice { ...@@ -78,10 +77,6 @@ class PollDevice : public AnyDevice {
bool _registered; bool _registered;
bool _promisc; bool _promisc;
#if CLICK_DEVICE_ADJUST_TICKETS
unsigned int _last_rx;
#endif
}; };
#endif #endif
......
...@@ -47,8 +47,7 @@ extern "C" { ...@@ -47,8 +47,7 @@ extern "C" {
ToDevice::ToDevice() ToDevice::ToDevice()
: _polling(0), _registered(0), : _polling(0), _registered(0),
_dev_idle(0), _last_tx(0), _last_busy(0), _dev_idle(0), _rejected(0), _hard_start(0)
_rejected(0), _hard_start(0)
{ {
// no MOD_INC_USE_COUNT; rely on AnyDevice // no MOD_INC_USE_COUNT; rely on AnyDevice
add_input(); add_input();
...@@ -104,7 +103,7 @@ ToDevice::initialize(ErrorHandler *errh) ...@@ -104,7 +103,7 @@ ToDevice::initialize(ErrorHandler *errh)
/* start out with max number of tickets */ /* start out with max number of tickets */
int max_tickets = ScheduleInfo::query(this, errh); int max_tickets = ScheduleInfo::query(this, errh);
set_max_tickets(max_tickets); set_max_tickets(max_tickets);
set_tickets(max_tickets); set_tickets(ScheduleInfo::DEFAULT);
#endif #endif
join_scheduler(); join_scheduler();
...@@ -120,8 +119,6 @@ ToDevice::reset_counts() ...@@ -120,8 +119,6 @@ ToDevice::reset_counts()
_busy_returns = 0; _busy_returns = 0;
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
_activations = 0; _activations = 0;
_idle_pulls = 0;
_idle_calls = 0;
_linux_pkts_sent = 0; _linux_pkts_sent = 0;
_time_clean = 0; _time_clean = 0;
_time_queue = 0; _time_queue = 0;
...@@ -255,14 +252,8 @@ should only be called from net_bh(). ...@@ -255,14 +252,8 @@ should only be called from net_bh().
if (sent > 0 || _activations > 0) _activations++; if (sent > 0 || _activations > 0) _activations++;
#endif #endif
#if CLICK_DEVICE_STATS
if (_activations > 0) {
if (sent == 0) _idle_calls++;
if (sent == 0 && !busy) _idle_pulls++;
}
#endif
if (busy) _busy_returns++; if (busy) _busy_returns++;
#if HAVE_POLLING #if HAVE_POLLING
if (_polling) { if (_polling) {
if (busy && sent == 0) { if (busy && sent == 0) {
...@@ -277,34 +268,8 @@ should only be called from net_bh(). ...@@ -277,34 +268,8 @@ should only be called from net_bh().
_dev_idle = 0; _dev_idle = 0;
} }
#endif #endif
#if CLICK_DEVICE_ADJUST_TICKETS
int base = tickets()/4;
if (base < 2) base = 2;
int adj = 0;
/* adjust_tickets(sent);
* didn't get much traffic and did not fill up the device, slow down.
*/
if (!busy && sent < (OUTPUT_BATCH/4))
adj = -base;
/*
* sent many packets, increase ticket.
*/
else if (sent > (OUTPUT_BATCH/2))
adj = base * 2;
/*
* was able to send more packets than last time, and last time device wasn't
* busy, this means we are getting more packets from queue.
*/
else if (sent > (OUTPUT_BATCH/4) && sent > _last_tx && !_last_busy)
adj = base;
adj_tickets(adj);
#endif
_last_tx = sent;
_last_busy = busy;
reschedule(); reschedule();
} }
...@@ -340,7 +305,8 @@ ToDevice::queue_packet(Packet *p) ...@@ -340,7 +305,8 @@ ToDevice::queue_packet(Packet *p)
_hard_start++; _hard_start++;
} }
if(ret != 0){ if(ret != 0){
printk("<1>ToDevice %s tx oops\n", _dev->name); if(_rejected == 0)
printk("<1>ToDevice %s rejected a packet!\n", _dev->name);
kfree_skb(skb1); kfree_skb(skb1);
_rejected++; _rejected++;
} }
...@@ -363,8 +329,6 @@ ToDevice_read_calls(Element *f, void *) ...@@ -363,8 +329,6 @@ ToDevice_read_calls(Element *f, void *)
String(td->_busy_returns) + " device busy returns\n" + String(td->_busy_returns) + " device busy returns\n" +
String(td->_npackets) + " packets sent\n" + String(td->_npackets) + " packets sent\n" +
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
String(td->_idle_calls) + " idle tx calls\n" +
String(td->_idle_pulls) + " idle pulls\n" +
String(td->_linux_pkts_sent) + " linux packets sent\n" + String(td->_linux_pkts_sent) + " linux packets sent\n" +
String(td->_pull_cycles) + " cycles pull\n" + String(td->_pull_cycles) + " cycles pull\n" +
String(td->_time_clean) + " cycles clean\n" + String(td->_time_clean) + " cycles clean\n" +
......
...@@ -62,8 +62,6 @@ class ToDevice : public AnyDevice { ...@@ -62,8 +62,6 @@ class ToDevice : public AnyDevice {
#if CLICK_DEVICE_STATS #if CLICK_DEVICE_STATS
// Statistics. // Statistics.
unsigned long long _idle_calls;
unsigned long long _idle_pulls;
unsigned long long _linux_pkts_sent; unsigned long long _linux_pkts_sent;
unsigned long long _time_clean; unsigned long long _time_clean;
unsigned long long _time_queue; unsigned long long _time_queue;
...@@ -90,8 +88,6 @@ class ToDevice : public AnyDevice { ...@@ -90,8 +88,6 @@ class ToDevice : public AnyDevice {
bool _registered; bool _registered;
bool _polling; bool _polling;
int _dev_idle; int _dev_idle;
int _last_tx;
int _last_busy;
int queue_packet(Packet *p); int queue_packet(Packet *p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment