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" {
#define INPUT_BATCH 8
#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 _DEV_OVRN_STATS_ 1
#define CLICK_CYCLE_COMPENSATION 54
......@@ -24,37 +25,37 @@ extern "C" {
# define CLICK_DEVICE_ADJUST_TICKETS 1
#endif
#if CLICK_DEVICE_STATS > 1
#if CLICK_DEVICE_PRFCTR
#define CLICK_DEVICE_STATS 1
#define SET_STATS(p0mark, p1mark, time_mark) \
{ \
unsigned high; \
rdpmc(0, p0mark, 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) \
{ \
unsigned high; \
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(1, low11, high); \
pctr0 += (low01 >= p0mark) ? low01-p0mark : (UINT_MAX-p0mark+low01); \
pctr1 += (low11 >= p1mark) ? low11-p1mark : (UINT_MAX-p1mark+low11); \
rdpmc(0, p0mark, 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) \
{ \
time_mark = click_get_cycles(); \
}
#define GET_STATS_RESET(p0mark, p1mark, time_mark, pctr0, pctr1, tctr) \
{ \
unsigned long long __now = click_get_cycles(); \
......@@ -75,6 +76,8 @@ class AnyDevice : public Element { protected:
struct device *_dev;
AnyDevice *_next;
void adjust_tickets(int work);
public:
AnyDevice();
......@@ -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 {
AnyDevice *_map[MAX_DEVICES];
......
......@@ -35,6 +35,7 @@
extern "C" {
#include <linux/netdevice.h>
#include <linux/sched.h>
#include <unistd.h>
}
......@@ -132,6 +133,8 @@ PollDevice::initialize(ErrorHandler *errh)
if (l->next() == 0) {
/* turn off interrupt if interrupts weren't already off */
_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);
......@@ -143,10 +146,6 @@ PollDevice::initialize(ErrorHandler *errh)
set_tickets(ScheduleInfo::DEFAULT);
#endif
#if CLICK_DEVICE_ADJUST_TICKETS
_last_rx = 0;
#endif
join_scheduler();
reset_counts();
......@@ -164,7 +163,6 @@ PollDevice::reset_counts()
#if CLICK_DEVICE_STATS
_activations = 0;
_idle_calls = 0;
_time_poll = 0;
_time_refill = 0;
_perfcnt1_poll = 0;
......@@ -217,8 +215,6 @@ PollDevice::run_scheduled()
_perfcnt1_poll, _perfcnt2_poll, _time_poll);
if (got > 0)
_activations++;
else
_idle_calls++;
#endif
_dev->rx_refill(_dev);
......@@ -266,32 +262,7 @@ PollDevice::run_scheduled()
}
#endif
#if CLICK_DEVICE_ADJUST_TICKETS
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
adjust_tickets(got);
reschedule();
#endif /* HAVE_POLLING */
......@@ -304,7 +275,6 @@ PollDevice_read_calls(Element *f, void *)
return
#if CLICK_DEVICE_STATS
String(kw->_npackets) + " packets received\n" +
String(kw->_idle_calls) + " idle calls\n" +
String(kw->_time_poll) + " cycles poll\n" +
String(kw->_time_refill) + " cycles refill\n" +
String(kw->_push_cycles) + " cycles pushing\n" +
......
......@@ -58,7 +58,6 @@ class PollDevice : public AnyDevice {
unsigned long _npackets;
#if CLICK_DEVICE_STATS
unsigned long long _idle_calls;
unsigned long long _time_poll;
unsigned long long _time_refill;
unsigned long long _perfcnt1_poll;
......@@ -78,10 +77,6 @@ class PollDevice : public AnyDevice {
bool _registered;
bool _promisc;
#if CLICK_DEVICE_ADJUST_TICKETS
unsigned int _last_rx;
#endif
};
#endif
......
......@@ -47,8 +47,7 @@ extern "C" {
ToDevice::ToDevice()
: _polling(0), _registered(0),
_dev_idle(0), _last_tx(0), _last_busy(0),
_rejected(0), _hard_start(0)
_dev_idle(0), _rejected(0), _hard_start(0)
{
// no MOD_INC_USE_COUNT; rely on AnyDevice
add_input();
......@@ -104,7 +103,7 @@ ToDevice::initialize(ErrorHandler *errh)
/* start out with max number of tickets */
int max_tickets = ScheduleInfo::query(this, errh);
set_max_tickets(max_tickets);
set_tickets(max_tickets);
set_tickets(ScheduleInfo::DEFAULT);
#endif
join_scheduler();
......@@ -120,8 +119,6 @@ ToDevice::reset_counts()
_busy_returns = 0;
#if CLICK_DEVICE_STATS
_activations = 0;
_idle_pulls = 0;
_idle_calls = 0;
_linux_pkts_sent = 0;
_time_clean = 0;
_time_queue = 0;
......@@ -255,12 +252,6 @@ should only be called from net_bh().
if (sent > 0 || _activations > 0) _activations++;
#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 HAVE_POLLING
......@@ -278,33 +269,7 @@ should only be called from net_bh().
}
#endif
#if CLICK_DEVICE_ADJUST_TICKETS
int base = tickets()/4;
if (base < 2) base = 2;
int adj = 0;
/*
* 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;
adjust_tickets(sent);
reschedule();
}
......@@ -340,7 +305,8 @@ ToDevice::queue_packet(Packet *p)
_hard_start++;
}
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);
_rejected++;
}
......@@ -363,8 +329,6 @@ ToDevice_read_calls(Element *f, void *)
String(td->_busy_returns) + " device busy returns\n" +
String(td->_npackets) + " packets sent\n" +
#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->_pull_cycles) + " cycles pull\n" +
String(td->_time_clean) + " cycles clean\n" +
......
......@@ -62,8 +62,6 @@ class ToDevice : public AnyDevice {
#if CLICK_DEVICE_STATS
// Statistics.
unsigned long long _idle_calls;
unsigned long long _idle_pulls;
unsigned long long _linux_pkts_sent;
unsigned long long _time_clean;
unsigned long long _time_queue;
......@@ -90,8 +88,6 @@ class ToDevice : public AnyDevice {
bool _registered;
bool _polling;
int _dev_idle;
int _last_tx;
int _last_busy;
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