mmd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Multidata dcmds and walkers, part of the genunix mdb module,
* and operate on core Multidata structures.
*/
#include <mdb/mdb_modapi.h>
#include <sys/sysmacros.h>
#include <sys/multidata.h>
#include <sys/multidata_impl.h>
#include "mmd.h"
/*
* Structure for passing internal variables.
*/
typedef struct mmd_data_s {
} mmd_data_t;
/*
* Structure to support circular, doubly-linked list (ql_t) walker.
*/
typedef struct q_walk_s {
char *qw_name; /* name of opaque list structure */
void *qw_data; /* opaque data structure */
} q_walk_t;
/*
* A dcmd which prints a summary of a multidata_t structure.
*/
/* ARGSUSED */
int
{
int i = 0;
return (DCMD_USAGE);
return (DCMD_ERR);
}
mdb_printf("Incorrect Multidata magic number at %p\n",
mdb_printf("\n");
return (i);
}
mdb_printf("%<b>%-5s %-?s %-4s %-?s %-4s %-4s %-4s %-?s%</b>",
"PDESC", "PATTBL", "HBUF", "HBUF", "PBUF", "PBUF", "PBUF", "PBUF");
mdb_printf("\n");
mdb_printf("%<b>%<u>%-5s %-?s %-4s %-?s %-4s %-4s %-4s %-?s%</u>%</b>",
"CNT", "ADDRESS", "REF", "ADDRESS", "REF", "CNT", "IDX",
"ADDRESS(ES)");
mdb_printf("\n");
if (mmd.mmd_pattbl != 0)
i = 0;
mdb_printf("%-5d %-16s %-4d %016p %-4d %-4d %-4d %016p\n",
for (++i; i < mmd.mmd_pbuf_cnt; i++)
return (DCMD_OK);
/* Walk packet descriptor slab list */
mmd_pd_slab_q))) == -1) {
mdb_warn("couldn't walk pdesc_slab_t list");
return (DCMD_ERR);
}
/* Walk packet descriptor list */
mmd_pd_q))) == -1) {
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* Print additional Multidata statistics
*/
static int
{
return (DCMD_ERR);
}
i++;
}
k += sz; /* total bytes */
j += i; /* total buffers */
mdb_printf("%<b>%<u>BUFFER STATS%</b>%</u>\n");
mdb_warn("couldn't read mblk_t at %p",
return (DCMD_ERR);
}
}
k += sz; /* total bytes */
j += i; /* total buffers */
mdb_printf("Total:\t\t\t%-4d buffers,\t%-12d bytes\n\n", j, k);
mdb_printf("%<b>%<u>PACKET DESCRIPTOR STATS%</u>%</b>\n");
/*
* Total claimed packet descriptors
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
mdb_printf("Total claimed:\t\t%-4d", i);
/*
* Total active header references
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
/*
* Total active packet descriptors
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
/*
* Total active payload references
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
mdb_printf("\t%<u>Active payload refs:\t%-12d bytes%</u>\n",
/*
* Number of removed packet descriptors (claimed - active)
*/
mdb_printf("Removed:\t\t%-4d", i - k);
/*
* Total active header and payload references
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
mdb_printf("%<b>%<u>ACTIVE ATTRIBUTE STATS%</u>%</b>\n");
/*
* Count local attributes
*/
mdb_warn("couldn't walk pdesc_t list");
return (DCMD_ERR);
}
/*
* Count global attributes
*/
if (patbkt != 0) {
/* Figure out the size of hash table */
/* Walk each bucket and count its contents */
i += sizeof (patbkt_t)) {
if (mdb_pwalk("pattr",
pbkt_pattr_q)) == -1) {
mdb_warn("couldn't walk pattr_t list");
return (DCMD_ERR);
}
}
}
mdb_printf("\n");
return (DCMD_OK);
}
/*
* Print the contents of a packet descriptor slab (pdesc_slab_t) structure.
*/
/* ARGSUSED */
static int
{
/* Figure out how many descriptors in a slab */
/* This shouldn't be true, unless something awful has happened */
if (pdslab_sz < 1) {
mdb_warn("incorrect pdslab_sz (0)");
pdslab_sz = 1;
}
/* Read in the entire slab chunk; may be of use one day */
return (WALK_ERR);
}
mdb_printf("\n%<b>%<u>%-?s %7s %7s%</u>%</b>\n",
"PDESC SLAB ADDR", "SIZE", "CLAIMED");
return (WALK_NEXT);
}
/*
* Generic packet descriptor (pdesc_t) counting routine.
*/
/* ARGSUSED */
static int
{
int i;
return (WALK_ERR);
}
mdb_printf("Incorrect pdesc magic number at %p\n",
if (f == 0) {
/* No flags set, count all pdescs */
/* Count only active (skip removed) pdescs */
} else if (f & PD_ATTR) {
/* Count local attributes */
if ((!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
/* Figure out the size of hash table */
/* Walk each bucket and count its contents */
i += sizeof (patbkt_t)) {
if (mdb_pwalk("pattr",
pbkt_pattr_q)) == -1) {
mdb_warn("couldn't walk pattr_t list");
return (WALK_ERR);
}
}
}
} else {
if (f & PD_HDR) {
/* Count header span referenced by pdesc */
if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
}
if (f & PD_PLD) {
/* Count payload span referenced by pdesc */
if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
}
}
}
return (WALK_NEXT);
}
/*
* Print the contents of a packet descriptor (pdesc_t) structure.
*/
/* ARGSUSED */
static int
{
int i = 0;
static const mdb_bitmask_t pd_flags_bits[] = {
{ NULL, 0, 0 }
};
return (WALK_ERR);
}
mdb_printf("Incorrect pdesc magic number at %p\n",
mdb_printf("\n");
mdb_printf("%<b>%-3s %-16s %-16s %-4s %-4s %-4s %-4s %-4s %-4s "
"%-4s %-6s%</b>",
"", "PDESC", "PATTBL", "HDR", "HDR",
"HDR", "HDR", "PLD", "PBUF", "PLD", "");
mdb_printf("\n");
"%<b>%<u>%-3s %-16s %-16s %-4s %-4s %-4s %-4s %-4s %-4s "
"%-4s %-6s%</u>%</b>",
"NO.", "ADDRESS", "ADDRESS", "SIZE", "HEAD",
"LEN", "TAIL", "CNT", "IDX", "SIZE", "FLAGS");
mdb_printf("\n");
}
mdb_printf("%-3d %016p %-16s %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-6b\n",
mdb_printf("%-62s %-4d %-4d\n",
return (WALK_NEXT);
}
/*
* General purpose ql_t walk_init routine.
*/
static int
{
/* Caller must have supplied an address */
return (WALK_ERR);
return (WALK_ERR);
}
return (WALK_DONE);
}
return (WALK_NEXT);
}
/*
* General purpose ql_t walk_step routine.
*/
int
{
/* We've wrapped around the circular list */
return (WALK_DONE);
wsp->walk_cbdata);
return (WALK_ERR);
}
/* Go forward to the next one */
/* We've done the first walk */
return (status);
}
/*
* General purpose ql_t walk_fini routine.
*/
void
{
}
/*
* Packet descriptor slab (pdesc_slab_t) walker initialization routine.
*/
int
{
return (WALK_DONE);
/*
* If we're called from multidata dcmd, then we're passed in
* the address of ql_t head; otherwise we'd have to get the
* address ourselves.
*/
/* Read in pdesc_slab_t */
mdb_warn("failed to read pdesc_slab_t at %p",
return (WALK_ERR);
}
/* pdesc_slab_t head is inside multidata_t */
} else
/* Pass it on to our generic ql_t walker init */
}
/*
* A dcmd which returns a multidata_t pointer from a pdesc_slab_t structure.
*/
/* ARGSUSED */
int
{
return (DCMD_USAGE);
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* Packet descriptor (pdesc_t) walker initialization routine.
*/
int
{
return (WALK_DONE);
/*
* If we're called from multidata dcmd, then we're passed in
* the address of ql_t head; otherwise we'd have to get the
* address ourselves.
*/
/* First we get pdsec_t */
mdb_warn("failed to read pdesc_t at %p",
return (WALK_ERR);
}
/* And then the pdesc_slab_t */
mdb_warn("failed to read pdesc_slab_t at %p",
return (WALK_ERR);
}
/* pdesc_t head is inside multidata_t */
} else
/* Pass it on to our generic ql_t walker init */
}
/*
* A dcmd which prints the attribute hash table.
*/
/* ARGSUSED */
int
{
int i, j;
return (DCMD_USAGE);
/* Figure out the size of hash table */
mdb_printf("\n");
mdb_printf("%<b>%<u>%-3s %-16s %-16s %-12s %-3s %-16s %-5s%</u>%</b>\n",
"BKT", "PATBKT ADDR", "PATTR ADDR", "TYPE", "LEN", "BUF ADDR",
"FLAGS");
/* Walk each bucket and print its contents */
i += sizeof (patbkt_t)) {
mdb_warn("couldn't walk pattr_t list");
return (DCMD_ERR);
}
mdb_printf("\n");
}
mdb_printf("\n");
return (DCMD_OK);
}
typedef struct pattr_type_s {
char *name; /* attribute name */
} pattr_type_t;
/*
* Generic packet attribute (pattr_t) counting routine.
*/
/* ARGSUSED */
static int
{
return (WALK_ERR);
}
mdb_printf("Incorrect pattr magic number at %p\n",
return (WALK_NEXT);
}
/*
* Print the contents of a packet attribute (pattr_t) structure.
*/
/* ARGSUSED */
static int
{
int i;
char *pa_name = "UNKNOWN";
static const pattr_type_t pa_type[] = {
{ "DSTADDRSAP", PATTR_DSTADDRSAP },
{ "SRCADDRSAP", PATTR_SRCADDRSAP },
{ "HCKSUM", PATTR_HCKSUM }
};
static const mdb_bitmask_t pa_flags_bits[] = {
{ NULL, 0, 0 }
};
return (WALK_ERR);
}
mdb_printf("Incorrect pattr magic number at %p\n",
/* Find a matching string */
}
mdb_printf("\n");
mdb_inc_indent(21);
}
mdb_dec_indent(21);
else
return (WALK_NEXT);
}
/*
* Packet attribute (pattr_t) walker initialization routine.
*/
int
{
return (WALK_DONE);
/*
* If we're called from pattbl dcmd, then we're passed in
* the address of ql_t head; otherwise we'd have to get the
* address ourselves.
*/
mdb_warn("failed to read pattr_t at %p",
return (WALK_ERR);
}
} else
/* Pass it on to our generic ql_t walker init */
}
/*
* A dcmd which returns a multidata_t pointer from a pattr_t.
*/
/* ARGSUSED */
int
{
return (DCMD_USAGE);
return (DCMD_ERR);
}
mdb_warn("Incorrect pattr magic number at %p",
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* A dcmd which returns a pdesc_slab_t from a pdesc_t.
*/
/* ARGSUSED */
int
{
return (DCMD_USAGE);
return (DCMD_ERR);
}
mdb_warn("Incorrect pdesc magic number at %p",
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* A dcmd which verifies the integrity of a pdesc_t.
*/
/* ARGSUSED */
int
{
return (DCMD_USAGE);
return (DCMD_ERR);
}
mdb_warn("Incorrect pdesc magic number at %p\n",
return (DCMD_ERR);
}
return (DCMD_ERR);
}
return (DCMD_ERR);
}
mdb_printf("Incorrect Multidata magic number at %p\n",
return (DCMD_ERR);
}
mdb_warn("Multidata pbuf count exceeds %d\n",
return (DCMD_ERR);
mdb_warn("descriptor pbuf count exceeds Multidata "
return (DCMD_ERR);
}
if (mmd.mmd_pbuf_cnt > 0) {
for (i = 0; i < mmd.mmd_pbuf_cnt; i++) {
mdb_warn("couldn't read mblk_t at %p",
return (DCMD_ERR);
}
}
}
/* It should have at least one buffer reference */
mdb_warn("descriptor has no buffer reference indicator "
return (DCMD_ERR);
mdb_warn("descriptor has no pbuf reference indicator in "
return (DCMD_ERR);
}
/* Bounds check the header fragment, if any */
PDESC_HDRSIZE(pdi)))) {
mdb_warn("descriptor has invalid header fragment\n");
return (DCMD_ERR);
}
i = 0;
/* Bounds check the payload fragment, if any */
PDESC_PLD_SPAN_SIZE(pdi, i)));
if (!valid) {
mdb_warn("descriptor has invalid payload fragment\n");
return (DCMD_ERR);
}
/* advance to next entry */
i++;
pa++;
}
return (DCMD_OK);
}