diff options
31 files changed, 59 insertions, 4115 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging index bd609f37d3..b885ac3518 100644 --- a/exception_lists/packaging +++ b/exception_lists/packaging @@ -22,7 +22,7 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. -# Copyright 2022 Garrett D'Amore <garrett@damore.org> +# Copyright 2022 Garrett D'Amore # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> # Copyright 2017 Toomas Soome <tsoome@me.com> # Copyright 2017 RackTop Systems. @@ -347,10 +347,6 @@ usr/include/libuutil_impl.h usr/lib/libuutil.so usr/lib/sparcv9/libuutil.so sparc # -# Private Multidata file. -# -usr/include/sys/multidata_impl.h -# # Even though all the objects built under usr/src/stand are later glommed # together into a couple of second-stage boot loaders, we dump the static # archives and lint libraries into $(ROOT)/stand for intermediate use @@ -4495,8 +4495,6 @@ f usr/include/sys/msg_impl.h 0644 root bin f usr/include/sys/msio.h 0644 root bin f usr/include/sys/msreg.h 0644 root bin f usr/include/sys/mtio.h 0644 root bin -f usr/include/sys/multidata.h 0644 root bin -f usr/include/sys/multidata_impl.h 0644 root bin f usr/include/sys/mutex.h 0644 root bin f usr/include/sys/mutex_impl.h 0644 root bin f usr/include/sys/nbmlock.h 0644 root bin diff --git a/usr/src/cmd/mdb/common/modules/genunix/Makefile.files b/usr/src/cmd/mdb/common/modules/genunix/Makefile.files index d371cf70fe..4e1900c44b 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/Makefile.files +++ b/usr/src/cmd/mdb/common/modules/genunix/Makefile.files @@ -23,6 +23,7 @@ # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2019 Joyent, Inc. # Copyright (c) 2013 by Delphix. All rights reserved. +# Copyright 2022 Garrett D'Amore # # @@ -63,7 +64,6 @@ GENUNIX_SRCS = \ log.c \ mdi.c \ memory.c \ - mmd.c \ modhash.c \ ndievents.c \ net.c \ diff --git a/usr/src/cmd/mdb/common/modules/genunix/genunix.c b/usr/src/cmd/mdb/common/modules/genunix/genunix.c index 2166f27bd7..30449f0631 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/genunix.c +++ b/usr/src/cmd/mdb/common/modules/genunix/genunix.c @@ -23,6 +23,7 @@ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2019 Joyent, Inc. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2022 Garrett D'Amore */ #include <mdb/mdb_param.h> @@ -90,7 +91,6 @@ #include "log.h" #include "mdi.h" #include "memory.h" -#include "mmd.h" #include "modhash.h" #include "ndievents.h" #include "net.h" @@ -4336,19 +4336,6 @@ static const mdb_dcmd_t dcmds[] = { { "swapinfo", "?", "display a struct swapinfo", swapinfof }, { "vnode2smap", ":[offset]", "translate vnode to smap", vnode2smap }, - /* from mmd.c */ - { "multidata", ":[-sv]", "display a summarized multidata_t", - multidata }, - { "pattbl", ":", "display a summarized multidata attribute table", - pattbl }, - { "pattr2multidata", ":", "print multidata pointer from pattr_t", - pattr2multidata }, - { "pdesc2slab", ":", "print pdesc slab pointer from pdesc_t", - pdesc2slab }, - { "pdesc_verify", ":", "verify integrity of a pdesc_t", pdesc_verify }, - { "slab2multidata", ":", "print multidata pointer from pdesc_slab_t", - slab2multidata }, - /* from modhash.c */ { "modhash", "?[-ceht] [-k key] [-v val] [-i index]", "display information about one or all mod_hash structures", @@ -4745,14 +4732,6 @@ static const mdb_walker_t walkers[] = { { "swapinfo", "walk swapinfo structures", swap_walk_init, swap_walk_step, NULL }, - /* from mmd.c */ - { "pattr", "walk pattr_t structures", pattr_walk_init, - mmdq_walk_step, mmdq_walk_fini }, - { "pdesc", "walk pdesc_t structures", - pdesc_walk_init, mmdq_walk_step, mmdq_walk_fini }, - { "pdesc_slab", "walk pdesc_slab_t structures", - pdesc_slab_walk_init, mmdq_walk_step, mmdq_walk_fini }, - /* from modhash.c */ { "modhash", "walk list of mod_hash structures", modhash_walk_init, modhash_walk_step, NULL }, diff --git a/usr/src/cmd/mdb/common/modules/genunix/mmd.c b/usr/src/cmd/mdb/common/modules/genunix/mmd.c deleted file mode 100644 index 119d51d122..0000000000 --- a/usr/src/cmd/mdb/common/modules/genunix/mmd.c +++ /dev/null @@ -1,1019 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -/* - * Multidata dcmds and walkers, part of the genunix mdb module, - * and operate on core Multidata structures. - */ - -#include <mdb/mdb_modapi.h> -#include <mdb/mdb_ks.h> - -#include <sys/types.h> -#include <sys/strsubr.h> -#include <sys/strsun.h> -#include <sys/stream.h> -#include <sys/modctl.h> -#include <sys/strft.h> -#include <sys/sysmacros.h> - -#include <sys/multidata.h> -#include <sys/multidata_impl.h> -#include <sys/pattr.h> - -#include "mmd.h" - -/* - * Structure for passing internal variables. - */ -typedef struct mmd_data_s { - uint_t flags; /* see flags values below */ - uint_t counter; /* scratch counter */ -} mmd_data_t; - -#define MMD_VERBOSE 0x1 /* multidata: provide more info */ -#define MMD_STATS 0x2 /* multidata: provide statistics */ -#define PD_HDR 0x4 /* pdesc: count header region */ -#define PD_PLD 0x8 /* pdesc: count payload region(s) */ -#define PD_ATTR 0x10 /* pdesc: count local attributes */ -#define PD_REM_NOCNT 0x20 /* pdesc: do not count removed pdesc */ - -/* - * Structure to support circular, doubly-linked list (ql_t) walker. - */ -typedef struct q_walk_s { - char *qw_name; /* name of opaque list structure */ - uintptr_t qw_head; /* address of list head */ - void *qw_data; /* opaque data structure */ - uint_t qw_sz; /* size of opaque data structure */ - uint_t qw_off; /* ql_t offset in opaque data structure */ - uint_t qw_step; /* walk_step has been called */ - uint_t qw_iprint; /* initial print */ -} q_walk_t; - -static int pdesc_slab_print(uintptr_t, q_walk_t *, mmd_data_t *); -static int pdesc_print(uintptr_t, q_walk_t *, mmd_data_t *); -static int pdesc_count(uintptr_t, q_walk_t *, mmd_data_t *); -static int pattr_print(uintptr_t, q_walk_t *, mmd_data_t *); -static int pattr_count(uintptr_t, q_walk_t *, mmd_data_t *); -static int multidata_stats(uintptr_t addr, multidata_t *); - -#define VA_OFF(x, o) (((uchar_t *)(x) + (o))) - -/* - * A dcmd which prints a summary of a multidata_t structure. - */ -/* ARGSUSED */ -int -multidata(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - mmd_data_t data; - multidata_t mmd; - char str[32] = "-"; - int i = 0; - - bzero(&data, sizeof (data)); - if (!(flags & DCMD_ADDRSPEC) || mdb_getopts(argc, argv, - 'v', MDB_OPT_SETBITS, MMD_VERBOSE, &data.flags, - 's', MDB_OPT_SETBITS, MMD_STATS, &data.flags, NULL) != argc) - return (DCMD_USAGE); - - if (mdb_vread(&mmd, sizeof (mmd), addr) == -1) { - mdb_warn("failed to read multidata_t structure at %p", addr); - return (DCMD_ERR); - } - - if (mmd.mmd_magic != MULTIDATA_MAGIC) - mdb_printf("Incorrect Multidata magic number at %p\n", - VA_OFF(addr, offsetof(multidata_t, mmd_magic))); - - mdb_printf("\n"); - if (data.flags & MMD_STATS) { - if ((i = multidata_stats(addr, &mmd)) != DCMD_OK) - 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) - mdb_snprintf(str, sizeof (str), "%016p", mmd.mmd_pattbl); - - i = 0; - mdb_printf("%-5d %-16s %-4d %016p %-4d %-4d %-4d %016p\n", - mmd.mmd_pd_cnt, str, mmd.mmd_hbuf_ref, mmd.mmd_hbuf, - mmd.mmd_pbuf_ref, mmd.mmd_pbuf_cnt, i, mmd.mmd_pbuf[i]); - - for (++i; i < mmd.mmd_pbuf_cnt; i++) - mdb_printf("%-54s %-4d %016p\n", "", i, mmd.mmd_pbuf[i]); - - if (!(data.flags & MMD_VERBOSE)) - return (DCMD_OK); - - /* Walk packet descriptor slab list */ - if (mdb_pwalk("pdesc_slab", (mdb_walk_cb_t)pdesc_slab_print, - &data, (uintptr_t)VA_OFF(addr, offsetof(multidata_t, - mmd_pd_slab_q))) == -1) { - mdb_warn("couldn't walk pdesc_slab_t list"); - return (DCMD_ERR); - } - - /* Walk packet descriptor list */ - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_print, - &data, (uintptr_t)VA_OFF(addr, offsetof(multidata_t, - mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - - return (DCMD_OK); -} - -/* - * Print additional Multidata statistics - */ -static int -multidata_stats(uintptr_t addr, multidata_t *mmd) -{ - mblk_t mp; - uint_t i = 0, j = 0, k = 0, sz = 0; - mmd_data_t data; - uintptr_t patbkt; - - bzero(&data, sizeof (data)); - - if (mmd->mmd_hbuf != 0) { - if (mdb_vread(&mp, sizeof (mp), - (uintptr_t)mmd->mmd_hbuf) == -1) { - mdb_warn("couldn't read mblk_t at %p", mmd->mmd_hbuf); - return (DCMD_ERR); - } - - i++; - sz = MBLKL(&mp); - } - - k += sz; /* total bytes */ - j += i; /* total buffers */ - - mdb_printf("%<b>%<u>BUFFER STATS%</b>%</u>\n"); - mdb_printf("Header:\t\t\t%-4d% buffer,\t%-12d bytes\n", i, sz); - - for (i = 0, sz = 0; i < mmd->mmd_pbuf_cnt; i++) { - if (mdb_vread(&mp, sizeof (mp), - (uintptr_t)mmd->mmd_pbuf[i]) == -1) { - mdb_warn("couldn't read mblk_t at %p", - mmd->mmd_pbuf[i]); - return (DCMD_ERR); - } - sz += MBLKL(&mp); - } - - k += sz; /* total bytes */ - j += i; /* total buffers */ - - mdb_printf("%<u>Payload:\t\t%-4d buffers,\t%-12d bytes%</u>\n", i, sz); - 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 - */ - data.flags = 0; - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - i = data.counter; /* claimed */ - mdb_printf("Total claimed:\t\t%-4d", i); - - /* - * Total active header references - */ - data.flags = (PD_HDR | PD_REM_NOCNT); - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - mdb_printf("\tActive header refs:\t%-12d bytes\n", data.counter); - - /* - * Total active packet descriptors - */ - data.flags = PD_REM_NOCNT; - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - k = data.counter; /* active */ - mdb_printf("Active:\t\t\t%-4d", data.counter); - - /* - * Total active payload references - */ - data.flags = (PD_PLD | PD_REM_NOCNT); - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - mdb_printf("\t%<u>Active payload refs:\t%-12d bytes%</u>\n", - data.counter); - - /* - * Number of removed packet descriptors (claimed - active) - */ - mdb_printf("Removed:\t\t%-4d", i - k); - - /* - * Total active header and payload references - */ - data.flags = (PD_PLD | PD_HDR | PD_REM_NOCNT); - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - mdb_printf("\tTotal:\t\t\t%-12d bytes\n\n", data.counter); - - mdb_printf("%<b>%<u>ACTIVE ATTRIBUTE STATS%</u>%</b>\n"); - - /* - * Count local attributes - */ - data.flags = (PD_ATTR | PD_REM_NOCNT); - data.counter = 0; - if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data, - (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) { - mdb_warn("couldn't walk pdesc_t list"); - return (DCMD_ERR); - } - mdb_printf("Local:\t\t\t%-4d", data.counter); - - /* - * Count global attributes - */ - data.counter = 0; - patbkt = (uintptr_t)mmd->mmd_pattbl; - if (patbkt != 0) { - uint_t pattbl_sz; - - /* Figure out the size of hash table */ - mdb_readvar(&pattbl_sz, "pattbl_sz"); - - /* Walk each bucket and count its contents */ - for (i = 0; i < (pattbl_sz * sizeof (patbkt_t)); - i += sizeof (patbkt_t)) { - if (mdb_pwalk("pattr", - (mdb_walk_cb_t)pattr_count, &data, - patbkt + i + offsetof(patbkt_t, - pbkt_pattr_q)) == -1) { - mdb_warn("couldn't walk pattr_t list"); - return (DCMD_ERR); - } - } - } - mdb_printf("\tGlobal:\t\t\t%-4d\n", data.counter); - mdb_printf("\n"); - - return (DCMD_OK); -} - -/* - * Print the contents of a packet descriptor slab (pdesc_slab_t) structure. - */ -/* ARGSUSED */ -static int -pdesc_slab_print(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data) -{ - pdesc_slab_t *slab; - uint_t pdslab_sz, slab_sz; - - /* Figure out how many descriptors in a slab */ - mdb_readvar(&pdslab_sz, "pdslab_sz"); - - /* 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 */ - slab_sz = PDESC_SLAB_SIZE(pdslab_sz); - slab = mdb_alloc(slab_sz, UM_SLEEP); - - if (mdb_vread(slab, slab_sz, addr) == -1) { - mdb_free(slab, slab_sz); - mdb_warn("failed to read pdesc_slab_t at %p", addr); - return (WALK_ERR); - } - - if (!qwp->qw_step) - mdb_printf("\n%<b>%<u>%-?s %7s %7s%</u>%</b>\n", - "PDESC SLAB ADDR", "SIZE", "CLAIMED"); - - mdb_printf("%016p %7d %7d\n", addr, slab->pds_sz, slab->pds_used); - - mdb_free(slab, slab_sz); - - return (WALK_NEXT); -} - -/* - * Generic packet descriptor (pdesc_t) counting routine. - */ -/* ARGSUSED */ -static int -pdesc_count(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data) -{ - pdesc_t pd; - int i; - uint_t f = data->flags; - - if (mdb_vread(&pd, sizeof (pd), addr) == -1) { - mdb_warn("failed to read pdesc_t at %p", addr); - return (WALK_ERR); - } - - if (pd.pd_magic != PDESC_MAGIC) - mdb_printf("Incorrect pdesc magic number at %p\n", - VA_OFF(addr, offsetof(pdesc_t, pd_magic))); - - if (f == 0) { - /* No flags set, count all pdescs */ - data->counter++; - } else if (f == PD_REM_NOCNT && !(pd.pd_pdi.flags & PDESC_REM_DEFER)) { - /* Count only active (skip removed) pdescs */ - data->counter++; - } else if (f & PD_ATTR) { - uint_t pattbl_sz; - uintptr_t patbkt = (uintptr_t)pd.pd_pattbl; - mmd_data_t attr_data; - - /* Count local attributes */ - if ((!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) && - !(pd.pd_pdi.flags & PDESC_REM_DEFER))) && patbkt != 0) { - - /* Figure out the size of hash table */ - mdb_readvar(&pattbl_sz, "pattbl_sz"); - - attr_data.counter = 0; - /* Walk each bucket and count its contents */ - for (i = 0; i < (pattbl_sz * sizeof (patbkt_t)); - i += sizeof (patbkt_t)) { - if (mdb_pwalk("pattr", - (mdb_walk_cb_t)pattr_count, &attr_data, - patbkt + i + offsetof(patbkt_t, - pbkt_pattr_q)) == -1) { - mdb_warn("couldn't walk pattr_t list"); - return (WALK_ERR); - } - } - data->counter += attr_data.counter; - } - } else { - if (f & PD_HDR) { - /* Count header span referenced by pdesc */ - if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) && - !(pd.pd_pdi.flags & PDESC_REM_DEFER))) - data->counter += PDESC_HDRL(&pd.pd_pdi); - } - - if (f & PD_PLD) { - /* Count payload span referenced by pdesc */ - if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) && - !(pd.pd_pdi.flags & PDESC_REM_DEFER))) { - for (i = 0; i < pd.pd_pdi.pld_cnt; i++) - data->counter += PDESC_PLD_SPAN_SIZE( - &pd.pd_pdi, i); - } - } - } - - return (WALK_NEXT); -} - -/* - * Print the contents of a packet descriptor (pdesc_t) structure. - */ -/* ARGSUSED */ -static int -pdesc_print(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data) -{ - pdesc_t pd; - int i = 0; - char str[32] = "-"; - static const mdb_bitmask_t pd_flags_bits[] = { - { "H", PDESC_HBUF_REF, PDESC_HBUF_REF }, - { "P", PDESC_PBUF_REF, PDESC_PBUF_REF }, - { "R", PDESC_REM_DEFER, PDESC_REM_DEFER }, - { NULL, 0, 0 } - }; - - if (mdb_vread(&pd, sizeof (pd), addr) == -1) { - mdb_warn("failed to read pdesc_t at %p", addr); - return (WALK_ERR); - } - - if (pd.pd_magic != PDESC_MAGIC) - mdb_printf("Incorrect pdesc magic number at %p\n", - VA_OFF(addr, offsetof(pdesc_t, pd_magic))); - - if (!qwp->qw_step) { - 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"); - mdb_printf( - "%<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"); - } - - if (pd.pd_pattbl != 0) - mdb_snprintf(str, sizeof (str), "%016p", pd.pd_pattbl); - - mdb_printf("%-3d %016p %-16s %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-6b\n", - ++data->counter, addr, str, - PDESC_HDRSIZE(&pd.pd_pdi), PDESC_HDRHEAD(&pd.pd_pdi), - PDESC_HDRL(&pd.pd_pdi), PDESC_HDRTAIL(&pd.pd_pdi), - pd.pd_pdi.pld_cnt, pd.pd_pdi.pld_ary[i].pld_pbuf_idx, - PDESC_PLD_SPAN_SIZE(&pd.pd_pdi, i), pd.pd_pdi.flags, pd_flags_bits); - - for (++i; i < pd.pd_pdi.pld_cnt; i++) - mdb_printf("%-62s %-4d %-4d\n", - "", pd.pd_pdi.pld_ary[i].pld_pbuf_idx, - PDESC_PLD_SPAN_SIZE(&pd.pd_pdi, i)); - - return (WALK_NEXT); -} - -/* - * General purpose ql_t walk_init routine. - */ -static int -mmdq_walk_init(mdb_walk_state_t *wsp, char *name, uintptr_t qh, - uint_t sz, uint_t ql_off) -{ - q_walk_t *qwp; - ql_t ql; - - /* Caller must have supplied an address */ - if (wsp->walk_addr == 0) - return (WALK_ERR); - - qwp = mdb_alloc(sizeof (*qwp), UM_SLEEP); - qwp->qw_name = name; - qwp->qw_head = qh; - qwp->qw_data = sz > 0 ? mdb_alloc(sz, UM_SLEEP) : NULL; - qwp->qw_sz = sz; - qwp->qw_off = ql_off; - qwp->qw_step = FALSE; - qwp->qw_iprint = TRUE; - - wsp->walk_data = qwp; - - if (mdb_vread(qwp->qw_data, qwp->qw_sz, wsp->walk_addr) == -1) { - mdb_warn("failed to read %s at %p", qwp->qw_name, - wsp->walk_addr); - mmdq_walk_fini(wsp); - return (WALK_ERR); - } - - bcopy((uchar_t *)qwp->qw_data + qwp->qw_off, &ql, sizeof (ql)); - if (qh == (uintptr_t)ql.ql_next) { - mmdq_walk_fini(wsp); - return (WALK_DONE); - } - - wsp->walk_addr = (uintptr_t)ql.ql_next; - - return (WALK_NEXT); -} - -/* - * General purpose ql_t walk_step routine. - */ -int -mmdq_walk_step(mdb_walk_state_t *wsp) -{ - q_walk_t *qwp = (q_walk_t *)wsp->walk_data; - int status = WALK_NEXT; - ql_t ql; - - /* We've wrapped around the circular list */ - if (qwp->qw_step && wsp->walk_addr == qwp->qw_head) - return (WALK_DONE); - - status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, - wsp->walk_cbdata); - - if (mdb_vread(qwp->qw_data, qwp->qw_sz, wsp->walk_addr) == -1) { - mdb_warn("failed to read %s at %p", qwp->qw_name, - wsp->walk_addr); - return (WALK_ERR); - } - - /* Go forward to the next one */ - bcopy((uchar_t *)qwp->qw_data + qwp->qw_off, &ql, sizeof (ql)); - wsp->walk_addr = (uintptr_t)ql.ql_next; - - /* We've done the first walk */ - qwp->qw_step = TRUE; - - return (status); -} - -/* - * General purpose ql_t walk_fini routine. - */ -void -mmdq_walk_fini(mdb_walk_state_t *wsp) -{ - q_walk_t *qwp = (q_walk_t *)wsp->walk_data; - - if (qwp->qw_data != NULL) - mdb_free(qwp->qw_data, qwp->qw_sz); - - mdb_free(qwp, sizeof (*qwp)); -} - -/* - * Packet descriptor slab (pdesc_slab_t) walker initialization routine. - */ -int -pdesc_slab_walk_init(mdb_walk_state_t *wsp) -{ - uintptr_t q_head; - - if (wsp->walk_addr == 0) - 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. - */ - if (wsp->walk_cbdata == NULL) { - pdesc_slab_t slab; - - /* Read in pdesc_slab_t */ - if (mdb_vread(&slab, sizeof (slab), wsp->walk_addr) == -1) { - mdb_warn("failed to read pdesc_slab_t at %p", - wsp->walk_addr); - return (WALK_ERR); - } - - /* pdesc_slab_t head is inside multidata_t */ - q_head = (uintptr_t)VA_OFF(slab.pds_mmd, - offsetof(multidata_t, mmd_pd_slab_q)); - } else - q_head = wsp->walk_addr; - - /* Pass it on to our generic ql_t walker init */ - return (mmdq_walk_init(wsp, "pdesc_slab_t", q_head, - sizeof (pdesc_slab_t), offsetof(pdesc_slab_t, pds_next))); -} - -/* - * A dcmd which returns a multidata_t pointer from a pdesc_slab_t structure. - */ -/* ARGSUSED */ -int -slab2multidata(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - pdesc_slab_t slab; - - if (!(flags & DCMD_ADDRSPEC) || argc != 0) - return (DCMD_USAGE); - - if (mdb_vread(&slab, sizeof (slab), addr) == -1) { - mdb_warn("couldn't read pdesc_slab_t at %p", addr); - return (DCMD_ERR); - } - - mdb_printf("%p\n", slab.pds_mmd); - - return (DCMD_OK); -} - -/* - * Packet descriptor (pdesc_t) walker initialization routine. - */ -int -pdesc_walk_init(mdb_walk_state_t *wsp) -{ - uintptr_t q_head; - - if (wsp->walk_addr == 0) - 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. - */ - if (wsp->walk_cbdata == NULL) { - pdesc_t pd; - pdesc_slab_t slab; - - /* First we get pdsec_t */ - if (mdb_vread(&pd, sizeof (pd), wsp->walk_addr) == -1) { - mdb_warn("failed to read pdesc_t at %p", - wsp->walk_addr); - return (WALK_ERR); - } - - /* And then the pdesc_slab_t */ - if (mdb_vread(&slab, sizeof (slab), - (uintptr_t)pd.pd_slab) == -1) { - mdb_warn("failed to read pdesc_slab_t at %p", - (uintptr_t)pd.pd_slab); - return (WALK_ERR); - } - - /* pdesc_t head is inside multidata_t */ - q_head = (uintptr_t)VA_OFF(slab.pds_mmd, - offsetof(multidata_t, mmd_pd_q)); - } else - q_head = wsp->walk_addr; - - /* Pass it on to our generic ql_t walker init */ - return (mmdq_walk_init(wsp, "pdesc_t", q_head, - sizeof (pdesc_t), offsetof(pdesc_t, pd_next))); -} - -/* - * A dcmd which prints the attribute hash table. - */ -/* ARGSUSED */ -int -pattbl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - mmd_data_t data; - uint_t pattbl_sz; - int i, j; - - bzero(&data, sizeof (data)); - if (!(flags & DCMD_ADDRSPEC) || argc != 0) - return (DCMD_USAGE); - - /* Figure out the size of hash table */ - mdb_readvar(&pattbl_sz, "pattbl_sz"); - - 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 */ - for (i = 0, j = 0; i < (pattbl_sz * sizeof (patbkt_t)); - i += sizeof (patbkt_t)) { - - mdb_printf("%-3d %016p ", j++, addr + i); - - if (mdb_pwalk("pattr", (mdb_walk_cb_t)pattr_print, &data, - addr + i + offsetof(patbkt_t, pbkt_pattr_q)) == -1) { - 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 */ - uint_t type; /* attribute type value */ -} pattr_type_t; - -/* - * Generic packet attribute (pattr_t) counting routine. - */ -/* ARGSUSED */ -static int -pattr_count(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data) -{ - pattr_t pattr; - - if (mdb_vread(&pattr, sizeof (pattr), addr) == -1) { - mdb_warn("failed to read pattr_t at %p", addr); - return (WALK_ERR); - } - - if (pattr.pat_magic != PATTR_MAGIC) - mdb_printf("Incorrect pattr magic number at %p\n", - VA_OFF(addr, offsetof(pattr_t, pat_magic))); - - data->counter++; - - return (WALK_NEXT); -} - -/* - * Print the contents of a packet attribute (pattr_t) structure. - */ -/* ARGSUSED */ -static int -pattr_print(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data) -{ - pattr_t pattr; - 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[] = { - { "R", PATTR_REM_DEFER, PATTR_REM_DEFER }, - { "P", PATTR_PERSIST, PATTR_PERSIST }, - { NULL, 0, 0 } - }; - - if (mdb_vread(&pattr, sizeof (pattr), addr) == -1) { - mdb_warn("failed to read pattr_t at %p", addr); - return (WALK_ERR); - } - - if (pattr.pat_magic != PATTR_MAGIC) - mdb_printf("Incorrect pattr magic number at %p\n", - VA_OFF(addr, offsetof(pattr_t, pat_magic))); - - /* Find a matching string */ - for (i = 0; i < (sizeof (pa_type) / sizeof (*pa_type)); i++) { - if (pa_type[i].type == pattr.pat_type) - pa_name = pa_type[i].name; - } - - if (!qwp->qw_iprint) { - mdb_printf("\n"); - mdb_inc_indent(21); - } - - mdb_printf("%016p %x:%-10s %-3d %016p %-5b", addr, pattr.pat_type, - pa_name, pattr.pat_buflen - sizeof (pattr), addr + sizeof (pattr), - pattr.pat_flags, pa_flags_bits); - - if (!qwp->qw_iprint) - mdb_dec_indent(21); - else - qwp->qw_iprint = FALSE; - - return (WALK_NEXT); -} - -/* - * Packet attribute (pattr_t) walker initialization routine. - */ -int -pattr_walk_init(mdb_walk_state_t *wsp) -{ - uintptr_t q_head; - - if (wsp->walk_addr == 0) - 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. - */ - if (wsp->walk_cbdata == NULL) { - pattr_t pattr; - - if (mdb_vread(&pattr, sizeof (pattr), wsp->walk_addr) == -1) { - mdb_warn("failed to read pattr_t at %p", - wsp->walk_addr); - return (WALK_ERR); - } - - q_head = (uintptr_t)VA_OFF(pattr.pat_lock, - -offsetof(patbkt_t, pbkt_lock)) + - offsetof(patbkt_t, pbkt_pattr_q); - } else - q_head = wsp->walk_addr; - - /* Pass it on to our generic ql_t walker init */ - return (mmdq_walk_init(wsp, "pattr_t", q_head, - sizeof (pattr_t), offsetof(pattr_t, pat_next))); -} - -/* - * A dcmd which returns a multidata_t pointer from a pattr_t. - */ -/* ARGSUSED */ -int -pattr2multidata(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - pattr_t pattr; - - if (!(flags & DCMD_ADDRSPEC) || argc != 0) - return (DCMD_USAGE); - - if (mdb_vread(&pattr, sizeof (pattr), addr) == -1) { - mdb_warn("couldn't read pattr_t at %p", addr); - return (DCMD_ERR); - } - - if (pattr.pat_magic != PATTR_MAGIC) { - mdb_warn("Incorrect pattr magic number at %p", - VA_OFF(addr, offsetof(pattr_t, pat_magic))); - return (DCMD_ERR); - } - - mdb_printf("%p\n", pattr.pat_mmd); - - return (DCMD_OK); -} - -/* - * A dcmd which returns a pdesc_slab_t from a pdesc_t. - */ -/* ARGSUSED */ -int -pdesc2slab(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - pdesc_t pd; - - if (!(flags & DCMD_ADDRSPEC) || argc != 0) - return (DCMD_USAGE); - - if (mdb_vread(&pd, sizeof (pd), addr) == -1) { - mdb_warn("couldn't read pdesc_t at %p", addr); - return (DCMD_ERR); - } - - if (pd.pd_magic != PDESC_MAGIC) { - mdb_warn("Incorrect pdesc magic number at %p", - VA_OFF(addr, offsetof(pdesc_t, pd_magic))); - return (DCMD_ERR); - } - - mdb_printf("%p\n", pd.pd_slab); - - return (DCMD_OK); -} - -/* - * A dcmd which verifies the integrity of a pdesc_t. - */ -/* ARGSUSED */ -int -pdesc_verify(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) -{ - multidata_t mmd; - pdesc_t pd; - pdescinfo_t *pdi = &pd.pd_pdi; - pdesc_slab_t slab; - mblk_t hbuf, pbuf[MULTIDATA_MAX_PBUFS]; - uint_t i, idx; - boolean_t valid = B_TRUE; - struct pld_ary_s *pa; - - if (!(flags & DCMD_ADDRSPEC) || argc != 0) - return (DCMD_USAGE); - - if (mdb_vread(&pd, sizeof (pd), addr) == -1) { - mdb_warn("couldn't read pdesc_t at %p", addr); - return (DCMD_ERR); - } - - if (pd.pd_magic != PDESC_MAGIC) { - mdb_warn("Incorrect pdesc magic number at %p\n", - VA_OFF(addr, offsetof(pdesc_t, pd_magic))); - return (DCMD_ERR); - } - - if (mdb_vread(&slab, sizeof (slab), (uintptr_t)pd.pd_slab) == -1) { - mdb_warn("couldn't read pdesc_slab_t at %p", pd.pd_slab); - return (DCMD_ERR); - } - - if (mdb_vread(&mmd, sizeof (mmd), (uintptr_t)slab.pds_mmd) == -1) { - mdb_warn("couldn't read multidata_t at %p", slab.pds_mmd); - return (DCMD_ERR); - } - - if (mmd.mmd_magic != MULTIDATA_MAGIC) - mdb_printf("Incorrect Multidata magic number at %p\n", - VA_OFF(slab.pds_mmd, offsetof(multidata_t, mmd_magic))); - - if (mmd.mmd_hbuf != 0 && - mdb_vread(&hbuf, sizeof (hbuf), (uintptr_t)mmd.mmd_hbuf) == -1) { - mdb_warn("couldn't read mblk_t at %p", mmd.mmd_hbuf); - return (DCMD_ERR); - } - - if (mmd.mmd_pbuf_cnt > MULTIDATA_MAX_PBUFS) { - mdb_warn("Multidata pbuf count exceeds %d\n", - MULTIDATA_MAX_PBUFS); - return (DCMD_ERR); - } else if (pdi->pld_cnt > mmd.mmd_pbuf_cnt) { - mdb_warn("descriptor pbuf count exceeds Multidata " - "pbuf count %d\n", mmd.mmd_pbuf_cnt); - return (DCMD_ERR); - } - - if (mmd.mmd_pbuf_cnt > 0) { - for (i = 0; i < mmd.mmd_pbuf_cnt; i++) { - if (mdb_vread(&pbuf[i], sizeof (mblk_t), - (uintptr_t)mmd.mmd_pbuf[i]) == -1) { - mdb_warn("couldn't read mblk_t at %p", - mmd.mmd_pbuf[i]); - return (DCMD_ERR); - } - } - } - - /* It should have at least one buffer reference */ - if (!(pdi->flags & PDESC_HAS_REF)) { - mdb_warn("descriptor has no buffer reference indicator " - "in flags (0x%x)\n", pdi->flags); - return (DCMD_ERR); - } else if (!(pdi->flags & PDESC_PBUF_REF) && pdi->pld_cnt > 0) { - mdb_warn("descriptor has no pbuf reference indicator in " - "flags (0x%x); but pld_cnt is %d\n", pdi->flags, - pdi->pld_cnt); - return (DCMD_ERR); - } - - /* Bounds check the header fragment, if any */ - if (!((pdi->flags & PDESC_HBUF_REF) && pdi->hdr_rptr != 0 && - pdi->hdr_wptr != 0 && pdi->hdr_base != 0 && - pdi->hdr_lim != 0 && pdi->hdr_lim >= pdi->hdr_base && - pdi->hdr_wptr >= pdi->hdr_rptr && pdi->hdr_base <= pdi->hdr_rptr && - pdi->hdr_lim >= pdi->hdr_wptr && pdi->hdr_base >= hbuf.b_rptr && - MBLKIN(&hbuf, (pdi->hdr_base - hbuf.b_rptr), - PDESC_HDRSIZE(pdi)))) { - mdb_warn("descriptor has invalid header fragment\n"); - return (DCMD_ERR); - } - - i = 0; - pa = &pdi->pld_ary[0]; - /* Bounds check the payload fragment, if any */ - while (valid && i < pdi->pld_cnt) { - valid = (((idx = pa->pld_pbuf_idx) < mmd.mmd_pbuf_cnt) && - pa->pld_rptr != NULL && pa->pld_wptr != NULL && - pa->pld_wptr >= pa->pld_rptr && - pa->pld_rptr >= pbuf[idx].b_rptr && - MBLKIN(&pbuf[idx], (pa->pld_rptr - pbuf[idx].b_rptr), - 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); -} diff --git a/usr/src/cmd/mdb/common/modules/genunix/mmd.h b/usr/src/cmd/mdb/common/modules/genunix/mmd.h deleted file mode 100644 index 2aba0d9b8a..0000000000 --- a/usr/src/cmd/mdb/common/modules/genunix/mmd.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MMD_H -#define _MMD_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <mdb/mdb_modapi.h> - -#ifdef __cplusplus -extern "C" { -#endif - -int multidata(uintptr_t, uint_t, int, const mdb_arg_t *); -int mmdq_walk_step(mdb_walk_state_t *); -void mmdq_walk_fini(mdb_walk_state_t *); -int pdesc_slab_walk_init(mdb_walk_state_t *); -int slab2multidata(uintptr_t, uint_t, int, const mdb_arg_t *); -int pdesc_walk_init(mdb_walk_state_t *); -int pattbl(uintptr_t, uint_t, int, const mdb_arg_t *); -int pattr_walk_init(mdb_walk_state_t *); -int pattr2multidata(uintptr_t, uint_t, int, const mdb_arg_t *); -int pdesc2slab(uintptr_t, uint_t, int, const mdb_arg_t *); -int pdesc_verify(uintptr_t, uint_t, int, const mdb_arg_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* _MMD_H */ diff --git a/usr/src/cmd/pcieadm/pcieadm_cfgspace.c b/usr/src/cmd/pcieadm/pcieadm_cfgspace.c index 73841d4c23..bdc04bbe2d 100644 --- a/usr/src/cmd/pcieadm/pcieadm_cfgspace.c +++ b/usr/src/cmd/pcieadm/pcieadm_cfgspace.c @@ -989,8 +989,17 @@ static pcieadm_regdef_t pcieadm_regdef_bist[] = { static pcieadm_regdef_t pcieadm_regdef_exprom[] = { { 0, 0, "enable", "Enable", PRDV_STRVAL, .prd_val = { .prdv_strval = { "disabled", "enabled" } } }, + { 1, 3, "valsts", "Validation Status", PRDV_STRVAL, + .prd_val = { .prdv_strval = { "not supported", "in progress", + "valid contents, no trust test performed", + "valid and trusted contents", + "invalid contents", + "valid but untrusted contents", + "valid contents with warning, no trust test performed", + "valid and trusted contents with warning" } } }, + { 4, 7, "valdet", "Validation Details", PRDV_HEX }, { 11, 31, "addr", "Base Address", PRDV_HEX, - .prd_val = { .prdv_hex = { 21 } } }, + .prd_val = { .prdv_hex = { 11 } } }, { -1, -1, NULL } }; diff --git a/usr/src/lib/smbclnt/libfknsmb/common/fake_stream.c b/usr/src/lib/smbclnt/libfknsmb/common/fake_stream.c index d89a732d69..ff8bb161d8 100644 --- a/usr/src/lib/smbclnt/libfknsmb/common/fake_stream.c +++ b/usr/src/lib/smbclnt/libfknsmb/common/fake_stream.c @@ -26,6 +26,7 @@ * Use is subject to license terms. * * Copyright 2017 Nexenta Systems, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore */ #include <sys/types.h> @@ -288,7 +289,7 @@ streams_msg_init(void) DBLK_CACHE_ALIGN, dblk_esb_constructor, dblk_destructor, NULL, (void *)sizeof (dblk_t), NULL, dblk_kmem_flags); - /* fthdr_cache, ftblk_cache, mmd_init... */ + /* fthdr_cache, ftblk_cache, ... */ } /*ARGSUSED*/ @@ -632,7 +633,7 @@ frnop_func(void *arg) */ static mblk_t * gesballoc(unsigned char *base, size_t size, uint32_t db_rtfu, frtn_t *frp, - void (*lastfree)(mblk_t *, dblk_t *), int kmflags) + void (*lastfree)(mblk_t *, dblk_t *), int kmflags) { dblk_t *dbp; mblk_t *mp; @@ -1008,15 +1009,6 @@ copyb(mblk_t *bp) if (dp->db_fthdr != NULL) STR_FTEVENT_MBLK(bp, caller(), FTEV_COPYB, 0); - /* - * Special handling for Multidata message; this should be - * removed once a copy-callback routine is made available. - */ - if (dp->db_type == M_MULTIDATA) { - /* _KERNEL mmd_copy stuff */ - return (NULL); - } - size = dp->db_lim - dp->db_base; unaligned = P2PHASE((uintptr_t)dp->db_base, sizeof (uint_t)); if ((nbp = allocb_tmpl(size + unaligned, bp)) == NULL) diff --git a/usr/src/lib/smbclnt/libfknsmb/common/fake_strsubr.c b/usr/src/lib/smbclnt/libfknsmb/common/fake_strsubr.c index e49313c37c..c415f5df02 100644 --- a/usr/src/lib/smbclnt/libfknsmb/common/fake_strsubr.c +++ b/usr/src/lib/smbclnt/libfknsmb/common/fake_strsubr.c @@ -27,6 +27,7 @@ * * Copyright (c) 2016 by Delphix. All rights reserved. * Copyright 2017 Nexenta Systems, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore */ #include <sys/types.h> @@ -136,13 +137,6 @@ mblk_free(mblk_t *mp) kmem_cache_free(dbp->db_cache, dbp); } -/* ARGSUSED */ -mblk_t * -mmd_copy(mblk_t *bp, int flags) -{ - return (NULL); -} - /* * A little bit from os/streamio.c */ diff --git a/usr/src/pkg/manifests/system-header.p5m b/usr/src/pkg/manifests/system-header.p5m index 348646b67d..0d6a472f4b 100644 --- a/usr/src/pkg/manifests/system-header.p5m +++ b/usr/src/pkg/manifests/system-header.p5m @@ -1164,7 +1164,6 @@ file path=usr/include/sys/msg_impl.h file path=usr/include/sys/msio.h file path=usr/include/sys/msreg.h file path=usr/include/sys/mtio.h -file path=usr/include/sys/multidata.h file path=usr/include/sys/mutex.h $(i386_ONLY)file path=usr/include/sys/mutex_impl.h file path=usr/include/sys/nbmlock.h diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index e5f23281f6..a818f8b39c 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -24,7 +24,7 @@ # Copyright (c) 2011, 2014 by Delphix. All rights reserved. # Copyright (c) 2013 by Saso Kiselkov. All rights reserved. # Copyright 2018 Nexenta Systems, Inc. -# Copyright 2022 Garrett D'Amore <garrett@damore.org> +# Copyright 2022 Garrett D'Amore # Copyright 2021 Joyent, Inc. # Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved. # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> @@ -250,7 +250,6 @@ GENUNIX_OBJS += \ mount.o \ move.o \ msacct.o \ - multidata.o \ nbmlock.o \ ndifm.o \ nice.o \ diff --git a/usr/src/uts/common/inet/tcp/tcp_tunables.c b/usr/src/uts/common/inet/tcp/tcp_tunables.c index 6348e02ae6..b09f34c72e 100644 --- a/usr/src/uts/common/inet/tcp/tcp_tunables.c +++ b/usr/src/uts/common/inet/tcp/tcp_tunables.c @@ -23,13 +23,13 @@ * Copyright 2016 Joyent, Inc. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012, 2017 by Delphix. All rights reserved. + * Copyright 2022 Garrett D'Amore */ /* Copyright (c) 1990 Mentat Inc. */ #include <inet/ip.h> #include <inet/tcp_impl.h> #include <inet/cc.h> -#include <sys/multidata.h> #include <sys/sunddi.h> /* Max size IP datagram is 64k - 1 */ diff --git a/usr/src/uts/common/io/gld.c b/usr/src/uts/common/io/gld.c index d29bb816b7..51d98468d5 100644 --- a/usr/src/uts/common/io/gld.c +++ b/usr/src/uts/common/io/gld.c @@ -23,6 +23,7 @@ * Use is subject to license terms. * Copyright (c) 2016 by Delphix. All rights reserved. * Copyright 2018 Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ /* @@ -60,7 +61,6 @@ #include <sys/policy.h> #include <sys/atomic.h> -#include <sys/multidata.h> #include <sys/gld.h> #include <sys/gldpriv.h> @@ -136,12 +136,9 @@ static dev_info_t *gld_finddevinfo(dev_t); /* called from wput, wsrv, unidata, and v0_sched to send a packet */ /* also from the source routing stuff for sending RDE protocol packets */ static int gld_start(queue_t *, mblk_t *, int, uint32_t); -static int gld_start_mdt(queue_t *, mblk_t *, int); -/* called from gld_start[_mdt] to loopback packet(s) in promiscuous mode */ +/* called from gld_start to loopback packet(s) in promiscuous mode */ static void gld_precv(gld_mac_info_t *, mblk_t *, uint32_t, struct gld_stats *); -static void gld_precv_mdt(gld_mac_info_t *, gld_vlan_t *, mblk_t *, - pdesc_t *, pktinfo_t *); /* receive group: called from gld_recv and gld_precv* with maclock held */ static void gld_sendup(gld_mac_info_t *, pktinfo_t *, mblk_t *, @@ -282,7 +279,6 @@ static gld_interface_t interfaces[] = { (uint_t)-1, sizeof (struct ether_header), gld_interpret_ether, - NULL, gld_fastpath_ether, gld_unitdata_ether, gld_init_ether, @@ -296,7 +292,6 @@ static gld_interface_t interfaces[] = { 4352, sizeof (struct fddi_mac_frm), gld_interpret_fddi, - NULL, gld_fastpath_fddi, gld_unitdata_fddi, gld_init_fddi, @@ -310,7 +305,6 @@ static gld_interface_t interfaces[] = { 17914, -1, /* variable header size */ gld_interpret_tr, - NULL, gld_fastpath_tr, gld_unitdata_tr, gld_init_tr, @@ -324,7 +318,6 @@ static gld_interface_t interfaces[] = { 4092, sizeof (struct ipoib_header), gld_interpret_ib, - gld_interpret_mdt_ib, gld_fastpath_ib, gld_unitdata_ib, gld_init_ib, @@ -659,29 +652,6 @@ gld_register(dev_info_t *devinfo, char *devname, gld_mac_info_t *macinfo) if (VLAN_CAPABLE(macinfo) && (macinfo->gldm_margin == 0)) macinfo->gldm_margin = VTAG_SIZE; - /* - * For now, only Infiniband drivers can use MDT. Do not add - * support for Ethernet, FDDI or TR. - */ - if (macinfo->gldm_mdt_pre != NULL) { - if (mediatype != DL_IB) { - cmn_err(CE_WARN, "GLD: MDT not supported for %s " - "driver of type %d", devname, mediatype); - goto failure; - } - - /* - * Validate entry points. - */ - if ((macinfo->gldm_mdt_send == NULL) || - (macinfo->gldm_mdt_post == NULL)) { - cmn_err(CE_WARN, "GLD: invalid MDT entry points for " - "%s driver of type %d", devname, mediatype); - goto failure; - } - macinfo->gldm_options |= GLDOPT_MDT; - } - mac_pvt = (gld_mac_pvt_t *)macinfo->gldm_mac_pvt; mac_pvt->major_dev = glddev; @@ -1705,7 +1675,6 @@ gld_wput(queue_t *q, mblk_t *mp) { gld_t *gld = (gld_t *)(q->q_ptr); int rc; - boolean_t multidata = B_TRUE; uint32_t upri; #ifdef GLD_DEBUG @@ -1729,13 +1698,6 @@ gld_wput(queue_t *q, mblk_t *mp) * modules. MBLK_VTAG is used to save the vtag information. */ GLD_CLEAR_MBLK_VTAG(mp); - multidata = B_FALSE; - /* FALLTHROUGH */ - case M_MULTIDATA: - /* Only call gld_start() directly if nothing queued ahead */ - /* No guarantees about ordering with different threads */ - if (q->q_first) - goto use_wsrv; /* * This can happen if wsrv has taken off the last mblk but @@ -1768,8 +1730,7 @@ gld_wput(queue_t *q, mblk_t *mp) upri = (gld->gld_flags & GLD_RAW) ? gld->gld_upri : UPRI(gld, mp->b_band); - rc = (multidata) ? gld_start_mdt(q, mp, GLD_WPUT) : - gld_start(q, mp, GLD_WPUT, upri); + rc = gld_start(q, mp, GLD_WPUT, upri); /* Allow DL_UNBIND again */ membar_exit(); @@ -1843,7 +1804,6 @@ gld_wsrv(queue_t *q) gld_mac_info_t *macinfo; union DL_primitives *prim; int err; - boolean_t multidata; uint32_t upri; #ifdef GLD_DEBUG @@ -1870,8 +1830,6 @@ gld_wsrv(queue_t *q) while ((mp = getq(q)) != NULL) { switch (DB_TYPE(mp)) { case M_DATA: - case M_MULTIDATA: - multidata = (DB_TYPE(mp) == M_MULTIDATA); /* * retry of a previously processed UNITDATA_REQ @@ -1893,8 +1851,7 @@ gld_wsrv(queue_t *q) upri = (gld->gld_flags & GLD_RAW) ? gld->gld_upri : UPRI(gld, mp->b_band); - err = (multidata) ? gld_start_mdt(q, mp, GLD_WSRV) : - gld_start(q, mp, GLD_WSRV, upri); + err = gld_start(q, mp, GLD_WSRV, upri); if (err == GLD_NORESOURCES) { /* gld_sched will qenable us later */ gld->gld_xwait = B_TRUE; /* want qenable */ @@ -2227,212 +2184,6 @@ badarg: } /* - * With MDT V.2 a single message mp can have one header area and multiple - * payload areas. A packet is described by dl_pkt_info, and each packet can - * span multiple payload areas (currently with TCP, each packet will have one - * header and at the most two payload areas). MACs might have a limit on the - * number of payload segments (i.e. per packet scatter-gather limit), and - * MDT V.2 has a way of specifying that with mdt_span_limit; the MAC driver - * might also have a limit on the total number of payloads in a message, and - * that is specified by mdt_max_pld. - */ -static int -gld_start_mdt(queue_t *q, mblk_t *mp, int caller) -{ - mblk_t *nextmp; - gld_t *gld = (gld_t *)q->q_ptr; - gld_mac_info_t *macinfo = gld->gld_mac_info; - gld_mac_pvt_t *mac_pvt = (gld_mac_pvt_t *)macinfo->gldm_mac_pvt; - int numpacks, mdtpacks; - gld_interface_t *ifp = mac_pvt->interfacep; - pktinfo_t pktinfo; - gld_vlan_t *vlan = (gld_vlan_t *)gld->gld_vlan; - boolean_t doloop = B_FALSE; - multidata_t *dlmdp; - pdescinfo_t pinfo; - pdesc_t *dl_pkt; - void *cookie; - uint_t totLen = 0; - - ASSERT(DB_TYPE(mp) == M_MULTIDATA); - - /* - * We're not holding the lock for this check. If the promiscuous - * state is in flux it doesn't matter much if we get this wrong. - */ - if (mac_pvt->nprom > 0) { - /* - * We want to loopback to the receive side, but to avoid - * recursive lock entry: if we came from wput(), which - * could have looped back via IP from our own receive - * interrupt thread, we decline this request. wput() - * will then queue the packet for wsrv(). This means - * that when snoop is running we don't get the advantage - * of the wput() multithreaded direct entry to the - * driver's send routine. - */ - if (caller == GLD_WPUT) { - (void) putbq(q, mp); - return (GLD_NORESOURCES); - } - doloop = B_TRUE; - - /* - * unlike the M_DATA case, we don't have to call - * dupmsg_noloan here because mmd_transform - * (called by gld_precv_mdt) will make a copy of - * each dblk. - */ - } - - while (mp != NULL) { - /* - * The lower layer driver only gets a single multidata - * message; this also makes it easier to handle noresources. - */ - nextmp = mp->b_cont; - mp->b_cont = NULL; - - /* - * Get number of packets in this message; if nothing - * to transmit, go to next message. - */ - dlmdp = mmd_getmultidata(mp); - if ((mdtpacks = (int)mmd_getcnt(dlmdp, NULL, NULL)) == 0) { - freemsg(mp); - mp = nextmp; - continue; - } - - /* - * Run interpreter to populate media specific pktinfo fields. - * This collects per MDT message information like sap, - * broad/multicast etc. - */ - (void) (*ifp->interpreter_mdt)(macinfo, mp, NULL, &pktinfo, - GLD_MDT_TX); - - numpacks = (*macinfo->gldm_mdt_pre)(macinfo, mp, &cookie); - - if (numpacks > 0) { - /* - * Driver indicates it can transmit at least 1, and - * possibly all, packets in MDT message. - */ - int count = numpacks; - - for (dl_pkt = mmd_getfirstpdesc(dlmdp, &pinfo); - (dl_pkt != NULL); - dl_pkt = mmd_getnextpdesc(dl_pkt, &pinfo)) { - /* - * Format this packet by adding link header and - * adjusting pdescinfo to include it; get - * packet length. - */ - (void) (*ifp->interpreter_mdt)(macinfo, NULL, - &pinfo, &pktinfo, GLD_MDT_TXPKT); - - totLen += pktinfo.pktLen; - - /* - * Loop back packet before handing to the - * driver. - */ - if (doloop && - mmd_adjpdesc(dl_pkt, &pinfo) != NULL) { - GLDM_LOCK(macinfo, RW_WRITER); - gld_precv_mdt(macinfo, vlan, mp, - dl_pkt, &pktinfo); - GLDM_UNLOCK(macinfo); - } - - /* - * And send off to driver. - */ - (*macinfo->gldm_mdt_send)(macinfo, cookie, - &pinfo); - - /* - * Be careful not to invoke getnextpdesc if we - * already sent the last packet, since driver - * might have posted it to hardware causing a - * completion and freemsg() so the MDT data - * structures might not be valid anymore. - */ - if (--count == 0) - break; - } - (*macinfo->gldm_mdt_post)(macinfo, mp, cookie); - pktinfo.pktLen = totLen; - UPDATE_STATS(vlan->gldv_stats, NULL, pktinfo, numpacks); - - /* - * In the noresources case (when driver indicates it - * can not transmit all packets in the MDT message), - * adjust to skip the first few packets on retrial. - */ - if (numpacks != mdtpacks) { - /* - * Release already processed packet descriptors. - */ - for (count = 0; count < numpacks; count++) { - dl_pkt = mmd_getfirstpdesc(dlmdp, - &pinfo); - mmd_rempdesc(dl_pkt); - } - ATOMIC_BUMP(vlan->gldv_stats, NULL, - glds_xmtretry, 1); - mp->b_cont = nextmp; - (void) putbq(q, mp); - return (GLD_NORESOURCES); - } - } else if (numpacks == 0) { - /* - * Driver indicates it can not transmit any packets - * currently and will request retrial later. - */ - ATOMIC_BUMP(vlan->gldv_stats, NULL, glds_xmtretry, 1); - mp->b_cont = nextmp; - (void) putbq(q, mp); - return (GLD_NORESOURCES); - } else { - ASSERT(numpacks == -1); - /* - * We're supposed to count failed attempts as well. - */ - dl_pkt = mmd_getfirstpdesc(dlmdp, &pinfo); - while (dl_pkt != NULL) { - /* - * Call interpreter to determine total packet - * bytes that are being dropped. - */ - (void) (*ifp->interpreter_mdt)(macinfo, NULL, - &pinfo, &pktinfo, GLD_MDT_TXPKT); - - totLen += pktinfo.pktLen; - - dl_pkt = mmd_getnextpdesc(dl_pkt, &pinfo); - } - pktinfo.pktLen = totLen; - UPDATE_STATS(vlan->gldv_stats, NULL, pktinfo, mdtpacks); - - /* - * Transmit error; drop the message, move on - * to the next one. - */ - freemsg(mp); - } - - /* - * Process the next multidata block, if there is one. - */ - mp = nextmp; - } - - return (GLD_SUCCESS); -} - -/* * gld_intr (macinfo) */ uint_t @@ -2539,31 +2290,6 @@ gld_precv(gld_mac_info_t *macinfo, mblk_t *mp, uint32_t vtag, } /* - * Called from gld_start_mdt to loopback packet(s) when in promiscuous mode. - * Note that 'vlan' is always a physical link, because MDT can only be - * enabled on non-VLAN streams. - */ -/*ARGSUSED*/ -static void -gld_precv_mdt(gld_mac_info_t *macinfo, gld_vlan_t *vlan, mblk_t *mp, - pdesc_t *dl_pkt, pktinfo_t *pktinfo) -{ - mblk_t *adjmp; - gld_mac_pvt_t *mac_pvt = (gld_mac_pvt_t *)macinfo->gldm_mac_pvt; - gld_interface_t *ifp = mac_pvt->interfacep; - - ASSERT(GLDM_LOCK_HELD_WRITE(macinfo)); - - /* - * Get source/destination. - */ - (void) (*ifp->interpreter_mdt)(macinfo, mp, NULL, pktinfo, - GLD_MDT_RXLOOP); - if ((adjmp = mmd_transform(dl_pkt)) != NULL) - gld_sendup(macinfo, pktinfo, adjmp, gld_paccept); -} - -/* * gld_recv (macinfo, mp) * called with an mac-level packet in a mblock; take the maclock, * try the ip4q and ip6q hack, and otherwise call gld_sendup. @@ -3680,23 +3406,17 @@ gld_cap_ack(queue_t *q, mblk_t *mp) { gld_t *gld = (gld_t *)q->q_ptr; gld_mac_info_t *macinfo = gld->gld_mac_info; - gld_interface_t *ifp; dl_capability_ack_t *dlap; dl_capability_sub_t *dlsp; size_t size = sizeof (dl_capability_ack_t); size_t subsize = 0; - ifp = ((gld_mac_pvt_t *)macinfo->gldm_mac_pvt)->interfacep; - if (macinfo->gldm_capabilities & GLD_CAP_CKSUM_ANY) subsize += sizeof (dl_capability_sub_t) + sizeof (dl_capab_hcksum_t); if (macinfo->gldm_capabilities & GLD_CAP_ZEROCOPY) subsize += sizeof (dl_capability_sub_t) + sizeof (dl_capab_zerocopy_t); - if (macinfo->gldm_options & GLDOPT_MDT) - subsize += (sizeof (dl_capability_sub_t) + - sizeof (dl_capab_mdt_t)); if ((mp = mexchange(q, mp, size + subsize, M_PROTO, DL_CAPABILITY_ACK)) == NULL) @@ -3742,21 +3462,6 @@ gld_cap_ack(queue_t *q, mblk_t *mp) dlsp = (dl_capability_sub_t *)&dlzp[1]; } - if (macinfo->gldm_options & GLDOPT_MDT) { - dl_capab_mdt_t *dlmp = (dl_capab_mdt_t *)&dlsp[1]; - - dlsp->dl_cap = DL_CAPAB_MDT; - dlsp->dl_length = sizeof (dl_capab_mdt_t); - - dlmp->mdt_version = MDT_VERSION_2; - dlmp->mdt_max_pld = macinfo->gldm_mdt_segs; - dlmp->mdt_span_limit = macinfo->gldm_mdt_sgl; - dlcapabsetqid(&dlmp->mdt_mid, OTHERQ(q)); - dlmp->mdt_flags = DL_CAPAB_MDT_ENABLE; - dlmp->mdt_hdr_head = ifp->hdr_size; - dlmp->mdt_hdr_tail = 0; - } - qreply(q, mp); return (GLDE_OK); } diff --git a/usr/src/uts/common/io/gldutil.c b/usr/src/uts/common/io/gldutil.c index 8f516b5d6e..cee02242bd 100644 --- a/usr/src/uts/common/io/gldutil.c +++ b/usr/src/uts/common/io/gldutil.c @@ -21,10 +21,9 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright 2022 Garrett D'Amore */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * gld - Generic LAN Driver * media dependent routines @@ -44,7 +43,6 @@ #include <sys/strsun.h> #include <sys/dlpi.h> #include <sys/ethernet.h> -#include <sys/multidata.h> #include <sys/gld.h> #include <sys/gldpriv.h> #include <sys/ddi.h> @@ -109,7 +107,7 @@ gld_init_ether(gld_mac_info_t *macinfo) KSTAT_DATA_ULONG); kstat_named_init(&sp->glds_defer, "defer_xmts", KSTAT_DATA_ULONG); kstat_named_init(&sp->glds_xmtlatecoll, "tx_late_collisions", - KSTAT_DATA_ULONG); + KSTAT_DATA_ULONG); kstat_named_init(&sp->glds_short, "runt_errors", KSTAT_DATA_ULONG); kstat_named_init(&sp->glds_excoll, "ex_collisions", KSTAT_DATA_ULONG); @@ -801,88 +799,6 @@ out: return (0); } -/* - * The packet format sent to the driver is: 2b sap :: 2b 0s :: data - */ -void -gld_interpret_mdt_ib(gld_mac_info_t *macinfo, mblk_t *mp, pdescinfo_t *pinfo, - pktinfo_t *pktinfo, mdt_packet_flag_t flags) -{ - gld_mac_pvt_t *mac_pvt; - multidata_t *dlmdp; - pattrinfo_t attr_info = { PATTR_DSTADDRSAP, }; - pattr_t *patr; - ipoib_ptxhdr_t *dlap = NULL; - - /* - * Per packet formatting. - */ - if (flags == GLD_MDT_TXPKT) { - ipoib_hdr_t *hptr; - uint_t seg; - - if (PDESC_HDRL(pinfo) == 0) - return; - - /* - * Update packet's link header. - */ - pinfo->hdr_rptr -= IPOIB_HDRSIZE; - hptr = (ipoib_hdr_t *)pinfo->hdr_rptr; - hptr->ipoib_mbz = htons(0); - hptr->ipoib_type = pktinfo->ethertype; - - /* - * Total #bytes that will be put on wire. - */ - pktinfo->pktLen = PDESC_HDRL(pinfo); - for (seg = 0; seg < pinfo->pld_cnt; seg++) - pktinfo->pktLen += PDESC_PLDL(pinfo, seg); - - return; - } - - /* - * The following two cases of GLD_MDT_TX and GLD_MDT_RXLOOP are per - * MDT message processing. - */ - dlmdp = mmd_getmultidata(mp); - patr = mmd_getpattr(dlmdp, NULL, &attr_info); - ASSERT(patr != NULL); - ASSERT(macinfo->gldm_saplen == -2); - if (patr != NULL) - dlap = (ipoib_ptxhdr_t *)((pattr_addr_t *)attr_info.buf)->addr; - - if (flags == GLD_MDT_TX) { - bzero((void *)pktinfo, sizeof (*pktinfo)); - if (dlap == NULL) - return; - - /* - * Check if mac is broadcast or multicast address; all these - * types of address have the top 4 bytes as 0x00FFFFFF. - */ - if (mac_eq(dlap, macinfo->gldm_broadcast_addr, - sizeof (uint32_t))) { - if (mac_eq(dlap, macinfo->gldm_broadcast_addr, - IPOIB_ADDRL)) - pktinfo->isBroadcast = 1; - else - pktinfo->isMulticast = 1; - } - pktinfo->ethertype = REF_NET_USHORT(dlap-> - ipoib_rhdr.ipoib_type); - } else { - ASSERT(flags == GLD_MDT_RXLOOP); - pktinfo->macLen = IPOIB_HDRSIZE; - mac_pvt = (gld_mac_pvt_t *)macinfo->gldm_mac_pvt; - mac_copy(mac_pvt->curr_macaddr, pktinfo->shost, IPOIB_ADDRL); - if (dlap == NULL) - return; - mac_copy(&dlap->ipoib_dest, pktinfo->dhost, IPOIB_ADDRL); - } -} - mblk_t * gld_unitdata_ib(gld_t *gld, mblk_t *mp) { @@ -1322,7 +1238,7 @@ gld_init_tr(gld_mac_info_t *macinfo) mutex_init(GLD_SR_MUTEX(macinfo), NULL, MUTEX_DRIVER, NULL); GLD_SR_VAR(macinfo) = kmem_zalloc(sizeof (struct srtab *)*SR_HASH_SIZE, - KM_SLEEP); + KM_SLEEP); /* Default is RDE enabled for this medium */ ((gld_mac_pvt_t *)macinfo->gldm_mac_pvt)->rde_enabled = diff --git a/usr/src/uts/common/io/ib/clients/ibd/ibd.c b/usr/src/uts/common/io/ib/clients/ibd/ibd.c index 8232642502..4607624583 100644 --- a/usr/src/uts/common/io/ib/clients/ibd/ibd.c +++ b/usr/src/uts/common/io/ib/clients/ibd/ibd.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2022 Garrett D'Amore */ /* @@ -58,7 +59,6 @@ #include <sys/ib/clients/ibd/ibd.h> #include <sys/ib/mgt/sm_attr.h> /* for SM_INIT_TYPE_* */ #include <sys/note.h> -#include <sys/multidata.h> #include <sys/ib/mgt/ibmf/ibmf.h> /* for ibd_get_portspeed */ @@ -653,9 +653,9 @@ _NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_txpost_lock, /* * id_acache_req_lock */ -_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_acache_req_lock, +_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_acache_req_lock, ibd_state_t::id_acache_req_cv)) -_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_acache_req_lock, +_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_acache_req_lock, ibd_state_t::id_req_list)) _NOTE(SCHEME_PROTECTS_DATA("atomic", ibd_acache_s::ac_ref)) @@ -717,7 +717,7 @@ _NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_sched_lock, /* * id_link_mutex */ -_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_link_mutex, +_NOTE(MUTEX_PROTECTS_DATA(ibd_state_t::id_link_mutex, ibd_state_t::id_link_state)) _NOTE(DATA_READABLE_WITHOUT_LOCK(ibd_state_t::id_link_state)) _NOTE(SCHEME_PROTECTS_DATA("only async thr and ibd_m_start", @@ -951,7 +951,7 @@ _NOTE(SCHEME_PROTECTS_DATA("counters for problem diagnosis", ibd_rc_stat_s::rc_rcv_copy_byte ibd_rc_stat_s::rc_rcv_copy_pkt ibd_rc_stat_s::rc_rcv_alloc_fail - ibd_rc_stat_s::rc_rcq_err + ibd_rc_stat_s::rc_rcq_err ibd_rc_stat_s::rc_rwqe_short ibd_rc_stat_s::rc_xmt_bytes ibd_rc_stat_s::rc_xmt_small_pkt @@ -8169,9 +8169,9 @@ ibd_create_partition(void *karg, intptr_t arg, int mode, cred_t *credp, ibd_state_t *state, *port_state, *p; int i, err, rval = 0; mac_register_t *macp; - ibt_hca_portinfo_t *pinfop = NULL; - ibt_status_t ibt_status; - uint_t psize, pinfosz; + ibt_hca_portinfo_t *pinfop = NULL; + ibt_status_t ibt_status; + uint_t psize, pinfosz; boolean_t force_create = B_FALSE; cmd->ibdioc.ioc_status = 0; @@ -8421,9 +8421,9 @@ ibd_get_partition_info(void *karg, intptr_t arg, int mode, cred_t *cred, #endif ibd_state_t *state, *port_state; int size; - ibt_hca_portinfo_t *pinfop = NULL; - ibt_status_t ibt_status; - uint_t psize, pinfosz; + ibt_hca_portinfo_t *pinfop = NULL; + ibt_status_t ibt_status; + uint_t psize, pinfosz; int rval = 0; size = sizeof (ibd_ioctl_t); diff --git a/usr/src/uts/common/io/multidata.c b/usr/src/uts/common/io/multidata.c deleted file mode 100644 index 459914ab5d..0000000000 --- a/usr/src/uts/common/io/multidata.c +++ /dev/null @@ -1,1604 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - * Copyright (c) 2016 by Delphix. All rights reserved. - */ - -/* - * Multidata, as described in the following papers: - * - * Adi Masputra, - * Multidata V.2: VA-Disjoint Packet Extents Framework Interface - * Design Specification. August 2004. - * Available as http://sac.sfbay/PSARC/2004/594/materials/mmd2.pdf. - * - * Adi Masputra, - * Multidata Interface Design Specification. Sep 2002. - * Available as http://sac.sfbay/PSARC/2002/276/materials/mmd.pdf. - * - * Adi Masputra, Frank DiMambro, Kacheong Poon, - * An Efficient Networking Transmit Mechanism for Solaris: - * Multidata Transmit (MDT). May 2002. - * Available as http://sac.sfbay/PSARC/2002/276/materials/mdt.pdf. - */ - -#include <sys/types.h> -#include <sys/stream.h> -#include <sys/dlpi.h> -#include <sys/stropts.h> -#include <sys/strsun.h> -#include <sys/strlog.h> -#include <sys/strsubr.h> -#include <sys/sysmacros.h> -#include <sys/cmn_err.h> -#include <sys/debug.h> -#include <sys/kmem.h> -#include <sys/atomic.h> - -#include <sys/multidata.h> -#include <sys/multidata_impl.h> - -static int mmd_constructor(void *, void *, int); -static void mmd_destructor(void *, void *); -static int pdslab_constructor(void *, void *, int); -static void pdslab_destructor(void *, void *); -static int pattbl_constructor(void *, void *, int); -static void pattbl_destructor(void *, void *); -static void mmd_esballoc_free(caddr_t); -static int mmd_copy_pattbl(patbkt_t *, multidata_t *, pdesc_t *, int); - -static boolean_t pbuf_ref_valid(multidata_t *, pdescinfo_t *); -#pragma inline(pbuf_ref_valid) - -static boolean_t pdi_in_range(pdescinfo_t *, pdescinfo_t *); -#pragma inline(pdi_in_range) - -static pdesc_t *mmd_addpdesc_int(multidata_t *, pdescinfo_t *, int *, int); -#pragma inline(mmd_addpdesc_int) - -static void mmd_destroy_pattbl(patbkt_t **); -#pragma inline(mmd_destroy_pattbl) - -static pattr_t *mmd_find_pattr(patbkt_t *, uint_t); -#pragma inline(mmd_find_pattr) - -static pdesc_t *mmd_destroy_pdesc(multidata_t *, pdesc_t *); -#pragma inline(mmd_destroy_pdesc) - -static pdesc_t *mmd_getpdesc(multidata_t *, pdesc_t *, pdescinfo_t *, uint_t, - boolean_t); -#pragma inline(mmd_getpdesc) - -static struct kmem_cache *mmd_cache; -static struct kmem_cache *pd_slab_cache; -static struct kmem_cache *pattbl_cache; - -int mmd_debug = 1; -#define MMD_DEBUG(s) if (mmd_debug > 0) cmn_err s - -/* - * Set to this to true to bypass pdesc bounds checking. - */ -boolean_t mmd_speed_over_safety = B_FALSE; - -/* - * Patchable kmem_cache flags. - */ -int mmd_kmem_flags = 0; -int pdslab_kmem_flags = 0; -int pattbl_kmem_flags = 0; - -/* - * Alignment (in bytes) of our kmem caches. - */ -#define MULTIDATA_CACHE_ALIGN 64 - -/* - * Default number of packet descriptors per descriptor slab. Making - * this too small will trigger more descriptor slab allocation; making - * it too large will create too many unclaimed descriptors. - */ -#define PDSLAB_SZ 15 -uint_t pdslab_sz = PDSLAB_SZ; - -/* - * Default attribute hash table size. It's okay to set this to a small - * value (even to 1) because there aren't that many attributes currently - * defined, and because we assume there won't be many attributes associated - * with a Multidata at a given time. Increasing the size will reduce - * attribute search time (given a large number of attributes in a Multidata), - * and decreasing it will reduce the memory footprints and the overhead - * associated with managing the table. - */ -#define PATTBL_SZ 1 -uint_t pattbl_sz = PATTBL_SZ; - -/* - * Attribute hash key. - */ -#define PATTBL_HASH(x, sz) ((x) % (sz)) - -/* - * Structure that precedes each Multidata metadata. - */ -struct mmd_buf_info { - frtn_t frp; /* free routine */ - uint_t buf_len; /* length of kmem buffer */ -}; - -/* - * The size of each metadata buffer. - */ -#define MMD_CACHE_SIZE \ - (sizeof (struct mmd_buf_info) + sizeof (multidata_t)) - -/* - * Called during startup in order to create the Multidata kmem caches. - */ -void -mmd_init(void) -{ - pdslab_sz = MAX(1, pdslab_sz); /* at least 1 descriptor */ - pattbl_sz = MAX(1, pattbl_sz); /* at least 1 bucket */ - - mmd_cache = kmem_cache_create("multidata", MMD_CACHE_SIZE, - MULTIDATA_CACHE_ALIGN, mmd_constructor, mmd_destructor, - NULL, NULL, NULL, mmd_kmem_flags); - - pd_slab_cache = kmem_cache_create("multidata_pdslab", - PDESC_SLAB_SIZE(pdslab_sz), MULTIDATA_CACHE_ALIGN, - pdslab_constructor, pdslab_destructor, NULL, - (void *)(uintptr_t)pdslab_sz, NULL, pdslab_kmem_flags); - - pattbl_cache = kmem_cache_create("multidata_pattbl", - sizeof (patbkt_t) * pattbl_sz, MULTIDATA_CACHE_ALIGN, - pattbl_constructor, pattbl_destructor, NULL, - (void *)(uintptr_t)pattbl_sz, NULL, pattbl_kmem_flags); -} - -/* - * Create a Multidata message block. - */ -multidata_t * -mmd_alloc(mblk_t *hdr_mp, mblk_t **mmd_mp, int kmflags) -{ - uchar_t *buf; - multidata_t *mmd; - uint_t mmd_mplen; - struct mmd_buf_info *buf_info; - - ASSERT(hdr_mp != NULL); - ASSERT(mmd_mp != NULL); - - /* - * Caller should never pass in a chain of mblks since we - * only care about the first one, hence the assertions. - */ - ASSERT(hdr_mp->b_cont == NULL); - - if ((buf = kmem_cache_alloc(mmd_cache, kmflags)) == NULL) - return (NULL); - - buf_info = (struct mmd_buf_info *)buf; - buf_info->frp.free_arg = (caddr_t)buf; - - mmd = (multidata_t *)(buf_info + 1); - mmd_mplen = sizeof (*mmd); - - if ((*mmd_mp = desballoc((uchar_t *)mmd, mmd_mplen, BPRI_HI, - &(buf_info->frp))) == NULL) { - kmem_cache_free(mmd_cache, buf); - return (NULL); - } - - DB_TYPE(*mmd_mp) = M_MULTIDATA; - (*mmd_mp)->b_wptr += mmd_mplen; - mmd->mmd_dp = (*mmd_mp)->b_datap; - mmd->mmd_hbuf = hdr_mp; - - return (mmd); -} - -/* - * Associate additional payload buffer to the Multidata. - */ -int -mmd_addpldbuf(multidata_t *mmd, mblk_t *pld_mp) -{ - int i; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(pld_mp != NULL); - - mutex_enter(&mmd->mmd_pd_slab_lock); - for (i = 0; i < MULTIDATA_MAX_PBUFS && - mmd->mmd_pbuf_cnt < MULTIDATA_MAX_PBUFS; i++) { - if (mmd->mmd_pbuf[i] == pld_mp) { - /* duplicate entry */ - MMD_DEBUG((CE_WARN, "mmd_addpldbuf: error adding " - "pld 0x%p to mmd 0x%p since it has been " - "previously added into slot %d (total %d)\n", - (void *)pld_mp, (void *)mmd, i, mmd->mmd_pbuf_cnt)); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (-1); - } else if (mmd->mmd_pbuf[i] == NULL) { - mmd->mmd_pbuf[i] = pld_mp; - mmd->mmd_pbuf_cnt++; - mutex_exit(&mmd->mmd_pd_slab_lock); - return (i); - } - } - - /* all slots are taken */ - MMD_DEBUG((CE_WARN, "mmd_addpldbuf: error adding pld 0x%p to mmd 0x%p " - "since no slot space is left (total %d max %d)\n", (void *)pld_mp, - (void *)mmd, mmd->mmd_pbuf_cnt, MULTIDATA_MAX_PBUFS)); - mutex_exit(&mmd->mmd_pd_slab_lock); - - return (-1); -} - -/* - * Multidata metadata kmem cache constructor routine. - */ -/* ARGSUSED */ -static int -mmd_constructor(void *buf, void *cdrarg, int kmflags) -{ - struct mmd_buf_info *buf_info; - multidata_t *mmd; - - bzero((void *)buf, MMD_CACHE_SIZE); - - buf_info = (struct mmd_buf_info *)buf; - buf_info->frp.free_func = mmd_esballoc_free; - buf_info->buf_len = MMD_CACHE_SIZE; - - mmd = (multidata_t *)(buf_info + 1); - mmd->mmd_magic = MULTIDATA_MAGIC; - - mutex_init(&(mmd->mmd_pd_slab_lock), NULL, MUTEX_DRIVER, NULL); - QL_INIT(&(mmd->mmd_pd_slab_q)); - QL_INIT(&(mmd->mmd_pd_q)); - - return (0); -} - -/* - * Multidata metadata kmem cache destructor routine. - */ -/* ARGSUSED */ -static void -mmd_destructor(void *buf, void *cdrarg) -{ - multidata_t *mmd; -#ifdef DEBUG - int i; -#endif - - mmd = (multidata_t *)((uchar_t *)buf + sizeof (struct mmd_buf_info)); - - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(mmd->mmd_dp == NULL); - ASSERT(mmd->mmd_hbuf == NULL); - ASSERT(mmd->mmd_pbuf_cnt == 0); -#ifdef DEBUG - for (i = 0; i < MULTIDATA_MAX_PBUFS; i++) - ASSERT(mmd->mmd_pbuf[i] == NULL); -#endif - ASSERT(mmd->mmd_pattbl == NULL); - - mutex_destroy(&(mmd->mmd_pd_slab_lock)); - ASSERT(mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q)); - ASSERT(mmd->mmd_slab_cnt == 0); - ASSERT(mmd->mmd_pd_q.ql_next == &(mmd->mmd_pd_q)); - ASSERT(mmd->mmd_pd_cnt == 0); - ASSERT(mmd->mmd_hbuf_ref == 0); - ASSERT(mmd->mmd_pbuf_ref == 0); -} - -/* - * Multidata message block free callback routine. - */ -static void -mmd_esballoc_free(caddr_t buf) -{ - multidata_t *mmd; - pdesc_t *pd; - pdesc_slab_t *slab; - int i; - - ASSERT(buf != NULL); - ASSERT(((struct mmd_buf_info *)buf)->buf_len == MMD_CACHE_SIZE); - - mmd = (multidata_t *)(buf + sizeof (struct mmd_buf_info)); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - ASSERT(mmd->mmd_dp != NULL); - ASSERT(mmd->mmd_dp->db_ref == 1); - - /* remove all packet descriptors and private attributes */ - pd = Q2PD(mmd->mmd_pd_q.ql_next); - while (pd != Q2PD(&(mmd->mmd_pd_q))) - pd = mmd_destroy_pdesc(mmd, pd); - - ASSERT(mmd->mmd_pd_q.ql_next == &(mmd->mmd_pd_q)); - ASSERT(mmd->mmd_pd_cnt == 0); - ASSERT(mmd->mmd_hbuf_ref == 0); - ASSERT(mmd->mmd_pbuf_ref == 0); - - /* remove all global attributes */ - if (mmd->mmd_pattbl != NULL) - mmd_destroy_pattbl(&(mmd->mmd_pattbl)); - - /* remove all descriptor slabs */ - slab = Q2PDSLAB(mmd->mmd_pd_slab_q.ql_next); - while (slab != Q2PDSLAB(&(mmd->mmd_pd_slab_q))) { - pdesc_slab_t *slab_next = Q2PDSLAB(slab->pds_next); - - remque(&(slab->pds_next)); - slab->pds_next = NULL; - slab->pds_prev = NULL; - slab->pds_mmd = NULL; - slab->pds_used = 0; - kmem_cache_free(pd_slab_cache, slab); - - ASSERT(mmd->mmd_slab_cnt > 0); - mmd->mmd_slab_cnt--; - slab = slab_next; - } - ASSERT(mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q)); - ASSERT(mmd->mmd_slab_cnt == 0); - - mmd->mmd_dp = NULL; - - /* finally, free all associated message blocks */ - if (mmd->mmd_hbuf != NULL) { - freeb(mmd->mmd_hbuf); - mmd->mmd_hbuf = NULL; - } - - for (i = 0; i < MULTIDATA_MAX_PBUFS; i++) { - if (mmd->mmd_pbuf[i] != NULL) { - freeb(mmd->mmd_pbuf[i]); - mmd->mmd_pbuf[i] = NULL; - ASSERT(mmd->mmd_pbuf_cnt > 0); - mmd->mmd_pbuf_cnt--; - } - } - - ASSERT(mmd->mmd_pbuf_cnt == 0); - ASSERT(MUTEX_NOT_HELD(&(mmd->mmd_pd_slab_lock))); - kmem_cache_free(mmd_cache, buf); -} - -/* - * Multidata message block copy routine, called by copyb() when it - * encounters a M_MULTIDATA data block type. This routine should - * not be called by anyone other than copyb(), since it may go away - * (read: become static to this module) once some sort of copy callback - * routine is made available. - */ -mblk_t * -mmd_copy(mblk_t *bp, int kmflags) -{ - multidata_t *mmd, *n_mmd; - mblk_t *n_hbuf = NULL, *n_pbuf[MULTIDATA_MAX_PBUFS]; - mblk_t **pmp_last = &n_pbuf[MULTIDATA_MAX_PBUFS - 1]; - mblk_t **pmp; - mblk_t *n_bp = NULL; - pdesc_t *pd; - uint_t n_pbuf_cnt = 0; - int idx, i; - -#define FREE_PBUFS() { \ - for (pmp = &n_pbuf[0]; pmp <= pmp_last; pmp++) \ - if (*pmp != NULL) freeb(*pmp); \ -} - -#define REL_OFF(p, base, n_base) \ - ((uchar_t *)(n_base) + ((uchar_t *)(p) - (uchar_t *)base)) - - ASSERT(bp != NULL && DB_TYPE(bp) == M_MULTIDATA); - mmd = mmd_getmultidata(bp); - - /* copy the header buffer */ - if (mmd->mmd_hbuf != NULL && (n_hbuf = copyb(mmd->mmd_hbuf)) == NULL) - return (NULL); - - /* copy the payload buffer(s) */ - mutex_enter(&mmd->mmd_pd_slab_lock); - bzero((void *)&n_pbuf[0], sizeof (mblk_t *) * MULTIDATA_MAX_PBUFS); - n_pbuf_cnt = mmd->mmd_pbuf_cnt; - for (i = 0; i < n_pbuf_cnt; i++) { - ASSERT(mmd->mmd_pbuf[i] != NULL); - n_pbuf[i] = copyb(mmd->mmd_pbuf[i]); - if (n_pbuf[i] == NULL) { - FREE_PBUFS(); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - } - - /* allocate new Multidata */ - n_mmd = mmd_alloc(n_hbuf, &n_bp, kmflags); - if (n_mmd == NULL) { - if (n_hbuf != NULL) - freeb(n_hbuf); - if (n_pbuf_cnt != 0) - FREE_PBUFS(); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - - /* - * Add payload buffer(s); upon success, leave n_pbuf array - * alone, as the newly-created Multidata had already contained - * the mblk pointers stored in the array. These will be freed - * along with the Multidata itself. - */ - for (i = 0, pmp = &n_pbuf[0]; i < n_pbuf_cnt; i++, pmp++) { - idx = mmd_addpldbuf(n_mmd, *pmp); - if (idx < 0) { - FREE_PBUFS(); - freeb(n_bp); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - } - - /* copy over global attributes */ - if (mmd->mmd_pattbl != NULL && - mmd_copy_pattbl(mmd->mmd_pattbl, n_mmd, NULL, kmflags) < 0) { - freeb(n_bp); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - - /* copy over packet descriptors and their atttributes */ - pd = mmd_getpdesc(mmd, NULL, NULL, 1, B_TRUE); /* first pdesc */ - while (pd != NULL) { - pdesc_t *n_pd; - pdescinfo_t *pdi, n_pdi; - uchar_t *n_base, *base; - pdesc_t *pd_next; - - /* next pdesc */ - pd_next = mmd_getpdesc(pd->pd_slab->pds_mmd, pd, NULL, - 1, B_TRUE); - - /* skip if already removed */ - if (pd->pd_flags & PDESC_REM_DEFER) { - pd = pd_next; - continue; - } - - pdi = &(pd->pd_pdi); - bzero(&n_pdi, sizeof (n_pdi)); - - /* - * Calculate new descriptor values based on the offset of - * each pointer relative to the associated buffer(s). - */ - ASSERT(pdi->flags & PDESC_HAS_REF); - if (pdi->flags & PDESC_HBUF_REF) { - n_base = n_mmd->mmd_hbuf->b_rptr; - base = mmd->mmd_hbuf->b_rptr; - - n_pdi.flags |= PDESC_HBUF_REF; - n_pdi.hdr_base = REL_OFF(pdi->hdr_base, base, n_base); - n_pdi.hdr_rptr = REL_OFF(pdi->hdr_rptr, base, n_base); - n_pdi.hdr_wptr = REL_OFF(pdi->hdr_wptr, base, n_base); - n_pdi.hdr_lim = REL_OFF(pdi->hdr_lim, base, n_base); - } - - if (pdi->flags & PDESC_PBUF_REF) { - n_pdi.flags |= PDESC_PBUF_REF; - n_pdi.pld_cnt = pdi->pld_cnt; - - for (i = 0; i < pdi->pld_cnt; i++) { - idx = pdi->pld_ary[i].pld_pbuf_idx; - ASSERT(idx < MULTIDATA_MAX_PBUFS); - ASSERT(n_mmd->mmd_pbuf[idx] != NULL); - ASSERT(mmd->mmd_pbuf[idx] != NULL); - - n_base = n_mmd->mmd_pbuf[idx]->b_rptr; - base = mmd->mmd_pbuf[idx]->b_rptr; - - n_pdi.pld_ary[i].pld_pbuf_idx = idx; - - /* - * We can't copy the pointers just like that, - * so calculate the relative offset. - */ - n_pdi.pld_ary[i].pld_rptr = - REL_OFF(pdi->pld_ary[i].pld_rptr, - base, n_base); - n_pdi.pld_ary[i].pld_wptr = - REL_OFF(pdi->pld_ary[i].pld_wptr, - base, n_base); - } - } - - /* add the new descriptor to the new Multidata */ - n_pd = mmd_addpdesc_int(n_mmd, &n_pdi, NULL, kmflags); - - if (n_pd == NULL || (pd->pd_pattbl != NULL && - mmd_copy_pattbl(pd->pd_pattbl, n_mmd, n_pd, kmflags) < 0)) { - freeb(n_bp); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - - pd = pd_next; - } -#undef REL_OFF -#undef FREE_PBUFS - - mutex_exit(&mmd->mmd_pd_slab_lock); - return (n_bp); -} - -/* - * Given a Multidata message block, return the Multidata metadata handle. - */ -multidata_t * -mmd_getmultidata(mblk_t *mp) -{ - multidata_t *mmd; - - ASSERT(mp != NULL); - - if (DB_TYPE(mp) != M_MULTIDATA) - return (NULL); - - mmd = (multidata_t *)mp->b_rptr; - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - return (mmd); -} - -/* - * Return the start and end addresses of the associated buffer(s). - */ -void -mmd_getregions(multidata_t *mmd, mbufinfo_t *mbi) -{ - int i; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(mbi != NULL); - - bzero((void *)mbi, sizeof (mbufinfo_t)); - - if (mmd->mmd_hbuf != NULL) { - mbi->hbuf_rptr = mmd->mmd_hbuf->b_rptr; - mbi->hbuf_wptr = mmd->mmd_hbuf->b_wptr; - } - - mutex_enter(&mmd->mmd_pd_slab_lock); - for (i = 0; i < mmd->mmd_pbuf_cnt; i++) { - ASSERT(mmd->mmd_pbuf[i] != NULL); - mbi->pbuf_ary[i].pbuf_rptr = mmd->mmd_pbuf[i]->b_rptr; - mbi->pbuf_ary[i].pbuf_wptr = mmd->mmd_pbuf[i]->b_wptr; - - } - mbi->pbuf_cnt = mmd->mmd_pbuf_cnt; - mutex_exit(&mmd->mmd_pd_slab_lock); -} - -/* - * Return the Multidata statistics. - */ -uint_t -mmd_getcnt(multidata_t *mmd, uint_t *hbuf_ref, uint_t *pbuf_ref) -{ - uint_t pd_cnt; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - mutex_enter(&(mmd->mmd_pd_slab_lock)); - if (hbuf_ref != NULL) - *hbuf_ref = mmd->mmd_hbuf_ref; - if (pbuf_ref != NULL) - *pbuf_ref = mmd->mmd_pbuf_ref; - pd_cnt = mmd->mmd_pd_cnt; - mutex_exit(&(mmd->mmd_pd_slab_lock)); - - return (pd_cnt); -} - -#define HBUF_REF_VALID(mmd, pdi) \ - ((mmd)->mmd_hbuf != NULL && (pdi)->hdr_rptr != NULL && \ - (pdi)->hdr_wptr != NULL && (pdi)->hdr_base != NULL && \ - (pdi)->hdr_lim != NULL && (pdi)->hdr_lim >= (pdi)->hdr_base && \ - (pdi)->hdr_wptr >= (pdi)->hdr_rptr && \ - (pdi)->hdr_base <= (pdi)->hdr_rptr && \ - (pdi)->hdr_lim >= (pdi)->hdr_wptr && \ - (pdi)->hdr_base >= (mmd)->mmd_hbuf->b_rptr && \ - MBLKIN((mmd)->mmd_hbuf, \ - (pdi->hdr_base - (mmd)->mmd_hbuf->b_rptr), \ - PDESC_HDRSIZE(pdi))) - -/* - * Bounds check payload area(s). - */ -static boolean_t -pbuf_ref_valid(multidata_t *mmd, pdescinfo_t *pdi) -{ - int i = 0, idx; - boolean_t valid = B_TRUE; - struct pld_ary_s *pa; - - mutex_enter(&mmd->mmd_pd_slab_lock); - if (pdi->pld_cnt == 0 || pdi->pld_cnt > mmd->mmd_pbuf_cnt) { - mutex_exit(&mmd->mmd_pd_slab_lock); - return (B_FALSE); - } - - pa = &pdi->pld_ary[0]; - while (valid && i < pdi->pld_cnt) { - valid = (((idx = pa->pld_pbuf_idx) < mmd->mmd_pbuf_cnt) && - pa->pld_rptr != NULL && pa->pld_wptr != NULL && - pa->pld_wptr >= pa->pld_rptr && - pa->pld_rptr >= mmd->mmd_pbuf[idx]->b_rptr && - MBLKIN(mmd->mmd_pbuf[idx], (pa->pld_rptr - - mmd->mmd_pbuf[idx]->b_rptr), - PDESC_PLD_SPAN_SIZE(pdi, i))); - - if (!valid) { - MMD_DEBUG((CE_WARN, - "pbuf_ref_valid: pdi 0x%p pld out of bound; " - "index %d has pld_cnt %d pbuf_idx %d " - "(mmd_pbuf_cnt %d), " - "pld_rptr 0x%p pld_wptr 0x%p len %d " - "(valid 0x%p-0x%p len %d)\n", (void *)pdi, - i, pdi->pld_cnt, idx, mmd->mmd_pbuf_cnt, - (void *)pa->pld_rptr, - (void *)pa->pld_wptr, - (int)PDESC_PLD_SPAN_SIZE(pdi, i), - (void *)mmd->mmd_pbuf[idx]->b_rptr, - (void *)mmd->mmd_pbuf[idx]->b_wptr, - (int)MBLKL(mmd->mmd_pbuf[idx]))); - } - - /* advance to next entry */ - i++; - pa++; - } - - mutex_exit(&mmd->mmd_pd_slab_lock); - return (valid); -} - -/* - * Add a packet descriptor to the Multidata. - */ -pdesc_t * -mmd_addpdesc(multidata_t *mmd, pdescinfo_t *pdi, int *err, int kmflags) -{ - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(pdi != NULL); - ASSERT(pdi->flags & PDESC_HAS_REF); - - /* do the references refer to invalid memory regions? */ - if (!mmd_speed_over_safety && - (((pdi->flags & PDESC_HBUF_REF) && !HBUF_REF_VALID(mmd, pdi)) || - ((pdi->flags & PDESC_PBUF_REF) && !pbuf_ref_valid(mmd, pdi)))) { - if (err != NULL) - *err = EINVAL; - return (NULL); - } - - return (mmd_addpdesc_int(mmd, pdi, err, kmflags)); -} - -/* - * Internal routine to add a packet descriptor, called when mmd_addpdesc - * or mmd_copy tries to allocate and add a descriptor to a Multidata. - */ -static pdesc_t * -mmd_addpdesc_int(multidata_t *mmd, pdescinfo_t *pdi, int *err, int kmflags) -{ - pdesc_slab_t *slab, *slab_last; - pdesc_t *pd; - - ASSERT(pdi->flags & PDESC_HAS_REF); - ASSERT(!(pdi->flags & PDESC_HBUF_REF) || HBUF_REF_VALID(mmd, pdi)); - ASSERT(!(pdi->flags & PDESC_PBUF_REF) || pbuf_ref_valid(mmd, pdi)); - - if (err != NULL) - *err = 0; - - mutex_enter(&(mmd->mmd_pd_slab_lock)); - /* - * Is slab list empty or the last-added slab is full? If so, - * allocate new slab for the descriptor; otherwise, use the - * last-added slab instead. - */ - slab_last = Q2PDSLAB(mmd->mmd_pd_slab_q.ql_prev); - if (mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q) || - slab_last->pds_used == slab_last->pds_sz) { - slab = kmem_cache_alloc(pd_slab_cache, kmflags); - if (slab == NULL) { - if (err != NULL) - *err = ENOMEM; - mutex_exit(&(mmd->mmd_pd_slab_lock)); - return (NULL); - } - slab->pds_mmd = mmd; - - ASSERT(slab->pds_used == 0); - ASSERT(slab->pds_next == NULL && slab->pds_prev == NULL); - - /* insert slab at end of list */ - insque(&(slab->pds_next), mmd->mmd_pd_slab_q.ql_prev); - mmd->mmd_slab_cnt++; - } else { - slab = slab_last; - } - ASSERT(slab->pds_used < slab->pds_sz); - pd = &(slab->pds_free_desc[slab->pds_used++]); - ASSERT(pd->pd_magic == PDESC_MAGIC); - pd->pd_next = NULL; - pd->pd_prev = NULL; - pd->pd_slab = slab; - pd->pd_pattbl = NULL; - - /* copy over the descriptor info from caller */ - PDI_COPY(pdi, &(pd->pd_pdi)); - - if (pd->pd_flags & PDESC_HBUF_REF) - mmd->mmd_hbuf_ref++; - if (pd->pd_flags & PDESC_PBUF_REF) - mmd->mmd_pbuf_ref += pd->pd_pdi.pld_cnt; - mmd->mmd_pd_cnt++; - - /* insert descriptor at end of list */ - insque(&(pd->pd_next), mmd->mmd_pd_q.ql_prev); - mutex_exit(&(mmd->mmd_pd_slab_lock)); - - return (pd); -} - -/* - * Packet descriptor slab kmem cache constructor routine. - */ -/* ARGSUSED */ -static int -pdslab_constructor(void *buf, void *cdrarg, int kmflags) -{ - pdesc_slab_t *slab; - uint_t cnt = (uint_t)(uintptr_t)cdrarg; - int i; - - ASSERT(cnt > 0); /* slab size can't be zero */ - - slab = (pdesc_slab_t *)buf; - slab->pds_next = NULL; - slab->pds_prev = NULL; - slab->pds_mmd = NULL; - slab->pds_used = 0; - slab->pds_sz = cnt; - - for (i = 0; i < cnt; i++) { - pdesc_t *pd = &(slab->pds_free_desc[i]); - pd->pd_magic = PDESC_MAGIC; - } - return (0); -} - -/* - * Packet descriptor slab kmem cache destructor routine. - */ -/* ARGSUSED */ -static void -pdslab_destructor(void *buf, void *cdrarg) -{ - pdesc_slab_t *slab; - - slab = (pdesc_slab_t *)buf; - ASSERT(slab->pds_next == NULL); - ASSERT(slab->pds_prev == NULL); - ASSERT(slab->pds_mmd == NULL); - ASSERT(slab->pds_used == 0); - ASSERT(slab->pds_sz > 0); -} - -/* - * Remove a packet descriptor from the in-use descriptor list, - * called by mmd_rempdesc or during free. - */ -static pdesc_t * -mmd_destroy_pdesc(multidata_t *mmd, pdesc_t *pd) -{ - pdesc_t *pd_next; - - pd_next = Q2PD(pd->pd_next); - remque(&(pd->pd_next)); - - /* remove all local attributes */ - if (pd->pd_pattbl != NULL) - mmd_destroy_pattbl(&(pd->pd_pattbl)); - - /* don't decrease counts for a removed descriptor */ - if (!(pd->pd_flags & PDESC_REM_DEFER)) { - if (pd->pd_flags & PDESC_HBUF_REF) { - ASSERT(mmd->mmd_hbuf_ref > 0); - mmd->mmd_hbuf_ref--; - } - if (pd->pd_flags & PDESC_PBUF_REF) { - ASSERT(mmd->mmd_pbuf_ref > 0); - mmd->mmd_pbuf_ref -= pd->pd_pdi.pld_cnt; - } - ASSERT(mmd->mmd_pd_cnt > 0); - mmd->mmd_pd_cnt--; - } - return (pd_next); -} - -/* - * Remove a packet descriptor from the Multidata. - */ -void -mmd_rempdesc(pdesc_t *pd) -{ - multidata_t *mmd; - - ASSERT(pd->pd_magic == PDESC_MAGIC); - ASSERT(pd->pd_slab != NULL); - - mmd = pd->pd_slab->pds_mmd; - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - mutex_enter(&(mmd->mmd_pd_slab_lock)); - /* - * We can't deallocate the associated resources if the Multidata - * is shared with other threads, because it's possible that the - * descriptor handle value is held by those threads. That's why - * we simply mark the entry as "removed" and decrement the counts. - * If there are no other threads, then we free the descriptor. - */ - if (mmd->mmd_dp->db_ref > 1) { - pd->pd_flags |= PDESC_REM_DEFER; - if (pd->pd_flags & PDESC_HBUF_REF) { - ASSERT(mmd->mmd_hbuf_ref > 0); - mmd->mmd_hbuf_ref--; - } - if (pd->pd_flags & PDESC_PBUF_REF) { - ASSERT(mmd->mmd_pbuf_ref > 0); - mmd->mmd_pbuf_ref -= pd->pd_pdi.pld_cnt; - } - ASSERT(mmd->mmd_pd_cnt > 0); - mmd->mmd_pd_cnt--; - } else { - (void) mmd_destroy_pdesc(mmd, pd); - } - mutex_exit(&(mmd->mmd_pd_slab_lock)); -} - -/* - * A generic routine to traverse the packet descriptor in-use list. - */ -static pdesc_t * -mmd_getpdesc(multidata_t *mmd, pdesc_t *pd, pdescinfo_t *pdi, uint_t forw, - boolean_t mutex_held) -{ - pdesc_t *pd_head; - - ASSERT(pd == NULL || pd->pd_slab->pds_mmd == mmd); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(!mutex_held || MUTEX_HELD(&(mmd->mmd_pd_slab_lock))); - - if (!mutex_held) - mutex_enter(&(mmd->mmd_pd_slab_lock)); - pd_head = Q2PD(&(mmd->mmd_pd_q)); - - if (pd == NULL) { - /* - * We're called by mmd_get{first,last}pdesc, and so - * return either the first or last list element. - */ - pd = forw ? Q2PD(mmd->mmd_pd_q.ql_next) : - Q2PD(mmd->mmd_pd_q.ql_prev); - } else { - /* - * We're called by mmd_get{next,prev}pdesc, and so - * return either the next or previous list element. - */ - pd = forw ? Q2PD(pd->pd_next) : Q2PD(pd->pd_prev); - } - - while (pd != pd_head) { - /* skip element if it has been removed */ - if (!(pd->pd_flags & PDESC_REM_DEFER)) - break; - pd = forw ? Q2PD(pd->pd_next) : Q2PD(pd->pd_prev); - } - if (!mutex_held) - mutex_exit(&(mmd->mmd_pd_slab_lock)); - - /* return NULL if we're back at the beginning */ - if (pd == pd_head) - pd = NULL; - - /* got an entry; copy descriptor info to caller */ - if (pd != NULL && pdi != NULL) - PDI_COPY(&(pd->pd_pdi), pdi); - - ASSERT(pd == NULL || pd->pd_magic == PDESC_MAGIC); - return (pd); - -} - -/* - * Return the first packet descriptor in the in-use list. - */ -pdesc_t * -mmd_getfirstpdesc(multidata_t *mmd, pdescinfo_t *pdi) -{ - return (mmd_getpdesc(mmd, NULL, pdi, 1, B_FALSE)); -} - -/* - * Return the last packet descriptor in the in-use list. - */ -pdesc_t * -mmd_getlastpdesc(multidata_t *mmd, pdescinfo_t *pdi) -{ - return (mmd_getpdesc(mmd, NULL, pdi, 0, B_FALSE)); -} - -/* - * Return the next packet descriptor in the in-use list. - */ -pdesc_t * -mmd_getnextpdesc(pdesc_t *pd, pdescinfo_t *pdi) -{ - return (mmd_getpdesc(pd->pd_slab->pds_mmd, pd, pdi, 1, B_FALSE)); -} - -/* - * Return the previous packet descriptor in the in-use list. - */ -pdesc_t * -mmd_getprevpdesc(pdesc_t *pd, pdescinfo_t *pdi) -{ - return (mmd_getpdesc(pd->pd_slab->pds_mmd, pd, pdi, 0, B_FALSE)); -} - -/* - * Check to see if pdi stretches over c_pdi; used to ensure that a packet - * descriptor's header and payload span may not be extended beyond the - * current boundaries. - */ -static boolean_t -pdi_in_range(pdescinfo_t *pdi, pdescinfo_t *c_pdi) -{ - int i; - struct pld_ary_s *pa = &pdi->pld_ary[0]; - struct pld_ary_s *c_pa = &c_pdi->pld_ary[0]; - - if (pdi->hdr_base < c_pdi->hdr_base || pdi->hdr_lim > c_pdi->hdr_lim) - return (B_FALSE); - - /* - * We don't allow the number of span to be reduced, for the sake - * of simplicity. Instead, we provide PDESC_PLD_SPAN_CLEAR() to - * clear a packet descriptor. Note that we allow the span count to - * be increased, and the bounds check for the new one happens - * in pbuf_ref_valid. - */ - if (pdi->pld_cnt < c_pdi->pld_cnt) - return (B_FALSE); - - /* compare only those which are currently defined */ - for (i = 0; i < c_pdi->pld_cnt; i++, pa++, c_pa++) { - if (pa->pld_pbuf_idx != c_pa->pld_pbuf_idx || - pa->pld_rptr < c_pa->pld_rptr || - pa->pld_wptr > c_pa->pld_wptr) - return (B_FALSE); - } - return (B_TRUE); -} - -/* - * Modify the layout of a packet descriptor. - */ -pdesc_t * -mmd_adjpdesc(pdesc_t *pd, pdescinfo_t *pdi) -{ - multidata_t *mmd; - pdescinfo_t *c_pdi; - - ASSERT(pd != NULL); - ASSERT(pdi != NULL); - ASSERT(pd->pd_magic == PDESC_MAGIC); - - mmd = pd->pd_slab->pds_mmd; - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - /* entry has been removed */ - if (pd->pd_flags & PDESC_REM_DEFER) - return (NULL); - - /* caller doesn't intend to specify any buffer reference? */ - if (!(pdi->flags & PDESC_HAS_REF)) - return (NULL); - - /* do the references refer to invalid memory regions? */ - if (!mmd_speed_over_safety && - (((pdi->flags & PDESC_HBUF_REF) && !HBUF_REF_VALID(mmd, pdi)) || - ((pdi->flags & PDESC_PBUF_REF) && !pbuf_ref_valid(mmd, pdi)))) - return (NULL); - - /* they're not subsets of current references? */ - c_pdi = &(pd->pd_pdi); - if (!pdi_in_range(pdi, c_pdi)) - return (NULL); - - /* copy over the descriptor info from caller */ - PDI_COPY(pdi, c_pdi); - - return (pd); -} - -/* - * Copy the contents of a packet descriptor into a new buffer. If the - * descriptor points to more than one buffer fragments, the contents - * of both fragments will be joined, with the header buffer fragment - * preceding the payload buffer fragment(s). - */ -mblk_t * -mmd_transform(pdesc_t *pd) -{ - multidata_t *mmd; - pdescinfo_t *pdi; - mblk_t *mp; - int h_size = 0, p_size = 0; - int i, len; - - ASSERT(pd != NULL); - ASSERT(pd->pd_magic == PDESC_MAGIC); - - mmd = pd->pd_slab->pds_mmd; - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - /* entry has been removed */ - if (pd->pd_flags & PDESC_REM_DEFER) - return (NULL); - - mutex_enter(&mmd->mmd_pd_slab_lock); - pdi = &(pd->pd_pdi); - if (pdi->flags & PDESC_HBUF_REF) - h_size = PDESC_HDRL(pdi); - if (pdi->flags & PDESC_PBUF_REF) { - for (i = 0; i < pdi->pld_cnt; i++) - p_size += PDESC_PLD_SPAN_SIZE(pdi, i); - } - - /* allocate space large enough to hold the fragment(s) */ - ASSERT(h_size + p_size >= 0); - if ((mp = allocb(h_size + p_size, BPRI_HI)) == NULL) { - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - - /* copy over the header fragment */ - if ((pdi->flags & PDESC_HBUF_REF) && h_size > 0) { - bcopy(pdi->hdr_rptr, mp->b_wptr, h_size); - mp->b_wptr += h_size; - } - - /* copy over the payload fragment */ - if ((pdi->flags & PDESC_PBUF_REF) && p_size > 0) { - for (i = 0; i < pdi->pld_cnt; i++) { - len = PDESC_PLD_SPAN_SIZE(pdi, i); - if (len > 0) { - bcopy(pdi->pld_ary[i].pld_rptr, - mp->b_wptr, len); - mp->b_wptr += len; - } - } - } - - mutex_exit(&mmd->mmd_pd_slab_lock); - return (mp); -} - -/* - * Return a chain of mblks representing the Multidata packet. - */ -mblk_t * -mmd_transform_link(pdesc_t *pd) -{ - multidata_t *mmd; - pdescinfo_t *pdi; - mblk_t *nmp = NULL; - - ASSERT(pd != NULL); - ASSERT(pd->pd_magic == PDESC_MAGIC); - - mmd = pd->pd_slab->pds_mmd; - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - /* entry has been removed */ - if (pd->pd_flags & PDESC_REM_DEFER) - return (NULL); - - pdi = &(pd->pd_pdi); - - /* duplicate header buffer */ - if ((pdi->flags & PDESC_HBUF_REF)) { - if ((nmp = dupb(mmd->mmd_hbuf)) == NULL) - return (NULL); - nmp->b_rptr = pdi->hdr_rptr; - nmp->b_wptr = pdi->hdr_wptr; - } - - /* duplicate payload buffer(s) */ - if (pdi->flags & PDESC_PBUF_REF) { - int i; - mblk_t *mp; - struct pld_ary_s *pa = &pdi->pld_ary[0]; - - mutex_enter(&mmd->mmd_pd_slab_lock); - for (i = 0; i < pdi->pld_cnt; i++, pa++) { - ASSERT(mmd->mmd_pbuf[pa->pld_pbuf_idx] != NULL); - - /* skip empty ones */ - if (PDESC_PLD_SPAN_SIZE(pdi, i) == 0) - continue; - - mp = dupb(mmd->mmd_pbuf[pa->pld_pbuf_idx]); - if (mp == NULL) { - if (nmp != NULL) - freemsg(nmp); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (NULL); - } - mp->b_rptr = pa->pld_rptr; - mp->b_wptr = pa->pld_wptr; - if (nmp == NULL) - nmp = mp; - else - linkb(nmp, mp); - } - mutex_exit(&mmd->mmd_pd_slab_lock); - } - - return (nmp); -} - -/* - * Return duplicate message block(s) of the associated buffer(s). - */ -int -mmd_dupbufs(multidata_t *mmd, mblk_t **hmp, mblk_t **pmp) -{ - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - if (hmp != NULL) { - *hmp = NULL; - if (mmd->mmd_hbuf != NULL && - (*hmp = dupb(mmd->mmd_hbuf)) == NULL) - return (-1); - } - - if (pmp != NULL) { - int i; - mblk_t *mp; - - mutex_enter(&mmd->mmd_pd_slab_lock); - *pmp = NULL; - for (i = 0; i < mmd->mmd_pbuf_cnt; i++) { - ASSERT(mmd->mmd_pbuf[i] != NULL); - mp = dupb(mmd->mmd_pbuf[i]); - if (mp == NULL) { - if (hmp != NULL && *hmp != NULL) - freeb(*hmp); - if (*pmp != NULL) - freemsg(*pmp); - mutex_exit(&mmd->mmd_pd_slab_lock); - return (-1); - } - if (*pmp == NULL) - *pmp = mp; - else - linkb(*pmp, mp); - } - mutex_exit(&mmd->mmd_pd_slab_lock); - } - - return (0); -} - -/* - * Return the layout of a packet descriptor. - */ -int -mmd_getpdescinfo(pdesc_t *pd, pdescinfo_t *pdi) -{ - ASSERT(pd != NULL); - ASSERT(pd->pd_magic == PDESC_MAGIC); - ASSERT(pd->pd_slab != NULL); - ASSERT(pd->pd_slab->pds_mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(pdi != NULL); - - /* entry has been removed */ - if (pd->pd_flags & PDESC_REM_DEFER) - return (-1); - - /* copy descriptor info to caller */ - PDI_COPY(&(pd->pd_pdi), pdi); - - return (0); -} - -/* - * Add a global or local attribute to a Multidata. Global attribute - * association is specified by a NULL packet descriptor. - */ -pattr_t * -mmd_addpattr(multidata_t *mmd, pdesc_t *pd, pattrinfo_t *pai, - boolean_t persistent, int kmflags) -{ - patbkt_t **tbl_p; - patbkt_t *tbl, *o_tbl; - patbkt_t *bkt; - pattr_t *pa; - uint_t size; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(pd == NULL || pd->pd_magic == PDESC_MAGIC); - ASSERT(pai != NULL); - - /* pointer to the attribute hash table (local or global) */ - tbl_p = pd != NULL ? &(pd->pd_pattbl) : &(mmd->mmd_pattbl); - - /* - * See if the hash table has not yet been created; if so, - * we create the table and store its address atomically. - */ - if ((tbl = *tbl_p) == NULL) { - tbl = kmem_cache_alloc(pattbl_cache, kmflags); - if (tbl == NULL) - return (NULL); - - /* if someone got there first, use their table instead */ - if ((o_tbl = atomic_cas_ptr(tbl_p, NULL, tbl)) != NULL) { - kmem_cache_free(pattbl_cache, tbl); - tbl = o_tbl; - } - } - - ASSERT(tbl->pbkt_tbl_sz > 0); - bkt = &(tbl[PATTBL_HASH(pai->type, tbl->pbkt_tbl_sz)]); - - /* attribute of the same type already exists? */ - if ((pa = mmd_find_pattr(bkt, pai->type)) != NULL) - return (NULL); - - size = sizeof (*pa) + pai->len; - if ((pa = kmem_zalloc(size, kmflags)) == NULL) - return (NULL); - - pa->pat_magic = PATTR_MAGIC; - pa->pat_lock = &(bkt->pbkt_lock); - pa->pat_mmd = mmd; - pa->pat_buflen = size; - pa->pat_type = pai->type; - pai->buf = pai->len > 0 ? ((uchar_t *)(pa + 1)) : NULL; - - if (persistent) - pa->pat_flags = PATTR_PERSIST; - - /* insert attribute at end of hash chain */ - mutex_enter(&(bkt->pbkt_lock)); - insque(&(pa->pat_next), bkt->pbkt_pattr_q.ql_prev); - mutex_exit(&(bkt->pbkt_lock)); - - return (pa); -} - -/* - * Attribute hash table kmem cache constructor routine. - */ -/* ARGSUSED */ -static int -pattbl_constructor(void *buf, void *cdrarg, int kmflags) -{ - patbkt_t *bkt; - uint_t tbl_sz = (uint_t)(uintptr_t)cdrarg; - uint_t i; - - ASSERT(tbl_sz > 0); /* table size can't be zero */ - - for (i = 0, bkt = (patbkt_t *)buf; i < tbl_sz; i++, bkt++) { - mutex_init(&(bkt->pbkt_lock), NULL, MUTEX_DRIVER, NULL); - QL_INIT(&(bkt->pbkt_pattr_q)); - - /* first bucket contains the table size */ - bkt->pbkt_tbl_sz = i == 0 ? tbl_sz : 0; - } - return (0); -} - -/* - * Attribute hash table kmem cache destructor routine. - */ -/* ARGSUSED */ -static void -pattbl_destructor(void *buf, void *cdrarg) -{ - patbkt_t *bkt; - uint_t tbl_sz = (uint_t)(uintptr_t)cdrarg; - uint_t i; - - ASSERT(tbl_sz > 0); /* table size can't be zero */ - - for (i = 0, bkt = (patbkt_t *)buf; i < tbl_sz; i++, bkt++) { - mutex_destroy(&(bkt->pbkt_lock)); - ASSERT(bkt->pbkt_pattr_q.ql_next == &(bkt->pbkt_pattr_q)); - ASSERT(i > 0 || bkt->pbkt_tbl_sz == tbl_sz); - } -} - -/* - * Destroy an attribute hash table, called by mmd_rempdesc or during free. - */ -static void -mmd_destroy_pattbl(patbkt_t **tbl) -{ - patbkt_t *bkt; - pattr_t *pa, *pa_next; - uint_t i, tbl_sz; - - ASSERT(tbl != NULL); - bkt = *tbl; - tbl_sz = bkt->pbkt_tbl_sz; - - /* make sure caller passes in the first bucket */ - ASSERT(tbl_sz > 0); - - /* destroy the contents of each bucket */ - for (i = 0; i < tbl_sz; i++, bkt++) { - /* we ought to be exclusive at this point */ - ASSERT(MUTEX_NOT_HELD(&(bkt->pbkt_lock))); - - pa = Q2PATTR(bkt->pbkt_pattr_q.ql_next); - while (pa != Q2PATTR(&(bkt->pbkt_pattr_q))) { - ASSERT(pa->pat_magic == PATTR_MAGIC); - pa_next = Q2PATTR(pa->pat_next); - remque(&(pa->pat_next)); - kmem_free(pa, pa->pat_buflen); - pa = pa_next; - } - } - - kmem_cache_free(pattbl_cache, *tbl); - *tbl = NULL; - - /* commit all previous stores */ - membar_producer(); -} - -/* - * Copy the contents of an attribute hash table, called by mmd_copy. - */ -static int -mmd_copy_pattbl(patbkt_t *src_tbl, multidata_t *n_mmd, pdesc_t *n_pd, - int kmflags) -{ - patbkt_t *bkt; - pattr_t *pa; - pattrinfo_t pai; - uint_t i, tbl_sz; - - ASSERT(src_tbl != NULL); - bkt = src_tbl; - tbl_sz = bkt->pbkt_tbl_sz; - - /* make sure caller passes in the first bucket */ - ASSERT(tbl_sz > 0); - - for (i = 0; i < tbl_sz; i++, bkt++) { - mutex_enter(&(bkt->pbkt_lock)); - pa = Q2PATTR(bkt->pbkt_pattr_q.ql_next); - while (pa != Q2PATTR(&(bkt->pbkt_pattr_q))) { - pattr_t *pa_next = Q2PATTR(pa->pat_next); - - /* skip if it's removed */ - if (pa->pat_flags & PATTR_REM_DEFER) { - pa = pa_next; - continue; - } - - pai.type = pa->pat_type; - pai.len = pa->pat_buflen - sizeof (*pa); - if (mmd_addpattr(n_mmd, n_pd, &pai, (pa->pat_flags & - PATTR_PERSIST) != 0, kmflags) == NULL) { - mutex_exit(&(bkt->pbkt_lock)); - return (-1); - } - - /* copy over the contents */ - if (pai.buf != NULL) - bcopy(pa + 1, pai.buf, pai.len); - - pa = pa_next; - } - mutex_exit(&(bkt->pbkt_lock)); - } - - return (0); -} - -/* - * Search for an attribute type within an attribute hash bucket. - */ -static pattr_t * -mmd_find_pattr(patbkt_t *bkt, uint_t type) -{ - pattr_t *pa_head, *pa; - - mutex_enter(&(bkt->pbkt_lock)); - pa_head = Q2PATTR(&(bkt->pbkt_pattr_q)); - pa = Q2PATTR(bkt->pbkt_pattr_q.ql_next); - - while (pa != pa_head) { - ASSERT(pa->pat_magic == PATTR_MAGIC); - - /* return a match; we treat removed entry as non-existent */ - if (pa->pat_type == type && !(pa->pat_flags & PATTR_REM_DEFER)) - break; - pa = Q2PATTR(pa->pat_next); - } - mutex_exit(&(bkt->pbkt_lock)); - - return (pa == pa_head ? NULL : pa); -} - -/* - * Remove an attribute from a Multidata. - */ -void -mmd_rempattr(pattr_t *pa) -{ - kmutex_t *pat_lock = pa->pat_lock; - - ASSERT(pa->pat_magic == PATTR_MAGIC); - - /* ignore if attribute was marked as persistent */ - if ((pa->pat_flags & PATTR_PERSIST) != 0) - return; - - mutex_enter(pat_lock); - /* - * We can't deallocate the associated resources if the Multidata - * is shared with other threads, because it's possible that the - * attribute handle value is held by those threads. That's why - * we simply mark the entry as "removed". If there are no other - * threads, then we free the attribute. - */ - if (pa->pat_mmd->mmd_dp->db_ref > 1) { - pa->pat_flags |= PATTR_REM_DEFER; - } else { - remque(&(pa->pat_next)); - kmem_free(pa, pa->pat_buflen); - } - mutex_exit(pat_lock); -} - -/* - * Find an attribute (according to its type) and return its handle. - */ -pattr_t * -mmd_getpattr(multidata_t *mmd, pdesc_t *pd, pattrinfo_t *pai) -{ - patbkt_t *tbl, *bkt; - pattr_t *pa; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - ASSERT(pai != NULL); - - /* get the right attribute hash table (local or global) */ - tbl = pd != NULL ? pd->pd_pattbl : mmd->mmd_pattbl; - - /* attribute hash table doesn't exist? */ - if (tbl == NULL) - return (NULL); - - ASSERT(tbl->pbkt_tbl_sz > 0); - bkt = &(tbl[PATTBL_HASH(pai->type, tbl->pbkt_tbl_sz)]); - - if ((pa = mmd_find_pattr(bkt, pai->type)) != NULL) { - ASSERT(pa->pat_buflen >= sizeof (*pa)); - pai->len = pa->pat_buflen - sizeof (*pa); - pai->buf = pai->len > 0 ? - (uchar_t *)pa + sizeof (pattr_t) : NULL; - } - ASSERT(pa == NULL || pa->pat_magic == PATTR_MAGIC); - return (pa); -} - -/* - * Return total size of buffers and total size of areas referenced - * by all in-use (unremoved) packet descriptors. - */ -void -mmd_getsize(multidata_t *mmd, uint_t *ptotal, uint_t *pinuse) -{ - pdesc_t *pd; - pdescinfo_t *pdi; - int i; - - ASSERT(mmd != NULL); - ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC); - - mutex_enter(&mmd->mmd_pd_slab_lock); - if (ptotal != NULL) { - *ptotal = 0; - - if (mmd->mmd_hbuf != NULL) - *ptotal += MBLKL(mmd->mmd_hbuf); - - for (i = 0; i < mmd->mmd_pbuf_cnt; i++) { - ASSERT(mmd->mmd_pbuf[i] != NULL); - *ptotal += MBLKL(mmd->mmd_pbuf[i]); - } - } - if (pinuse != NULL) { - *pinuse = 0; - - /* first pdesc */ - pd = mmd_getpdesc(mmd, NULL, NULL, 1, B_TRUE); - while (pd != NULL) { - pdi = &pd->pd_pdi; - - /* next pdesc */ - pd = mmd_getpdesc(mmd, pd, NULL, 1, B_TRUE); - - /* skip over removed descriptor */ - if (pdi->flags & PDESC_REM_DEFER) - continue; - - if (pdi->flags & PDESC_HBUF_REF) - *pinuse += PDESC_HDRL(pdi); - - if (pdi->flags & PDESC_PBUF_REF) { - for (i = 0; i < pdi->pld_cnt; i++) - *pinuse += PDESC_PLDL(pdi, i); - } - } - } - mutex_exit(&mmd->mmd_pd_slab_lock); -} diff --git a/usr/src/uts/common/io/softmac/softmac_capab.c b/usr/src/uts/common/io/softmac/softmac_capab.c index d1178d19aa..8d67f42155 100644 --- a/usr/src/uts/common/io/softmac/softmac_capab.c +++ b/usr/src/uts/common/io/softmac/softmac_capab.c @@ -21,10 +21,10 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/mac.h> #include <sys/softmac_impl.h> @@ -32,18 +32,14 @@ typedef struct softmac_capab_ops { int (*sc_hcksum_ack)(void *, t_uscalar_t); int (*sc_zcopy_ack)(void *, t_uscalar_t); - int (*sc_mdt_ack)(void *, dl_capab_mdt_t *); } softmac_capab_ops_t; static int dl_capab(ldi_handle_t, mblk_t **); static int softmac_fill_hcksum_ack(void *, t_uscalar_t); static int softmac_fill_zcopy_ack(void *, t_uscalar_t); -static int softmac_fill_mdt_ack(void *, dl_capab_mdt_t *); static int softmac_adv_hcksum_ack(void *, t_uscalar_t); static int softmac_adv_zcopy_ack(void *, t_uscalar_t); -static int softmac_adv_mdt_ack(void *, dl_capab_mdt_t *); static int softmac_enable_hcksum_ack(void *, t_uscalar_t); -static int softmac_enable_mdt_ack(void *, dl_capab_mdt_t *); static int softmac_capab_send(softmac_lower_t *, boolean_t); static int i_capab_ack(mblk_t *, queue_t *, softmac_capab_ops_t *, void *); static int i_capab_id_ack(mblk_t *, dl_capability_sub_t *, queue_t *, @@ -54,31 +50,25 @@ static int i_capab_hcksum_ack(dl_capab_hcksum_t *, queue_t *, softmac_capab_ops_t *, void *); static int i_capab_zcopy_ack(dl_capab_zerocopy_t *, queue_t *, softmac_capab_ops_t *, void *); -static int i_capab_mdt_ack(dl_capab_mdt_t *, queue_t *, - softmac_capab_ops_t *, void *); static int i_capab_hcksum_verify(dl_capab_hcksum_t *, queue_t *); static int i_capab_zcopy_verify(dl_capab_zerocopy_t *, queue_t *); -static int i_capab_mdt_verify(dl_capab_mdt_t *, queue_t *); static softmac_capab_ops_t softmac_fill_capab_ops = { softmac_fill_hcksum_ack, softmac_fill_zcopy_ack, - softmac_fill_mdt_ack, }; static softmac_capab_ops_t softmac_adv_capab_ops = { softmac_adv_hcksum_ack, softmac_adv_zcopy_ack, - softmac_adv_mdt_ack }; static softmac_capab_ops_t softmac_enable_capab_ops = { softmac_enable_hcksum_ack, NULL, - softmac_enable_mdt_ack }; int @@ -196,28 +186,6 @@ softmac_fill_zcopy_ack(void *arg, t_uscalar_t flags) return (0); } -static int -softmac_fill_mdt_ack(void *arg, dl_capab_mdt_t *mdt) -{ - softmac_t *softmac = (softmac_t *)arg; - - /* - * There are two types of acks we process here: - * 1. acks in reply to a (first form) generic capability req - * (ENABLE flag might be set by some drivers) - * 2. acks in reply to a ENABLE capability req. - * (ENABLE flag set) - */ - - ASSERT(mdt->mdt_version == MDT_VERSION_2); - softmac->smac_mdt = B_TRUE; - softmac->smac_mdt_capab.mdt_hdr_head = mdt->mdt_hdr_head; - softmac->smac_mdt_capab.mdt_hdr_tail = mdt->mdt_hdr_tail; - softmac->smac_mdt_capab.mdt_max_pld = mdt->mdt_max_pld; - softmac->smac_mdt_capab.mdt_span_limit = mdt->mdt_span_limit; - return (0); -} - int softmac_capab_enable(softmac_lower_t *slp) { @@ -260,18 +228,6 @@ softmac_capab_send(softmac_lower_t *slp, boolean_t enable) size += sizeof (dl_capability_sub_t) + sizeof (dl_capab_hcksum_t); - if (softmac->smac_mdt) { - if (!(softmac->smac_mdt_capab.mdt_flags & - DL_CAPAB_MDT_ENABLE)) { - /* - * The MDT capability was not enabled for the - * first time, enable it now. - */ - size += sizeof (dl_capability_sub_t) + - sizeof (dl_capab_mdt_t); - } - } - if (size == 0) return (0); } @@ -312,36 +268,6 @@ softmac_capab_send(softmac_lower_t *slp, boolean_t enable) softmac->smac_hcksum_txflags | HCKSUM_ENABLE; } - if (softmac->smac_mdt) { - if (!(softmac->smac_mdt_capab.mdt_flags & - DL_CAPAB_MDT_ENABLE)) { - dl_capab_mdt_t *mdt_subcapp; - - size = sizeof (dl_capability_sub_t) + - sizeof (dl_capab_mdt_t); - capb->dl_sub_length += size; - - subcapb = (dl_capability_sub_t *) - ((uint8_t *)(subcapb + 1) + subcapb->dl_length); - - subcapb->dl_cap = DL_CAPAB_MDT; - subcapb->dl_length = sizeof (dl_capab_mdt_t); - mdt_subcapp = (dl_capab_mdt_t *)(subcapb + 1); - mdt_subcapp->mdt_version = MDT_VERSION_2; - mdt_subcapp->mdt_flags = - (softmac->smac_mdt_capab.mdt_flags | - DL_CAPAB_MDT_ENABLE); - mdt_subcapp->mdt_hdr_head = - softmac->smac_mdt_capab.mdt_hdr_head; - mdt_subcapp->mdt_hdr_tail = - softmac->smac_mdt_capab.mdt_hdr_tail; - mdt_subcapp->mdt_max_pld = - softmac->smac_mdt_capab.mdt_max_pld; - mdt_subcapp->mdt_span_limit = - softmac->smac_mdt_capab.mdt_span_limit; - } - } - output: err = softmac_proto_tx(slp, reqmp, &ackmp); if (err == 0) { @@ -414,35 +340,6 @@ softmac_adv_zcopy_ack(void *arg, t_uscalar_t flags) } static int -softmac_adv_mdt_ack(void *arg, dl_capab_mdt_t *mdt) -{ - softmac_t *softmac = (softmac_t *)arg; - - /* - * The acknowledgement should be the same as we got when - * the softmac is created. - */ - if (!softmac->smac_mdt) { - ASSERT(B_FALSE); - return (-1); - } - - if ((softmac->smac_mdt_capab.mdt_hdr_head != mdt->mdt_hdr_head) || - (softmac->smac_mdt_capab.mdt_hdr_tail != mdt->mdt_hdr_tail) || - (softmac->smac_mdt_capab.mdt_max_pld != mdt->mdt_max_pld) || - (softmac->smac_mdt_capab.mdt_span_limit != mdt->mdt_span_limit)) { - ASSERT(B_FALSE); - return (-1); - } - /* - * We need the mdt_flags field to know whether an additional - * DL_CAPAB_MDT_ENABLE is necessary. - */ - softmac->smac_mdt_capab.mdt_flags = mdt->mdt_flags; - return (0); -} - -static int softmac_enable_hcksum_ack(void *arg, t_uscalar_t flags) { softmac_t *softmac = (softmac_t *)arg; @@ -472,43 +369,6 @@ softmac_enable_hcksum_ack(void *arg, t_uscalar_t flags) } static int -softmac_enable_mdt_ack(void *arg, dl_capab_mdt_t *mdt) -{ - softmac_t *softmac = (softmac_t *)arg; - - /* - * There are two types of acks we process here: - * 1. acks in reply to a (first form) generic capability req - * (no ENABLE flag set) - * 2. acks in reply to a ENABLE capability req. - * (ENABLE flag set) - * Only the second type should be expected here. - */ - - if (mdt->mdt_flags & DL_CAPAB_MDT_ENABLE) { - if ((softmac->smac_mdt_capab.mdt_hdr_head != - mdt->mdt_hdr_head) || - (softmac->smac_mdt_capab.mdt_hdr_tail != - mdt->mdt_hdr_tail) || - (softmac->smac_mdt_capab.mdt_max_pld != - mdt->mdt_max_pld) || - (softmac->smac_mdt_capab.mdt_span_limit != - mdt->mdt_span_limit)) { - cmn_err(CE_WARN, "softmac_enable_mdt_ack: " - "unexpected MDT capability value"); - return (-1); - } - softmac->smac_mdt_capab.mdt_flags = mdt->mdt_flags; - } else { - cmn_err(CE_WARN, "softmac_enable_mdt_ack: " - "MDT flag DL_CAPAB_MDT_ENABLE is not set"); - return (-1); - } - - return (0); -} - -static int i_capab_ack(mblk_t *mp, queue_t *q, softmac_capab_ops_t *op, void *arg) { union DL_primitives *prim; @@ -595,7 +455,6 @@ i_capab_sub_ack(mblk_t *mp, dl_capability_sub_t *sub, queue_t *q, caddr_t capend; dl_capab_hcksum_t *hcksum; dl_capab_zerocopy_t *zcopy; - dl_capab_mdt_t *mdt; int err = 0; capend = (caddr_t)(sub + 1) + sub->dl_length; @@ -616,11 +475,6 @@ i_capab_sub_ack(mblk_t *mp, dl_capability_sub_t *sub, queue_t *q, err = i_capab_zcopy_ack(zcopy, q, op, arg); break; - case DL_CAPAB_MDT: - mdt = (dl_capab_mdt_t *)(sub + 1); - err = i_capab_mdt_ack(mdt, q, op, arg); - break; - default: cmn_err(CE_WARN, "i_capab_sub_ack: unknown capab type %d", sub->dl_cap); @@ -684,24 +538,6 @@ i_capab_zcopy_ack(dl_capab_zerocopy_t *zcopy, queue_t *q, } static int -i_capab_mdt_ack(dl_capab_mdt_t *mdt, queue_t *q, - softmac_capab_ops_t *op, void *arg) -{ - int err; - - if ((err = i_capab_mdt_verify(mdt, q)) != 0) - return (err); - - if (op->sc_mdt_ack) - return (op->sc_mdt_ack(arg, mdt)); - else { - cmn_err(CE_WARN, "i_capab_mdt_ack: unexpected MDT " - "acknowledgement"); - return (EINVAL); - } -} - -static int i_capab_hcksum_verify(dl_capab_hcksum_t *hcksum, queue_t *q) { if (hcksum->hcksum_version != HCKSUM_VERSION_1) { @@ -736,21 +572,3 @@ i_capab_zcopy_verify(dl_capab_zerocopy_t *zcopy, queue_t *q) } return (0); } - -static int -i_capab_mdt_verify(dl_capab_mdt_t *mdt, queue_t *q) -{ - if (mdt->mdt_version != MDT_VERSION_2) { - cmn_err(CE_WARN, "i_capab_mdt_verify: unsupported MDT " - "capability (version %d, expected %d)", - mdt->mdt_version, MDT_VERSION_2); - return (-1); - } - - if ((q != NULL) && !dlcapabcheckqid(&mdt->mdt_mid, q)) { - cmn_err(CE_WARN, "i_capab_mdt_verify: unexpected pass-thru " - "module detected; MDT capability discarded"); - return (-1); - } - return (0); -} diff --git a/usr/src/uts/common/io/softmac/softmac_dev.c b/usr/src/uts/common/io/softmac/softmac_dev.c index 60415e3422..4d3bd9ab8b 100644 --- a/usr/src/uts/common/io/softmac/softmac_dev.c +++ b/usr/src/uts/common/io/softmac/softmac_dev.c @@ -25,6 +25,7 @@ /* * Copyright 2019, Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ #include <sys/types.h> @@ -625,7 +626,6 @@ softmac_drv_wput(queue_t *wq, mblk_t *mp) switch (DB_TYPE(mp)) { case M_DATA: - case M_MULTIDATA: softmac_wput_data(sup, mp); break; case M_PROTO: diff --git a/usr/src/uts/common/io/softmac/softmac_fp.c b/usr/src/uts/common/io/softmac/softmac_fp.c index 174a7b2e86..6748ccde5b 100644 --- a/usr/src/uts/common/io/softmac/softmac_fp.c +++ b/usr/src/uts/common/io/softmac/softmac_fp.c @@ -25,6 +25,7 @@ /* * Copyright 2019, Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ /* @@ -312,7 +313,6 @@ softmac_capability_advertise(softmac_upper_t *sup, mblk_t *mp) boolean_t dld_capable = B_FALSE; boolean_t hcksum_capable = B_FALSE; boolean_t zcopy_capable = B_FALSE; - boolean_t mdt_capable = B_FALSE; ASSERT(sup->su_mode == SOFTMAC_FASTPATH); @@ -348,12 +348,6 @@ softmac_capability_advertise(softmac_upper_t *sup, mblk_t *mp) sizeof (dl_capab_zerocopy_t); } - if (softmac->smac_mdt) { - mdt_capable = B_TRUE; - subsize += sizeof (dl_capability_sub_t) + - sizeof (dl_capab_mdt_t); - } - /* * If there are no capabilities to advertise or if we * can't allocate a response, send a DL_ERROR_ACK. @@ -435,30 +429,6 @@ softmac_capability_advertise(softmac_upper_t *sup, mblk_t *mp) ptr += sizeof (dl_capab_zerocopy_t); } - /* - * MDT - */ - if (mdt_capable) { - dl_capab_mdt_t mdt; - - dlsp = (dl_capability_sub_t *)ptr; - - dlsp->dl_cap = DL_CAPAB_MDT; - dlsp->dl_length = sizeof (dl_capab_mdt_t); - ptr += sizeof (dl_capability_sub_t); - - bzero(&mdt, sizeof (dl_capab_mdt_t)); - mdt.mdt_version = MDT_VERSION_2; - mdt.mdt_flags = DL_CAPAB_MDT_ENABLE; - mdt.mdt_hdr_head = softmac->smac_mdt_capab.mdt_hdr_head; - mdt.mdt_hdr_tail = softmac->smac_mdt_capab.mdt_hdr_tail; - mdt.mdt_max_pld = softmac->smac_mdt_capab.mdt_max_pld; - mdt.mdt_span_limit = softmac->smac_mdt_capab.mdt_span_limit; - dlcapabsetqid(&(mdt.mdt_mid), sup->su_rq); - bcopy(&mdt, ptr, sizeof (dl_capab_mdt_t)); - ptr += sizeof (dl_capab_mdt_t); - } - ASSERT(ptr == mp->b_rptr + sizeof (dl_capability_ack_t) + subsize); qreply(q, mp); } diff --git a/usr/src/uts/common/io/stream.c b/usr/src/uts/common/io/stream.c index 81bc8d6692..018ebcc4f0 100644 --- a/usr/src/uts/common/io/stream.c +++ b/usr/src/uts/common/io/stream.c @@ -26,6 +26,7 @@ * Use is subject to license terms. * * Copyright 2021 Tintri by DDN, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore */ #include <sys/types.h> @@ -45,8 +46,6 @@ #include <sys/vtrace.h> #include <sys/ftrace.h> #include <sys/ontrap.h> -#include <sys/multidata.h> -#include <sys/multidata_impl.h> #include <sys/sdt.h> #include <sys/strft.h> @@ -406,9 +405,6 @@ streams_msg_init(void) ftblk_cache = kmem_cache_create("streams_ftblk", sizeof (ftblk_t), 32, ftblk_constructor, ftblk_destructor, NULL, NULL, NULL, 0); - /* Initialize Multidata caches */ - mmd_init(); - /* initialize throttling queue for esballoc */ esballoc_queue_init(); } @@ -1433,31 +1429,6 @@ copyb(mblk_t *bp) if (dp->db_fthdr != NULL) STR_FTEVENT_MBLK(bp, caller(), FTEV_COPYB, 0); - /* - * Special handling for Multidata message; this should be - * removed once a copy-callback routine is made available. - */ - if (dp->db_type == M_MULTIDATA) { - cred_t *cr; - - if ((nbp = mmd_copy(bp, KM_NOSLEEP)) == NULL) - return (NULL); - - nbp->b_flag = bp->b_flag; - nbp->b_band = bp->b_band; - ndp = nbp->b_datap; - - /* See comments below on potential issues. */ - STR_FTEVENT_MBLK(nbp, caller(), FTEV_COPYB, 1); - - ASSERT(ndp->db_type == dp->db_type); - cr = dp->db_credp; - if (cr != NULL) - crhold(ndp->db_credp = cr); - ndp->db_cpid = dp->db_cpid; - return (nbp); - } - size = dp->db_lim - dp->db_base; unaligned = P2PHASE((uintptr_t)dp->db_base, sizeof (uint_t)); if ((nbp = allocb_tmpl(size + unaligned, bp)) == NULL) @@ -1589,15 +1560,6 @@ pullupmsg(mblk_t *mp, ssize_t len) ASSERT(mp->b_datap->db_ref > 0); ASSERT(mp->b_next == NULL && mp->b_prev == NULL); - /* - * We won't handle Multidata message, since it contains - * metadata which this function has no knowledge of; we - * assert on DEBUG, and return failure otherwise. - */ - ASSERT(mp->b_datap->db_type != M_MULTIDATA); - if (mp->b_datap->db_type == M_MULTIDATA) - return (0); - if (len == -1) { if (mp->b_cont == NULL && str_aligned(mp->b_rptr)) return (1); @@ -1663,15 +1625,6 @@ msgpullup(mblk_t *mp, ssize_t len) ssize_t totlen; ssize_t n; - /* - * We won't handle Multidata message, since it contains - * metadata which this function has no knowledge of; we - * assert on DEBUG, and return failure otherwise. - */ - ASSERT(mp->b_datap->db_type != M_MULTIDATA); - if (mp->b_datap->db_type == M_MULTIDATA) - return (NULL); - totlen = xmsgsize(mp); if ((len > 0) && (len > totlen)) @@ -1730,14 +1683,6 @@ adjmsg(mblk_t *mp, ssize_t len) int first; ASSERT(mp != NULL); - /* - * We won't handle Multidata message, since it contains - * metadata which this function has no knowledge of; we - * assert on DEBUG, and return failure otherwise. - */ - ASSERT(mp->b_datap->db_type != M_MULTIDATA); - if (mp->b_datap->db_type == M_MULTIDATA) - return (0); if (len < 0) { fromhead = 0; @@ -1901,21 +1846,6 @@ getq(queue_t *q) } /* - * Calculate number of data bytes in a single data message block taking - * multidata messages into account. - */ - -#define ADD_MBLK_SIZE(mp, size) \ - if (DB_TYPE(mp) != M_MULTIDATA) { \ - (size) += MBLKL(mp); \ - } else { \ - uint_t pinuse; \ - \ - mmd_getsize(mmd_getmultidata(mp), NULL, &pinuse); \ - (size) += pinuse; \ - } - -/* * Returns the number of bytes in a message (a message is defined as a * chain of mblks linked by b_cont). If a non-NULL mblkcnt is supplied we * also return the number of distinct mblks in the message. @@ -1928,7 +1858,7 @@ mp_cont_len(mblk_t *bp, int *mblkcnt) int bytes = 0; for (mp = bp; mp != NULL; mp = mp->b_cont) { - ADD_MBLK_SIZE(mp, bytes); + bytes += MBLKL(mp); mblks++; } @@ -1982,7 +1912,7 @@ getq_noenab(queue_t *q, ssize_t rbytes) */ for (mp1 = bp; mp1 != NULL; mp1 = mp1->b_cont) { mblkcnt++; - ADD_MBLK_SIZE(mp1, bytecnt); + bytecnt += MBLKL(mp1); if (bytecnt >= rbytes) break; } diff --git a/usr/src/uts/common/os/ip_cksum.c b/usr/src/uts/common/os/ip_cksum.c index 51a93dfa24..862b33cd11 100644 --- a/usr/src/uts/common/os/ip_cksum.c +++ b/usr/src/uts/common/os/ip_cksum.c @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2021 Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ /* Copyright (c) 1990 Mentat Inc. */ @@ -37,9 +38,6 @@ #include <inet/ip.h> #include <inet/ip6.h> -#include <sys/multidata.h> -#include <sys/multidata_impl.h> - extern unsigned int ip_ocsum(ushort_t *, int, unsigned int); /* @@ -401,136 +399,6 @@ sctp_cksum(mblk_t *mp, int offset) return (crc32); } -/* - * Routine to compute Internet checksum (16-bit 1's complement) of a given - * Multidata packet descriptor. As in the non-Multidata routine, this doesn't - * 1's complement the result, such that it may be used to compute partial - * checksums. Since it works on buffer spans rather than mblks, this routine - * does not handle existing partial checksum value as in the STRUIO_IP special - * mblk case (supporting this is rather trivial, but is perhaps of no use at - * the moment unless synchronous streams and delayed checksum calculation are - * revived.) - * - * Note also here that the given Multidata packet descriptor must refer to - * a header buffer, i.e. it must have a header fragment. In addition, the - * offset must lie within the boundary of the header fragment. For the - * outbound tcp (MDT) case, this will not be an issue because the stack - * ensures that such conditions are met, and that there is no need whatsoever - * to compute partial checksums on an arbitrary offset that is not part of - * the header fragment. We may need to revisit this routine to handle all - * cases of the inbound (MDR) case, especially when we need to perform partial - * checksum calculation due to padded bytes (non-zeroes) in the frame. - */ -uint_t -ip_md_cksum(pdesc_t *pd, int offset, uint_t sum) -{ - pdescinfo_t *pdi = &pd->pd_pdi; - uchar_t *reg_start, *reg_end; - ssize_t mlen, i; - ushort_t *w; - boolean_t byteleft = B_FALSE; - - ASSERT((pdi->flags & PDESC_HAS_REF) != 0); - ASSERT(pdi->hdr_rptr != NULL && pdi->hdr_wptr != NULL); - ASSERT(offset <= PDESC_HDRL(pdi)); - - for (i = 0; i < pdi->pld_cnt + 1; i++) { - if (i == 0) { - reg_start = pdi->hdr_rptr; - reg_end = pdi->hdr_wptr; - } else { - reg_start = pdi->pld_ary[i - 1].pld_rptr; - reg_end = pdi->pld_ary[i - 1].pld_wptr; - offset = 0; - } - - w = (ushort_t *)(reg_start + offset); - mlen = reg_end - (uchar_t *)w; - - if (mlen > 0 && byteleft) { - /* - * There is a byte left from the last - * segment; add it into the checksum. - * Don't have to worry about a carry- - * out here because we make sure that - * high part of (32 bit) sum is small - * below. - */ -#ifdef _LITTLE_ENDIAN - sum += *(uchar_t *)w << 8; -#else - sum += *(uchar_t *)w; -#endif - w = (ushort_t *)((char *)w + 1); - mlen--; - byteleft = B_FALSE; - } - - if (mlen == 0) - continue; - - if (is_even(w)) { - sum = ip_ocsum(w, mlen >> 1, sum); - w += mlen >> 1; - /* - * If we had an odd number of bytes, - * then the last byte goes in the high - * part of the sum, and we take the - * first byte to the low part of the sum - * the next time around the loop. - */ - if (is_odd(mlen)) { -#ifdef _LITTLE_ENDIAN - sum += *(uchar_t *)w; -#else - sum += *(uchar_t *)w << 8; -#endif - byteleft = B_TRUE; - } - } else { - ushort_t swsum; -#ifdef _LITTLE_ENDIAN - sum += *(uchar_t *)w; -#else - sum += *(uchar_t *)w << 8; -#endif - mlen--; - w = (ushort_t *)(1 + (uintptr_t)w); - - /* Do a separate checksum and copy operation */ - swsum = ip_ocsum(w, mlen >> 1, 0); - sum += ((swsum << 8) & 0xffff) | (swsum >> 8); - w += mlen >> 1; - /* - * If we had an even number of bytes, - * then the last byte goes in the low - * part of the sum. Otherwise we had an - * odd number of bytes and we take the first - * byte to the low part of the sum the - * next time around the loop. - */ - if (is_odd(mlen)) { -#ifdef _LITTLE_ENDIAN - sum += *(uchar_t *)w << 8; -#else - sum += *(uchar_t *)w; -#endif - } else { - byteleft = B_TRUE; - } - } - } - - /* - * Add together high and low parts of sum and carry to get cksum. - * Have to be careful to not drop the last carry here. - */ - sum = (sum & 0xffff) + (sum >> 16); - sum = (sum & 0xffff) + (sum >> 16); - - return (sum); -} - /* Return the IP checksum for the IP header at "iph". */ uint16_t ip_csum_hdr(ipha_t *ipha) diff --git a/usr/src/uts/common/os/strsubr.c b/usr/src/uts/common/os/strsubr.c index 796f89dca2..f2b91365d9 100644 --- a/usr/src/uts/common/os/strsubr.c +++ b/usr/src/uts/common/os/strsubr.c @@ -29,6 +29,7 @@ * Copyright 2018 Joyent, Inc. * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. * Copyright 2018 Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ #include <sys/types.h> @@ -74,7 +75,6 @@ #include <sys/sunldi_impl.h> #include <sys/strsun.h> #include <sys/isa_defs.h> -#include <sys/multidata.h> #include <sys/pattr.h> #include <sys/strft.h> #include <sys/fs/snode.h> @@ -8482,102 +8482,6 @@ mblk_copycred(mblk_t *mp, const mblk_t *src) dbp->db_cpid = cpid; } - -/* - * Now that NIC drivers are expected to deal only with M_DATA mblks, the - * hcksum_assoc and hcksum_retrieve functions are deprecated in favor of their - * respective mac_hcksum_set and mac_hcksum_get counterparts. - */ -int -hcksum_assoc(mblk_t *mp, multidata_t *mmd, pdesc_t *pd, - uint32_t start, uint32_t stuff, uint32_t end, uint32_t value, - uint32_t flags, int km_flags) -{ - int rc = 0; - - ASSERT(DB_TYPE(mp) == M_DATA || DB_TYPE(mp) == M_MULTIDATA); - if (mp->b_datap->db_type == M_DATA) { - /* Associate values for M_DATA type */ - DB_CKSUMSTART(mp) = (intptr_t)start; - DB_CKSUMSTUFF(mp) = (intptr_t)stuff; - DB_CKSUMEND(mp) = (intptr_t)end; - DB_CKSUMFLAGS(mp) = flags; - DB_CKSUM16(mp) = (uint16_t)value; - - } else { - pattrinfo_t pa_info; - - ASSERT(mmd != NULL); - - pa_info.type = PATTR_HCKSUM; - pa_info.len = sizeof (pattr_hcksum_t); - - if (mmd_addpattr(mmd, pd, &pa_info, B_TRUE, km_flags) != NULL) { - pattr_hcksum_t *hck = (pattr_hcksum_t *)pa_info.buf; - - hck->hcksum_start_offset = start; - hck->hcksum_stuff_offset = stuff; - hck->hcksum_end_offset = end; - hck->hcksum_cksum_val.inet_cksum = (uint16_t)value; - hck->hcksum_flags = flags; - } else { - rc = -1; - } - } - return (rc); -} - -void -hcksum_retrieve(mblk_t *mp, multidata_t *mmd, pdesc_t *pd, - uint32_t *start, uint32_t *stuff, uint32_t *end, - uint32_t *value, uint32_t *flags) -{ - ASSERT(DB_TYPE(mp) == M_DATA || DB_TYPE(mp) == M_MULTIDATA); - if (mp->b_datap->db_type == M_DATA) { - if (flags != NULL) { - *flags = DB_CKSUMFLAGS(mp) & HCK_FLAGS; - if ((*flags & (HCK_PARTIALCKSUM | - HCK_FULLCKSUM)) != 0) { - if (value != NULL) - *value = (uint32_t)DB_CKSUM16(mp); - if ((*flags & HCK_PARTIALCKSUM) != 0) { - if (start != NULL) - *start = - (uint32_t)DB_CKSUMSTART(mp); - if (stuff != NULL) - *stuff = - (uint32_t)DB_CKSUMSTUFF(mp); - if (end != NULL) - *end = - (uint32_t)DB_CKSUMEND(mp); - } - } - } - } else { - pattrinfo_t hck_attr = {PATTR_HCKSUM}; - - ASSERT(mmd != NULL); - - /* get hardware checksum attribute */ - if (mmd_getpattr(mmd, pd, &hck_attr) != NULL) { - pattr_hcksum_t *hck = (pattr_hcksum_t *)hck_attr.buf; - - ASSERT(hck_attr.len >= sizeof (pattr_hcksum_t)); - if (flags != NULL) - *flags = hck->hcksum_flags; - if (start != NULL) - *start = hck->hcksum_start_offset; - if (stuff != NULL) - *stuff = hck->hcksum_stuff_offset; - if (end != NULL) - *end = hck->hcksum_end_offset; - if (value != NULL) - *value = (uint32_t) - hck->hcksum_cksum_val.inet_cksum; - } - } -} - void lso_info_set(mblk_t *mp, uint32_t mss, uint32_t flags) { @@ -8659,23 +8563,6 @@ bcksum(uchar_t *bp, int len, unsigned int psum) return ((psum >> 16) + (psum & 0xFFFF)); } -boolean_t -is_vmloaned_mblk(mblk_t *mp, multidata_t *mmd, pdesc_t *pd) -{ - boolean_t rc; - - ASSERT(DB_TYPE(mp) == M_DATA || DB_TYPE(mp) == M_MULTIDATA); - if (DB_TYPE(mp) == M_DATA) { - rc = (((mp)->b_datap->db_struioflag & STRUIO_ZC) != 0); - } else { - pattrinfo_t zcopy_attr = {PATTR_ZCOPY}; - - ASSERT(mmd != NULL); - rc = (mmd_getpattr(mmd, pd, &zcopy_attr) != NULL); - } - return (rc); -} - void freemsgchain(mblk_t *mp) { diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index 8e1dcbe57c..96c0fba77f 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -413,8 +413,6 @@ CHKHDRS= \ msio.h \ msreg.h \ mtio.h \ - multidata.h \ - multidata_impl.h \ mutex.h \ nbmlock.h \ ndifm.h \ diff --git a/usr/src/uts/common/sys/dlpi.h b/usr/src/uts/common/sys/dlpi.h index f3a5fd6f70..e71a55ab84 100644 --- a/usr/src/uts/common/sys/dlpi.h +++ b/usr/src/uts/common/sys/dlpi.h @@ -21,6 +21,7 @@ /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2018 Joyent, Inc. + * Copyright 2022 Garrett D'Amore */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -598,8 +599,7 @@ union DL_qos_types { /* dl_data is dl_capab_id_t */ #define DL_CAPAB_HCKSUM 0x01 /* Checksum offload */ /* dl_data is dl_capab_hcksum_t */ -#define DL_CAPAB_MDT 0x04 /* Multidata Transmit capability */ - /* dl_data is dl_capab_mdt_t */ +#define DL_CAPAB_MDT 0x04 /* OBSOLETE, DO NOT USE */ #define DL_CAPAB_ZEROCOPY 0x05 /* Zero-copy capability */ /* dl_data is dl_capab_zerocopy_t */ #define DL_CAPAB_DLD 0x06 /* dld capability */ @@ -631,30 +631,6 @@ typedef struct { } dl_capab_id_t; /* - * Multidata Transmit sub-capability (follows dl_capability_sub_t) - */ -typedef struct { - t_uscalar_t mdt_version; /* interface version */ - t_uscalar_t mdt_flags; /* flags */ - t_uscalar_t mdt_hdr_head; /* minimum leading header space */ - t_uscalar_t mdt_hdr_tail; /* minimum trailing header space */ - t_uscalar_t mdt_max_pld; /* maximum doable payload buffers */ - t_uscalar_t mdt_span_limit; /* scatter-gather descriptor limit */ - dl_mid_t mdt_mid; /* module ID token */ -} dl_capab_mdt_t; - -/* - * Multidata Transmit revision definition history - */ -#define MDT_CURRENT_VERSION 0x02 -#define MDT_VERSION_2 0x02 - -/* - * mdt_flags values - */ -#define DL_CAPAB_MDT_ENABLE 0x01 /* enable Multidata Transmit */ - -/* * DL_CAPAB_HCKSUM * Used for negotiating different flavors of checksum offload * capabilities. diff --git a/usr/src/uts/common/sys/gld.h b/usr/src/uts/common/sys/gld.h index fd7b8d37d2..59dced7237 100644 --- a/usr/src/uts/common/sys/gld.h +++ b/usr/src/uts/common/sys/gld.h @@ -21,6 +21,8 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore */ /* @@ -30,8 +32,6 @@ #ifndef _SYS_GLD_H #define _SYS_GLD_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/ethernet.h> #ifdef __cplusplus @@ -191,7 +191,7 @@ typedef struct gld_mac_info { unsigned char reserved9[ETHERADDRL]; /* GLD PRIVATE */ t_uscalar_t gldm_ppa; /* SET BY DRIVER */ int32_t reserved10; /* GLD PRIVATE */ - uint32_t gldm_capabilities; /* SET BY DRIVER */ + uint32_t gldm_capabilities; /* SET BY DRIVER */ int32_t gldm_linkstate; /* GLD PRIVATE */ uint32_t reserved11; /* GLD PRIVATE */ caddr_t reserved12; /* GLD PRIVATE */ @@ -211,19 +211,10 @@ typedef struct gld_mac_info { int (*gldm_set_promiscuous)(); /* SET BY DRIVER */ int (*gldm_get_stats)(); /* SET BY DRIVER */ int (*gldm_ioctl)(); /* SET BY DRIVER */ - int (*gldm_set_multicast)(); /* SET BY DRIVER */ + int (*gldm_set_multicast)(); /* SET BY DRIVER */ uint_t (*gldm_intr)(); /* SET BY DRIVER */ int (*gldm_mctl)(); /* SET BY DRIVER */ int (*gldm_send_tagged)(); /* SET BY DRIVER */ - /* - * The following MDT related entry points are Sun private, - * meant only for use by Sun's IPoIB (ibd) driver. - */ - int (*gldm_mdt_pre)(); /* SET BY DRIVER */ - void (*gldm_mdt_send)(); /* SET BY DRIVER */ - void (*gldm_mdt_post)(); /* SET BY DRIVER */ - int gldm_mdt_sgl; /* SET BY DRIVER */ - int gldm_mdt_segs; /* SET BY DRIVER */ } gld_mac_info_t; /* flags for physical promiscuous state */ diff --git a/usr/src/uts/common/sys/gldpriv.h b/usr/src/uts/common/sys/gldpriv.h index cbbb872232..263bdd88ed 100644 --- a/usr/src/uts/common/sys/gldpriv.h +++ b/usr/src/uts/common/sys/gldpriv.h @@ -21,6 +21,8 @@ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore */ /* @@ -33,8 +35,6 @@ #ifndef _SYS_GLDPRIV_H #define _SYS_GLDPRIV_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -58,7 +58,6 @@ extern "C" { /* gld per instance options */ #define GLDOPT_FAST_RECV 0x40 #define GLDOPT_CANONICAL_ADDR 0x08 -#define GLDOPT_MDT 0x100 /* * This version of GLD allows a "Virtual-LAN-PPA" to be specified in @@ -226,20 +225,10 @@ typedef enum packet_flag { } packet_flag_t; /* - * Flags input to the gld_interpret_mdt_*() interpreter routines. - */ -typedef enum mdt_packet_flag { - GLD_MDT_TX, - GLD_MDT_TXPKT, - GLD_MDT_RXLOOP -} mdt_packet_flag_t; - -/* * Describes characteristics of the Media Access Layer. * The mac_type is one of the supported DLPI media types (see <sys/dlpi.h>). * The mtu_size is the size of the largest frame. * The interpreter is the function that "knows" how to interpret the frame. - * The interpreter_mdt routine knows how to interpret/format MDT packets. * Other routines create and/or add headers to packets. */ typedef struct { @@ -248,8 +237,6 @@ typedef struct { int hdr_size; int (*interpreter)(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); - void (*interpreter_mdt)(gld_mac_info_t *, mblk_t *, - struct pdescinfo_s *, pktinfo_t *, mdt_packet_flag_t); mblk_t *(*mkfastpath)(gld_t *, mblk_t *); mblk_t *(*mkunitdata)(gld_t *, mblk_t *); void (*init)(gld_mac_info_t *); @@ -628,8 +615,6 @@ int gld_interpret_ether(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); int gld_interpret_fddi(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); int gld_interpret_tr(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); int gld_interpret_ib(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); -void gld_interpret_mdt_ib(gld_mac_info_t *, mblk_t *, pdescinfo_t *, - pktinfo_t *, mdt_packet_flag_t); mblk_t *gld_fastpath_ether(gld_t *, mblk_t *); mblk_t *gld_fastpath_fddi(gld_t *, mblk_t *); diff --git a/usr/src/uts/common/sys/multidata.h b/usr/src/uts/common/sys/multidata.h deleted file mode 100644 index f649b187bc..0000000000 --- a/usr/src/uts/common/sys/multidata.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -#ifndef _SYS_MULTIDATA_H -#define _SYS_MULTIDATA_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Multidata interface declarations. - * These interfaces are still evolving; do not use them in unbundled drivers. - */ - -/* - * Multidata packet attribute information. - */ -typedef struct pattrinfo_s { - uint_t type; /* attribute type value */ - uint_t len; /* attribute length */ - void *buf; /* pointer to user data area */ -} pattrinfo_t; - -/* - * Maximum number of payload areas for a single packet descriptor. - */ -#define MULTIDATA_MAX_PBUFS 16 - -/* - * Multidata buffer information. - */ -typedef struct mbufinfo_s { - uchar_t *hbuf_rptr; /* start address of header buffer */ - uchar_t *hbuf_wptr; /* end address of header buffer */ - uint_t pbuf_cnt; /* number of payload buffer */ - struct pbuf_ary_s { - uchar_t *pbuf_rptr; /* start address of payload buffer */ - uchar_t *pbuf_wptr; /* end address of payload buffer */ - } pbuf_ary[MULTIDATA_MAX_PBUFS]; -} mbufinfo_t; - -/* - * Multidata packet descriptor information. - */ -struct pld_ary_s { - int pld_pbuf_idx; /* payload buffer index */ - uchar_t *pld_rptr; /* start address of payload data */ - uchar_t *pld_wptr; /* pointer to end of payload data */ -}; - -#define PDESCINFO_STRUCT(elems) \ -{ \ - uint_t flags; /* misc. flags */ \ - uchar_t *hdr_base; /* start address of header area */ \ - uchar_t *hdr_rptr; /* start address of header data */ \ - uchar_t *hdr_wptr; /* end address of header data */ \ - uchar_t *hdr_lim; /* end address of header area */ \ - uint_t pld_cnt; /* number of payload area */ \ - struct pld_ary_s pld_ary[(elems)]; \ -} - -typedef struct pdescinfo_s PDESCINFO_STRUCT(MULTIDATA_MAX_PBUFS) pdescinfo_t; - -/* - * Possible values for flags - */ -#define PDESC_HBUF_REF 0x1 /* descriptor uses header buffer */ -#define PDESC_PBUF_REF 0x2 /* descriptor uses payload buffer(s) */ - -#define PDESC_HDRSIZE(p) ((p)->hdr_lim - (p)->hdr_base) -#define PDESC_HDRL(p) ((p)->hdr_wptr - (p)->hdr_rptr) -#define PDESC_HDRHEAD(p) ((p)->hdr_rptr - (p)->hdr_base) -#define PDESC_HDRTAIL(p) ((p)->hdr_lim - (p)->hdr_wptr) - -#define PDESC_HDR_ADD(p, base, head, len, tail) { \ - (p)->hdr_base = (base); \ - (p)->hdr_rptr = (base) + (head); \ - (p)->hdr_wptr = (p)->hdr_rptr + (len); \ - (p)->hdr_lim = (p)->hdr_wptr + (tail); \ -} - -#define PDESC_PLD_INIT(p) ((p)->pld_cnt = 0) - -#define PDESC_PLD_SPAN_SIZE(p, n) \ - ((p)->pld_ary[(n)].pld_wptr - (p)->pld_ary[(n)].pld_rptr) - -#define PDESC_PLDL(p, n) PDESC_PLD_SPAN_SIZE(p, n) - -#define PDESC_PLD_SPAN_TRIM(p, n, b) { \ - ((p)->pld_ary[(n)].pld_wptr -= (b)); \ - ASSERT((p)->pld_ary[(n)].pld_wptr >= (p)->pld_ary[(n)].pld_rptr); \ -} - -#define PDESC_PLD_SPAN_CLEAR(p, n) \ - PDESC_PLD_SPAN_TRIM(p, n, PDESC_PLD_SPAN_SIZE(p, n)) - -#define PDESC_PLD_SPAN_ADD(p, pbuf_idx, rptr, len) { \ - ASSERT((p)->pld_cnt < MULTIDATA_MAX_PBUFS); \ - (p)->pld_ary[(p)->pld_cnt].pld_pbuf_idx = (pbuf_idx); \ - (p)->pld_ary[(p)->pld_cnt].pld_rptr = (rptr); \ - (p)->pld_ary[(p)->pld_cnt].pld_wptr = (rptr) + (len); \ - (p)->pld_cnt++; \ -} - -/* - * These structures are opaque to multidata clients. - */ -struct pdesc_s; -typedef struct pdesc_s pdesc_t; - -struct pattr_s; -typedef struct pattr_s pattr_t; - -struct multidata_s; -typedef struct multidata_s multidata_t; - -#ifdef _KERNEL - -extern multidata_t *mmd_alloc(mblk_t *, mblk_t **, int); -extern int mmd_addpldbuf(multidata_t *, mblk_t *); -extern multidata_t *mmd_getmultidata(mblk_t *); -extern void mmd_getregions(multidata_t *, mbufinfo_t *); -extern uint_t mmd_getcnt(multidata_t *, uint_t *, uint_t *); -extern pdesc_t *mmd_addpdesc(multidata_t *, pdescinfo_t *, int *, int); -extern void mmd_rempdesc(pdesc_t *); -extern pdesc_t *mmd_getfirstpdesc(multidata_t *, pdescinfo_t *); -extern pdesc_t *mmd_getlastpdesc(multidata_t *, pdescinfo_t *); -extern pdesc_t *mmd_getnextpdesc(pdesc_t *, pdescinfo_t *); -extern pdesc_t *mmd_getprevpdesc(pdesc_t *, pdescinfo_t *); -extern pdesc_t *mmd_adjpdesc(pdesc_t *, pdescinfo_t *); -extern mblk_t *mmd_transform(pdesc_t *); -extern mblk_t *mmd_transform_link(pdesc_t *); -extern int mmd_dupbufs(multidata_t *, mblk_t **, mblk_t **); -extern int mmd_getpdescinfo(pdesc_t *, pdescinfo_t *); -extern pattr_t *mmd_addpattr(multidata_t *, pdesc_t *, pattrinfo_t *, - boolean_t, int); -extern void mmd_rempattr(pattr_t *); -extern pattr_t *mmd_getpattr(multidata_t *, pdesc_t *, pattrinfo_t *); -extern void mmd_getsize(multidata_t *, uint_t *, uint_t *); - -#endif /* _KERNEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_MULTIDATA_H */ diff --git a/usr/src/uts/common/sys/multidata_impl.h b/usr/src/uts/common/sys/multidata_impl.h deleted file mode 100644 index 05589c6f03..0000000000 --- a/usr/src/uts/common/sys/multidata_impl.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -#ifndef _SYS_MULTIDATA_IMPL_H -#define _SYS_MULTIDATA_IMPL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Multidata: implementation-private data structure and declarations. - */ - -/* - * Structure used for insque/remque circular list operations. - */ -typedef struct ql_s { - struct ql_s *ql_next; /* pointer to next list element */ - struct ql_s *ql_prev; /* pointer to previous list element */ -} ql_t; - -#define QL_INIT(q) { \ - ((ql_t *)(q))->ql_next = (ql_t *)(q); \ - ((ql_t *)(q))->ql_prev = (ql_t *)(q); \ -} - -typedef struct pdesc_slab_s pdesc_slab_t; - -/* - * Attribute hash bucket structure. - */ -typedef struct patbkt_s { - kmutex_t pbkt_lock; /* per-bucket lock */ - ql_t pbkt_pattr_q; /* list of attributes */ - uint_t pbkt_tbl_sz; /* table size (if this is first bucket) */ -} patbkt_t; - -/* - * Attribute structure. - */ -#define PATTR_MAGIC 0x50615472 /* "PaTr" */ - -struct pattr_s { - pattr_t *pat_next; /* pointer to next attribute in bucket */ - pattr_t *pat_prev; /* pointer to previous attribute in bucket */ - - uint_t pat_magic; /* set to PATTR_MAGIC */ - - kmutex_t *pat_lock; /* pointer to per-bucket lock */ - multidata_t *pat_mmd; /* back pointer to Multidata */ - uint_t pat_buflen; /* length of this structure + attribute */ - uint_t pat_type; /* type of encapsulated attribute */ - uint_t pat_flags; /* misc. flags */ -}; - -/* - * Values for pat_flags. - */ -#define PATTR_REM_DEFER 0x1 /* entry is marked unusable but still exists */ -#define PATTR_PERSIST 0x2 /* entry can't be removed */ - -#define Q2PATTR(p) \ - ((pattr_t *)((caddr_t)(p) - offsetof(pattr_t, pat_next))) - -/* - * Packet descriptor structure. - */ -#define PDESC_MAGIC 0x506b5464 /* "PkTd" */ - -struct pdesc_s { - pdesc_t *pd_next; /* pointer to next descriptor */ - pdesc_t *pd_prev; /* pointer to previous descriptor */ - - uint_t pd_magic; /* set to PDESC_MAGIC */ - - pdesc_slab_t *pd_slab; /* back pointer to descriptor slab */ - patbkt_t *pd_pattbl; /* hash table of local attributes */ - - pdescinfo_t pd_pdi; /* embedded descriptor info structure */ - -#define pd_flags pd_pdi.flags -}; - -/* - * Additional internal flags for pd_flags (see multidata.h for the rest). - */ -#define PDESC_REM_DEFER 0x1000 /* entry is marked unusable but still exists */ -#define PDESC_HAS_REF (PDESC_HBUF_REF | PDESC_PBUF_REF) - -#define Q2PD(p) \ - ((pdesc_t *)((caddr_t)(p) - offsetof(pdesc_t, pd_next))) - -#define PDI_COPY(pd_src, pd_dst) { \ - (pd_dst)->flags = (pd_src)->flags & PDESC_HAS_REF; \ - if ((pd_dst)->flags & PDESC_HBUF_REF) { \ - (pd_dst)->hdr_base = (pd_src)->hdr_base; \ - (pd_dst)->hdr_rptr = (pd_src)->hdr_rptr; \ - (pd_dst)->hdr_wptr = (pd_src)->hdr_wptr; \ - (pd_dst)->hdr_lim = (pd_src)->hdr_lim; \ - } else { \ - (pd_dst)->hdr_base = NULL; \ - (pd_dst)->hdr_rptr = NULL; \ - (pd_dst)->hdr_wptr = NULL; \ - (pd_dst)->hdr_lim = NULL; \ - } \ - \ - if ((pd_dst)->flags & PDESC_PBUF_REF) { \ - int i; \ - \ - (pd_dst)->pld_cnt = (pd_src)->pld_cnt; \ - for (i = 0; i < (pd_dst)->pld_cnt; i++) { \ - (pd_dst)->pld_ary[i].pld_pbuf_idx = \ - (pd_src)->pld_ary[i].pld_pbuf_idx; \ - (pd_dst)->pld_ary[i].pld_rptr = \ - (pd_src)->pld_ary[i].pld_rptr; \ - (pd_dst)->pld_ary[i].pld_wptr = \ - (pd_src)->pld_ary[i].pld_wptr; \ - } \ - } else { \ - (pd_dst)->pld_cnt = 0; \ - } \ -} - -/* - * Packet descriptor slab structure. - */ -struct pdesc_slab_s { - pdesc_slab_t *pds_next; /* pointer to next descriptor slab */ - pdesc_slab_t *pds_prev; /* pointer to previous descriptor slab */ - - multidata_t *pds_mmd; /* back pointer to Multidata */ - uint_t pds_used; /* always-increasing index to array */ - uint_t pds_sz; /* size of descriptor array */ - - pdesc_t pds_free_desc[1]; /* array of available descriptors */ -}; - -#define Q2PDSLAB(p) \ - ((pdesc_slab_t *)((caddr_t)(p) - offsetof(pdesc_slab_t, pds_next))) - -#define PDESC_SLAB_SIZE(npd) \ - ((size_t)(&((pdesc_slab_t *)0)->pds_free_desc[npd])) - -/* - * Multidata metadata structure. - */ -#define MULTIDATA_MAGIC 0x4d645461 /* "MdTa" */ - -struct multidata_s { - uint_t mmd_magic; /* set to MULTIDATA_MAGIC */ - - dblk_t *mmd_dp; /* back pointer to wrapper dblk structure */ - mblk_t *mmd_hbuf; /* pointer to header buffer mblk */ - - patbkt_t *mmd_pattbl; /* hash table of global attributes */ - - kmutex_t mmd_pd_slab_lock; /* lock to protect the following items */ - uint_t mmd_pbuf_cnt; /* number of data buffer */ - mblk_t *mmd_pbuf[MULTIDATA_MAX_PBUFS]; /* data buffer mblk(s) */ - ql_t mmd_pd_slab_q; /* list of packet descriptor slabs */ - ql_t mmd_pd_q; /* list of packet descriptors */ - uint_t mmd_slab_cnt; /* number of packet descriptor slabs */ - uint_t mmd_pd_cnt; /* number of in-use packet desciptors */ - uint_t mmd_hbuf_ref; /* descriptors referring to header buffer */ - uint_t mmd_pbuf_ref; /* descriptors referring to payload buffer(s) */ -}; - -#ifdef _KERNEL - -extern void mmd_init(void); -extern mblk_t *mmd_copy(mblk_t *, int); - -#endif /* _KERNEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_MULTIDATA_IMPL_H */ diff --git a/usr/src/uts/common/sys/softmac_impl.h b/usr/src/uts/common/sys/softmac_impl.h index 00c37d3422..8bfd5c6322 100644 --- a/usr/src/uts/common/sys/softmac_impl.h +++ b/usr/src/uts/common/sys/softmac_impl.h @@ -21,6 +21,8 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore */ #ifndef _SYS_SOFTMAC_IMPL_H @@ -183,8 +185,6 @@ typedef struct softmac { uint32_t smac_capab_flags; uint32_t smac_hcksum_txflags; boolean_t smac_no_capability_req; - dl_capab_mdt_t smac_mdt_capab; - boolean_t smac_mdt; /* * Lower stream structure, accessed by the MAC provider API. The GLDv3 diff --git a/usr/src/uts/common/sys/stream.h b/usr/src/uts/common/sys/stream.h index 38361695ab..7d118b09e8 100644 --- a/usr/src/uts/common/sys/stream.h +++ b/usr/src/uts/common/sys/stream.h @@ -24,6 +24,7 @@ * Copyright 2015 Joyent, Inc. All rights reserved. * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -445,7 +446,7 @@ typedef struct bcache { */ #define M_DATA 0x00 /* regular data */ #define M_PROTO 0x01 /* protocol control */ -#define M_MULTIDATA 0x02 /* reserved for Multidata use only */ +#define M_MULTIDATA 0x02 /* obsolete, do not use */ /* * Control messages (regular and priority) @@ -745,7 +746,6 @@ typedef struct cmdblk { */ #define datamsg(type) \ ((type) == M_DATA || \ - (type) == M_MULTIDATA || \ (type) == M_PROTO || \ (type) == M_PCPROTO || \ (type) == M_DELAY) diff --git a/usr/src/uts/common/sys/strsubr.h b/usr/src/uts/common/sys/strsubr.h index 14e17c1c0c..a552e3938e 100644 --- a/usr/src/uts/common/sys/strsubr.h +++ b/usr/src/uts/common/sys/strsubr.h @@ -30,6 +30,7 @@ /* * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Garrett D'Amore */ #ifndef _SYS_STRSUBR_H @@ -1256,21 +1257,9 @@ extern void strsignal_nolock(stdata_t *, int, uchar_t); struct multidata_s; struct pdesc_s; -/* - * Now that NIC drivers are expected to deal only with M_DATA mblks, the - * hcksum_assoc and hcksum_retrieve functions are deprecated in favor of their - * respective mac_hcksum_set and mac_hcksum_get counterparts. - */ -extern int hcksum_assoc(mblk_t *, struct multidata_s *, struct pdesc_s *, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int); -extern void hcksum_retrieve(mblk_t *, struct multidata_s *, struct pdesc_s *, - uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *); - extern void lso_info_set(mblk_t *, uint32_t, uint32_t); extern void lso_info_cleanup(mblk_t *); extern unsigned int bcksum(uchar_t *, int, unsigned int); -extern boolean_t is_vmloaned_mblk(mblk_t *, struct multidata_s *, - struct pdesc_s *); extern int fmodsw_register(const char *, struct streamtab *, int); extern int fmodsw_unregister(const char *); |