From owner-p4-projects@FreeBSD.ORG Mon Nov 12 05:24:22 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CA1D516A468; Mon, 12 Nov 2007 05:24:21 +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 7DFF916A420 for ; Mon, 12 Nov 2007 05:24:21 +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 6B96E13C4A6 for ; Mon, 12 Nov 2007 05:24:21 +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 lAC5OLrg031523 for ; Mon, 12 Nov 2007 05:24:21 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lAC5OK7T031519 for perforce@freebsd.org; Mon, 12 Nov 2007 05:24:21 GMT (envelope-from kmacy@freebsd.org) Date: Mon, 12 Nov 2007 05:24:21 GMT Message-Id: <200711120524.lAC5OK7T031519@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 128972 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: Mon, 12 Nov 2007 05:24:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=128972 Change 128972 by kmacy@kmacy:storage:toestack on 2007/11/12 05:23:35 update to work on freebsd Affected files ... .. //depot/projects/toestack/usr.sbin/cxgbtool/cxgbtool.c#2 edit Differences ... ==== //depot/projects/toestack/usr.sbin/cxgbtool/cxgbtool.c#2 (text+ko) ==== @@ -68,6 +68,41 @@ #include #include "version.h" +struct toetool_reg { + uint32_t cmd; + uint32_t addr; + uint32_t val; +}; + +struct toetool_mtus { + uint32_t cmd; + uint32_t nmtus; + uint16_t mtus[NMTUS]; +}; + +struct toetool_pm { + uint32_t cmd; + uint32_t tx_pg_sz; + uint32_t tx_num_pg; + uint32_t rx_pg_sz; + uint32_t rx_num_pg; + uint32_t pm_total; +}; + +struct toetool_tcam { + uint32_t cmd; + uint32_t tcam_size; + uint32_t nservers; + uint32_t nroutes; + uint32_t nfilters; +}; + +struct toetool_tcb { + uint32_t cmd; + uint32_t tcb_index; + uint32_t tcb_data[TCB_WORDS]; +}; + struct reg_info { const char *name; uint16_t addr; @@ -75,6 +110,80 @@ }; +struct toetool_tcam_word { + uint32_t cmd; + uint32_t addr; + uint32_t buf[3]; +}; + + +struct toetool_cntxt { + uint32_t cmd; + uint32_t cntxt_type; + uint32_t cntxt_id; + uint32_t data[4]; +}; + +struct toetool_desc { + uint32_t cmd; + uint32_t queue_num; + uint32_t idx; + uint32_t size; + uint8_t data[128]; +}; + +struct toetool_proto { + uint32_t cmd; + uint32_t data[5 * 128]; +}; + +struct toetool_qset_params { + uint32_t cmd; + uint32_t qset_idx; + int32_t txq_size[3]; + int32_t rspq_size; + int32_t fl_size[2]; + int32_t intr_lat; + int32_t polling; + int32_t lro; + int32_t cong_thres; + int32_t vector; + int32_t qnum; +}; + +struct toetool_trace { + uint32_t cmd; + uint32_t sip; + uint32_t sip_mask; + uint32_t dip; + uint32_t dip_mask; + uint16_t sport; + uint16_t sport_mask; + uint16_t dport; + uint16_t dport_mask; + uint32_t vlan:12; + uint32_t vlan_mask:12; + uint32_t intf:4; + uint32_t intf_mask:4; + uint8_t proto; + uint8_t proto_mask; + uint8_t invert_match:1; + uint8_t config_tx:1; + uint8_t config_rx:1; + uint8_t trace_tx:1; + uint8_t trace_rx:1; +}; + +struct toetool_pktsched_params { + uint32_t cmd; + uint8_t sched; + uint8_t idx; + uint8_t min; + uint8_t max; + uint8_t binding; +}; + + #include "reg_defs.c" #if defined(CONFIG_T3_REGS) # include "reg_defs_t3.c" @@ -447,9 +556,11 @@ if (revision == 0) return dump_regs_t3(argc, argv, start_arg, (uint32_t *)regs.data, is_pcie); - if (revision == 2) + if (revision == 2 || revision == 3) return dump_regs_t3b(argc, argv, start_arg, (uint32_t *)regs.data, is_pcie); + else + printf("revision=%d :-( \n", revision); } #endif errx(1, "unknown card type %d", vers); @@ -562,14 +673,14 @@ if (argc == start_arg) { op.cmd = TOETOOL_GETMTUTAB; - op.nmtus = MAX_NMTUS; + op.nmtus = NMTUS; if (doit(iff_name, &op) < 0) err(1, "get MTU table"); for (i = 0; i < op.nmtus; ++i) printf("%u ", op.mtus[i]); printf("\n"); - } else if (argc <= start_arg + MAX_NMTUS) { + } else if (argc <= start_arg + NMTUS) { op.cmd = TOETOOL_SETMTUTAB; op.nmtus = argc - start_arg; @@ -830,14 +941,10 @@ #define FBUF_WRAP_FSZ (FBUF_WRAP_SZ >> 3) #define MEM_CM_WRC_SIZE WRC_SIZE -typedef char int8_t; -typedef short int16_t; -typedef int int32_t; typedef long long _s64; typedef unsigned char _u8; typedef unsigned short _u16; typedef unsigned int _uint32_t; -typedef unsigned long long uint64_t; enum fw_ri_mpa_attrs { FW_RI_MPA_RX_MARKER_ENABLE = 0x1, @@ -1005,7 +1112,7 @@ static void print_wrc(unsigned int wrc_idx, struct wrc *p) { - u32 *buf = (u32 *)p; + uint32_t *buf = (uint32_t *)p; unsigned int i, j; printf("WRC STATE (raw)\n"); @@ -1094,7 +1201,7 @@ static int get_wrc(int argc, char *argv[], int start_arg, const char *iff_name) { - struct toetool_mem_range *op; + struct ch_mem_range op; uint64_t *p; uint32_t *buf; unsigned int idx, i = 0; @@ -1105,34 +1212,33 @@ if (get_int_arg(argv[start_arg], &idx)) return -1; - op = malloc(sizeof(*op) + MEM_CM_WRC_SIZE); - if (!op) + op.buf =malloc(MEM_CM_WRC_SIZE); + if (!op.buf) err(1, "get_wrc: malloc failed"); - op->cmd = TOETOOL_GET_MEM; - op->mem_id = MEM_CM; - op->addr = read_reg(iff_name, 0x28c) + CM_WRCONTEXT_OFFSET + + buf = (uint32_t *)op.buf; + op.mem_id = MEM_CM; + op.addr = read_reg(iff_name, 0x28c) + CM_WRCONTEXT_OFFSET + idx * MEM_CM_WRC_SIZE; - op->len = MEM_CM_WRC_SIZE; - buf = (uint32_t *)op->buf; + op.len = MEM_CM_WRC_SIZE; - if (doit(iff_name, op) < 0) + if (doit(iff_name, CHELSIO_GET_MEM, &op) < 0) err(1, "get_wrc"); - + /* driver manges with the data... put it back into the the FW's view */ - for (p = (uint64_t *)op->buf; - p < (uint64_t *)(op->buf + MEM_CM_WRC_SIZE); p++) { + for (p = (uint64_t *)op.buf; + p < (uint64_t *)(op.buf + MEM_CM_WRC_SIZE); p++) { uint64_t flit = *p; buf[i++] = htonl((uint32_t)(flit >> 32)); buf[i++] = htonl((uint32_t)flit); } - print_wrc(idx, (struct wrc *)op->buf); - print_wrc_zero(idx, (struct wrc *)op->buf); - print_wrc_history((struct wrc *)op->buf); + print_wrc(idx, (struct wrc *)op.buf); + print_wrc_zero(idx, (struct wrc *)op.buf); + print_wrc_history((struct wrc *)op.buf); - free(op); + free(buf); return 0; } #endif @@ -1737,7 +1843,8 @@ } } - if (argc < 3) usage(stderr); + if (argc < 3) + usage(stderr); iff_name = argv[1]; if (!strcmp(argv[2], "reg")) @@ -1757,11 +1864,12 @@ r = conf_tcam(argc, argv, 3, iff_name); else if (!strcmp(argv[2], "tcb")) r = get_tcb(argc, argv, 3, iff_name); +#endif #ifdef WRC - else if (!strcmp(argv[2], "wrc")) + else if (!strcmp(argv[2], "wrc")) r = get_wrc(argc, argv, 3, iff_name); #endif -#endif + else if (!strcmp(argv[2], "regdump")) r = dump_regs(argc, argv, 3, iff_name); #ifdef CHELSIO_INTERNAL