pastebin - collaborative debugging tool
rovema.kpaste.net RSS

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

    
11
diff --git a/lib/Makefile b/lib/Makefile
22
index 8a0c415..6aebf3b 100644
33
--- a/lib/Makefile
44
+++ b/lib/Makefile
55
@@ -1,7 +1,7 @@
66
 OBJS=igb
77
 INCL=e1000_82575.h e1000_defines.h e1000_hw.h e1000_osdep.h e1000_regs.h igb.h
88
 AVBLIB=libigb.a
99
-#CFLAGS=-ggdb
1010
+CFLAGS=-ggdb -Wall
1111
1212
 CC?=gcc
1313
 RANLIB?=ranlib
1414
diff --git a/lib/igb.c b/lib/igb.c
15-
index 647234f..90f4062 100644
15+
index 647234f..b4ecbf6 100644
1616
--- a/lib/igb.c
1717
+++ b/lib/igb.c
1818
@@ -51,12 +51,43 @@
1919
 #include <semaphore.h>
2020
 #include <pthread.h>
2121
2222
+#define USE_DPRINTF 1
2323
+
2424
+#ifdef USE_DPRINTF
2525
+#include <stdarg.h>
2626
+#endif
2727
+
2828
 #include "e1000_hw.h"
2929
 #include "e1000_82575.h"
3030
 #include "igb_internal.h"
3131
3232
 #undef DEBUG
3333
3434
+#ifdef USE_DPRINTF
3535
+int g_debug_level = 2;
3636
+
3737
+#define DPRINTF_LEVEL_ENABLED(level) ((level) <= g_debug_level)
3838
+#define DPRINTF(level, args) \
3939
+	{ \
4040
+		if (DPRINTF_LEVEL_ENABLED(level)) { \
4141
+			int saved_errno = errno; \
4242
+			dprintf_out args; \
4343
+			errno = saved_errno; \
4444
+		} \
4545
+	}
4646
+
4747
+void dprintf_out(const char *fmt, ...)
4848
+{
4949
+	const char buffer[1024];
5050
+	va_list args;
5151
+	va_start(args, fmt);
5252
+	(void)vsnprintf(buffer, sizeof(buffer), fmt, args);
5353
+	syslog(LOG_DAEMON|LOG_ERR, buffer);
5454
+	va_end(args);
5555
+}
5656
+#endif /* USE_DPRINTF */
5757
+
5858
+
5959
 /*********************************************************************
6060
  *  PCI Device ID Table
6161
  *
6262
@@ -1008,8 +1039,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
6363
 	if (packet == NULL)
6464
 		return -EINVAL;
6565
6666
-	if (igb_lock(dev) != 0)
6767
+	if (igb_lock(dev) != 0) {
6868
+		DPRINTF(1, ("igb_xmit: igb_lock() failed, errno=%d\n", errno));
6969
 		return errno;
7070
+	}
7171
7272
 	packet->next = NULL; /* used for cleanup */
7373
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+
 	 */
7681
82+
@@ -1100,8 +1134,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
7785
 unlock:
7886
-	if (igb_unlock(dev) != 0)
7987
+	if (igb_unlock(dev) != 0) {
8088
+		DPRINTF(1, ("igb_xmit: igb_unlock() failed, errno=%d\n", errno));
8189
 		return errno;
8290
+	}
8391
8492
 	return error;
8593
 }
86-
@@ -1179,11 +1214,15 @@ int igb_lock(device_t *dev)
94+
@@ -1179,11 +1215,15 @@ int igb_lock(device_t *dev)
8795
 		case 0:
8896
 			break;
8997
 		case EOWNERDEAD:
9098
+			DPRINTF(0, ("igb_lock: trying to recover mutex %p\n", adapter->memlock));
9199
 			// some process terminated without unlocking the mutex
92100
-			if (pthread_mutex_consistent(adapter->memlock) != 0)
93101
+			if (pthread_mutex_consistent(adapter->memlock) != 0) {
94102
+				DPRINTF(0, ("igb_lock: pthread_mutex_consistent() failed, errno=%d\n", errno));
95103
 				return -errno;
96104
+			}
97105
 			break;
98106
 		default:
99107
+			DPRINTF(0, ("igb_lock: pthread_mutex_lock() failed, errno=%d\n", errno));
100108
 			return -errno;
101109
 			break;
102110
 	}
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)
104112
 	bool attr_allocated = false;
105113
 	pthread_mutexattr_t attr;
106114
107115
+	DPRINTF(2, ("--> igb_create_lock(adapter=%p)\n", adapter));
108116
+
109117
 	if (!adapter) {
110118
 		errno = EINVAL;
111119
 		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)
113121
 	fl.l_len = 1;
114122
 	fl.l_pid = getpid();
115123
116124
-	if (fcntl(fd, F_SETLKW, &fl) != 0)
117125
+	if (fcntl(fd, F_SETLKW, &fl) != 0) {
118126
+		DPRINTF(1, ("igb_create_lock: F_SETLKW failed, errno=%d\n", errno));
119127
 		goto err;
120128
+	}
121129
122130
 	locked = true;
123131
124132
-	if (fstat(fd, &stat) != 0)
125133
+	if (fstat(fd, &stat) != 0) {
126134
+		DPRINTF(1, ("igb_create_lock: fstat() failed, errno=%d\n", errno));
127135
 		goto err;
128136
+	}
129137
130138
 	if (stat.st_size == 0) { // file is empty, do initialization
131139
 		/*
132-
@@ -2604,5 +2649,7 @@ err:
140+
@@ -2604,5 +2650,7 @@ err:
133141
 		(void) close(fd);
134142
 	}
135143
136144
+	DPRINTF(2, ("<-- igb_create_lock, error=%d\n", (int)error));
137145
+
138146
 	return error;
139147
 }
140148

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at