Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Feb 2008 06:47:41 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 134879 for review
Message-ID:  <200802060647.m166lfFl076896@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134879

Change 134879 by kmacy@kmacy:storage:toehead on 2008/02/06 06:46:58

	fix endian issues and tcb fetch

Affected files ...

.. //depot/projects/toehead/usr.sbin/cxgbtool/cxgbtool.c#2 edit

Differences ...

==== //depot/projects/toehead/usr.sbin/cxgbtool/cxgbtool.c#2 (text+ko) ====

@@ -43,6 +43,7 @@
 #include <err.h>
 #include <errno.h>
 #include <inttypes.h>
+#include <sys/endian.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
@@ -695,11 +696,9 @@
 	return 0;
 }
 
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define ntohll(n) (n)
-#else
-# define ntohll(n) bswap_64(n)
-#endif
+
+#define ntohll(n) be64toh((n))
+
 
 static int get_sge_desc(int argc, char *argv[], int start_arg,
 			const char *iff_name)
@@ -747,25 +746,28 @@
 }
 #endif
 
-#ifdef notyet
 static int get_tcb2(unsigned int tcb_idx, const char *iff_name)
 {
 	uint64_t *d;
 	unsigned int i;
-	struct toetool_mem_range *op;
-
-	op = malloc(sizeof(*op) + TCB_SIZE);
+	struct ch_mem_range *op;
+	char buf[TCB_SIZE];
+	
+	op = malloc(sizeof(*op));
 	if (!op)
 		err(1, "get TCB");
 
-	op->cmd    = TOETOOL_GET_MEM;
 	op->mem_id = MEM_CM;
 	op->addr   = tcb_idx * TCB_SIZE;
 	op->len    = TCB_SIZE;
-
-	if (doit(iff_name, op) < 0)
+	op->buf	   = buf;
+	
+	if (doit(iff_name, CHELSIO_GET_MEM, op) < 0) {
+		printf("failed to get mem\n");
+		
 		err(1, "get TCB");
-
+	}
+	
 	for (d = (uint64_t *)op->buf, i = 0; i < TCB_SIZE / 32; i++) {
 		printf("%2u:", i);
 		printf(" %08x %08x %08x %08x", (uint32_t)d[1],
@@ -785,11 +787,11 @@
 {
 	int i;
 	uint32_t *d;
-	struct toetool_tcb op;
+	struct ch_tcb op;
 
 	if (argc != start_arg + 1) return -1;
 
-	op.cmd = TOETOOL_GET_TCB;
+	op.cmd = CH_GET_TCB;
 	if (get_int_arg(argv[start_arg], &op.tcb_index))
 		return -1;
 
@@ -797,9 +799,13 @@
 	 * If this operation isn't directly supported by the driver we may
 	 * still be able to read TCBs using the generic memory dump operation.
 	 */
-	if (doit(iff_name, &op) < 0) {
-		if (errno != EOPNOTSUPP)
+	if (doit(iff_name, CHELSIO_GET_TCB, &op) < 0) {
+		if (errno != EOPNOTSUPP) {
+			printf("fail\n");
+			
 			err(1, "get TCB");
+		}
+		
 		return get_tcb2(op.tcb_index, iff_name);
 	}
 
@@ -813,7 +819,7 @@
 	}
 	return 0;
 }
-#endif
+
 #ifdef WRC
 /*
  * The following defines, typedefs and structures are defined in the FW and
@@ -1755,8 +1761,10 @@
 		r = conf_pm(argc, argv, 3, iff_name);
 	else if (!strcmp(argv[2], "tcam"))
 		r = conf_tcam(argc, argv, 3, iff_name);
+#endif	
 	else if (!strcmp(argv[2], "tcb"))
 		r = get_tcb(argc, argv, 3, iff_name);
+#ifdef notyet
 #ifdef WRC
 	else if (!strcmp(argv[2], "wrc"))
 		r = get_wrc(argc, argv, 3, iff_name);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802060647.m166lfFl076896>