Difference between
modified post 47dc0c6c by Anonymous on Tue 25th Jun 2024 10:52
original post 841080c by Anonymous on Tue 25th Jun 2024 10:13
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | diff --git a/lib/Makefile b/lib/Makefile | |
| 2 | 2 | index 8a0c415..6aebf3b 100644 | |
| 3 | 3 | --- a/lib/Makefile | |
| 4 | 4 | +++ b/lib/Makefile | |
| 5 | 5 | @@ -1,7 +1,7 @@ | |
| 6 | 6 | OBJS=igb | |
| 7 | 7 | INCL=e1000_82575.h e1000_defines.h e1000_hw.h e1000_osdep.h e1000_regs.h igb.h | |
| 8 | 8 | AVBLIB=libigb.a | |
| 9 | 9 | -#CFLAGS=-ggdb | |
| 10 | 10 | +CFLAGS=-ggdb -Wall | |
| 11 | 11 | ||
| 12 | 12 | CC?=gcc | |
| 13 | 13 | RANLIB?=ranlib | |
| 14 | 14 | diff --git a/lib/igb.c b/lib/igb.c | |
| 15 | - | index 647234f..7480ad8 100644 | |
| 15 | + | index 647234f..90f4062 100644 | |
| 16 | 16 | --- a/lib/igb.c | |
| 17 | 17 | +++ b/lib/igb.c | |
| 18 | - | @@ -57,6 +57,21 @@ | |
| 18 | + | @@ -51,12 +51,43 @@ | |
| 19 | + | #include <semaphore.h> | |
| 19 | 21 | ||
| 20 | - | #undef DEBUG | |
| 22 | + | +#define USE_DPRINTF 1 | |
| 22 | 23 | + | |
| 23 | - | +int g_debug_level = 2; | |
| 24 | + | +#ifdef USE_DPRINTF | |
| 25 | + | +#include <stdarg.h> | |
| 24 | 27 | + | |
| 25 | - | +#define dprintf_out printf | |
| 28 | + | #include "e1000_hw.h" | |
| 29 | + | #include "e1000_82575.h" | |
| 26 | 36 | + | |
| 27 | 37 | +#define DPRINTF_LEVEL_ENABLED(level) ((level) <= g_debug_level) | |
| 28 | 38 | +#define DPRINTF(level, args) \ | |
| 29 | 39 | + { \ | |
| 30 | 40 | + if (DPRINTF_LEVEL_ENABLED(level)) { \ | |
| 31 | 41 | + int saved_errno = errno; \ | |
| 32 | 42 | + dprintf_out args; \ | |
| 33 | 43 | + errno = saved_errno; \ | |
| 34 | 44 | + } \ | |
| 35 | 45 | + } | |
| 36 | 46 | + | |
| 37 | - | /********************************************************************* | |
| 47 | + | +void dprintf_out(const char *fmt, ...) | |
| 38 | - | * PCI Device ID Table | |
| 48 | + | +{ | |
| 39 | - | * | |
| 49 | + | + const char buffer[1024]; | |
| 40 | - | @@ -1008,8 +1023,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet) | |
| 50 | + | + va_list args; | |
| 41 | - | if (packet == NULL) | |
| 51 | + | + va_start(args, fmt); | |
| 42 | - | return -EINVAL; | |
| 52 | + | + (void)vsnprintf(buffer, sizeof(buffer), fmt, args); | |
| 43 | - | ||
| 53 | + | + syslog(LOG_DAEMON|LOG_ERR, buffer); | |
| 44 | - | - if (igb_lock(dev) != 0) | |
| 54 | + | + va_end(args); | |
| 45 | - | + if (igb_lock(dev) != 0) { | |
| 55 | + | +} | |
| 46 | - | + DPRINTF(1, ("igb_xmit: igb_lock() failed, errno=%d\n", errno)); | |
| 56 | + | +#endif /* USE_DPRINTF */ | |
| 47 | - | return errno; | |
| 57 | + | + | |
| 48 | - | + } | |
| 58 | + | + | |
| 59 | + | /********************************************************************* | |
| 49 | 65 | ||
| 66 | + | - if (igb_lock(dev) != 0) | |
| 51 | 71 | ||
| 52 | - | @@ -1100,8 +1117,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet) | |
| 72 | + | packet->next = NULL; /* used for cleanup */ | |
| 54 | 73 | ||
| 74 | + | @@ -1100,8 +1133,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet) | |
| 55 | 77 | unlock: | |
| 56 | 78 | - if (igb_unlock(dev) != 0) | |
| 57 | 79 | + if (igb_unlock(dev) != 0) { | |
| 58 | 80 | + DPRINTF(1, ("igb_xmit: igb_unlock() failed, errno=%d\n", errno)); | |
| 59 | 81 | return errno; | |
| 60 | 82 | + } | |
| 61 | 83 | ||
| 62 | 84 | return error; | |
| 63 | 85 | } | |
| 64 | - | @@ -1179,11 +1198,15 @@ int igb_lock(device_t *dev) | |
| 86 | + | @@ -1179,11 +1214,15 @@ int igb_lock(device_t *dev) | |
| 65 | 87 | case 0: | |
| 66 | 88 | break; | |
| 67 | 89 | case EOWNERDEAD: | |
| 68 | 90 | + DPRINTF(0, ("igb_lock: trying to recover mutex %p\n", adapter->memlock)); | |
| 69 | 91 | // some process terminated without unlocking the mutex | |
| 70 | 92 | - if (pthread_mutex_consistent(adapter->memlock) != 0) | |
| 71 | 93 | + if (pthread_mutex_consistent(adapter->memlock) != 0) { | |
| 72 | 94 | + DPRINTF(0, ("igb_lock: pthread_mutex_consistent() failed, errno=%d\n", errno)); | |
| 73 | 95 | return -errno; | |
| 74 | 96 | + } | |
| 75 | 97 | break; | |
| 76 | 98 | default: | |
| 77 | 99 | + DPRINTF(0, ("igb_lock: pthread_mutex_lock() failed, errno=%d\n", errno)); | |
| 78 | 100 | return -errno; | |
| 79 | 101 | break; | |
| 80 | 102 | } | |
| 81 | - | @@ -2486,6 +2509,8 @@ static int igb_create_lock(struct adapter *adapter) | |
| 103 | + | @@ -2486,6 +2525,8 @@ static int igb_create_lock(struct adapter *adapter) | |
| 82 | 104 | bool attr_allocated = false; | |
| 83 | 105 | pthread_mutexattr_t attr; | |
| 84 | 106 | ||
| 85 | 107 | + DPRINTF(2, ("--> igb_create_lock(adapter=%p)\n", adapter)); | |
| 86 | 108 | + | |
| 87 | 109 | if (!adapter) { | |
| 88 | 110 | errno = EINVAL; | |
| 89 | 111 | goto err; | |
| 90 | - | @@ -2541,13 +2566,17 @@ static int igb_create_lock(struct adapter *adapter) | |
| 112 | + | @@ -2541,13 +2582,17 @@ static int igb_create_lock(struct adapter *adapter) | |
| 91 | 113 | fl.l_len = 1; | |
| 92 | 114 | fl.l_pid = getpid(); | |
| 93 | 115 | ||
| 94 | 116 | - if (fcntl(fd, F_SETLKW, &fl) != 0) | |
| 95 | 117 | + if (fcntl(fd, F_SETLKW, &fl) != 0) { | |
| 96 | 118 | + DPRINTF(1, ("igb_create_lock: F_SETLKW failed, errno=%d\n", errno)); | |
| 97 | 119 | goto err; | |
| 98 | 120 | + } | |
| 99 | 121 | ||
| 100 | 122 | locked = true; | |
| 101 | 123 | ||
| 102 | 124 | - if (fstat(fd, &stat) != 0) | |
| 103 | 125 | + if (fstat(fd, &stat) != 0) { | |
| 104 | 126 | + DPRINTF(1, ("igb_create_lock: fstat() failed, errno=%d\n", errno)); | |
| 105 | 127 | goto err; | |
| 106 | 128 | + } | |
| 107 | 129 | ||
| 108 | 130 | if (stat.st_size == 0) { // file is empty, do initialization | |
| 109 | 131 | /* | |
| 110 | - | @@ -2604,5 +2633,7 @@ err: | |
| 132 | + | @@ -2604,5 +2649,7 @@ err: | |
| 111 | 133 | (void) close(fd); | |
| 112 | 134 | } | |
| 113 | 135 | ||
| 114 | 136 | + DPRINTF(2, ("<-- igb_create_lock, error=%d\n", (int)error)); | |
| 115 | 137 | + | |
| 116 | 138 | return error; | |
| 117 | 139 | } | |
| 118 | 140 |
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.
rovema.kpaste.net RSS