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 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * tavor_rsrc.c
29 * Tavor Resource Management Routines
30 *
31 * Implements all the routines necessary for setup, teardown, and
32 * alloc/free of all Tavor resources, including those that are managed
33 * by Tavor hardware or which live in Tavor's direct attached DDR memory.
34 */
35
36 #include <sys/types.h>
37 #include <sys/conf.h>
38 #include <sys/ddi.h>
39 #include <sys/sunddi.h>
40 #include <sys/modctl.h>
41 #include <sys/vmem.h>
42 #include <sys/bitmap.h>
43
44 #include <sys/ib/adapters/tavor/tavor.h>
45
46 /*
47 * The following routines are used for initializing and destroying
48 * the resource pools used by the Tavor resource allocation routines.
49 * They consist of four classes of object:
50 *
51 * Mailboxes: The "In" and "Out" mailbox types are used by the Tavor
52 * command interface routines. Mailboxes are used to pass information
53 * back and forth to the Tavor firmware. Either type of mailbox may
54 * be allocated from Tavor's direct attached DDR memory or from system
55 * memory (although currently all "In" mailboxes are in DDR and all "out"
2868 TAVOR_TNF_ENTER(tavor_rsrc_mrhdl_destructor);
2869 }
2870
2871
2872 /*
2873 * tavor_rsrc_mcg_entry_get_size()
2874 */
2875 static int
2876 tavor_rsrc_mcg_entry_get_size(tavor_state_t *state, uint_t *mcg_size_shift)
2877 {
2878 uint_t num_qp_per_mcg, max_qp_per_mcg, log2;
2879
2880 TAVOR_TNF_ENTER(tavor_rsrc_mcg_entry_get_size);
2881
2882 /*
2883 * Round the configured number of QP per MCG to next larger
2884 * power-of-2 size and update.
2885 */
2886 num_qp_per_mcg = state->ts_cfg_profile->cp_num_qp_per_mcg + 8;
2887 log2 = highbit(num_qp_per_mcg);
2888 if ((num_qp_per_mcg & (num_qp_per_mcg - 1)) == 0) {
2889 log2 = log2 - 1;
2890 }
2891 state->ts_cfg_profile->cp_num_qp_per_mcg = (1 << log2) - 8;
2892
2893 /* Now make sure number of QP per MCG makes sense */
2894 num_qp_per_mcg = state->ts_cfg_profile->cp_num_qp_per_mcg;
2895 max_qp_per_mcg = (1 << state->ts_devlim.log_max_qp_mcg);
2896 if (num_qp_per_mcg > max_qp_per_mcg) {
2897 TNF_PROBE_1(tavor_rsrc_mcg_getsz_toomany_qppermcg_fail,
2898 TAVOR_TNF_ERROR, "", tnf_uint, maxqpmcg, max_qp_per_mcg);
2899 TAVOR_TNF_EXIT(tavor_rsrc_mcg_entry_get_size);
2900 return (DDI_FAILURE);
2901 }
2902
2903 /* Return the (shift) size of an individual MCG HW entry */
2904 *mcg_size_shift = log2 + 2;
2905
2906 TAVOR_TNF_EXIT(tavor_rsrc_mcg_entry_get_size);
2907 return (DDI_SUCCESS);
2908 }
|
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 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * tavor_rsrc.c
29 * Tavor Resource Management Routines
30 *
31 * Implements all the routines necessary for setup, teardown, and
32 * alloc/free of all Tavor resources, including those that are managed
33 * by Tavor hardware or which live in Tavor's direct attached DDR memory.
34 */
35
36 #include <sys/sysmacros.h>
37 #include <sys/types.h>
38 #include <sys/conf.h>
39 #include <sys/ddi.h>
40 #include <sys/sunddi.h>
41 #include <sys/modctl.h>
42 #include <sys/vmem.h>
43 #include <sys/bitmap.h>
44
45 #include <sys/ib/adapters/tavor/tavor.h>
46
47 /*
48 * The following routines are used for initializing and destroying
49 * the resource pools used by the Tavor resource allocation routines.
50 * They consist of four classes of object:
51 *
52 * Mailboxes: The "In" and "Out" mailbox types are used by the Tavor
53 * command interface routines. Mailboxes are used to pass information
54 * back and forth to the Tavor firmware. Either type of mailbox may
55 * be allocated from Tavor's direct attached DDR memory or from system
56 * memory (although currently all "In" mailboxes are in DDR and all "out"
2869 TAVOR_TNF_ENTER(tavor_rsrc_mrhdl_destructor);
2870 }
2871
2872
2873 /*
2874 * tavor_rsrc_mcg_entry_get_size()
2875 */
2876 static int
2877 tavor_rsrc_mcg_entry_get_size(tavor_state_t *state, uint_t *mcg_size_shift)
2878 {
2879 uint_t num_qp_per_mcg, max_qp_per_mcg, log2;
2880
2881 TAVOR_TNF_ENTER(tavor_rsrc_mcg_entry_get_size);
2882
2883 /*
2884 * Round the configured number of QP per MCG to next larger
2885 * power-of-2 size and update.
2886 */
2887 num_qp_per_mcg = state->ts_cfg_profile->cp_num_qp_per_mcg + 8;
2888 log2 = highbit(num_qp_per_mcg);
2889 if (ISP2(num_qp_per_mcg)) {
2890 log2 = log2 - 1;
2891 }
2892 state->ts_cfg_profile->cp_num_qp_per_mcg = (1 << log2) - 8;
2893
2894 /* Now make sure number of QP per MCG makes sense */
2895 num_qp_per_mcg = state->ts_cfg_profile->cp_num_qp_per_mcg;
2896 max_qp_per_mcg = (1 << state->ts_devlim.log_max_qp_mcg);
2897 if (num_qp_per_mcg > max_qp_per_mcg) {
2898 TNF_PROBE_1(tavor_rsrc_mcg_getsz_toomany_qppermcg_fail,
2899 TAVOR_TNF_ERROR, "", tnf_uint, maxqpmcg, max_qp_per_mcg);
2900 TAVOR_TNF_EXIT(tavor_rsrc_mcg_entry_get_size);
2901 return (DDI_FAILURE);
2902 }
2903
2904 /* Return the (shift) size of an individual MCG HW entry */
2905 *mcg_size_shift = log2 + 2;
2906
2907 TAVOR_TNF_EXIT(tavor_rsrc_mcg_entry_get_size);
2908 return (DDI_SUCCESS);
2909 }
|