From owner-p4-projects@FreeBSD.ORG Wed Feb 6 06:47:42 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7DB1216A419; Wed, 6 Feb 2008 06:47:42 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 435DC16A41B for ; Wed, 6 Feb 2008 06:47:42 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3247713C46A for ; Wed, 6 Feb 2008 06:47:42 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m166lfWb076899 for ; Wed, 6 Feb 2008 06:47:41 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m166lfFl076896 for perforce@freebsd.org; Wed, 6 Feb 2008 06:47:41 GMT (envelope-from kmacy@freebsd.org) Date: Wed, 6 Feb 2008 06:47:41 GMT Message-Id: <200802060647.m166lfFl076896@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 134879 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2008 06:47:42 -0000 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 #include #include +#include #include #include #include @@ -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);