- diff --git a/lib/Makefile b/lib/Makefile
- index 8a0c415..6aebf3b 100644
- --- a/lib/Makefile
- +++ b/lib/Makefile
- @@ -1,7 +1,7 @@
- OBJS=igb
- INCL=e1000_82575.h e1000_defines.h e1000_hw.h e1000_osdep.h e1000_regs.h igb.h
- AVBLIB=libigb.a
- -#CFLAGS=-ggdb
- +CFLAGS=-ggdb -Wall
- CC?=gcc
- RANLIB?=ranlib
- diff --git a/lib/igb.c b/lib/igb.c
- index 647234f..7480ad8 100644
- --- a/lib/igb.c
- +++ b/lib/igb.c
- @@ -57,6 +57,21 @@
- #undef DEBUG
- +
- +int g_debug_level = 2;
- +
- +#define dprintf_out printf
- +
- +#define DPRINTF_LEVEL_ENABLED(level) ((level) <= g_debug_level)
- +#define DPRINTF(level, args) \
- + { \
- + if (DPRINTF_LEVEL_ENABLED(level)) { \
- + int saved_errno = errno; \
- + dprintf_out args; \
- + errno = saved_errno; \
- + } \
- + }
- +
- /*********************************************************************
- * PCI Device ID Table
- *
- @@ -1008,8 +1023,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
- if (packet == NULL)
- return -EINVAL;
- - if (igb_lock(dev) != 0)
- + if (igb_lock(dev) != 0) {
- + DPRINTF(1, ("igb_xmit: igb_lock() failed, errno=%d\n", errno));
- return errno;
- + }
- packet->next = NULL; /* used for cleanup */
- @@ -1100,8 +1117,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
- ++txr->tx_packets;
- unlock:
- - if (igb_unlock(dev) != 0)
- + if (igb_unlock(dev) != 0) {
- + DPRINTF(1, ("igb_xmit: igb_unlock() failed, errno=%d\n", errno));
- return errno;
- + }
- return error;
- }
- @@ -1179,11 +1198,15 @@ int igb_lock(device_t *dev)
- case 0:
- break;
- case EOWNERDEAD:
- + DPRINTF(0, ("igb_lock: trying to recover mutex %p\n", adapter->memlock));
- // some process terminated without unlocking the mutex
- - if (pthread_mutex_consistent(adapter->memlock) != 0)
- + if (pthread_mutex_consistent(adapter->memlock) != 0) {
- + DPRINTF(0, ("igb_lock: pthread_mutex_consistent() failed, errno=%d\n", errno));
- return -errno;
- + }
- break;
- default:
- + DPRINTF(0, ("igb_lock: pthread_mutex_lock() failed, errno=%d\n", errno));
- return -errno;
- break;
- }
- @@ -2486,6 +2509,8 @@ static int igb_create_lock(struct adapter *adapter)
- bool attr_allocated = false;
- pthread_mutexattr_t attr;
- + DPRINTF(2, ("--> igb_create_lock(adapter=%p)\n", adapter));
- +
- if (!adapter) {
- errno = EINVAL;
- goto err;
- @@ -2541,13 +2566,17 @@ static int igb_create_lock(struct adapter *adapter)
- fl.l_len = 1;
- fl.l_pid = getpid();
- - if (fcntl(fd, F_SETLKW, &fl) != 0)
- + if (fcntl(fd, F_SETLKW, &fl) != 0) {
- + DPRINTF(1, ("igb_create_lock: F_SETLKW failed, errno=%d\n", errno));
- goto err;
- + }
- locked = true;
- - if (fstat(fd, &stat) != 0)
- + if (fstat(fd, &stat) != 0) {
- + DPRINTF(1, ("igb_create_lock: fstat() failed, errno=%d\n", errno));
- goto err;
- + }
- if (stat.st_size == 0) { // file is empty, do initialization
- /*
- @@ -2604,5 +2633,7 @@ err:
- (void) close(fd);
- }
- + DPRINTF(2, ("<-- igb_create_lock, error=%d\n", (int)error));
- +
- return error;
- }
libigbavb debug code
Posted by Anonymous on Tue 25th Jun 2024 10:13
raw | new post
view followups (newest first): libigbavb debug code by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.