diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-12-16 13:53:29 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-12-16 13:53:29 +0000 |
| commit | ccdbde2d1a0b7ea394250166cb0c2899252fd21e (patch) | |
| tree | 5889c4cbe28d32c4bd6504369985ee6235b16d35 /usr/src | |
| parent | ef0c70910b8d8d5e35f7ce69df9280f494169834 (diff) | |
| parent | 2b1b28a876929b1115c4fb169d5af92fbf4ae607 (diff) | |
| download | illumos-joyent-ccdbde2d1a0b7ea394250166cb0c2899252fd21e.tar.gz | |
[illumos-gate merge]
commit 2b1b28a876929b1115c4fb169d5af92fbf4ae607
12059 libtopo: add API for doing deep copy of a topo_list
commit 07de4b8b08600eb9a66746ea6cc4a9fbc7981e4f
10152 bge debugging always on
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/mapfile-vers | 1 | ||||
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/topo_list.c | 45 | ||||
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/topo_list.h | 7 | ||||
| -rw-r--r-- | usr/src/uts/common/io/bge/bge_impl.h | 16 |
4 files changed, 57 insertions, 12 deletions
diff --git a/usr/src/lib/fm/topo/libtopo/common/mapfile-vers b/usr/src/lib/fm/topo/libtopo/common/mapfile-vers index 76c7f15f85..290b5af43c 100644 --- a/usr/src/lib/fm/topo/libtopo/common/mapfile-vers +++ b/usr/src/lib/fm/topo/libtopo/common/mapfile-vers @@ -83,6 +83,7 @@ SYMBOL_VERSION SUNWprivate { topo_led_state_name; topo_led_type_name; topo_list_append; + topo_list_deepcopy; topo_list_delete; topo_method_invoke; topo_method_register; diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_list.c b/usr/src/lib/fm/topo/libtopo/common/topo_list.c index 6e87d3b5d2..2ec1200af7 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_list.c +++ b/usr/src/lib/fm/topo/libtopo/common/topo_list.c @@ -23,12 +23,15 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2019 Joyent, Inc. + */ -#pragma ident "%Z%%M% %I% %E% SMI" - +#include <string.h> #include <unistd.h> #include <assert.h> +#include <topo_error.h> #include <topo_list.h> #include <topo_tree.h> @@ -183,3 +186,41 @@ topo_child_next(tnode_t *pnode, tnode_t *node) return (NULL); } + +int +topo_list_deepcopy(topo_hdl_t *thp, topo_list_t *dest, topo_list_t *src, + size_t elem_sz) +{ + void *elem; + + /* if the destination list is not empty - bail out */ + if (topo_list_next(dest) != NULL) + return (topo_hdl_seterrno(thp, ETOPO_UNKNOWN)); + + for (elem = topo_list_next(src); elem != NULL; + elem = topo_list_next(elem)) { + void *elem_copy; + + if ((elem_copy = topo_hdl_alloc(thp, elem_sz)) == NULL) { + goto err; + } + (void) memcpy(elem_copy, elem, elem_sz); + topo_list_append(dest, elem_copy); + } + return (0); + +err: + /* + * If we hit an error, cleanup any partially copied list elements + * before we return. + */ + elem = topo_list_next(dest); + while (elem != NULL) { + void *tmp = elem; + + elem = topo_list_next(elem); + topo_list_delete(dest, tmp); + topo_hdl_free(thp, tmp, elem_sz); + } + return (topo_hdl_seterrno(thp, ETOPO_NOMEM)); +} diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_list.h b/usr/src/lib/fm/topo/libtopo/common/topo_list.h index e85b1035ff..854d6e060c 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_list.h +++ b/usr/src/lib/fm/topo/libtopo/common/topo_list.h @@ -22,12 +22,13 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2019 Joyent, Inc. + */ #ifndef _TOPO_LIST_H #define _TOPO_LIST_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <fm/libtopo.h> #ifdef __cplusplus @@ -42,6 +43,8 @@ extern void topo_list_prepend(topo_list_t *, void *); extern void topo_list_insert_before(topo_list_t *, void *, void *); extern void topo_list_insert_after(topo_list_t *, void *, void *); extern void topo_list_delete(topo_list_t *, void *); +extern int topo_list_deepcopy(topo_hdl_t *, topo_list_t *, topo_list_t *, + size_t); /* Helpers for child/sibling lists */ extern tnode_t *topo_child_first(tnode_t *); diff --git a/usr/src/uts/common/io/bge/bge_impl.h b/usr/src/uts/common/io/bge/bge_impl.h index ccc57b94e7..848f039359 100644 --- a/usr/src/uts/common/io/bge/bge_impl.h +++ b/usr/src/uts/common/io/bge/bge_impl.h @@ -111,7 +111,7 @@ typedef uchar_t ether_addr_t[ETHERADDRL]; */ extern int secpolicy_net_config(const cred_t *, boolean_t); -#include <sys/miiregs.h> /* by fjlite out of intel */ +#include <sys/miiregs.h> /* by fjlite out of intel */ #include "bge.h" #include "bge_hw.h" @@ -409,7 +409,7 @@ typedef struct buff_ring { uint64_t rf_next; /* next slot to refill */ /* ("producer index") */ - sw_rbd_t *sw_rbds; /* software descriptors */ + sw_rbd_t *sw_rbds; /* software descriptors */ void *spare[4]; /* padding */ } buff_ring_t; /* 0x100 (256) bytes */ @@ -558,7 +558,7 @@ typedef struct send_ring { uint64_t tc_next; /* next slot to recycle */ /* ("consumer index") */ - sw_sbd_t *sw_sbds; /* software descriptors */ + sw_sbd_t *sw_sbds; /* software descriptors */ uint64_t mac_resid; /* special per resource id */ uint64_t pushed_bytes; } send_ring_t; /* 0x100 (256) bytes */ @@ -757,7 +757,7 @@ typedef struct bge { ddi_softintr_t factotum_id; /* factotum callback */ ddi_softintr_t drain_id; /* reschedule callback */ - ddi_intr_handle_t *htable; /* For array of interrupts */ + ddi_intr_handle_t *htable; /* For array of interrupts */ int intr_type; /* What type of interrupt */ int intr_cnt; /* # of intrs count returned */ uint_t intr_pri; /* Interrupt priority */ @@ -826,7 +826,7 @@ typedef struct bge { * protects the critical cyclic counters etc. * * Each send ring contains two locks: <tx_lock> for the send-path - * protocol data and <tc_lock> for send-buffer recycling. + * protocol data and <tc_lock> for send-buffer recycling. * * Finally <genlock> is a general lock, protecting most other * operational data in the state structure and chip register @@ -983,7 +983,7 @@ typedef struct bge { uint32_t param_loop_mode; uint32_t param_msi_cnt; - uint32_t param_drain_max; + uint32_t param_drain_max; uint64_t param_link_speed; link_duplex_t param_link_duplex; uint32_t eee_lpi_wait; @@ -1097,7 +1097,7 @@ typedef struct bge { #ifdef DEBUG #define BGE_DEBUGGING 1 #else -#define BGE_DEBUGGING 1 +#define BGE_DEBUGGING 0 #endif /* DEBUG */ @@ -1119,7 +1119,7 @@ typedef struct bge { { command; } \ _NOTE(CONSTANTCONDITION) \ } while (0) -#else /* BGE_DEBUGGING */ +#else /* BGE_DEBUGGING */ #define BGE_DDB(command) do { \ { _NOTE(EMPTY); } \ _NOTE(CONSTANTCONDITION) \ |
