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