19e39c5baSBill Taylor /* 29e39c5baSBill Taylor * CDDL HEADER START 39e39c5baSBill Taylor * 49e39c5baSBill Taylor * The contents of this file are subject to the terms of the 59e39c5baSBill Taylor * Common Development and Distribution License (the "License"). 69e39c5baSBill Taylor * You may not use this file except in compliance with the License. 79e39c5baSBill Taylor * 89e39c5baSBill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99e39c5baSBill Taylor * or http://www.opensolaris.org/os/licensing. 109e39c5baSBill Taylor * See the License for the specific language governing permissions 119e39c5baSBill Taylor * and limitations under the License. 129e39c5baSBill Taylor * 139e39c5baSBill Taylor * When distributing Covered Code, include this CDDL HEADER in each 149e39c5baSBill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159e39c5baSBill Taylor * If applicable, add the following below this CDDL HEADER, with the 169e39c5baSBill Taylor * fields enclosed by brackets "[]" replaced with your own identifying 179e39c5baSBill Taylor * information: Portions Copyright [yyyy] [name of copyright owner] 189e39c5baSBill Taylor * 199e39c5baSBill Taylor * CDDL HEADER END 209e39c5baSBill Taylor */ 219e39c5baSBill Taylor 229e39c5baSBill Taylor /* 23*c7facc54SBill Taylor * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 249e39c5baSBill Taylor * Use is subject to license terms. 259e39c5baSBill Taylor */ 269e39c5baSBill Taylor 279e39c5baSBill Taylor #ifndef _SYS_IB_ADAPTERS_TAVOR_MISC_H 289e39c5baSBill Taylor #define _SYS_IB_ADAPTERS_TAVOR_MISC_H 299e39c5baSBill Taylor 309e39c5baSBill Taylor /* 319e39c5baSBill Taylor * tavor_misc.h 329e39c5baSBill Taylor * Contains all of the prototypes, #defines, and structures necessary 339e39c5baSBill Taylor * for the Tavor Miscellaneous routines - Address Handle, Multicast, 349e39c5baSBill Taylor * Protection Domain, port-related, statistics (kstat) routines, and 359e39c5baSBill Taylor * extra VTS related routines. 369e39c5baSBill Taylor * Many of these functions are called by other parts of the Tavor driver 379e39c5baSBill Taylor * (and several routines are directly exposed through the IBTF CI 389e39c5baSBill Taylor * interface and/or kstat interface). 399e39c5baSBill Taylor */ 409e39c5baSBill Taylor 419e39c5baSBill Taylor #include <sys/types.h> 429e39c5baSBill Taylor #include <sys/conf.h> 439e39c5baSBill Taylor #include <sys/ddi.h> 449e39c5baSBill Taylor #include <sys/sunddi.h> 459e39c5baSBill Taylor 469e39c5baSBill Taylor #include <sys/ib/adapters/tavor/tavor_ioctl.h> 479e39c5baSBill Taylor 489e39c5baSBill Taylor #ifdef __cplusplus 499e39c5baSBill Taylor extern "C" { 509e39c5baSBill Taylor #endif 519e39c5baSBill Taylor 529e39c5baSBill Taylor /* 539e39c5baSBill Taylor * The following defines specify the default number of Address Handles (AH) 549e39c5baSBill Taylor * and their size (in the hardware). By default the maximum number of address 559e39c5baSBill Taylor * handles is set to 32K. This value is controllable through the 569e39c5baSBill Taylor * "tavor_log_num_ah" configuration variable. Note: Tavor Address Handles 579e39c5baSBill Taylor * are also referred to as UD Address Vectors (UDAV). 589e39c5baSBill Taylor */ 599e39c5baSBill Taylor #define TAVOR_NUM_AH_SHIFT 0xF 609e39c5baSBill Taylor #define TAVOR_NUM_AH (1 << TAVOR_NUM_AH_SHIFT) 619e39c5baSBill Taylor #define TAVOR_UDAV_SIZE_SHIFT 0x5 629e39c5baSBill Taylor #define TAVOR_UDAV_SIZE (1 << TAVOR_UDAV_SIZE_SHIFT) 639e39c5baSBill Taylor 649e39c5baSBill Taylor /* 659e39c5baSBill Taylor * Minimal configuration value. 669e39c5baSBill Taylor */ 679e39c5baSBill Taylor #define TAVOR_NUM_AH_SHIFT_MIN 0xA 689e39c5baSBill Taylor 699e39c5baSBill Taylor /* 709e39c5baSBill Taylor * The following macro determines whether the contents of a UDAV need to be 719e39c5baSBill Taylor * sync'd (with ddi_dma_sync()). This decision is based on whether the 729e39c5baSBill Taylor * UDAV is in DDR memory (no sync) or system memory (sync required). 739e39c5baSBill Taylor */ 749e39c5baSBill Taylor #define TAVOR_UDAV_IS_SYNC_REQ(state) \ 759e39c5baSBill Taylor (((&((state)->ts_rsrc_hdl[TAVOR_UDAV]))->rsrc_loc == \ 769e39c5baSBill Taylor TAVOR_IN_DDR) ? 0 : 1) 779e39c5baSBill Taylor 789e39c5baSBill Taylor /* 799e39c5baSBill Taylor * These defines are used by tavor_get_addr_path() and tavor_set_addr_path() 809e39c5baSBill Taylor * below. They indicate the type of hardware context being passed in the 819e39c5baSBill Taylor * "path" argument. Because the Tavor hardware formats for the QP address 829e39c5baSBill Taylor * path and UDAV address path structures is so similar, but not exactly the 839e39c5baSBill Taylor * same, we use these flags to indicate which type of structure is being 849e39c5baSBill Taylor * read from or written to. 859e39c5baSBill Taylor */ 869e39c5baSBill Taylor #define TAVOR_ADDRPATH_QP 0x0 879e39c5baSBill Taylor #define TAVOR_ADDRPATH_UDAV 0x1 889e39c5baSBill Taylor 899e39c5baSBill Taylor 909e39c5baSBill Taylor /* 919e39c5baSBill Taylor * The following defines specify the default number of Multicast Groups (MCG) 929e39c5baSBill Taylor * and the maximum number of QP which can be associated with each. By default 939e39c5baSBill Taylor * the maximum number of multicast groups is set to 256, and the maximum number 949e39c5baSBill Taylor * of QP per multicast group is set to 8. These values are controllable 959e39c5baSBill Taylor * through the "tavor_log_num_mcg" and "tavor_num_qp_per_mcg" configuration 969e39c5baSBill Taylor * variables. 979e39c5baSBill Taylor * We also define a macro below that is used to determine the size of each 989e39c5baSBill Taylor * individual MCG entry (in hardware) based on the number of QP to be 999e39c5baSBill Taylor * supported per multicast group. 1009e39c5baSBill Taylor */ 1019e39c5baSBill Taylor #define TAVOR_NUM_MCG_SHIFT 0x8 1029e39c5baSBill Taylor #define TAVOR_NUM_MCG (1 << TAVOR_NUM_MCG_SHIFT) 1039e39c5baSBill Taylor #define TAVOR_NUM_QP_PER_MCG 8 1049e39c5baSBill Taylor 1059e39c5baSBill Taylor /* 1069e39c5baSBill Taylor * Minimal configuration values. 1079e39c5baSBill Taylor */ 1089e39c5baSBill Taylor #define TAVOR_NUM_MCG_SHIFT_MIN 0x4 1099e39c5baSBill Taylor #define TAVOR_NUM_QP_PER_MCG_MIN 0x1 1109e39c5baSBill Taylor 1119e39c5baSBill Taylor /* 1129e39c5baSBill Taylor * Macro to compute the offset of the QP list in a given MCG entry. 1139e39c5baSBill Taylor */ 1149e39c5baSBill Taylor #define TAVOR_MCGMEM_SZ(state) \ 1159e39c5baSBill Taylor ((((state)->ts_cfg_profile->cp_num_qp_per_mcg) + 8) << 2) 1169e39c5baSBill Taylor #define TAVOR_MCG_GET_QPLIST_PTR(mcg) \ 1179e39c5baSBill Taylor ((tavor_hw_mcg_qp_list_t *)((uintptr_t)(mcg) + \ 1189e39c5baSBill Taylor sizeof (tavor_hw_mcg_t))) 1199e39c5baSBill Taylor 1209e39c5baSBill Taylor /* 1219e39c5baSBill Taylor * The following defines specify the characteristics of the Tavor multicast 1229e39c5baSBill Taylor * group hash table. The TAVOR_NUM_MCG_HASH_SHIFT defines the size of the 1239e39c5baSBill Taylor * hash table (as a power-of-2), which is set to 16 by default. This value 1249e39c5baSBill Taylor * is controllable through the "tavor_log_num_mcg_hash" configuration variable, 1259e39c5baSBill Taylor * but serious consideration should be taken before changing this value. Note: 1269e39c5baSBill Taylor * its appropriate size should be a function of the entire table size (as 1279e39c5baSBill Taylor * defined by "tavor_log_num_mcg" and TAVOR_NUM_MCG_SHIFT above). 1289e39c5baSBill Taylor */ 1299e39c5baSBill Taylor #define TAVOR_NUM_MCG_HASH_SHIFT 0x4 1309e39c5baSBill Taylor 1319e39c5baSBill Taylor /* 1329e39c5baSBill Taylor * Minimal configuration value. 1339e39c5baSBill Taylor */ 1349e39c5baSBill Taylor #define TAVOR_NUM_MCG_HASH_SHIFT_MIN 0x2 1359e39c5baSBill Taylor 1369e39c5baSBill Taylor /* 1379e39c5baSBill Taylor * The following defines are used by the multicast routines to determine 1389e39c5baSBill Taylor * if a given "multicast GID" is valid or not (see tavor_mcg_is_mgid_valid 1399e39c5baSBill Taylor * for more details. These values are pulled from the IBA specification, 1409e39c5baSBill Taylor * rev. 1.1 1419e39c5baSBill Taylor */ 1429e39c5baSBill Taylor #define TAVOR_MCG_TOPBITS_SHIFT 56 1439e39c5baSBill Taylor #define TAVOR_MCG_TOPBITS_MASK 0xFF 1449e39c5baSBill Taylor #define TAVOR_MCG_TOPBITS 0xFF 1459e39c5baSBill Taylor 1469e39c5baSBill Taylor #define TAVOR_MCG_FLAGS_SHIFT 52 1479e39c5baSBill Taylor #define TAVOR_MCG_FLAGS_MASK 0xF 1489e39c5baSBill Taylor #define TAVOR_MCG_FLAGS_PERM 0x0 1499e39c5baSBill Taylor #define TAVOR_MCG_FLAGS_NONPERM 0x1 1509e39c5baSBill Taylor 1519e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_SHIFT 48 1529e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_MASK 0xF 1539e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_LINKLOC 0x2 1549e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_SITELOC 0x5 1559e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_ORGLOC 0x8 1569e39c5baSBill Taylor #define TAVOR_MCG_SCOPE_GLOBAL 0xE 1579e39c5baSBill Taylor 1589e39c5baSBill Taylor 1599e39c5baSBill Taylor /* 1609e39c5baSBill Taylor * The following defines specify the default number of Protection Domains (PD). 1619e39c5baSBill Taylor * By default the maximum number of protection domains is set to 64K. This 1629e39c5baSBill Taylor * value is controllable through the "tavor_log_num_pd" configuration variable. 1639e39c5baSBill Taylor */ 1649e39c5baSBill Taylor #define TAVOR_NUM_PD_SHIFT 0x10 1659e39c5baSBill Taylor #define TAVOR_NUM_PD (1 << TAVOR_NUM_PD_SHIFT) 1669e39c5baSBill Taylor 1679e39c5baSBill Taylor /* 1689e39c5baSBill Taylor * The following defines specify the default number of Partition Keys (PKey) 1699e39c5baSBill Taylor * per port. By default the maximum number of PKeys is set to 32 per port, for 1709e39c5baSBill Taylor * a total of 64 (assuming two ports) . This value is controllable through the 1719e39c5baSBill Taylor * "tavor_log_max_pkeytbl" configuration variable. 1729e39c5baSBill Taylor */ 1739e39c5baSBill Taylor #define TAVOR_NUM_PKEYTBL_SHIFT 0x5 1749e39c5baSBill Taylor #define TAVOR_NUM_PKEYTBL (1 << TAVOR_NUM_PKEYTBL_SHIFT) 1759e39c5baSBill Taylor 1769e39c5baSBill Taylor /* 1779e39c5baSBill Taylor * The following defines specify the default number of SGIDs per port. By 1789e39c5baSBill Taylor * default the maximum number of GIDS per port is set to 16. This value 1799e39c5baSBill Taylor * is controllable through the "tavor_log_max_gidtbl" configuration variable. 1809e39c5baSBill Taylor */ 1819e39c5baSBill Taylor #define TAVOR_NUM_GIDTBL_SHIFT 0x4 1829e39c5baSBill Taylor #define TAVOR_NUM_GIDTBL (1 << TAVOR_NUM_GIDTBL_SHIFT) 1839e39c5baSBill Taylor 1849e39c5baSBill Taylor /* 1859e39c5baSBill Taylor * The following defines specify the default number of UAR pages. By 1869e39c5baSBill Taylor * default the maximum number of UAR pages is set to 1024. This value 1879e39c5baSBill Taylor * is controllable through the "tavor_log_num_uar" configuration variable. 1889e39c5baSBill Taylor * NOTE: This value should not be set larger than 15 (0xF) because the 1899e39c5baSBill Taylor * UAR index number is used as part of the minor number calculation (see 1909e39c5baSBill Taylor * tavor_open() for details) and the minor numbers should not be larger 1919e39c5baSBill Taylor * than eighteen bits (i.e. 15 bits of UAR index, 3 bits of driver instance 1929e39c5baSBill Taylor * number). This is especially true for 32-bit kernels. 1939e39c5baSBill Taylor */ 1949e39c5baSBill Taylor #define TAVOR_NUM_UAR_SHIFT 0xA 1959e39c5baSBill Taylor #define TAVOR_NUM_UAR (1 << TAVOR_NUM_UAR_SHIFT) 1969e39c5baSBill Taylor 1979e39c5baSBill Taylor /* 1989e39c5baSBill Taylor * Minimal configuration value. 1999e39c5baSBill Taylor */ 2009e39c5baSBill Taylor #define TAVOR_NUM_UAR_SHIFT_MIN 0x4 2019e39c5baSBill Taylor 2029e39c5baSBill Taylor /* 2039e39c5baSBill Taylor * These defines specify some miscellaneous port-related configuration 2049e39c5baSBill Taylor * information. Specifically, TAVOR_MAX_MTU is used to define the maximum 2059e39c5baSBill Taylor * MTU supported for each Tavor port, TAVOR_MAX_PORT_WIDTH is used to define 2069e39c5baSBill Taylor * the maximum supported port width, and the TAVOR_MAX_VLCAP define is used 2079e39c5baSBill Taylor * to specify the maximum number of VLs supported, excluding VL15. Both 2089e39c5baSBill Taylor * of these values are controllable and get be set using the "tavor_max_mtu" 2099e39c5baSBill Taylor * and "tavor_max_vlcap" configuration variables. Note: as with many of the 2109e39c5baSBill Taylor * configurable variables, caution should be exercised when changing these 2119e39c5baSBill Taylor * values. These values, specifically, should not be set any larger than 2129e39c5baSBill Taylor * they are defined here as these are set to the current Tavor device 2139e39c5baSBill Taylor * maximums. 2149e39c5baSBill Taylor */ 2159e39c5baSBill Taylor #define TAVOR_MAX_MTU 0x4 2169e39c5baSBill Taylor #define TAVOR_MAX_PORT_WIDTH 0x3 2179e39c5baSBill Taylor #define TAVOR_MAX_VLCAP 0x8 2189e39c5baSBill Taylor 2199e39c5baSBill Taylor /* 2209e39c5baSBill Taylor * These last defines are used by the statistics counting routines (kstats) 2219e39c5baSBill Taylor * for initialization of the structures associated with the IB statistics 2229e39c5baSBill Taylor * access routines. The TAVOR_CNTR_MASK and TAVOR_CNTR_SIZE defines are 2239e39c5baSBill Taylor * used to divide the "pcr" register into two 32-bit counters (one for "pic0" 2249e39c5baSBill Taylor * and the other for "pic1") 2259e39c5baSBill Taylor */ 2269e39c5baSBill Taylor #define TAVOR_CNTR_MASK 0xFFFFFFFF 2279e39c5baSBill Taylor #define TAVOR_CNTR_SIZE 32 2289e39c5baSBill Taylor #define TAVOR_CNTR_NUMENTRIES 17 2299e39c5baSBill Taylor 2309e39c5baSBill Taylor /* 2319e39c5baSBill Taylor * The following defines are used by tavor_queue_alloc() to specify whether 2329e39c5baSBill Taylor * a given QP/CQ/EQ queue memory should be allocated from kernel system memory 2339e39c5baSBill Taylor * (TAVOR_QUEUE_LOCATION_NORMAL), from user-mappable system memory 2349e39c5baSBill Taylor * (TAVOR_QUEUE_LOCATION_USERLAND), or from local-attached DDR memory 2359e39c5baSBill Taylor * (TAVOR_QUEUE_LOCATION_INDDR). 2369e39c5baSBill Taylor */ 2379e39c5baSBill Taylor #define TAVOR_QUEUE_LOCATION_NORMAL 0x1 2389e39c5baSBill Taylor #define TAVOR_QUEUE_LOCATION_USERLAND 0x2 2399e39c5baSBill Taylor #define TAVOR_QUEUE_LOCATION_INDDR 0x3 2409e39c5baSBill Taylor 2419e39c5baSBill Taylor /* 2429e39c5baSBill Taylor * Minimum number of ticks to delay between successive polls of the CQ in 2439e39c5baSBill Taylor * VTS ioctl loopback test 2449e39c5baSBill Taylor */ 2459e39c5baSBill Taylor #define TAVOR_VTS_LOOPBACK_MIN_WAIT_DUR 50 2469e39c5baSBill Taylor 2479e39c5baSBill Taylor 2489e39c5baSBill Taylor /* 2499e39c5baSBill Taylor * The tavor_sw_ah_s structure is also referred to using the "tavor_ahhdl_t" 2509e39c5baSBill Taylor * typedef (see tavor_typedef.h). It encodes all the information necessary 2519e39c5baSBill Taylor * to track the various resources (e.g. the UDAV hardware resource) needed to 2529e39c5baSBill Taylor * allocate, query, modify, and (later) free an address handle. 2539e39c5baSBill Taylor * 2549e39c5baSBill Taylor * In specific, it has a lock to ensure single-threaded access, it stores a 2559e39c5baSBill Taylor * pointer to the associated MR handle (for the mapped UDAV memory) and a 2569e39c5baSBill Taylor * pointer to the associated PD handle. And it also contains a copy of the 2579e39c5baSBill Taylor * GUID stored into the address handle. The reason for this extra copy of 2589e39c5baSBill Taylor * the GUID info has to do with Tavor PRM compliance and is fully explained 2599e39c5baSBill Taylor * in tavor_misc.c 2609e39c5baSBill Taylor * 2619e39c5baSBill Taylor * It also has the always necessary backpointer to the resource for the AH 2629e39c5baSBill Taylor * handle structure itself. 2639e39c5baSBill Taylor */ 2649e39c5baSBill Taylor struct tavor_sw_ah_s { 2659e39c5baSBill Taylor kmutex_t ah_lock; 2669e39c5baSBill Taylor tavor_pdhdl_t ah_pdhdl; 2679e39c5baSBill Taylor tavor_mrhdl_t ah_mrhdl; 2689e39c5baSBill Taylor tavor_rsrc_t *ah_udavrsrcp; 2699e39c5baSBill Taylor tavor_rsrc_t *ah_rsrcp; 2709e39c5baSBill Taylor uint64_t ah_save_guid; 2719e39c5baSBill Taylor ibt_srate_t ah_save_srate; 2729e39c5baSBill Taylor uint_t ah_sync; 2739e39c5baSBill Taylor }; 2749e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_ah_s::ah_lock, 2759e39c5baSBill Taylor tavor_sw_ah_s::ah_pdhdl 2769e39c5baSBill Taylor tavor_sw_ah_s::ah_mrhdl 2779e39c5baSBill Taylor tavor_sw_ah_s::ah_udavrsrcp 2789e39c5baSBill Taylor tavor_sw_ah_s::ah_rsrcp 2799e39c5baSBill Taylor tavor_sw_ah_s::ah_save_guid 2809e39c5baSBill Taylor tavor_sw_ah_s::ah_sync)) 2819e39c5baSBill Taylor 2829e39c5baSBill Taylor /* 2839e39c5baSBill Taylor * The tavor_sw_mcg_list_s structure is also referred to using the 2849e39c5baSBill Taylor * "tavor_mcghdl_t" typedef (see tavor_typedef.h). It encodes all the 2859e39c5baSBill Taylor * information necessary to track the various resources needed to for attaching 2869e39c5baSBill Taylor * and detaching QP from multicast groups. 2879e39c5baSBill Taylor * 2889e39c5baSBill Taylor * The Tavor driver keeps an array of these and uses them as a shadow for 2899e39c5baSBill Taylor * the real HW-based MCG table. They hold all the necessary information 2909e39c5baSBill Taylor * to track the resources and to allow fast access to the MCG table. First, 2919e39c5baSBill Taylor * it had a 128-bit multicast GID (stored in "mcg_mgid_h" and "mcg_mgid_l". 2929e39c5baSBill Taylor * next if has a field to indicate the index of the next tavor_mcghdl_t in 2939e39c5baSBill Taylor * the current hash chain (zero is the end of the chain). Note: this very 2949e39c5baSBill Taylor * closely mimics what the hardware MCG entry has. Then it has a field to 2959e39c5baSBill Taylor * indicate how many QP are currently attached to the given MCG. And, lastly, 2969e39c5baSBill Taylor * it has the obligatory backpointer to the resource for the MCH handle 2979e39c5baSBill Taylor * structure itself. 2989e39c5baSBill Taylor */ 2999e39c5baSBill Taylor struct tavor_sw_mcg_list_s { 3009e39c5baSBill Taylor uint64_t mcg_mgid_h; 3019e39c5baSBill Taylor uint64_t mcg_mgid_l; 3029e39c5baSBill Taylor uint_t mcg_next_indx; 3039e39c5baSBill Taylor uint_t mcg_num_qps; 3049e39c5baSBill Taylor tavor_rsrc_t *mcg_rsrcp; 3059e39c5baSBill Taylor }; 3069e39c5baSBill Taylor 3079e39c5baSBill Taylor /* 3089e39c5baSBill Taylor * The tavor_sw_pd_s structure is also referred to using the "tavor_pdhdl_t" 3099e39c5baSBill Taylor * typedef (see tavor_typedef.h). It encodes all the information necessary 3109e39c5baSBill Taylor * to track the various resources needed to allocate and free protection 3119e39c5baSBill Taylor * domains 3129e39c5baSBill Taylor * 3139e39c5baSBill Taylor * Specifically, it has reference count and a lock to ensure single threaded 3149e39c5baSBill Taylor * access to it. It has a field for the protection domain number ("pd_pdnum"). 3159e39c5baSBill Taylor * And it also has the obligatory backpointer to the resource for the PD 3169e39c5baSBill Taylor * handle structure itself. 3179e39c5baSBill Taylor */ 3189e39c5baSBill Taylor struct tavor_sw_pd_s { 3199e39c5baSBill Taylor kmutex_t pd_lock; 3209e39c5baSBill Taylor uint32_t pd_pdnum; 3219e39c5baSBill Taylor uint32_t pd_refcnt; 3229e39c5baSBill Taylor tavor_rsrc_t *pd_rsrcp; 3239e39c5baSBill Taylor }; 3249e39c5baSBill Taylor _NOTE(READ_ONLY_DATA(tavor_sw_pd_s::pd_pdnum 3259e39c5baSBill Taylor tavor_sw_pd_s::pd_rsrcp)) 3269e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_pd_s::pd_lock, 3279e39c5baSBill Taylor tavor_sw_pd_s::pd_refcnt)) 3289e39c5baSBill Taylor 3299e39c5baSBill Taylor /* 3309e39c5baSBill Taylor * The tavor_qalloc_info_s structure is also referred to using the 3319e39c5baSBill Taylor * "tavor_qalloc_info_t" typedef (see tavor_typedef.h). It holds all the 3329e39c5baSBill Taylor * information necessary to track the resources for each of the various Tavor 3339e39c5baSBill Taylor * queue types (i.e. Event Queue, Completion Queue, Work Queue). 3349e39c5baSBill Taylor * 3359e39c5baSBill Taylor * Specifically, it has the size, alignment restrictions, and location (in DDR 3369e39c5baSBill Taylor * or in system memory). And depending on the location, it also has the 3379e39c5baSBill Taylor * ddi_dma_handle_t, ddi_acc_handle_t, and pointers used for reading/writing to 3389e39c5baSBill Taylor * the queue's memory. 3399e39c5baSBill Taylor */ 3409e39c5baSBill Taylor struct tavor_qalloc_info_s { 3419e39c5baSBill Taylor uint64_t qa_size; 3429e39c5baSBill Taylor uint64_t qa_alloc_align; 3439e39c5baSBill Taylor uint64_t qa_bind_align; 3449e39c5baSBill Taylor uint32_t *qa_buf_real; 3459e39c5baSBill Taylor uint32_t *qa_buf_aligned; 3469e39c5baSBill Taylor uint64_t qa_buf_realsz; 3479e39c5baSBill Taylor uint_t qa_location; 3489e39c5baSBill Taylor ddi_dma_handle_t qa_dmahdl; 3499e39c5baSBill Taylor ddi_acc_handle_t qa_acchdl; 3509e39c5baSBill Taylor ddi_umem_cookie_t qa_umemcookie; 3519e39c5baSBill Taylor }; 3529e39c5baSBill Taylor 3539e39c5baSBill Taylor /* 3549e39c5baSBill Taylor * The tavor_ks_mask_t structure encodes all the information necessary for 3559e39c5baSBill Taylor * the individual kstat entries. The "ks_reg_offset" field contains the 3569e39c5baSBill Taylor * hardware offset for the corresponding counter, and "ks_reg_shift" and 3579e39c5baSBill Taylor * "ks_reg_mask" contain shift and mask registers used by the access routines. 3589e39c5baSBill Taylor * Also the "ks_old_pic0" and "ks_old_pic1" fields contain the most recently 3599e39c5baSBill Taylor * read value for the corresponding port ("pic"). Note: An array of these 3609e39c5baSBill Taylor * structures is part of the "tavor_ks_info_t" structure below. 3619e39c5baSBill Taylor */ 3629e39c5baSBill Taylor typedef struct tavor_ks_mask_s { 3639e39c5baSBill Taylor char *ks_evt_name; 3649e39c5baSBill Taylor uint64_t ks_reg_offset; 3659e39c5baSBill Taylor uint32_t ks_reg_shift; 3669e39c5baSBill Taylor uint32_t ks_reg_mask; 3679e39c5baSBill Taylor uint32_t ks_old_pic0; 3689e39c5baSBill Taylor uint32_t ks_old_pic1; 3699e39c5baSBill Taylor } tavor_ks_mask_t; 3709e39c5baSBill Taylor 371e9dc6bffSRamaswamy Tummala /* 372e9dc6bffSRamaswamy Tummala * Index into the named data components of 64 bit "perf_counters" kstat. 373e9dc6bffSRamaswamy Tummala */ 374e9dc6bffSRamaswamy Tummala enum { 375e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_ENABLE_IDX = 0, 376e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_XMIT_DATA_IDX, 377e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_RECV_DATA_IDX, 378e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_XMIT_PKTS_IDX, 379e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_RECV_PKTS_IDX, 380e9dc6bffSRamaswamy Tummala TAVOR_PERFCNTR64_NUM_COUNTERS 381e9dc6bffSRamaswamy Tummala }; 382e9dc6bffSRamaswamy Tummala 383e9dc6bffSRamaswamy Tummala /* 384e9dc6bffSRamaswamy Tummala * Data associated with the 64 bit "perf_counters" kstat. One for each port. 385e9dc6bffSRamaswamy Tummala */ 386e9dc6bffSRamaswamy Tummala typedef struct tavor_perfcntr64_ks_info_s { 387e9dc6bffSRamaswamy Tummala struct kstat *tki64_ksp; 388e9dc6bffSRamaswamy Tummala int tki64_enabled; 389e9dc6bffSRamaswamy Tummala uint64_t tki64_counters[TAVOR_PERFCNTR64_NUM_COUNTERS]; 390e9dc6bffSRamaswamy Tummala uint32_t tki64_last_read[TAVOR_PERFCNTR64_NUM_COUNTERS]; 391e9dc6bffSRamaswamy Tummala uint_t tki64_port_num; 392e9dc6bffSRamaswamy Tummala tavor_state_t *tki64_state; 393e9dc6bffSRamaswamy Tummala } tavor_perfcntr64_ks_info_t; 394e9dc6bffSRamaswamy Tummala 395e9dc6bffSRamaswamy Tummala 3969e39c5baSBill Taylor /* 3979e39c5baSBill Taylor * The tavor_ks_info_t structure stores all the information necessary for 3989e39c5baSBill Taylor * tracking the resources associated with each of the various kstats. In 3999e39c5baSBill Taylor * addition to containing pointers to each of the counter and pic kstats, 4009e39c5baSBill Taylor * this structure also contains "tki_pcr" which is the control register that 4019e39c5baSBill Taylor * determines which of the countable entries (from the "tki_ib_perfcnt[]" 4029e39c5baSBill Taylor * array) is being currently accessed. 4039e39c5baSBill Taylor */ 4049e39c5baSBill Taylor typedef struct tavor_ks_info_s { 4059e39c5baSBill Taylor struct kstat *tki_cntr_ksp; 4069e39c5baSBill Taylor struct kstat *tki_picN_ksp[TAVOR_NUM_PORTS]; 4079e39c5baSBill Taylor uint64_t tki_pcr; 4089e39c5baSBill Taylor uint64_t tki_pic0; 4099e39c5baSBill Taylor uint64_t tki_pic1; 4109e39c5baSBill Taylor tavor_ks_mask_t tki_ib_perfcnt[TAVOR_CNTR_NUMENTRIES]; 411e9dc6bffSRamaswamy Tummala kt_did_t tki_perfcntr64_thread_id; 412e9dc6bffSRamaswamy Tummala kmutex_t tki_perfcntr64_lock; 413e9dc6bffSRamaswamy Tummala kcondvar_t tki_perfcntr64_cv; 414e9dc6bffSRamaswamy Tummala uint_t tki_perfcntr64_flags; /* see below */ 415e9dc6bffSRamaswamy Tummala tavor_perfcntr64_ks_info_t tki_perfcntr64[TAVOR_NUM_PORTS]; 4169e39c5baSBill Taylor } tavor_ks_info_t; 4179e39c5baSBill Taylor 418e9dc6bffSRamaswamy Tummala /* tki_perfcntr64_flags */ 419e9dc6bffSRamaswamy Tummala #define TAVOR_PERFCNTR64_THREAD_CREATED 0x0001 420e9dc6bffSRamaswamy Tummala #define TAVOR_PERFCNTR64_THREAD_EXIT 0x0002 421e9dc6bffSRamaswamy Tummala 4229e39c5baSBill Taylor /* 4239e39c5baSBill Taylor * The tavor_ports_ioctl32_t, tavor_loopback_ioctl32_t, and 4249e39c5baSBill Taylor * tavor_flash_ioctl32_s structures are used internally by the Tavor 4259e39c5baSBill Taylor * driver to accomodate 32-bit applications which need to access the 4269e39c5baSBill Taylor * Tavor ioctls. They are 32-bit versions of externally available 4279e39c5baSBill Taylor * structures defined in tavor_ioctl.h 4289e39c5baSBill Taylor */ 4299e39c5baSBill Taylor typedef struct tavor_ports_ioctl32_s { 4309e39c5baSBill Taylor uint_t tp_revision; 4319e39c5baSBill Taylor caddr32_t tp_ports; 4329e39c5baSBill Taylor uint8_t tp_num_ports; 4339e39c5baSBill Taylor } tavor_ports_ioctl32_t; 4349e39c5baSBill Taylor 4359e39c5baSBill Taylor typedef struct tavor_loopback_ioctl32_s { 4369e39c5baSBill Taylor uint_t tlb_revision; 4379e39c5baSBill Taylor caddr32_t tlb_send_buf; 4389e39c5baSBill Taylor caddr32_t tlb_fail_buf; 4399e39c5baSBill Taylor uint_t tlb_buf_sz; 4409e39c5baSBill Taylor uint_t tlb_num_iter; 4419e39c5baSBill Taylor uint_t tlb_pass_done; 4429e39c5baSBill Taylor uint_t tlb_timeout; 4439e39c5baSBill Taylor tavor_loopback_error_t tlb_error_type; 4449e39c5baSBill Taylor uint8_t tlb_port_num; 4459e39c5baSBill Taylor uint8_t tlb_num_retry; 4469e39c5baSBill Taylor } tavor_loopback_ioctl32_t; 4479e39c5baSBill Taylor 4489e39c5baSBill Taylor typedef struct tavor_flash_ioctl32_s { 4499e39c5baSBill Taylor uint32_t tf_type; 4509e39c5baSBill Taylor caddr32_t tf_sector; 4519e39c5baSBill Taylor uint32_t tf_sector_num; 4529e39c5baSBill Taylor uint32_t tf_addr; 4539e39c5baSBill Taylor uint32_t tf_quadlet; 4549e39c5baSBill Taylor uint8_t tf_byte; 4559e39c5baSBill Taylor } tavor_flash_ioctl32_t; 4569e39c5baSBill Taylor 4579e39c5baSBill Taylor /* 4589e39c5baSBill Taylor * The tavor_loopback_comm_t and tavor_loopback_state_t structures below 4599e39c5baSBill Taylor * are used to store all of the relevant state information needed to keep 4609e39c5baSBill Taylor * track of a single VTS ioctl loopback test run. 4619e39c5baSBill Taylor */ 4629e39c5baSBill Taylor typedef struct tavor_loopback_comm_s { 4639e39c5baSBill Taylor uint8_t *tlc_buf; 4649e39c5baSBill Taylor size_t tlc_buf_sz; 4659e39c5baSBill Taylor ibt_mr_desc_t tlc_mrdesc; 4669e39c5baSBill Taylor 4679e39c5baSBill Taylor tavor_mrhdl_t tlc_mrhdl; 4689e39c5baSBill Taylor tavor_cqhdl_t tlc_cqhdl[2]; 4699e39c5baSBill Taylor tavor_qphdl_t tlc_qp_hdl; 4709e39c5baSBill Taylor 4719e39c5baSBill Taylor ibt_mr_attr_t tlc_memattr; 4729e39c5baSBill Taylor uint_t tlc_qp_num; 4739e39c5baSBill Taylor ibt_cq_attr_t tlc_cq_attr; 4749e39c5baSBill Taylor ibt_qp_alloc_attr_t tlc_qp_attr; 4759e39c5baSBill Taylor ibt_chan_sizes_t tlc_chan_sizes; 4769e39c5baSBill Taylor ibt_qp_info_t tlc_qp_info; 4779e39c5baSBill Taylor ibt_queue_sizes_t tlc_queue_sizes; 4789e39c5baSBill Taylor ibt_send_wr_t tlc_wr; 4799e39c5baSBill Taylor ibt_wr_ds_t tlc_sgl; 4809e39c5baSBill Taylor ibt_wc_t tlc_wc; 4819e39c5baSBill Taylor uint_t tlc_num_polled; 4829e39c5baSBill Taylor ibt_status_t tlc_status; 4839e39c5baSBill Taylor int tlc_complete; 4849e39c5baSBill Taylor int tlc_wrid; 4859e39c5baSBill Taylor } tavor_loopback_comm_t; 4869e39c5baSBill Taylor 4879e39c5baSBill Taylor typedef struct tavor_loopback_state_s { 4889e39c5baSBill Taylor uint8_t tls_port; 4899e39c5baSBill Taylor uint_t tls_lid; 4909e39c5baSBill Taylor uint8_t tls_retry; 4919e39c5baSBill Taylor tavor_state_t *tls_state; 4929e39c5baSBill Taylor ibc_hca_hdl_t tls_hca_hdl; 4939e39c5baSBill Taylor tavor_pdhdl_t tls_pd_hdl; 4949e39c5baSBill Taylor tavor_loopback_comm_t tls_tx; 4959e39c5baSBill Taylor tavor_loopback_comm_t tls_rx; 4969e39c5baSBill Taylor ibt_status_t tls_status; 4979e39c5baSBill Taylor int tls_err; 4989e39c5baSBill Taylor int tls_pkey_ix; 4999e39c5baSBill Taylor int tls_timeout; 5009e39c5baSBill Taylor } tavor_loopback_state_t; 5019e39c5baSBill Taylor 5029e39c5baSBill Taylor /* Tavor Address Handle routines */ 5039e39c5baSBill Taylor int tavor_ah_alloc(tavor_state_t *state, tavor_pdhdl_t pd, 5049e39c5baSBill Taylor ibt_adds_vect_t *attr_p, tavor_ahhdl_t *ahhdl, uint_t sleepflag); 5059e39c5baSBill Taylor int tavor_ah_free(tavor_state_t *state, tavor_ahhdl_t *ahhdl, 5069e39c5baSBill Taylor uint_t sleepflag); 5079e39c5baSBill Taylor int tavor_ah_query(tavor_state_t *state, tavor_ahhdl_t ahhdl, 5089e39c5baSBill Taylor tavor_pdhdl_t *pdhdl, ibt_adds_vect_t *attr_p); 5099e39c5baSBill Taylor int tavor_ah_modify(tavor_state_t *state, tavor_ahhdl_t ahhdl, 5109e39c5baSBill Taylor ibt_adds_vect_t *attr_p); 5119e39c5baSBill Taylor 5129e39c5baSBill Taylor /* Tavor Multicast Group routines */ 5139e39c5baSBill Taylor int tavor_mcg_attach(tavor_state_t *state, tavor_qphdl_t qphdl, ib_gid_t gid, 5149e39c5baSBill Taylor ib_lid_t lid); 5159e39c5baSBill Taylor int tavor_mcg_detach(tavor_state_t *state, tavor_qphdl_t qphdl, ib_gid_t gid, 5169e39c5baSBill Taylor ib_lid_t lid); 5179e39c5baSBill Taylor 5189e39c5baSBill Taylor /* Tavor Protection Domain routines */ 5199e39c5baSBill Taylor int tavor_pd_alloc(tavor_state_t *state, tavor_pdhdl_t *pdhdl, 5209e39c5baSBill Taylor uint_t sleepflag); 5219e39c5baSBill Taylor int tavor_pd_free(tavor_state_t *state, tavor_pdhdl_t *pdhdl); 5229e39c5baSBill Taylor void tavor_pd_refcnt_inc(tavor_pdhdl_t pd); 5239e39c5baSBill Taylor void tavor_pd_refcnt_dec(tavor_pdhdl_t pd); 5249e39c5baSBill Taylor 5259e39c5baSBill Taylor /* Tavor port-related routines */ 5269e39c5baSBill Taylor int tavor_port_query(tavor_state_t *state, uint_t port, 5279e39c5baSBill Taylor ibt_hca_portinfo_t *pi); 5289e39c5baSBill Taylor int tavor_port_modify(tavor_state_t *state, uint8_t port, 5299e39c5baSBill Taylor ibt_port_modify_flags_t flags, uint8_t init_type); 5309e39c5baSBill Taylor 5319e39c5baSBill Taylor /* Tavor statistics (kstat) routines */ 5329e39c5baSBill Taylor int tavor_kstat_init(tavor_state_t *state); 5339e39c5baSBill Taylor void tavor_kstat_fini(tavor_state_t *state); 5349e39c5baSBill Taylor 5359e39c5baSBill Taylor /* Miscellaneous routines */ 5369e39c5baSBill Taylor int tavor_set_addr_path(tavor_state_t *state, ibt_adds_vect_t *av, 5379e39c5baSBill Taylor tavor_hw_addr_path_t *path, uint_t type, tavor_qphdl_t qp); 5389e39c5baSBill Taylor void tavor_get_addr_path(tavor_state_t *state, tavor_hw_addr_path_t *path, 5399e39c5baSBill Taylor ibt_adds_vect_t *av, uint_t type, tavor_qphdl_t qp); 5409e39c5baSBill Taylor int tavor_portnum_is_valid(tavor_state_t *state, uint_t portnum); 5419e39c5baSBill Taylor int tavor_pkeyindex_is_valid(tavor_state_t *state, uint_t pkeyindx); 5429e39c5baSBill Taylor int tavor_queue_alloc(tavor_state_t *state, tavor_qalloc_info_t *qa_info, 5439e39c5baSBill Taylor uint_t sleepflag); 5449e39c5baSBill Taylor void tavor_queue_free(tavor_state_t *state, tavor_qalloc_info_t *qa_info); 5459e39c5baSBill Taylor void tavor_dma_attr_init(ddi_dma_attr_t *dma_attr); 5469e39c5baSBill Taylor 5479e39c5baSBill Taylor #ifdef __cplusplus 5489e39c5baSBill Taylor } 5499e39c5baSBill Taylor #endif 5509e39c5baSBill Taylor 5519e39c5baSBill Taylor #endif /* _SYS_IB_ADAPTERS_TAVOR_MISC_H */ 552