da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * CDDL HEADER START
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The contents of this file are subject to the terms of the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Common Development and Distribution License (the "License").
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * You may not use this file except in compliance with the License.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * See the License for the specific language governing permissions
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * and limitations under the License.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * When distributing Covered Code, include this CDDL HEADER in each
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * If applicable, add the following below this CDDL HEADER, with the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * fields enclosed by brackets "[]" replaced with your own identifying
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * information: Portions Copyright [yyyy] [name of copyright owner]
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * CDDL HEADER END
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Use is subject to license terms.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#define MAC_RX_SRS_SIZE (MAX_RINGS_PER_GROUP * sizeof (uintptr_t))
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#define LAYERED_WALKER_FOR_FLOW "flow_entry_cache"
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi#define LAYERED_WALKER_FOR_GROUP "mac_impl_cache"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* arguments passed to mac_flow dee-command */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* arguments passed to mac_srs dee-command */
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_RXSTAT (MAC_SRS_RX|MAC_SRS_STAT)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_TXSTAT (MAC_SRS_TX|MAC_SRS_STAT)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_RXCPU (MAC_SRS_RX|MAC_SRS_CPU)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_TXCPU (MAC_SRS_TX|MAC_SRS_CPU)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_RXCPUVERBOSE (MAC_SRS_RXCPU|MAC_SRS_VERBOSE)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail#define MAC_SRS_TXCPUVERBOSE (MAC_SRS_TXCPU|MAC_SRS_VERBOSE)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer#define MAC_SRS_RXINTR (MAC_SRS_RX|MAC_SRS_INTR)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer#define MAC_SRS_TXINTR (MAC_SRS_TX|MAC_SRS_INTR)
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi/* arguments passed to mac_group dcmd */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("tcp");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("udp");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("sctp");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("icmp");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("icmpv6");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("--");
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("low");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("medium");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("high");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("reset");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("--");
4a3b1d5b615ff6e54da1cc17f331e1ac794c5191Bart Coddens * Convert bandwidth in bps to a string in Mbps.
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_flow_bw2str(uint64_t bw, char *buf, ssize_t len)
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%?s %-20s %4s %?s %?s %-16s\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%<u>%?s %-20s %4s %?s %?s %-16s%</u>\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "ADDR", "FLOW NAME", "ID", "MCIP", "MIP", "NAME");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "%-9s %s%</u>\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%20s %4s%</u>\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%?s %-24s %3s %s\n", "", "", "SRS", "RX");
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%<u>%?s %-32s %16s %16s%</u>\n",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Display selected fields of the flow_entry_t structure
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_flow_dcmd_output(uintptr_t addr, uint_t flags, uint_t args)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#define FLOW_MAX_TYPE (sizeof (flow_type_bits) / sizeof (mdb_bitmask_t))
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#define FLOW_MAX_FLAGS (sizeof (flow_flag_bits) / sizeof (mdb_bitmask_t))
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_warn("failed to read struct flow_entry_s at %p", addr);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (fe.fe_mcip != NULL && mdb_vread(&mcip, sizeof (mcip),
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_vread(&mip, sizeof (mip), (uintptr_t)mcip.mci_mip);
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%?p %-16s\n",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng addr, fe.fe_flow_name, fe.fe_link_id, fe.fe_mcip,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng desc_addr = addr + OFFSETOF(flow_entry_t, fe_flow_desc);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_vread(&fdesc, sizeof (fdesc), desc_addr) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_warn("failed to read struct flow_description at %p",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "%4d:%-4d ",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_flow_proto2str(fdesc.fd_protocol), fdesc.fd_local_port,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng IN6_V4MAPPED_TO_INADDR(&fdesc.fd_local_addr, &in4);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng prop_addr = addr + OFFSETOF(flow_entry_t, fe_resource_props);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_vread(&fprop, sizeof (fprop), prop_addr) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_warn("failed to read struct mac_resoource_props "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "%8s %9s\n",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_flow_bw2str(fprop.mrp_maxbw, bwstr, STRSIZE),
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng match_addr = addr + OFFSETOF(flow_entry_t, fe_match);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_vread(&func, sizeof (func), match_addr);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_lookup_by_addr(func, MDB_SYM_EXACT, func_name,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_snprintf(flow_flags, 2 * FLOW_MAX_FLAGS, "%hb",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_snprintf(flow_type, 2 * FLOW_MAX_TYPE, "%hb",
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy addr, fe.fe_flow_name, flow_type, flow_flags, func_name);
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail uintptr_t rxaddr, rx_srs[MAX_RINGS_PER_GROUP] = {0};
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rxaddr = addr + OFFSETOF(flow_entry_t, fe_rx_srs);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_vread(rx_srs, MAC_RX_SRS_SIZE, rxaddr);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < MAX_RINGS_PER_GROUP; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (rx_srs[i] == 0)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng txaddr = addr + OFFSETOF(flow_entry_t, fe_tx_srs);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_vread(&tx_srs, sizeof (uintptr_t), txaddr);
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski * Sum bytes for all Rx SRS.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_srs = (mac_soft_ring_set_t *)(fe.fe_rx_srs[i]);
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski if (mdb_vread(&mac_rx_stat, sizeof (mac_rx_stats_t),
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski mdb_warn("failed to read mac_rx_stats_t at %p",
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski * Sum bytes for Tx SRS.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_srs = (mac_soft_ring_set_t *)(fe.fe_tx_srs);
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski if (mdb_vread(&mac_tx_stat, sizeof (mac_tx_stats_t),
78b013d7a408ae8e9eacdb67cae24fc8ecab1ebfRyan Zezeski mdb_warn("failed to read max_tx_stats_t at %p",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer addr, fe.fe_flow_name, totibytes, totobytes);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parse the arguments passed to the dcmd and print all or one flow_entry_t
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * structures
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_flow_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_walk_dcmd("mac_flow", "mac_flow", argc, argv) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi 'u', MDB_OPT_SETBITS, MAC_FLOW_USER, &args,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (argc > 2 || (argc == 2 && !(args & MAC_FLOW_USER)))
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * If no arguments was specified or just "-u" was specified then
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * we default to printing basic information of flows.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (mac_flow_dcmd_output(addr, flags, args));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_printf("If an address is specified, then flow_entry structure at "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "that address is printed. Otherwise all the flows in the system "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "are printed.\n");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-u\tdisplay user defined link & vnic flows.\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-a\tdisplay flow attributes\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-p\tdisplay flow properties\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-r\tdisplay rx side information\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-t\tdisplay tx side information\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-s\tdisplay flow statistics\n"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-m\tdisplay miscellaneous flow information\n\n");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_printf("%<u>Interpreting Flow type and Flow flags output.%</u>\n");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * called once by the debugger when the mac_flow walk begins.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_layered_walk(LAYERED_WALKER_FOR_FLOW, wsp) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Common walker step funciton for flow_entry_t, mac_soft_ring_set_t and
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * mac_ring_t.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Steps through each flow_entry_t and calls the callback function. If the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * user executed ::walk mac_flow, it just prints the address or if the user
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * executed ::mac_flow it displays selected fields of flow_entry_t structure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * by calling "mac_flow_dcmd"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail return ("DEF");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail return ("SER");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail return ("FO");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail return ("BW");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail return ("BWFO");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return ("AG");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return ("BWAG");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("--");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_printf("If an address is specified, then mac_soft_ring_set "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "structure at that address is printed. Otherwise all the "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "SRS in the system are printed.\n");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "\t-r\tdisplay recieve side SRS structures\n"
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "\t-t\tdisplay transmit side SRS structures\n"
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "\t-s\tdisplay statistics for RX or TX side\n"
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "\t-c\tdisplay CPU binding for RX or TX side\n"
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "\t-v\tverbose flag for CPU binding to list cpus\n"
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "\t-i\tdisplay mac_ring_t and interrupt information\n"
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "Note: use -r or -t (to specify RX or TX side respectively) along "
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "with -c or -s\n");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_printf("\n%<u>Interpreting TX Modes%</u>\n");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_printf("\tBWFO --> Bandwidth Fanout\n");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail * In verbose mode "::mac_srs -rcv or ::mac_srs -tcv", we print the CPUs
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail * assigned to a link and CPUS assigned to the soft rings.
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail * 'len' is used for formatting the output and represents the number of
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail * spaces between CPU list and Fanout CPU list in the output.
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbailmac_srs_print_cpu(int *i, uint32_t cnt, uint32_t *cpu_list, int *len)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail while (*i < cnt) {
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail /* We print 6 CPU's at a time to keep display within 80 cols */
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_printf("%02x%c", cpu_list[*i], ((*i == cnt - 1)?')':','));
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_srs_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_walk_dcmd("mac_srs", "mac_srs", argc, argv) == -1) {
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail 'v', MDB_OPT_SETBITS, MAC_SRS_VERBOSE, &args,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_warn("failed to read struct mac_soft_ring_set_s at %p",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail if (mdb_vread(&mci, sizeof (mci), (uintptr_t)srs.srs_mcip) == -1) {
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_warn("failed to read struct mac_client_impl_t at %p "
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%8s %3s%</u>\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "ADDR", "LINK_NAME", "STATE", "TYPE", "CNT",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%8d %8d %3d\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail addr, mci.mci_name, srs.srs_state, srs.srs_type,
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail srs.srs_count, srs.srs_size, srs.srs_soft_ring_count);
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%-8s %8s %8s %3s\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%-8s %8s %8s %3s%</u>\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%08x %08x %8d %8d %3d\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail addr, mci.mci_name, mac_srs_txmode2str(srs.srs_tx.st_mode),
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail srs.srs_state, srs.srs_type, srs.srs_count, srs.srs_size,
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "%-6s %-4s %-7s\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "%-6s %-4s %-7s%</u>\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail if ((args & MAC_SRS_RX) && (srs.srs_type & SRST_TX))
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "%-6d %-4d %-7d\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer addr, mci.mci_name, mc.mc_ncpus, mc.mc_rx_pollid,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mc.mc_rx_workerid, mc.mc_rx_intr_cpu, mc.mc_rx_fanout_cnt);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "", "", "SOFT", "WORKER", "INTR", "RETARGETED");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%<u>%?s %-12s %?s %8s %8s %8s%</u>\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "ADDR", "LINK_NAME", "RING", "CPU", "CPU", "CPU");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%?p %-12s ", addr, mci.mci_name);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Case of no soft rings, print the info from
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * mac_srs_tx_t.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (s_ringp = srs.srs_soft_ring_head, i = 0; s_ringp != NULL;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mc.mc_tx_intr_cpu[i], mc.mc_tx_retargeted_cpu[i]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%?s %-12s %?s %8s %?s %6s %6s\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "", "", "SOFT", "WORKER", "MAC", "", "INTR");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%<u>%?s %-12s %?s %8s %?s %6s %6s%</u>\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%?p %-12s ", addr, mci.mci_name);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Case of no soft rings, print the info from
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * mac_srs_tx_t.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (s_ringp = srs.srs_soft_ring_head, i = 0; s_ringp != NULL;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%?s %-12s %?p %8d %?p %6d %6d\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer m_ringp, m_ring.mr_info.mri_intr.mi_ddi_shared,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%<u>%?s %-12s %?s %8s %6s %6s%</u>\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "ADDR", "LINK_NAME", "RING", "SHARED", "CPU",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if ((args & MAC_SRS_RX) && (srs.srs_type & SRST_TX))
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mdb_printf("%?p %-12s ", addr, mci.mci_name);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer m_ringp, m_ring.mr_info.mri_intr.mi_ddi_shared,
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail int cpu_index = 0, fanout_index = 0, len = 0;
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail boolean_t cpu_done = B_FALSE, fanout_done = B_FALSE;
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "%-20s %-20s%</u>\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail if (((args & MAC_SRS_TX) && !(srs.srs_type & SRST_TX)) ||
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail ((args & MAC_SRS_RX) && (srs.srs_type & SRST_TX)))
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_printf("%?p %-20s %-20d %-20d\n", addr, mci.mci_name,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (mc.mc_ncpus == 0 && mc.mc_rx_fanout_cnt == 0)
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail /* print all cpus and cpus for soft rings */
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail fanout_done = mac_srs_print_cpu(&fanout_index,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_rx_stats_t *mac_rx_stat = &srs.srs_rx.sr_stat;
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%8s %8s %8s\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "%8s %8s %8s%</u>\n",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer addr, mci.mci_name, mac_rx_stat->mrs_intrcnt,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_rx_stat->mrs_pollcnt, mac_rx_stat->mrs_chaincntundr10,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_tx_stats_t *mac_tx_stat = &srs.srs_tx.st_stat;
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "", "", "SOFT", "DROP", "BLOCK", "UNBLOCK");
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%<u>%?s %-20s %?s %8s %8s %8s%</u>\n",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail "ADDR", "LINK_NAME", "RING", "COUNT", "COUNT",
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail mdb_printf("%?p %-20s ", addr, mci.mci_name);
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail * Case of no soft rings, print the info from
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail * mac_srs_tx_t.
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail for (s_ringp = srs.srs_soft_ring_head; s_ringp != NULL;
fcff38ebb7bf8c483f8a0427b4885ef7bbdc0c58Girish Moodalbail (void) mdb_vread(&s_ring, sizeof (s_ring),
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail mdb_printf("%<u>%?s %-20s %?s %?s %-3s%</u>\n",
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail "ADDR", "LINK_NAME", "FLENT", "HW RING", "DIR");
2ae51e795e518fd8980f736920a1a38dd17b3ad6Girish Moodalbail addr, mci.mci_name, srs.srs_flent, srs.srs_ring,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_layered_walk(LAYERED_WALKER_FOR_SRS, wsp) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("free");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("new");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("inuse");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("--");
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic char *
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_ring_classify2str(mac_classify_type_t classify)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("no");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("sw");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("hw");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return ("--");
da14cebe459d3275048785f25bd869cb09b5307fEric Chengmac_ring_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_walk_dcmd("mac_ring", "mac_ring", argc, argv) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_vread(&ring, sizeof (ring), addr) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_warn("failed to read struct mac_ring_s at %p", addr);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_vread(&srs, sizeof (srs), (uintptr_t)ring.mr_srs) != -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) mdb_vread(&group, sizeof (group), (uintptr_t)ring.mr_gh);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "%5s %?s %?s %s %</u>\n",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "%?p %?p %s\n",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring.mr_gh, mac_ring_classify2str(ring.mr_classify_type),
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (mdb_layered_walk(LAYERED_WALKER_FOR_RING, wsp) == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mdb_printf("If an address is specified, then mac_ring_t "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "structure at that address is printed. Otherwise all the "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "hardware rings in the system are printed.\n");
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * To walk groups we have to have our own somewhat-complicated state machine. We
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * basically start by walking the mac_impl_t walker as all groups are stored off
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * of the various mac_impl_t in the system. The tx and rx rings are kept
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * separately. So we'll need to walk through all the rx rings and then all of
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * the tx rings.
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("non-global walks are not supported\n");
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if ((ret = mdb_layered_walk(LAYERED_WALKER_FOR_GROUP, wsp)) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("couldn't walk '%s'", LAYERED_WALKER_FOR_GROUP);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * Nothing to do if we can't find the layer above us. But the kmem
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * walkers are a bit unsporting, they don't actually read in the data
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_vread(&mi, sizeof (mac_impl_t), wsp->walk_addr) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("failed to read mac_impl_t at %p", wsp->walk_addr);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * First go for rx groups, then tx groups.
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_vread(&mg, sizeof (mac_group_t), mgp) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("failed to read mac_group_t at %p", mgp);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi ret = wsp->walk_callback(mgp, &mg, wsp->walk_cbdata);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_vread(&mg, sizeof (mac_group_t), mgp) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("failed to read mac_group_t at %p", mgp);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi ret = wsp->walk_callback(mgp, &mg, wsp->walk_cbdata);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi uintptr_t mcp = (uintptr_t)mgp->mrg_clients;
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_vread(&c, sizeof (c), mcp) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("failed to read mac_grp_client_t at %p", mcp);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchistatic const char *
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchistatic const char *
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchimac_group_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_walk_dcmd("mac_group", "mac_group", argc, argv) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi 'u', MDB_OPT_SETBITS, MAC_GROUP_UNINIT, &args,
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mdb_vread(&mg, sizeof (mac_group_t), addr) == -1) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_warn("failed to read mac_group_t at %p", addr);
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (DCMD_HDRSPEC(flags) && !(flags & DCMD_PIPE_OUT)) {
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_printf("%<u>%-?s %-8s %-10s %6s %8s %-?s%</u>\n",
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi "ADDR", "TYPE", "STATE", "NRINGS", "NCLIENTS", "RINGS");
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if ((args & MAC_GROUP_RX) != 0 && mg.mrg_type != MAC_RING_TYPE_RX)
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if ((args & MAC_GROUP_TX) != 0 && mg.mrg_type != MAC_RING_TYPE_TX)
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * By default, don't show uninitialized groups. They're not very
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi * interesting. They have no rings and no clients.
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi if (mg.mrg_state == MAC_GROUP_STATE_UNINIT &&
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mdb_printf("%?p %-8s %-10s %6d %8d %?p\n", addr, mac_group_type(&mg),
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi mac_group_state(&mg), mg.mrg_cur_count, clients, mg.mrg_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* Supported dee-commands */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng {"mac_flow", "?[-u] [-aprtsm]", "display Flow Entry structures",
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi {"mac_group", "?[-rtu]", "display MAC Ring Groups", mac_group_dcmd,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer {"mac_srs", "?[ -r[i|s|c[v]] | -t[i|s|c[v]] ]",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "display MAC Soft Ring Set" " structures", mac_srs_dcmd,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng {"mac_ring", "?", "display MAC ring (hardware) structures",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* Supported walkers */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng {"mac_flow", "walk list of flow entry structures", mac_flow_walk_init,
d47ced1f1801c1c1ca309ff7c5997bf0c8cb4092Robert Mustacchi {"mac_group", "walk list of ring group structures", mac_group_walk_init,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng {"mac_srs", "walk list of mac soft ring set structures",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_srs_walk_init, mac_common_walk_step, NULL, NULL},
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng {"mac_ring", "walk list of mac ring structures", mac_ring_walk_init,
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };