added profiling code, can be enabled in debug.h
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7595 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|
||||||
|
// #define PROFILING
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define TRACE(a...) dprintf("rtl8169: " a)
|
#define TRACE(a...) dprintf("rtl8169: " a)
|
||||||
#define ASSERT(a) if (a) ; else panic("rtl8169: ASSERT failed, " #a)
|
#define ASSERT(a) if (a) ; else panic("rtl8169: ASSERT failed, " #a)
|
||||||
@@ -29,6 +31,12 @@
|
|||||||
#define ASSERT(a...)
|
#define ASSERT(a...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PROFILING
|
||||||
|
#define PROFILING_ONLY(a) a
|
||||||
|
#else
|
||||||
|
#define PROFILING_ONLY(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ERROR(a...) dprintf("rtl8169: ERROR " a)
|
#define ERROR(a...) dprintf("rtl8169: ERROR " a)
|
||||||
#define PRINT(a...) dprintf("rtl8169: " a)
|
#define PRINT(a...) dprintf("rtl8169: " a)
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,35 @@ print_link_status(rtl8169_device *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PROFILING
|
||||||
|
static void
|
||||||
|
print_debug_info(void *cookie)
|
||||||
|
{
|
||||||
|
rtl8169_device *device = (rtl8169_device *)cookie;
|
||||||
|
|
||||||
|
// only print if interrupt count changed
|
||||||
|
if (device->intTotalCount == device->intTotalCountOld)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PRINT("Int %10d, %6d/s Rx: %10d, %6d/s Tx: %10d, %6d/s Tmr %10d, %6d/s\n",
|
||||||
|
device->intTotalCount,
|
||||||
|
device->intCurrentCount,
|
||||||
|
device->intRxTotalCount,
|
||||||
|
device->intRxCurrentCount,
|
||||||
|
device->intTxTotalCount,
|
||||||
|
device->intTxCurrentCount,
|
||||||
|
device->intTimerTotalCount,
|
||||||
|
device->intTimerCurrentCount);
|
||||||
|
|
||||||
|
device->intTotalCountOld = device->intTotalCount;
|
||||||
|
device->intCurrentCount = 0;
|
||||||
|
device->intRxCurrentCount = 0;
|
||||||
|
device->intTxCurrentCount = 0;
|
||||||
|
device->intTimerCurrentCount = 0;
|
||||||
|
}
|
||||||
|
#endif // PROFILING
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
init_buf_desc(rtl8169_device *device)
|
init_buf_desc(rtl8169_device *device)
|
||||||
{
|
{
|
||||||
@@ -319,23 +348,34 @@ rtl8169_int(void *data)
|
|||||||
write16(REG_INT_STAT, stat);
|
write16(REG_INT_STAT, stat);
|
||||||
ret = B_HANDLED_INTERRUPT;
|
ret = B_HANDLED_INTERRUPT;
|
||||||
|
|
||||||
|
PROFILING_ONLY(device->intTotalCount++);
|
||||||
|
PROFILING_ONLY(device->intCurrentCount++);
|
||||||
|
|
||||||
if (stat & INT_FOVW) {
|
if (stat & INT_FOVW) {
|
||||||
TRACE("INT_FOVW\n");
|
TRACE("INT_FOVW\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stat & INT_TimeOut) {
|
||||||
|
PROFILING_ONLY(device->intTimerTotalCount++);
|
||||||
|
PROFILING_ONLY(device->intTimerCurrentCount++);
|
||||||
|
}
|
||||||
|
|
||||||
if (stat & INT_PUN) {
|
if (stat & INT_PUN) {
|
||||||
TRACE("INT_PUN\n");
|
|
||||||
dump_phy_stat(device);
|
dump_phy_stat(device);
|
||||||
print_link_status(device);
|
print_link_status(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat & (INT_TOK | INT_TER)) {
|
if (stat & (INT_TOK | INT_TER)) {
|
||||||
rtl8169_tx_int(device);
|
rtl8169_tx_int(device);
|
||||||
|
PROFILING_ONLY(device->intTxTotalCount++);
|
||||||
|
PROFILING_ONLY(device->intTxCurrentCount++);
|
||||||
ret = B_INVOKE_SCHEDULER;
|
ret = B_INVOKE_SCHEDULER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat & (INT_ROK | INT_RER)) {
|
if (stat & (INT_ROK | INT_RER)) {
|
||||||
rtl8169_rx_int(device);
|
rtl8169_rx_int(device);
|
||||||
|
PROFILING_ONLY(device->intRxTotalCount++);
|
||||||
|
PROFILING_ONLY(device->intRxCurrentCount++);
|
||||||
ret = B_INVOKE_SCHEDULER;
|
ret = B_INVOKE_SCHEDULER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,6 +521,19 @@ rtl8169_open(const char *name, uint32 flags, void** cookie)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PROFILING
|
||||||
|
device->intTotalCount = 0;
|
||||||
|
device->intTotalCountOld = 0;
|
||||||
|
device->intRxTotalCount = 0;
|
||||||
|
device->intTxTotalCount = 0;
|
||||||
|
device->intTimerTotalCount = 0;
|
||||||
|
device->intCurrentCount = 0;
|
||||||
|
device->intRxCurrentCount = 0;
|
||||||
|
device->intTxCurrentCount = 0;
|
||||||
|
device->intTimerCurrentCount = 0;
|
||||||
|
device->timer = create_timer(print_debug_info, device, 1000000, B_PERIODIC_TIMER);
|
||||||
|
#endif // PROFILING
|
||||||
|
|
||||||
write16(0xe0, read16(0xe0)); // write CR+ command
|
write16(0xe0, read16(0xe0)); // write CR+ command
|
||||||
|
|
||||||
write16(0xe0, read16(0xe0) | 0x0003); // don't know what this does, BSD says "enable C+ Tx/Rx"
|
write16(0xe0, read16(0xe0) | 0x0003); // don't know what this does, BSD says "enable C+ Tx/Rx"
|
||||||
@@ -573,6 +626,8 @@ rtl8169_free(void* cookie)
|
|||||||
// disable interrupts
|
// disable interrupts
|
||||||
write16(REG_INT_MASK, 0);
|
write16(REG_INT_MASK, 0);
|
||||||
|
|
||||||
|
PROFILING_ONLY(delete_timer(device->timer));
|
||||||
|
|
||||||
// well...
|
// well...
|
||||||
remove_io_interrupt_handler (device->irq, rtl8169_int, device);
|
remove_io_interrupt_handler (device->irq, rtl8169_int, device);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
#define __DEVICE_H
|
#define __DEVICE_H
|
||||||
|
|
||||||
#include <PCI.h>
|
#include <PCI.h>
|
||||||
|
#include "debug.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
#define TX_TIMEOUT 6000000 // 6 seconds
|
#define TX_TIMEOUT 6000000 // 6 seconds
|
||||||
#define FRAME_SIZE 1536 // must be multiple of 8
|
#define FRAME_SIZE 1536 // must be multiple of 8
|
||||||
@@ -43,6 +45,20 @@ typedef struct {
|
|||||||
volatile bool nonblocking;
|
volatile bool nonblocking;
|
||||||
volatile bool closed;
|
volatile bool closed;
|
||||||
|
|
||||||
|
#ifdef PROFILING
|
||||||
|
volatile int intTotalCount;
|
||||||
|
volatile int intTotalCountOld;
|
||||||
|
volatile int intRxTotalCount;
|
||||||
|
volatile int intTxTotalCount;
|
||||||
|
volatile int intTimerTotalCount;
|
||||||
|
volatile int intCurrentCount;
|
||||||
|
volatile int intRxCurrentCount;
|
||||||
|
volatile int intTxCurrentCount;
|
||||||
|
volatile int intTimerCurrentCount;
|
||||||
|
#endif // PROFILING
|
||||||
|
|
||||||
|
timer_id timer;
|
||||||
|
|
||||||
spinlock txSpinlock;
|
spinlock txSpinlock;
|
||||||
sem_id txFreeSem;
|
sem_id txFreeSem;
|
||||||
volatile int32 txNextIndex; // next descriptor that will be used for writing
|
volatile int32 txNextIndex; // next descriptor that will be used for writing
|
||||||
|
|||||||
Reference in New Issue
Block a user