Print this page
5255 uts shouldn't open-code ISP2


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 

  26 #include <sys/ib/clients/rds/rds.h>
  27 #include <sys/ib/clients/rds/rds_kstat.h>
  28 
  29 #include <inet/ipclassifier.h>
  30 
  31 struct rds_kstat_s rds_kstat = {
  32         {"rds_nports",                  KSTAT_DATA_ULONG},
  33         {"rds_nsessions",               KSTAT_DATA_ULONG},
  34         {"rds_tx_bytes",                KSTAT_DATA_ULONG},
  35         {"rds_tx_pkts",                 KSTAT_DATA_ULONG},
  36         {"rds_tx_errors",               KSTAT_DATA_ULONG},
  37         {"rds_rx_bytes",                KSTAT_DATA_ULONG},
  38         {"rds_rx_pkts",                 KSTAT_DATA_ULONG},
  39         {"rds_rx_pkts_pending",         KSTAT_DATA_ULONG},
  40         {"rds_rx_errors",               KSTAT_DATA_ULONG},
  41         {"rds_tx_acks",                 KSTAT_DATA_ULONG},
  42         {"rds_post_recv_buf_called",    KSTAT_DATA_ULONG},
  43         {"rds_stalls_triggered",        KSTAT_DATA_ULONG},
  44         {"rds_stalls_sent",             KSTAT_DATA_ULONG},
  45         {"rds_unstalls_triggered",      KSTAT_DATA_ULONG},


 132         /*
 133          * kstats
 134          */
 135         rds_kstatsp = kstat_create("rds", 0,
 136             "rds_kstat", "misc", KSTAT_TYPE_NAMED,
 137             sizeof (rds_kstat) / sizeof (kstat_named_t),
 138             KSTAT_FLAG_VIRTUAL | KSTAT_FLAG_WRITABLE);
 139         if (rds_kstatsp != NULL) {
 140                 rds_kstatsp->ks_lock = &rds_kstat_mutex;
 141                 rds_kstatsp->ks_data = (void *)&rds_kstat;
 142                 kstat_install(rds_kstatsp);
 143         }
 144 }
 145 
 146 #define UINT_32_BITS 31
 147 void
 148 rds_hash_init()
 149 {
 150         int i;
 151 
 152         if (rds_bind_fanout_size & (rds_bind_fanout_size - 1)) {
 153                 /* Not a power of two. Round up to nearest power of two */
 154                 for (i = 0; i < UINT_32_BITS; i++) {
 155                         if (rds_bind_fanout_size < (1 << i))
 156                                 break;
 157                 }
 158                 rds_bind_fanout_size = 1 << i;
 159         }
 160         rds_bind_fanout = kmem_zalloc(rds_bind_fanout_size *
 161             sizeof (rds_bf_t), KM_SLEEP);
 162         for (i = 0; i < rds_bind_fanout_size; i++) {
 163                 mutex_init(&rds_bind_fanout[i].rds_bf_lock, NULL, MUTEX_DEFAULT,
 164                     NULL);
 165         }
 166 }
 167 
 168 void
 169 rds_free(rds_t *rds)
 170 {
 171         ASSERT(rds->rds_refcnt == 0);
 172         ASSERT(MUTEX_HELD(&rds->rds_lock));




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <sys/sysmacros.h>
  27 #include <sys/ib/clients/rds/rds.h>
  28 #include <sys/ib/clients/rds/rds_kstat.h>
  29 
  30 #include <inet/ipclassifier.h>
  31 
  32 struct rds_kstat_s rds_kstat = {
  33         {"rds_nports",                  KSTAT_DATA_ULONG},
  34         {"rds_nsessions",               KSTAT_DATA_ULONG},
  35         {"rds_tx_bytes",                KSTAT_DATA_ULONG},
  36         {"rds_tx_pkts",                 KSTAT_DATA_ULONG},
  37         {"rds_tx_errors",               KSTAT_DATA_ULONG},
  38         {"rds_rx_bytes",                KSTAT_DATA_ULONG},
  39         {"rds_rx_pkts",                 KSTAT_DATA_ULONG},
  40         {"rds_rx_pkts_pending",         KSTAT_DATA_ULONG},
  41         {"rds_rx_errors",               KSTAT_DATA_ULONG},
  42         {"rds_tx_acks",                 KSTAT_DATA_ULONG},
  43         {"rds_post_recv_buf_called",    KSTAT_DATA_ULONG},
  44         {"rds_stalls_triggered",        KSTAT_DATA_ULONG},
  45         {"rds_stalls_sent",             KSTAT_DATA_ULONG},
  46         {"rds_unstalls_triggered",      KSTAT_DATA_ULONG},


 133         /*
 134          * kstats
 135          */
 136         rds_kstatsp = kstat_create("rds", 0,
 137             "rds_kstat", "misc", KSTAT_TYPE_NAMED,
 138             sizeof (rds_kstat) / sizeof (kstat_named_t),
 139             KSTAT_FLAG_VIRTUAL | KSTAT_FLAG_WRITABLE);
 140         if (rds_kstatsp != NULL) {
 141                 rds_kstatsp->ks_lock = &rds_kstat_mutex;
 142                 rds_kstatsp->ks_data = (void *)&rds_kstat;
 143                 kstat_install(rds_kstatsp);
 144         }
 145 }
 146 
 147 #define UINT_32_BITS 31
 148 void
 149 rds_hash_init()
 150 {
 151         int i;
 152 
 153         if (!ISP2(rds_bind_fanout_size)) {
 154                 /* Not a power of two. Round up to nearest power of two */
 155                 for (i = 0; i < UINT_32_BITS; i++) {
 156                         if (rds_bind_fanout_size < (1 << i))
 157                                 break;
 158                 }
 159                 rds_bind_fanout_size = 1 << i;
 160         }
 161         rds_bind_fanout = kmem_zalloc(rds_bind_fanout_size *
 162             sizeof (rds_bf_t), KM_SLEEP);
 163         for (i = 0; i < rds_bind_fanout_size; i++) {
 164                 mutex_init(&rds_bind_fanout[i].rds_bf_lock, NULL, MUTEX_DEFAULT,
 165                     NULL);
 166         }
 167 }
 168 
 169 void
 170 rds_free(rds_t *rds)
 171 {
 172         ASSERT(rds->rds_refcnt == 0);
 173         ASSERT(MUTEX_HELD(&rds->rds_lock));