19517SBill.Taylor@Sun.COM /*
29517SBill.Taylor@Sun.COM * CDDL HEADER START
39517SBill.Taylor@Sun.COM *
49517SBill.Taylor@Sun.COM * The contents of this file are subject to the terms of the
59517SBill.Taylor@Sun.COM * Common Development and Distribution License (the "License").
69517SBill.Taylor@Sun.COM * You may not use this file except in compliance with the License.
79517SBill.Taylor@Sun.COM *
89517SBill.Taylor@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99517SBill.Taylor@Sun.COM * or http://www.opensolaris.org/os/licensing.
109517SBill.Taylor@Sun.COM * See the License for the specific language governing permissions
119517SBill.Taylor@Sun.COM * and limitations under the License.
129517SBill.Taylor@Sun.COM *
139517SBill.Taylor@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
149517SBill.Taylor@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159517SBill.Taylor@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
169517SBill.Taylor@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
179517SBill.Taylor@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
189517SBill.Taylor@Sun.COM *
199517SBill.Taylor@Sun.COM * CDDL HEADER END
209517SBill.Taylor@Sun.COM */
219517SBill.Taylor@Sun.COM
229517SBill.Taylor@Sun.COM /*
2312096SWilliam.Taylor@Oracle.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249517SBill.Taylor@Sun.COM */
259517SBill.Taylor@Sun.COM
269517SBill.Taylor@Sun.COM /*
279517SBill.Taylor@Sun.COM * hermon_ci.c
289517SBill.Taylor@Sun.COM * Hermon Channel Interface (CI) Routines
299517SBill.Taylor@Sun.COM *
309517SBill.Taylor@Sun.COM * Implements all the routines necessary to interface with the IBTF.
319517SBill.Taylor@Sun.COM * Pointers to all of these functions are passed to the IBTF at attach()
329517SBill.Taylor@Sun.COM * time in the ibc_operations_t structure. These functions include all
339517SBill.Taylor@Sun.COM * of the necessary routines to implement the required InfiniBand "verbs"
349517SBill.Taylor@Sun.COM * and additional IBTF-specific interfaces.
359517SBill.Taylor@Sun.COM */
369517SBill.Taylor@Sun.COM
379517SBill.Taylor@Sun.COM #include <sys/types.h>
389517SBill.Taylor@Sun.COM #include <sys/conf.h>
399517SBill.Taylor@Sun.COM #include <sys/ddi.h>
409517SBill.Taylor@Sun.COM #include <sys/sunddi.h>
419517SBill.Taylor@Sun.COM
429517SBill.Taylor@Sun.COM #include <sys/ib/adapters/hermon/hermon.h>
439517SBill.Taylor@Sun.COM
4411972SBill.Taylor@Sun.COM extern uint32_t hermon_kernel_data_ro;
4511972SBill.Taylor@Sun.COM extern uint32_t hermon_user_data_ro;
4611972SBill.Taylor@Sun.COM
479517SBill.Taylor@Sun.COM /* HCA and port related operations */
489517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_hca_ports(ibc_hca_hdl_t, uint8_t,
499517SBill.Taylor@Sun.COM ibt_hca_portinfo_t *);
509517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_ports(ibc_hca_hdl_t, uint8_t,
519517SBill.Taylor@Sun.COM ibt_port_modify_flags_t, uint8_t);
529517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_system_image(ibc_hca_hdl_t, ib_guid_t);
539517SBill.Taylor@Sun.COM
549517SBill.Taylor@Sun.COM /* Protection Domains */
559517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_pd(ibc_hca_hdl_t, ibt_pd_flags_t,
569517SBill.Taylor@Sun.COM ibc_pd_hdl_t *);
579517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_pd(ibc_hca_hdl_t, ibc_pd_hdl_t);
589517SBill.Taylor@Sun.COM
599517SBill.Taylor@Sun.COM /* Reliable Datagram Domains */
609517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_rdd(ibc_hca_hdl_t, ibc_rdd_flags_t,
619517SBill.Taylor@Sun.COM ibc_rdd_hdl_t *);
629517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_rdd(ibc_hca_hdl_t, ibc_rdd_hdl_t);
639517SBill.Taylor@Sun.COM
649517SBill.Taylor@Sun.COM /* Address Handles */
659517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_ah(ibc_hca_hdl_t, ibt_ah_flags_t,
669517SBill.Taylor@Sun.COM ibc_pd_hdl_t, ibt_adds_vect_t *, ibc_ah_hdl_t *);
679517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_ah(ibc_hca_hdl_t, ibc_ah_hdl_t);
689517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_ah(ibc_hca_hdl_t, ibc_ah_hdl_t,
699517SBill.Taylor@Sun.COM ibc_pd_hdl_t *, ibt_adds_vect_t *);
709517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_ah(ibc_hca_hdl_t, ibc_ah_hdl_t,
719517SBill.Taylor@Sun.COM ibt_adds_vect_t *);
729517SBill.Taylor@Sun.COM
739517SBill.Taylor@Sun.COM /* Queue Pairs */
749517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_qp(ibc_hca_hdl_t, ibtl_qp_hdl_t,
759517SBill.Taylor@Sun.COM ibt_qp_type_t, ibt_qp_alloc_attr_t *, ibt_chan_sizes_t *, ib_qpn_t *,
769517SBill.Taylor@Sun.COM ibc_qp_hdl_t *);
779517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_special_qp(ibc_hca_hdl_t, uint8_t,
789517SBill.Taylor@Sun.COM ibtl_qp_hdl_t, ibt_sqp_type_t, ibt_qp_alloc_attr_t *,
799517SBill.Taylor@Sun.COM ibt_chan_sizes_t *, ibc_qp_hdl_t *);
809517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_qp_range(ibc_hca_hdl_t, uint_t,
819517SBill.Taylor@Sun.COM ibtl_qp_hdl_t *, ibt_qp_type_t, ibt_qp_alloc_attr_t *, ibt_chan_sizes_t *,
829517SBill.Taylor@Sun.COM ibc_cq_hdl_t *, ibc_cq_hdl_t *, ib_qpn_t *, ibc_qp_hdl_t *);
839517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_qp(ibc_hca_hdl_t, ibc_qp_hdl_t,
849517SBill.Taylor@Sun.COM ibc_free_qp_flags_t, ibc_qpn_hdl_t *);
859517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_release_qpn(ibc_hca_hdl_t, ibc_qpn_hdl_t);
869517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_qp(ibc_hca_hdl_t, ibc_qp_hdl_t,
879517SBill.Taylor@Sun.COM ibt_qp_query_attr_t *);
889517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_qp(ibc_hca_hdl_t, ibc_qp_hdl_t,
899517SBill.Taylor@Sun.COM ibt_cep_modify_flags_t, ibt_qp_info_t *, ibt_queue_sizes_t *);
909517SBill.Taylor@Sun.COM
919517SBill.Taylor@Sun.COM /* Completion Queues */
929517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_cq(ibc_hca_hdl_t, ibt_cq_hdl_t,
939517SBill.Taylor@Sun.COM ibt_cq_attr_t *, ibc_cq_hdl_t *, uint_t *);
949517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_cq(ibc_hca_hdl_t, ibc_cq_hdl_t);
959517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_cq(ibc_hca_hdl_t, ibc_cq_hdl_t,
969517SBill.Taylor@Sun.COM uint_t *, uint_t *, uint_t *, ibt_cq_handler_id_t *);
979517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_resize_cq(ibc_hca_hdl_t, ibc_cq_hdl_t,
989517SBill.Taylor@Sun.COM uint_t, uint_t *);
999517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_cq(ibc_hca_hdl_t, ibc_cq_hdl_t,
1009517SBill.Taylor@Sun.COM uint_t, uint_t, ibt_cq_handler_id_t);
1019517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_cq_sched(ibc_hca_hdl_t,
102*12965SWilliam.Taylor@Oracle.COM ibt_cq_sched_attr_t *, ibc_sched_hdl_t *);
103*12965SWilliam.Taylor@Oracle.COM static ibt_status_t hermon_ci_free_cq_sched(ibc_hca_hdl_t, ibc_sched_hdl_t);
104*12965SWilliam.Taylor@Oracle.COM static ibt_status_t hermon_ci_query_cq_handler_id(ibc_hca_hdl_t,
105*12965SWilliam.Taylor@Oracle.COM ibt_cq_handler_id_t, ibt_cq_handler_attr_t *);
1069517SBill.Taylor@Sun.COM
1079517SBill.Taylor@Sun.COM /* EE Contexts */
1089517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_eec(ibc_hca_hdl_t, ibc_eec_flags_t,
1099517SBill.Taylor@Sun.COM ibt_eec_hdl_t, ibc_rdd_hdl_t, ibc_eec_hdl_t *);
1109517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_eec(ibc_hca_hdl_t, ibc_eec_hdl_t);
1119517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_eec(ibc_hca_hdl_t, ibc_eec_hdl_t,
1129517SBill.Taylor@Sun.COM ibt_eec_query_attr_t *);
1139517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_eec(ibc_hca_hdl_t, ibc_eec_hdl_t,
1149517SBill.Taylor@Sun.COM ibt_cep_modify_flags_t, ibt_eec_info_t *);
1159517SBill.Taylor@Sun.COM
1169517SBill.Taylor@Sun.COM /* Memory Registration */
1179517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_register_mr(ibc_hca_hdl_t, ibc_pd_hdl_t,
1189517SBill.Taylor@Sun.COM ibt_mr_attr_t *, void *, ibc_mr_hdl_t *, ibt_mr_desc_t *);
1199517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_register_buf(ibc_hca_hdl_t, ibc_pd_hdl_t,
1209517SBill.Taylor@Sun.COM ibt_smr_attr_t *, struct buf *, void *, ibt_mr_hdl_t *, ibt_mr_desc_t *);
1219517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_register_shared_mr(ibc_hca_hdl_t,
1229517SBill.Taylor@Sun.COM ibc_mr_hdl_t, ibc_pd_hdl_t, ibt_smr_attr_t *, void *,
1239517SBill.Taylor@Sun.COM ibc_mr_hdl_t *, ibt_mr_desc_t *);
1249517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_deregister_mr(ibc_hca_hdl_t, ibc_mr_hdl_t);
1259517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_mr(ibc_hca_hdl_t, ibc_mr_hdl_t,
1269517SBill.Taylor@Sun.COM ibt_mr_query_attr_t *);
1279517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_reregister_mr(ibc_hca_hdl_t, ibc_mr_hdl_t,
1289517SBill.Taylor@Sun.COM ibc_pd_hdl_t, ibt_mr_attr_t *, void *, ibc_mr_hdl_t *,
1299517SBill.Taylor@Sun.COM ibt_mr_desc_t *);
1309517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_reregister_buf(ibc_hca_hdl_t, ibc_mr_hdl_t,
1319517SBill.Taylor@Sun.COM ibc_pd_hdl_t, ibt_smr_attr_t *, struct buf *, void *, ibc_mr_hdl_t *,
1329517SBill.Taylor@Sun.COM ibt_mr_desc_t *);
1339517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_sync_mr(ibc_hca_hdl_t, ibt_mr_sync_t *, size_t);
134*12965SWilliam.Taylor@Oracle.COM static ibt_status_t hermon_ci_register_dma_mr(ibc_hca_hdl_t, ibc_pd_hdl_t,
135*12965SWilliam.Taylor@Oracle.COM ibt_dmr_attr_t *, void *, ibc_mr_hdl_t *, ibt_mr_desc_t *);
1369517SBill.Taylor@Sun.COM
1379517SBill.Taylor@Sun.COM /* Memory Windows */
1389517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_mw(ibc_hca_hdl_t, ibc_pd_hdl_t,
1399517SBill.Taylor@Sun.COM ibt_mw_flags_t, ibc_mw_hdl_t *, ibt_rkey_t *);
1409517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_mw(ibc_hca_hdl_t, ibc_mw_hdl_t);
1419517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_mw(ibc_hca_hdl_t, ibc_mw_hdl_t,
1429517SBill.Taylor@Sun.COM ibt_mw_query_attr_t *);
1439517SBill.Taylor@Sun.COM
1449517SBill.Taylor@Sun.COM /* Multicast Groups */
1459517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_attach_mcg(ibc_hca_hdl_t, ibc_qp_hdl_t,
1469517SBill.Taylor@Sun.COM ib_gid_t, ib_lid_t);
1479517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_detach_mcg(ibc_hca_hdl_t, ibc_qp_hdl_t,
1489517SBill.Taylor@Sun.COM ib_gid_t, ib_lid_t);
1499517SBill.Taylor@Sun.COM
1509517SBill.Taylor@Sun.COM /* Work Request and Completion Processing */
1519517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_post_send(ibc_hca_hdl_t, ibc_qp_hdl_t,
1529517SBill.Taylor@Sun.COM ibt_send_wr_t *, uint_t, uint_t *);
1539517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_post_recv(ibc_hca_hdl_t, ibc_qp_hdl_t,
1549517SBill.Taylor@Sun.COM ibt_recv_wr_t *, uint_t, uint_t *);
1559517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_poll_cq(ibc_hca_hdl_t, ibc_cq_hdl_t,
1569517SBill.Taylor@Sun.COM ibt_wc_t *, uint_t, uint_t *);
1579517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_notify_cq(ibc_hca_hdl_t, ibc_cq_hdl_t,
1589517SBill.Taylor@Sun.COM ibt_cq_notify_flags_t);
1599517SBill.Taylor@Sun.COM
1609517SBill.Taylor@Sun.COM /* CI Object Private Data */
1619517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_ci_data_in(ibc_hca_hdl_t, ibt_ci_data_flags_t,
1629517SBill.Taylor@Sun.COM ibt_object_type_t, void *, void *, size_t);
1639517SBill.Taylor@Sun.COM
1649517SBill.Taylor@Sun.COM /* CI Object Private Data */
1659517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_ci_data_out(ibc_hca_hdl_t, ibt_ci_data_flags_t,
1669517SBill.Taylor@Sun.COM ibt_object_type_t, void *, void *, size_t);
1679517SBill.Taylor@Sun.COM
1689517SBill.Taylor@Sun.COM /* Shared Receive Queues */
1699517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_srq(ibc_hca_hdl_t, ibt_srq_flags_t,
1709517SBill.Taylor@Sun.COM ibt_srq_hdl_t, ibc_pd_hdl_t, ibt_srq_sizes_t *, ibc_srq_hdl_t *,
1719517SBill.Taylor@Sun.COM ibt_srq_sizes_t *);
1729517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_srq(ibc_hca_hdl_t, ibc_srq_hdl_t);
1739517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_query_srq(ibc_hca_hdl_t, ibc_srq_hdl_t,
1749517SBill.Taylor@Sun.COM ibc_pd_hdl_t *, ibt_srq_sizes_t *, uint_t *);
1759517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_modify_srq(ibc_hca_hdl_t, ibc_srq_hdl_t,
1769517SBill.Taylor@Sun.COM ibt_srq_modify_flags_t, uint_t, uint_t, uint_t *);
1779517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_post_srq(ibc_hca_hdl_t, ibc_srq_hdl_t,
1789517SBill.Taylor@Sun.COM ibt_recv_wr_t *, uint_t, uint_t *);
1799517SBill.Taylor@Sun.COM
1809517SBill.Taylor@Sun.COM /* Address translation */
1819517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_map_mem_area(ibc_hca_hdl_t, ibt_va_attr_t *,
18211972SBill.Taylor@Sun.COM void *, uint_t, ibt_reg_req_t *, ibc_ma_hdl_t *);
1839517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_unmap_mem_area(ibc_hca_hdl_t, ibc_ma_hdl_t);
1849517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_map_mem_iov(ibc_hca_hdl_t, ibt_iov_attr_t *,
1859517SBill.Taylor@Sun.COM ibt_all_wr_t *, ibc_mi_hdl_t *);
1869517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_unmap_mem_iov(ibc_hca_hdl_t, ibc_mi_hdl_t);
1879517SBill.Taylor@Sun.COM
1889517SBill.Taylor@Sun.COM /* Allocate L_Key */
1899517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_lkey(ibc_hca_hdl_t, ibc_pd_hdl_t,
1909517SBill.Taylor@Sun.COM ibt_lkey_flags_t, uint_t, ibc_mr_hdl_t *, ibt_pmr_desc_t *);
1919517SBill.Taylor@Sun.COM
1929517SBill.Taylor@Sun.COM /* Physical Register Memory Region */
1939517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_register_physical_mr(ibc_hca_hdl_t, ibc_pd_hdl_t,
1949517SBill.Taylor@Sun.COM ibt_pmr_attr_t *, void *, ibc_mr_hdl_t *, ibt_pmr_desc_t *);
1959517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_reregister_physical_mr(ibc_hca_hdl_t,
1969517SBill.Taylor@Sun.COM ibc_mr_hdl_t, ibc_pd_hdl_t, ibt_pmr_attr_t *, void *, ibc_mr_hdl_t *,
1979517SBill.Taylor@Sun.COM ibt_pmr_desc_t *);
1989517SBill.Taylor@Sun.COM
1999517SBill.Taylor@Sun.COM /* Mellanox FMR */
2009517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_create_fmr_pool(ibc_hca_hdl_t hca,
2019517SBill.Taylor@Sun.COM ibc_pd_hdl_t pd, ibt_fmr_pool_attr_t *fmr_params,
2029517SBill.Taylor@Sun.COM ibc_fmr_pool_hdl_t *fmr_pool);
2039517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_destroy_fmr_pool(ibc_hca_hdl_t hca,
2049517SBill.Taylor@Sun.COM ibc_fmr_pool_hdl_t fmr_pool);
2059517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_flush_fmr_pool(ibc_hca_hdl_t hca,
2069517SBill.Taylor@Sun.COM ibc_fmr_pool_hdl_t fmr_pool);
2079517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_register_physical_fmr(ibc_hca_hdl_t hca,
2089517SBill.Taylor@Sun.COM ibc_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr,
2099517SBill.Taylor@Sun.COM void *ibtl_reserved, ibc_mr_hdl_t *mr_hdl_p, ibt_pmr_desc_t *mem_desc_p);
2109517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_deregister_fmr(ibc_hca_hdl_t hca,
2119517SBill.Taylor@Sun.COM ibc_mr_hdl_t mr);
2129517SBill.Taylor@Sun.COM
2139517SBill.Taylor@Sun.COM /* Memory Allocation/Deallocation */
2149517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_alloc_io_mem(ibc_hca_hdl_t hca, size_t size,
2159517SBill.Taylor@Sun.COM ibt_mr_flags_t mr_flag, caddr_t *kaddrp,
2169517SBill.Taylor@Sun.COM ibc_mem_alloc_hdl_t *mem_alloc_hdl_p);
2179517SBill.Taylor@Sun.COM static ibt_status_t hermon_ci_free_io_mem(ibc_hca_hdl_t hca,
2189517SBill.Taylor@Sun.COM ibc_mem_alloc_hdl_t mem_alloc_hdl);
219*12965SWilliam.Taylor@Oracle.COM static ibt_status_t hermon_ci_not_supported();
2209517SBill.Taylor@Sun.COM
2219517SBill.Taylor@Sun.COM /*
2229517SBill.Taylor@Sun.COM * This ibc_operations_t structure includes pointers to all the entry points
2239517SBill.Taylor@Sun.COM * provided by the Hermon driver. This structure is passed to the IBTF at
2249517SBill.Taylor@Sun.COM * driver attach time, using the ibc_attach() call.
2259517SBill.Taylor@Sun.COM */
2269517SBill.Taylor@Sun.COM ibc_operations_t hermon_ibc_ops = {
2279517SBill.Taylor@Sun.COM /* HCA and port related operations */
2289517SBill.Taylor@Sun.COM hermon_ci_query_hca_ports,
2299517SBill.Taylor@Sun.COM hermon_ci_modify_ports,
2309517SBill.Taylor@Sun.COM hermon_ci_modify_system_image,
2319517SBill.Taylor@Sun.COM
2329517SBill.Taylor@Sun.COM /* Protection Domains */
2339517SBill.Taylor@Sun.COM hermon_ci_alloc_pd,
2349517SBill.Taylor@Sun.COM hermon_ci_free_pd,
2359517SBill.Taylor@Sun.COM
2369517SBill.Taylor@Sun.COM /* Reliable Datagram Domains */
2379517SBill.Taylor@Sun.COM hermon_ci_alloc_rdd,
2389517SBill.Taylor@Sun.COM hermon_ci_free_rdd,
2399517SBill.Taylor@Sun.COM
2409517SBill.Taylor@Sun.COM /* Address Handles */
2419517SBill.Taylor@Sun.COM hermon_ci_alloc_ah,
2429517SBill.Taylor@Sun.COM hermon_ci_free_ah,
2439517SBill.Taylor@Sun.COM hermon_ci_query_ah,
2449517SBill.Taylor@Sun.COM hermon_ci_modify_ah,
2459517SBill.Taylor@Sun.COM
2469517SBill.Taylor@Sun.COM /* Queue Pairs */
2479517SBill.Taylor@Sun.COM hermon_ci_alloc_qp,
2489517SBill.Taylor@Sun.COM hermon_ci_alloc_special_qp,
2499517SBill.Taylor@Sun.COM hermon_ci_alloc_qp_range,
2509517SBill.Taylor@Sun.COM hermon_ci_free_qp,
2519517SBill.Taylor@Sun.COM hermon_ci_release_qpn,
2529517SBill.Taylor@Sun.COM hermon_ci_query_qp,
2539517SBill.Taylor@Sun.COM hermon_ci_modify_qp,
2549517SBill.Taylor@Sun.COM
2559517SBill.Taylor@Sun.COM /* Completion Queues */
2569517SBill.Taylor@Sun.COM hermon_ci_alloc_cq,
2579517SBill.Taylor@Sun.COM hermon_ci_free_cq,
2589517SBill.Taylor@Sun.COM hermon_ci_query_cq,
2599517SBill.Taylor@Sun.COM hermon_ci_resize_cq,
2609517SBill.Taylor@Sun.COM hermon_ci_modify_cq,
2619517SBill.Taylor@Sun.COM hermon_ci_alloc_cq_sched,
2629517SBill.Taylor@Sun.COM hermon_ci_free_cq_sched,
263*12965SWilliam.Taylor@Oracle.COM hermon_ci_query_cq_handler_id,
2649517SBill.Taylor@Sun.COM
2659517SBill.Taylor@Sun.COM /* EE Contexts */
2669517SBill.Taylor@Sun.COM hermon_ci_alloc_eec,
2679517SBill.Taylor@Sun.COM hermon_ci_free_eec,
2689517SBill.Taylor@Sun.COM hermon_ci_query_eec,
2699517SBill.Taylor@Sun.COM hermon_ci_modify_eec,
2709517SBill.Taylor@Sun.COM
2719517SBill.Taylor@Sun.COM /* Memory Registration */
2729517SBill.Taylor@Sun.COM hermon_ci_register_mr,
2739517SBill.Taylor@Sun.COM hermon_ci_register_buf,
2749517SBill.Taylor@Sun.COM hermon_ci_register_shared_mr,
2759517SBill.Taylor@Sun.COM hermon_ci_deregister_mr,
2769517SBill.Taylor@Sun.COM hermon_ci_query_mr,
2779517SBill.Taylor@Sun.COM hermon_ci_reregister_mr,
2789517SBill.Taylor@Sun.COM hermon_ci_reregister_buf,
2799517SBill.Taylor@Sun.COM hermon_ci_sync_mr,
2809517SBill.Taylor@Sun.COM
2819517SBill.Taylor@Sun.COM /* Memory Windows */
2829517SBill.Taylor@Sun.COM hermon_ci_alloc_mw,
2839517SBill.Taylor@Sun.COM hermon_ci_free_mw,
2849517SBill.Taylor@Sun.COM hermon_ci_query_mw,
2859517SBill.Taylor@Sun.COM
2869517SBill.Taylor@Sun.COM /* Multicast Groups */
2879517SBill.Taylor@Sun.COM hermon_ci_attach_mcg,
2889517SBill.Taylor@Sun.COM hermon_ci_detach_mcg,
2899517SBill.Taylor@Sun.COM
2909517SBill.Taylor@Sun.COM /* Work Request and Completion Processing */
2919517SBill.Taylor@Sun.COM hermon_ci_post_send,
2929517SBill.Taylor@Sun.COM hermon_ci_post_recv,
2939517SBill.Taylor@Sun.COM hermon_ci_poll_cq,
2949517SBill.Taylor@Sun.COM hermon_ci_notify_cq,
2959517SBill.Taylor@Sun.COM
2969517SBill.Taylor@Sun.COM /* CI Object Mapping Data */
2979517SBill.Taylor@Sun.COM hermon_ci_ci_data_in,
2989517SBill.Taylor@Sun.COM hermon_ci_ci_data_out,
2999517SBill.Taylor@Sun.COM
3009517SBill.Taylor@Sun.COM /* Shared Receive Queue */
3019517SBill.Taylor@Sun.COM hermon_ci_alloc_srq,
3029517SBill.Taylor@Sun.COM hermon_ci_free_srq,
3039517SBill.Taylor@Sun.COM hermon_ci_query_srq,
3049517SBill.Taylor@Sun.COM hermon_ci_modify_srq,
3059517SBill.Taylor@Sun.COM hermon_ci_post_srq,
3069517SBill.Taylor@Sun.COM
3079517SBill.Taylor@Sun.COM /* Address translation */
3089517SBill.Taylor@Sun.COM hermon_ci_map_mem_area,
3099517SBill.Taylor@Sun.COM hermon_ci_unmap_mem_area,
3109517SBill.Taylor@Sun.COM hermon_ci_map_mem_iov,
3119517SBill.Taylor@Sun.COM hermon_ci_unmap_mem_iov,
3129517SBill.Taylor@Sun.COM
3139517SBill.Taylor@Sun.COM /* Allocate L_key */
3149517SBill.Taylor@Sun.COM hermon_ci_alloc_lkey,
3159517SBill.Taylor@Sun.COM
3169517SBill.Taylor@Sun.COM /* Physical Register Memory Region */
3179517SBill.Taylor@Sun.COM hermon_ci_register_physical_mr,
3189517SBill.Taylor@Sun.COM hermon_ci_reregister_physical_mr,
3199517SBill.Taylor@Sun.COM
3209517SBill.Taylor@Sun.COM /* Mellanox FMR */
3219517SBill.Taylor@Sun.COM hermon_ci_create_fmr_pool,
3229517SBill.Taylor@Sun.COM hermon_ci_destroy_fmr_pool,
3239517SBill.Taylor@Sun.COM hermon_ci_flush_fmr_pool,
3249517SBill.Taylor@Sun.COM hermon_ci_register_physical_fmr,
3259517SBill.Taylor@Sun.COM hermon_ci_deregister_fmr,
3269517SBill.Taylor@Sun.COM
3279517SBill.Taylor@Sun.COM /* Memory allocation */
3289517SBill.Taylor@Sun.COM hermon_ci_alloc_io_mem,
3299517SBill.Taylor@Sun.COM hermon_ci_free_io_mem,
330*12965SWilliam.Taylor@Oracle.COM
331*12965SWilliam.Taylor@Oracle.COM /* XRC not yet supported */
332*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_alloc_xrc_domain */
333*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_free_xrc_domain */
334*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_alloc_xrc_srq */
335*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_free_xrc_srq */
336*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_query_xrc_srq */
337*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_modify_xrc_srq */
338*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_alloc_xrc_tgt_qp */
339*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_free_xrc_tgt_qp */
340*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_query_xrc_tgt_qp */
341*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_modify_xrc_tgt_qp */
342*12965SWilliam.Taylor@Oracle.COM
343*12965SWilliam.Taylor@Oracle.COM /* Memory Region (physical) */
344*12965SWilliam.Taylor@Oracle.COM hermon_ci_register_dma_mr,
345*12965SWilliam.Taylor@Oracle.COM
346*12965SWilliam.Taylor@Oracle.COM /* Next enhancements */
347*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_enhancement1 */
348*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_enhancement2 */
349*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_enhancement3 */
350*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported, /* ibc_enhancement4 */
3519517SBill.Taylor@Sun.COM };
3529517SBill.Taylor@Sun.COM
353*12965SWilliam.Taylor@Oracle.COM /*
354*12965SWilliam.Taylor@Oracle.COM * Not yet implemented OPS
355*12965SWilliam.Taylor@Oracle.COM */
356*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
357*12965SWilliam.Taylor@Oracle.COM static ibt_status_t
hermon_ci_not_supported()358*12965SWilliam.Taylor@Oracle.COM hermon_ci_not_supported()
359*12965SWilliam.Taylor@Oracle.COM {
360*12965SWilliam.Taylor@Oracle.COM return (IBT_NOT_SUPPORTED);
361*12965SWilliam.Taylor@Oracle.COM }
362*12965SWilliam.Taylor@Oracle.COM
3639517SBill.Taylor@Sun.COM
3649517SBill.Taylor@Sun.COM /*
3659517SBill.Taylor@Sun.COM * hermon_ci_query_hca_ports()
3669517SBill.Taylor@Sun.COM * Returns HCA port attributes for either one or all of the HCA's ports.
3679517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
3689517SBill.Taylor@Sun.COM */
3699517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_hca_ports(ibc_hca_hdl_t hca,uint8_t query_port,ibt_hca_portinfo_t * info_p)3709517SBill.Taylor@Sun.COM hermon_ci_query_hca_ports(ibc_hca_hdl_t hca, uint8_t query_port,
3719517SBill.Taylor@Sun.COM ibt_hca_portinfo_t *info_p)
3729517SBill.Taylor@Sun.COM {
3739517SBill.Taylor@Sun.COM hermon_state_t *state;
3749517SBill.Taylor@Sun.COM uint_t start, end, port;
3759517SBill.Taylor@Sun.COM int status, indx;
3769517SBill.Taylor@Sun.COM
3779517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
3789517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
3799517SBill.Taylor@Sun.COM
3809517SBill.Taylor@Sun.COM /*
3819517SBill.Taylor@Sun.COM * If the specified port is zero, then we are supposed to query all
3829517SBill.Taylor@Sun.COM * ports. Otherwise, we query only the port number specified.
3839517SBill.Taylor@Sun.COM * Setup the start and end port numbers as appropriate for the loop
3849517SBill.Taylor@Sun.COM * below. Note: The first Hermon port is port number one (1).
3859517SBill.Taylor@Sun.COM */
3869517SBill.Taylor@Sun.COM if (query_port == 0) {
3879517SBill.Taylor@Sun.COM start = 1;
3889517SBill.Taylor@Sun.COM end = start + (state->hs_cfg_profile->cp_num_ports - 1);
3899517SBill.Taylor@Sun.COM } else {
3909517SBill.Taylor@Sun.COM end = start = query_port;
3919517SBill.Taylor@Sun.COM }
3929517SBill.Taylor@Sun.COM
3939517SBill.Taylor@Sun.COM /* Query the port(s) */
3949517SBill.Taylor@Sun.COM for (port = start, indx = 0; port <= end; port++, indx++) {
3959517SBill.Taylor@Sun.COM status = hermon_port_query(state, port, &info_p[indx]);
3969517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
3979517SBill.Taylor@Sun.COM return (status);
3989517SBill.Taylor@Sun.COM }
3999517SBill.Taylor@Sun.COM }
4009517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
4019517SBill.Taylor@Sun.COM }
4029517SBill.Taylor@Sun.COM
4039517SBill.Taylor@Sun.COM
4049517SBill.Taylor@Sun.COM /*
4059517SBill.Taylor@Sun.COM * hermon_ci_modify_ports()
4069517SBill.Taylor@Sun.COM * Modify HCA port attributes
4079517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
4089517SBill.Taylor@Sun.COM */
4099517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_ports(ibc_hca_hdl_t hca,uint8_t port,ibt_port_modify_flags_t flags,uint8_t init_type)4109517SBill.Taylor@Sun.COM hermon_ci_modify_ports(ibc_hca_hdl_t hca, uint8_t port,
4119517SBill.Taylor@Sun.COM ibt_port_modify_flags_t flags, uint8_t init_type)
4129517SBill.Taylor@Sun.COM {
4139517SBill.Taylor@Sun.COM hermon_state_t *state;
4149517SBill.Taylor@Sun.COM int status;
4159517SBill.Taylor@Sun.COM
4169517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
4179517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
4189517SBill.Taylor@Sun.COM
4199517SBill.Taylor@Sun.COM /* Modify the port(s) */
4209517SBill.Taylor@Sun.COM status = hermon_port_modify(state, port, flags, init_type);
4219517SBill.Taylor@Sun.COM return (status);
4229517SBill.Taylor@Sun.COM }
4239517SBill.Taylor@Sun.COM
4249517SBill.Taylor@Sun.COM /*
4259517SBill.Taylor@Sun.COM * hermon_ci_modify_system_image()
4269517SBill.Taylor@Sun.COM * Modify the System Image GUID
4279517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
4289517SBill.Taylor@Sun.COM */
4299517SBill.Taylor@Sun.COM /* ARGSUSED */
4309517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_system_image(ibc_hca_hdl_t hca,ib_guid_t sys_guid)4319517SBill.Taylor@Sun.COM hermon_ci_modify_system_image(ibc_hca_hdl_t hca, ib_guid_t sys_guid)
4329517SBill.Taylor@Sun.COM {
4339517SBill.Taylor@Sun.COM /*
4349517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
4359517SBill.Taylor@Sun.COM * interface is necessary to support modification of the System
4369517SBill.Taylor@Sun.COM * Image GUID. Hermon is only capable of modifying this parameter
4379517SBill.Taylor@Sun.COM * once (during driver initialization).
4389517SBill.Taylor@Sun.COM */
4399517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
4409517SBill.Taylor@Sun.COM }
4419517SBill.Taylor@Sun.COM
4429517SBill.Taylor@Sun.COM /*
4439517SBill.Taylor@Sun.COM * hermon_ci_alloc_pd()
4449517SBill.Taylor@Sun.COM * Allocate a Protection Domain
4459517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
4469517SBill.Taylor@Sun.COM */
4479517SBill.Taylor@Sun.COM /* ARGSUSED */
4489517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_pd(ibc_hca_hdl_t hca,ibt_pd_flags_t flags,ibc_pd_hdl_t * pd_p)4499517SBill.Taylor@Sun.COM hermon_ci_alloc_pd(ibc_hca_hdl_t hca, ibt_pd_flags_t flags, ibc_pd_hdl_t *pd_p)
4509517SBill.Taylor@Sun.COM {
4519517SBill.Taylor@Sun.COM hermon_state_t *state;
4529517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
4539517SBill.Taylor@Sun.COM int status;
4549517SBill.Taylor@Sun.COM
4559517SBill.Taylor@Sun.COM ASSERT(pd_p != NULL);
4569517SBill.Taylor@Sun.COM
4579517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
4589517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
4599517SBill.Taylor@Sun.COM
4609517SBill.Taylor@Sun.COM /* Allocate the PD */
4619517SBill.Taylor@Sun.COM status = hermon_pd_alloc(state, &pdhdl, HERMON_NOSLEEP);
4629517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
4639517SBill.Taylor@Sun.COM return (status);
4649517SBill.Taylor@Sun.COM }
4659517SBill.Taylor@Sun.COM
4669517SBill.Taylor@Sun.COM /* Return the Hermon PD handle */
4679517SBill.Taylor@Sun.COM *pd_p = (ibc_pd_hdl_t)pdhdl;
4689517SBill.Taylor@Sun.COM
4699517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
4709517SBill.Taylor@Sun.COM }
4719517SBill.Taylor@Sun.COM
4729517SBill.Taylor@Sun.COM
4739517SBill.Taylor@Sun.COM /*
4749517SBill.Taylor@Sun.COM * hermon_ci_free_pd()
4759517SBill.Taylor@Sun.COM * Free a Protection Domain
4769517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context
4779517SBill.Taylor@Sun.COM */
4789517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_pd(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd)4799517SBill.Taylor@Sun.COM hermon_ci_free_pd(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd)
4809517SBill.Taylor@Sun.COM {
4819517SBill.Taylor@Sun.COM hermon_state_t *state;
4829517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
4839517SBill.Taylor@Sun.COM int status;
4849517SBill.Taylor@Sun.COM
4859517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and PD handle */
4869517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
4879517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
4889517SBill.Taylor@Sun.COM
4899517SBill.Taylor@Sun.COM /* Free the PD */
4909517SBill.Taylor@Sun.COM status = hermon_pd_free(state, &pdhdl);
4919517SBill.Taylor@Sun.COM return (status);
4929517SBill.Taylor@Sun.COM }
4939517SBill.Taylor@Sun.COM
4949517SBill.Taylor@Sun.COM
4959517SBill.Taylor@Sun.COM /*
4969517SBill.Taylor@Sun.COM * hermon_ci_alloc_rdd()
4979517SBill.Taylor@Sun.COM * Allocate a Reliable Datagram Domain
4989517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
4999517SBill.Taylor@Sun.COM */
5009517SBill.Taylor@Sun.COM /* ARGSUSED */
5019517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_rdd(ibc_hca_hdl_t hca,ibc_rdd_flags_t flags,ibc_rdd_hdl_t * rdd_p)5029517SBill.Taylor@Sun.COM hermon_ci_alloc_rdd(ibc_hca_hdl_t hca, ibc_rdd_flags_t flags,
5039517SBill.Taylor@Sun.COM ibc_rdd_hdl_t *rdd_p)
5049517SBill.Taylor@Sun.COM {
5059517SBill.Taylor@Sun.COM /*
5069517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
5079517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
5089517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
5099517SBill.Taylor@Sun.COM */
5109517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
5119517SBill.Taylor@Sun.COM }
5129517SBill.Taylor@Sun.COM
5139517SBill.Taylor@Sun.COM
5149517SBill.Taylor@Sun.COM /*
5159517SBill.Taylor@Sun.COM * hermon_free_rdd()
5169517SBill.Taylor@Sun.COM * Free a Reliable Datagram Domain
5179517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
5189517SBill.Taylor@Sun.COM */
5199517SBill.Taylor@Sun.COM /* ARGSUSED */
5209517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_rdd(ibc_hca_hdl_t hca,ibc_rdd_hdl_t rdd)5219517SBill.Taylor@Sun.COM hermon_ci_free_rdd(ibc_hca_hdl_t hca, ibc_rdd_hdl_t rdd)
5229517SBill.Taylor@Sun.COM {
5239517SBill.Taylor@Sun.COM /*
5249517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
5259517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
5269517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
5279517SBill.Taylor@Sun.COM */
5289517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
5299517SBill.Taylor@Sun.COM }
5309517SBill.Taylor@Sun.COM
5319517SBill.Taylor@Sun.COM
5329517SBill.Taylor@Sun.COM /*
5339517SBill.Taylor@Sun.COM * hermon_ci_alloc_ah()
5349517SBill.Taylor@Sun.COM * Allocate an Address Handle
5359517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
5369517SBill.Taylor@Sun.COM */
5379517SBill.Taylor@Sun.COM /* ARGSUSED */
5389517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_ah(ibc_hca_hdl_t hca,ibt_ah_flags_t flags,ibc_pd_hdl_t pd,ibt_adds_vect_t * attr_p,ibc_ah_hdl_t * ah_p)5399517SBill.Taylor@Sun.COM hermon_ci_alloc_ah(ibc_hca_hdl_t hca, ibt_ah_flags_t flags, ibc_pd_hdl_t pd,
5409517SBill.Taylor@Sun.COM ibt_adds_vect_t *attr_p, ibc_ah_hdl_t *ah_p)
5419517SBill.Taylor@Sun.COM {
5429517SBill.Taylor@Sun.COM hermon_state_t *state;
5439517SBill.Taylor@Sun.COM hermon_ahhdl_t ahhdl;
5449517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
5459517SBill.Taylor@Sun.COM int status;
5469517SBill.Taylor@Sun.COM
5479517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and PD handle */
5489517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
5499517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
5509517SBill.Taylor@Sun.COM
5519517SBill.Taylor@Sun.COM /* Allocate the AH */
5529517SBill.Taylor@Sun.COM status = hermon_ah_alloc(state, pdhdl, attr_p, &ahhdl, HERMON_NOSLEEP);
5539517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
5549517SBill.Taylor@Sun.COM return (status);
5559517SBill.Taylor@Sun.COM }
5569517SBill.Taylor@Sun.COM
5579517SBill.Taylor@Sun.COM /* Return the Hermon AH handle */
5589517SBill.Taylor@Sun.COM *ah_p = (ibc_ah_hdl_t)ahhdl;
5599517SBill.Taylor@Sun.COM
5609517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
5619517SBill.Taylor@Sun.COM }
5629517SBill.Taylor@Sun.COM
5639517SBill.Taylor@Sun.COM
5649517SBill.Taylor@Sun.COM /*
5659517SBill.Taylor@Sun.COM * hermon_ci_free_ah()
5669517SBill.Taylor@Sun.COM * Free an Address Handle
5679517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
5689517SBill.Taylor@Sun.COM */
5699517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_ah(ibc_hca_hdl_t hca,ibc_ah_hdl_t ah)5709517SBill.Taylor@Sun.COM hermon_ci_free_ah(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah)
5719517SBill.Taylor@Sun.COM {
5729517SBill.Taylor@Sun.COM hermon_state_t *state;
5739517SBill.Taylor@Sun.COM hermon_ahhdl_t ahhdl;
5749517SBill.Taylor@Sun.COM int status;
5759517SBill.Taylor@Sun.COM
5769517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and AH handle */
5779517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
5789517SBill.Taylor@Sun.COM ahhdl = (hermon_ahhdl_t)ah;
5799517SBill.Taylor@Sun.COM
5809517SBill.Taylor@Sun.COM /* Free the AH */
5819517SBill.Taylor@Sun.COM status = hermon_ah_free(state, &ahhdl, HERMON_NOSLEEP);
5829517SBill.Taylor@Sun.COM
5839517SBill.Taylor@Sun.COM return (status);
5849517SBill.Taylor@Sun.COM }
5859517SBill.Taylor@Sun.COM
5869517SBill.Taylor@Sun.COM
5879517SBill.Taylor@Sun.COM /*
5889517SBill.Taylor@Sun.COM * hermon_ci_query_ah()
5899517SBill.Taylor@Sun.COM * Return the Address Vector information for a specified Address Handle
5909517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
5919517SBill.Taylor@Sun.COM */
5929517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_ah(ibc_hca_hdl_t hca,ibc_ah_hdl_t ah,ibc_pd_hdl_t * pd_p,ibt_adds_vect_t * attr_p)5939517SBill.Taylor@Sun.COM hermon_ci_query_ah(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah, ibc_pd_hdl_t *pd_p,
5949517SBill.Taylor@Sun.COM ibt_adds_vect_t *attr_p)
5959517SBill.Taylor@Sun.COM {
5969517SBill.Taylor@Sun.COM hermon_state_t *state;
5979517SBill.Taylor@Sun.COM hermon_ahhdl_t ahhdl;
5989517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
5999517SBill.Taylor@Sun.COM int status;
6009517SBill.Taylor@Sun.COM
6019517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and AH handle */
6029517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
6039517SBill.Taylor@Sun.COM ahhdl = (hermon_ahhdl_t)ah;
6049517SBill.Taylor@Sun.COM
6059517SBill.Taylor@Sun.COM /* Query the AH */
6069517SBill.Taylor@Sun.COM status = hermon_ah_query(state, ahhdl, &pdhdl, attr_p);
6079517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
6089517SBill.Taylor@Sun.COM return (status);
6099517SBill.Taylor@Sun.COM }
6109517SBill.Taylor@Sun.COM
6119517SBill.Taylor@Sun.COM /* Return the Hermon PD handle */
6129517SBill.Taylor@Sun.COM *pd_p = (ibc_pd_hdl_t)pdhdl;
6139517SBill.Taylor@Sun.COM
6149517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
6159517SBill.Taylor@Sun.COM }
6169517SBill.Taylor@Sun.COM
6179517SBill.Taylor@Sun.COM
6189517SBill.Taylor@Sun.COM /*
6199517SBill.Taylor@Sun.COM * hermon_ci_modify_ah()
6209517SBill.Taylor@Sun.COM * Modify the Address Vector information of a specified Address Handle
6219517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
6229517SBill.Taylor@Sun.COM */
6239517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_ah(ibc_hca_hdl_t hca,ibc_ah_hdl_t ah,ibt_adds_vect_t * attr_p)6249517SBill.Taylor@Sun.COM hermon_ci_modify_ah(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah, ibt_adds_vect_t *attr_p)
6259517SBill.Taylor@Sun.COM {
6269517SBill.Taylor@Sun.COM hermon_state_t *state;
6279517SBill.Taylor@Sun.COM hermon_ahhdl_t ahhdl;
6289517SBill.Taylor@Sun.COM int status;
6299517SBill.Taylor@Sun.COM
6309517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and AH handle */
6319517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
6329517SBill.Taylor@Sun.COM ahhdl = (hermon_ahhdl_t)ah;
6339517SBill.Taylor@Sun.COM
6349517SBill.Taylor@Sun.COM /* Modify the AH */
6359517SBill.Taylor@Sun.COM status = hermon_ah_modify(state, ahhdl, attr_p);
6369517SBill.Taylor@Sun.COM
6379517SBill.Taylor@Sun.COM return (status);
6389517SBill.Taylor@Sun.COM }
6399517SBill.Taylor@Sun.COM
6409517SBill.Taylor@Sun.COM
6419517SBill.Taylor@Sun.COM /*
6429517SBill.Taylor@Sun.COM * hermon_ci_alloc_qp()
6439517SBill.Taylor@Sun.COM * Allocate a Queue Pair
6449517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
6459517SBill.Taylor@Sun.COM */
6469517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_qp(ibc_hca_hdl_t hca,ibtl_qp_hdl_t ibt_qphdl,ibt_qp_type_t type,ibt_qp_alloc_attr_t * attr_p,ibt_chan_sizes_t * queue_sizes_p,ib_qpn_t * qpn,ibc_qp_hdl_t * qp_p)6479517SBill.Taylor@Sun.COM hermon_ci_alloc_qp(ibc_hca_hdl_t hca, ibtl_qp_hdl_t ibt_qphdl,
6489517SBill.Taylor@Sun.COM ibt_qp_type_t type, ibt_qp_alloc_attr_t *attr_p,
6499517SBill.Taylor@Sun.COM ibt_chan_sizes_t *queue_sizes_p, ib_qpn_t *qpn, ibc_qp_hdl_t *qp_p)
6509517SBill.Taylor@Sun.COM {
6519517SBill.Taylor@Sun.COM hermon_state_t *state;
652*12965SWilliam.Taylor@Oracle.COM hermon_qp_info_t qpinfo;
6539517SBill.Taylor@Sun.COM int status;
6549517SBill.Taylor@Sun.COM
6559517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*attr_p))
6569517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*queue_sizes_p))
6579517SBill.Taylor@Sun.COM
6589517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
6599517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
6609517SBill.Taylor@Sun.COM
6619517SBill.Taylor@Sun.COM /* Allocate the QP */
6629517SBill.Taylor@Sun.COM qpinfo.qpi_attrp = attr_p;
6639517SBill.Taylor@Sun.COM qpinfo.qpi_type = type;
6649517SBill.Taylor@Sun.COM qpinfo.qpi_ibt_qphdl = ibt_qphdl;
6659517SBill.Taylor@Sun.COM qpinfo.qpi_queueszp = queue_sizes_p;
6669517SBill.Taylor@Sun.COM qpinfo.qpi_qpn = qpn;
6679517SBill.Taylor@Sun.COM status = hermon_qp_alloc(state, &qpinfo, HERMON_NOSLEEP);
6689517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
6699517SBill.Taylor@Sun.COM return (status);
6709517SBill.Taylor@Sun.COM }
6719517SBill.Taylor@Sun.COM
6729517SBill.Taylor@Sun.COM /* Return the Hermon QP handle */
6739517SBill.Taylor@Sun.COM *qp_p = (ibc_qp_hdl_t)qpinfo.qpi_qphdl;
6749517SBill.Taylor@Sun.COM
6759517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
6769517SBill.Taylor@Sun.COM }
6779517SBill.Taylor@Sun.COM
6789517SBill.Taylor@Sun.COM
6799517SBill.Taylor@Sun.COM /*
6809517SBill.Taylor@Sun.COM * hermon_ci_alloc_special_qp()
6819517SBill.Taylor@Sun.COM * Allocate a Special Queue Pair
6829517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
6839517SBill.Taylor@Sun.COM */
6849517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_special_qp(ibc_hca_hdl_t hca,uint8_t port,ibtl_qp_hdl_t ibt_qphdl,ibt_sqp_type_t type,ibt_qp_alloc_attr_t * attr_p,ibt_chan_sizes_t * queue_sizes_p,ibc_qp_hdl_t * qp_p)6859517SBill.Taylor@Sun.COM hermon_ci_alloc_special_qp(ibc_hca_hdl_t hca, uint8_t port,
6869517SBill.Taylor@Sun.COM ibtl_qp_hdl_t ibt_qphdl, ibt_sqp_type_t type,
6879517SBill.Taylor@Sun.COM ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p,
6889517SBill.Taylor@Sun.COM ibc_qp_hdl_t *qp_p)
6899517SBill.Taylor@Sun.COM {
6909517SBill.Taylor@Sun.COM hermon_state_t *state;
691*12965SWilliam.Taylor@Oracle.COM hermon_qp_info_t qpinfo;
6929517SBill.Taylor@Sun.COM int status;
6939517SBill.Taylor@Sun.COM
6949517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*attr_p))
6959517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*queue_sizes_p))
6969517SBill.Taylor@Sun.COM
6979517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
6989517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
6999517SBill.Taylor@Sun.COM
7009517SBill.Taylor@Sun.COM /* Allocate the Special QP */
7019517SBill.Taylor@Sun.COM qpinfo.qpi_attrp = attr_p;
7029517SBill.Taylor@Sun.COM qpinfo.qpi_type = type;
7039517SBill.Taylor@Sun.COM qpinfo.qpi_port = port;
7049517SBill.Taylor@Sun.COM qpinfo.qpi_ibt_qphdl = ibt_qphdl;
7059517SBill.Taylor@Sun.COM qpinfo.qpi_queueszp = queue_sizes_p;
7069517SBill.Taylor@Sun.COM status = hermon_special_qp_alloc(state, &qpinfo, HERMON_NOSLEEP);
7079517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
7089517SBill.Taylor@Sun.COM return (status);
7099517SBill.Taylor@Sun.COM }
7109517SBill.Taylor@Sun.COM /* Return the Hermon QP handle */
7119517SBill.Taylor@Sun.COM *qp_p = (ibc_qp_hdl_t)qpinfo.qpi_qphdl;
7129517SBill.Taylor@Sun.COM
7139517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
7149517SBill.Taylor@Sun.COM }
7159517SBill.Taylor@Sun.COM
716*12965SWilliam.Taylor@Oracle.COM /*
717*12965SWilliam.Taylor@Oracle.COM * hermon_ci_alloc_qp_range()
718*12965SWilliam.Taylor@Oracle.COM * Free a Queue Pair
719*12965SWilliam.Taylor@Oracle.COM * Context: Can be called only from user or kernel context.
720*12965SWilliam.Taylor@Oracle.COM */
7219517SBill.Taylor@Sun.COM /* ARGSUSED */
7229517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_qp_range(ibc_hca_hdl_t hca,uint_t log2,ibtl_qp_hdl_t * ibtl_qp,ibt_qp_type_t type,ibt_qp_alloc_attr_t * attr_p,ibt_chan_sizes_t * queue_sizes_p,ibc_cq_hdl_t * send_cq,ibc_cq_hdl_t * recv_cq,ib_qpn_t * qpn,ibc_qp_hdl_t * qp_p)7239517SBill.Taylor@Sun.COM hermon_ci_alloc_qp_range(ibc_hca_hdl_t hca, uint_t log2,
724*12965SWilliam.Taylor@Oracle.COM ibtl_qp_hdl_t *ibtl_qp, ibt_qp_type_t type,
7259517SBill.Taylor@Sun.COM ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p,
726*12965SWilliam.Taylor@Oracle.COM ibc_cq_hdl_t *send_cq, ibc_cq_hdl_t *recv_cq,
727*12965SWilliam.Taylor@Oracle.COM ib_qpn_t *qpn, ibc_qp_hdl_t *qp_p)
7289517SBill.Taylor@Sun.COM {
729*12965SWilliam.Taylor@Oracle.COM hermon_state_t *state;
730*12965SWilliam.Taylor@Oracle.COM hermon_qp_info_t qpinfo;
731*12965SWilliam.Taylor@Oracle.COM int status;
732*12965SWilliam.Taylor@Oracle.COM
733*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*attr_p))
734*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*queue_sizes_p))
735*12965SWilliam.Taylor@Oracle.COM
736*12965SWilliam.Taylor@Oracle.COM /* Grab the Hermon softstate pointer */
737*12965SWilliam.Taylor@Oracle.COM state = (hermon_state_t *)hca;
738*12965SWilliam.Taylor@Oracle.COM
739*12965SWilliam.Taylor@Oracle.COM /* Allocate the QP */
740*12965SWilliam.Taylor@Oracle.COM qpinfo.qpi_attrp = attr_p;
741*12965SWilliam.Taylor@Oracle.COM qpinfo.qpi_type = type;
742*12965SWilliam.Taylor@Oracle.COM qpinfo.qpi_queueszp = queue_sizes_p;
743*12965SWilliam.Taylor@Oracle.COM qpinfo.qpi_qpn = qpn;
744*12965SWilliam.Taylor@Oracle.COM status = hermon_qp_alloc_range(state, log2, &qpinfo, ibtl_qp,
745*12965SWilliam.Taylor@Oracle.COM send_cq, recv_cq, (hermon_qphdl_t *)qp_p, HERMON_NOSLEEP);
746*12965SWilliam.Taylor@Oracle.COM return (status);
7479517SBill.Taylor@Sun.COM }
7489517SBill.Taylor@Sun.COM
7499517SBill.Taylor@Sun.COM /*
7509517SBill.Taylor@Sun.COM * hermon_ci_free_qp()
7519517SBill.Taylor@Sun.COM * Free a Queue Pair
7529517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
7539517SBill.Taylor@Sun.COM */
7549517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_qp(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ibc_free_qp_flags_t free_qp_flags,ibc_qpn_hdl_t * qpnh_p)7559517SBill.Taylor@Sun.COM hermon_ci_free_qp(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
7569517SBill.Taylor@Sun.COM ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh_p)
7579517SBill.Taylor@Sun.COM {
7589517SBill.Taylor@Sun.COM hermon_state_t *state;
7599517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
7609517SBill.Taylor@Sun.COM int status;
7619517SBill.Taylor@Sun.COM
7629517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
7639517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
7649517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
7659517SBill.Taylor@Sun.COM
7669517SBill.Taylor@Sun.COM /* Free the QP */
7679517SBill.Taylor@Sun.COM status = hermon_qp_free(state, &qphdl, free_qp_flags, qpnh_p,
7689517SBill.Taylor@Sun.COM HERMON_NOSLEEP);
7699517SBill.Taylor@Sun.COM
7709517SBill.Taylor@Sun.COM return (status);
7719517SBill.Taylor@Sun.COM }
7729517SBill.Taylor@Sun.COM
7739517SBill.Taylor@Sun.COM
7749517SBill.Taylor@Sun.COM /*
7759517SBill.Taylor@Sun.COM * hermon_ci_release_qpn()
7769517SBill.Taylor@Sun.COM * Release a Queue Pair Number (QPN)
7779517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
7789517SBill.Taylor@Sun.COM */
7799517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_release_qpn(ibc_hca_hdl_t hca,ibc_qpn_hdl_t qpnh)7809517SBill.Taylor@Sun.COM hermon_ci_release_qpn(ibc_hca_hdl_t hca, ibc_qpn_hdl_t qpnh)
7819517SBill.Taylor@Sun.COM {
7829517SBill.Taylor@Sun.COM hermon_state_t *state;
7839517SBill.Taylor@Sun.COM hermon_qpn_entry_t *entry;
7849517SBill.Taylor@Sun.COM
7859517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
7869517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
7879517SBill.Taylor@Sun.COM entry = (hermon_qpn_entry_t *)qpnh;
7889517SBill.Taylor@Sun.COM
7899517SBill.Taylor@Sun.COM /* Release the QP number */
7909517SBill.Taylor@Sun.COM hermon_qp_release_qpn(state, entry, HERMON_QPN_RELEASE);
7919517SBill.Taylor@Sun.COM
7929517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
7939517SBill.Taylor@Sun.COM }
7949517SBill.Taylor@Sun.COM
7959517SBill.Taylor@Sun.COM
7969517SBill.Taylor@Sun.COM /*
7979517SBill.Taylor@Sun.COM * hermon_ci_query_qp()
7989517SBill.Taylor@Sun.COM * Query a Queue Pair
7999517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
8009517SBill.Taylor@Sun.COM */
8019517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_qp(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ibt_qp_query_attr_t * attr_p)8029517SBill.Taylor@Sun.COM hermon_ci_query_qp(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
8039517SBill.Taylor@Sun.COM ibt_qp_query_attr_t *attr_p)
8049517SBill.Taylor@Sun.COM {
8059517SBill.Taylor@Sun.COM hermon_state_t *state;
8069517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
8079517SBill.Taylor@Sun.COM int status;
8089517SBill.Taylor@Sun.COM
8099517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
8109517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
8119517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
8129517SBill.Taylor@Sun.COM
8139517SBill.Taylor@Sun.COM /* Query the QP */
8149517SBill.Taylor@Sun.COM status = hermon_qp_query(state, qphdl, attr_p);
8159517SBill.Taylor@Sun.COM return (status);
8169517SBill.Taylor@Sun.COM }
8179517SBill.Taylor@Sun.COM
8189517SBill.Taylor@Sun.COM
8199517SBill.Taylor@Sun.COM /*
8209517SBill.Taylor@Sun.COM * hermon_ci_modify_qp()
8219517SBill.Taylor@Sun.COM * Modify a Queue Pair
8229517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
8239517SBill.Taylor@Sun.COM */
8249517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_qp(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ibt_cep_modify_flags_t flags,ibt_qp_info_t * info_p,ibt_queue_sizes_t * actual_sz)8259517SBill.Taylor@Sun.COM hermon_ci_modify_qp(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
8269517SBill.Taylor@Sun.COM ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
8279517SBill.Taylor@Sun.COM ibt_queue_sizes_t *actual_sz)
8289517SBill.Taylor@Sun.COM {
8299517SBill.Taylor@Sun.COM hermon_state_t *state;
8309517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
8319517SBill.Taylor@Sun.COM int status;
8329517SBill.Taylor@Sun.COM
8339517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
8349517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
8359517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
8369517SBill.Taylor@Sun.COM
8379517SBill.Taylor@Sun.COM /* Modify the QP */
8389517SBill.Taylor@Sun.COM status = hermon_qp_modify(state, qphdl, flags, info_p, actual_sz);
8399517SBill.Taylor@Sun.COM return (status);
8409517SBill.Taylor@Sun.COM }
8419517SBill.Taylor@Sun.COM
8429517SBill.Taylor@Sun.COM
8439517SBill.Taylor@Sun.COM /*
8449517SBill.Taylor@Sun.COM * hermon_ci_alloc_cq()
8459517SBill.Taylor@Sun.COM * Allocate a Completion Queue
8469517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
8479517SBill.Taylor@Sun.COM */
8489517SBill.Taylor@Sun.COM /* ARGSUSED */
8499517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_cq(ibc_hca_hdl_t hca,ibt_cq_hdl_t ibt_cqhdl,ibt_cq_attr_t * attr_p,ibc_cq_hdl_t * cq_p,uint_t * actual_size)8509517SBill.Taylor@Sun.COM hermon_ci_alloc_cq(ibc_hca_hdl_t hca, ibt_cq_hdl_t ibt_cqhdl,
8519517SBill.Taylor@Sun.COM ibt_cq_attr_t *attr_p, ibc_cq_hdl_t *cq_p, uint_t *actual_size)
8529517SBill.Taylor@Sun.COM {
8539517SBill.Taylor@Sun.COM hermon_state_t *state;
8549517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
8559517SBill.Taylor@Sun.COM int status;
8569517SBill.Taylor@Sun.COM
8579517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
8589517SBill.Taylor@Sun.COM
8599517SBill.Taylor@Sun.COM /* Allocate the CQ */
8609517SBill.Taylor@Sun.COM status = hermon_cq_alloc(state, ibt_cqhdl, attr_p, actual_size,
8619517SBill.Taylor@Sun.COM &cqhdl, HERMON_NOSLEEP);
8629517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
8639517SBill.Taylor@Sun.COM return (status);
8649517SBill.Taylor@Sun.COM }
8659517SBill.Taylor@Sun.COM
8669517SBill.Taylor@Sun.COM /* Return the Hermon CQ handle */
8679517SBill.Taylor@Sun.COM *cq_p = (ibc_cq_hdl_t)cqhdl;
8689517SBill.Taylor@Sun.COM
8699517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
8709517SBill.Taylor@Sun.COM }
8719517SBill.Taylor@Sun.COM
8729517SBill.Taylor@Sun.COM
8739517SBill.Taylor@Sun.COM /*
8749517SBill.Taylor@Sun.COM * hermon_ci_free_cq()
8759517SBill.Taylor@Sun.COM * Free a Completion Queue
8769517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
8779517SBill.Taylor@Sun.COM */
8789517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq)8799517SBill.Taylor@Sun.COM hermon_ci_free_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq)
8809517SBill.Taylor@Sun.COM {
8819517SBill.Taylor@Sun.COM hermon_state_t *state;
8829517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
8839517SBill.Taylor@Sun.COM int status;
8849517SBill.Taylor@Sun.COM
8859517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and CQ handle */
8869517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
8879517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq;
8889517SBill.Taylor@Sun.COM
8899517SBill.Taylor@Sun.COM
8909517SBill.Taylor@Sun.COM /* Free the CQ */
8919517SBill.Taylor@Sun.COM status = hermon_cq_free(state, &cqhdl, HERMON_NOSLEEP);
8929517SBill.Taylor@Sun.COM return (status);
8939517SBill.Taylor@Sun.COM }
8949517SBill.Taylor@Sun.COM
8959517SBill.Taylor@Sun.COM
8969517SBill.Taylor@Sun.COM /*
8979517SBill.Taylor@Sun.COM * hermon_ci_query_cq()
8989517SBill.Taylor@Sun.COM * Return the size of a Completion Queue
8999517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
9009517SBill.Taylor@Sun.COM */
9019517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq,uint_t * entries_p,uint_t * count_p,uint_t * usec_p,ibt_cq_handler_id_t * hid_p)9029517SBill.Taylor@Sun.COM hermon_ci_query_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, uint_t *entries_p,
9039517SBill.Taylor@Sun.COM uint_t *count_p, uint_t *usec_p, ibt_cq_handler_id_t *hid_p)
9049517SBill.Taylor@Sun.COM {
905*12965SWilliam.Taylor@Oracle.COM hermon_state_t *state;
9069517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
9079517SBill.Taylor@Sun.COM
9089517SBill.Taylor@Sun.COM /* Grab the CQ handle */
909*12965SWilliam.Taylor@Oracle.COM state = (hermon_state_t *)hca;
9109517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq;
9119517SBill.Taylor@Sun.COM
9129517SBill.Taylor@Sun.COM /* Query the current CQ size */
9139517SBill.Taylor@Sun.COM *entries_p = cqhdl->cq_bufsz;
9149517SBill.Taylor@Sun.COM *count_p = cqhdl->cq_intmod_count;
9159517SBill.Taylor@Sun.COM *usec_p = cqhdl->cq_intmod_usec;
916*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*cqhdl))
917*12965SWilliam.Taylor@Oracle.COM *hid_p = HERMON_EQNUM_TO_HID(state, cqhdl->cq_eqnum);
9189517SBill.Taylor@Sun.COM
9199517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
9209517SBill.Taylor@Sun.COM }
9219517SBill.Taylor@Sun.COM
9229517SBill.Taylor@Sun.COM
9239517SBill.Taylor@Sun.COM /*
9249517SBill.Taylor@Sun.COM * hermon_ci_resize_cq()
9259517SBill.Taylor@Sun.COM * Change the size of a Completion Queue
9269517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
9279517SBill.Taylor@Sun.COM */
9289517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_resize_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq,uint_t size,uint_t * actual_size)9299517SBill.Taylor@Sun.COM hermon_ci_resize_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, uint_t size,
9309517SBill.Taylor@Sun.COM uint_t *actual_size)
9319517SBill.Taylor@Sun.COM {
9329517SBill.Taylor@Sun.COM hermon_state_t *state;
9339517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
9349517SBill.Taylor@Sun.COM int status;
9359517SBill.Taylor@Sun.COM
9369517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and CQ handle */
9379517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
9389517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq;
9399517SBill.Taylor@Sun.COM
9409517SBill.Taylor@Sun.COM /* Resize the CQ */
9419517SBill.Taylor@Sun.COM status = hermon_cq_resize(state, cqhdl, size, actual_size,
9429517SBill.Taylor@Sun.COM HERMON_NOSLEEP);
9439517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
9449517SBill.Taylor@Sun.COM return (status);
9459517SBill.Taylor@Sun.COM }
9469517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
9479517SBill.Taylor@Sun.COM }
9489517SBill.Taylor@Sun.COM
9499517SBill.Taylor@Sun.COM /*
9509517SBill.Taylor@Sun.COM * hermon_ci_modify_cq()
9519517SBill.Taylor@Sun.COM * Change the interrupt moderation values of a Completion Queue
9529517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
9539517SBill.Taylor@Sun.COM */
9549517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq,uint_t count,uint_t usec,ibt_cq_handler_id_t hid)9559517SBill.Taylor@Sun.COM hermon_ci_modify_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, uint_t count,
9569517SBill.Taylor@Sun.COM uint_t usec, ibt_cq_handler_id_t hid)
9579517SBill.Taylor@Sun.COM {
9589517SBill.Taylor@Sun.COM hermon_state_t *state;
9599517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
9609517SBill.Taylor@Sun.COM int status;
9619517SBill.Taylor@Sun.COM
9629517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and CQ handle */
9639517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
9649517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq;
9659517SBill.Taylor@Sun.COM
9669517SBill.Taylor@Sun.COM /* Resize the CQ */
9679517SBill.Taylor@Sun.COM status = hermon_cq_modify(state, cqhdl, count, usec, hid,
9689517SBill.Taylor@Sun.COM HERMON_NOSLEEP);
9699517SBill.Taylor@Sun.COM return (status);
9709517SBill.Taylor@Sun.COM }
9719517SBill.Taylor@Sun.COM
9729517SBill.Taylor@Sun.COM
9739517SBill.Taylor@Sun.COM /*
9749517SBill.Taylor@Sun.COM * hermon_ci_alloc_cq_sched()
9759517SBill.Taylor@Sun.COM * Reserve a CQ scheduling class resource
9769517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
9779517SBill.Taylor@Sun.COM */
9789517SBill.Taylor@Sun.COM /* ARGSUSED */
9799517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_cq_sched(ibc_hca_hdl_t hca,ibt_cq_sched_attr_t * attr,ibc_sched_hdl_t * sched_hdl_p)980*12965SWilliam.Taylor@Oracle.COM hermon_ci_alloc_cq_sched(ibc_hca_hdl_t hca, ibt_cq_sched_attr_t *attr,
981*12965SWilliam.Taylor@Oracle.COM ibc_sched_hdl_t *sched_hdl_p)
9829517SBill.Taylor@Sun.COM {
983*12965SWilliam.Taylor@Oracle.COM int status;
984*12965SWilliam.Taylor@Oracle.COM
985*12965SWilliam.Taylor@Oracle.COM status = hermon_cq_sched_alloc((hermon_state_t *)hca, attr,
986*12965SWilliam.Taylor@Oracle.COM (hermon_cq_sched_t **)sched_hdl_p);
987*12965SWilliam.Taylor@Oracle.COM return (status);
9889517SBill.Taylor@Sun.COM }
9899517SBill.Taylor@Sun.COM
9909517SBill.Taylor@Sun.COM
9919517SBill.Taylor@Sun.COM /*
9929517SBill.Taylor@Sun.COM * hermon_ci_free_cq_sched()
9939517SBill.Taylor@Sun.COM * Free a CQ scheduling class resource
9949517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
9959517SBill.Taylor@Sun.COM */
996*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
9979517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_cq_sched(ibc_hca_hdl_t hca,ibc_sched_hdl_t sched_hdl)998*12965SWilliam.Taylor@Oracle.COM hermon_ci_free_cq_sched(ibc_hca_hdl_t hca, ibc_sched_hdl_t sched_hdl)
9999517SBill.Taylor@Sun.COM {
1000*12965SWilliam.Taylor@Oracle.COM int status;
1001*12965SWilliam.Taylor@Oracle.COM
1002*12965SWilliam.Taylor@Oracle.COM status = hermon_cq_sched_free((hermon_state_t *)hca,
1003*12965SWilliam.Taylor@Oracle.COM (hermon_cq_sched_t *)sched_hdl);
1004*12965SWilliam.Taylor@Oracle.COM return (status);
1005*12965SWilliam.Taylor@Oracle.COM }
1006*12965SWilliam.Taylor@Oracle.COM
1007*12965SWilliam.Taylor@Oracle.COM static ibt_status_t
hermon_ci_query_cq_handler_id(ibc_hca_hdl_t hca,ibt_cq_handler_id_t hid,ibt_cq_handler_attr_t * attrs)1008*12965SWilliam.Taylor@Oracle.COM hermon_ci_query_cq_handler_id(ibc_hca_hdl_t hca,
1009*12965SWilliam.Taylor@Oracle.COM ibt_cq_handler_id_t hid, ibt_cq_handler_attr_t *attrs)
1010*12965SWilliam.Taylor@Oracle.COM {
1011*12965SWilliam.Taylor@Oracle.COM hermon_state_t *state;
1012*12965SWilliam.Taylor@Oracle.COM
1013*12965SWilliam.Taylor@Oracle.COM state = (hermon_state_t *)hca;
1014*12965SWilliam.Taylor@Oracle.COM if (!HERMON_HID_VALID(state, hid))
1015*12965SWilliam.Taylor@Oracle.COM return (IBT_CQ_HID_INVALID);
1016*12965SWilliam.Taylor@Oracle.COM if (attrs == NULL)
1017*12965SWilliam.Taylor@Oracle.COM return (IBT_INVALID_PARAM);
1018*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*attrs))
1019*12965SWilliam.Taylor@Oracle.COM attrs->cha_ih = state->hs_intrmsi_hdl[hid - 1];
1020*12965SWilliam.Taylor@Oracle.COM attrs->cha_dip = state->hs_dip;
10219517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
10229517SBill.Taylor@Sun.COM }
10239517SBill.Taylor@Sun.COM
10249517SBill.Taylor@Sun.COM /*
10259517SBill.Taylor@Sun.COM * hermon_ci_alloc_eec()
10269517SBill.Taylor@Sun.COM * Allocate an End-to-End context
10279517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
10289517SBill.Taylor@Sun.COM */
10299517SBill.Taylor@Sun.COM /* ARGSUSED */
10309517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_eec(ibc_hca_hdl_t hca,ibc_eec_flags_t flags,ibt_eec_hdl_t ibt_eec,ibc_rdd_hdl_t rdd,ibc_eec_hdl_t * eec_p)10319517SBill.Taylor@Sun.COM hermon_ci_alloc_eec(ibc_hca_hdl_t hca, ibc_eec_flags_t flags,
10329517SBill.Taylor@Sun.COM ibt_eec_hdl_t ibt_eec, ibc_rdd_hdl_t rdd, ibc_eec_hdl_t *eec_p)
10339517SBill.Taylor@Sun.COM {
10349517SBill.Taylor@Sun.COM /*
10359517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
10369517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
10379517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
10389517SBill.Taylor@Sun.COM */
10399517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
10409517SBill.Taylor@Sun.COM }
10419517SBill.Taylor@Sun.COM
10429517SBill.Taylor@Sun.COM
10439517SBill.Taylor@Sun.COM /*
10449517SBill.Taylor@Sun.COM * hermon_ci_free_eec()
10459517SBill.Taylor@Sun.COM * Free an End-to-End context
10469517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
10479517SBill.Taylor@Sun.COM */
10489517SBill.Taylor@Sun.COM /* ARGSUSED */
10499517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_eec(ibc_hca_hdl_t hca,ibc_eec_hdl_t eec)10509517SBill.Taylor@Sun.COM hermon_ci_free_eec(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec)
10519517SBill.Taylor@Sun.COM {
10529517SBill.Taylor@Sun.COM /*
10539517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
10549517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
10559517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
10569517SBill.Taylor@Sun.COM */
10579517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
10589517SBill.Taylor@Sun.COM }
10599517SBill.Taylor@Sun.COM
10609517SBill.Taylor@Sun.COM
10619517SBill.Taylor@Sun.COM /*
10629517SBill.Taylor@Sun.COM * hermon_ci_query_eec()
10639517SBill.Taylor@Sun.COM * Query an End-to-End context
10649517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
10659517SBill.Taylor@Sun.COM */
10669517SBill.Taylor@Sun.COM /* ARGSUSED */
10679517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_eec(ibc_hca_hdl_t hca,ibc_eec_hdl_t eec,ibt_eec_query_attr_t * attr_p)10689517SBill.Taylor@Sun.COM hermon_ci_query_eec(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
10699517SBill.Taylor@Sun.COM ibt_eec_query_attr_t *attr_p)
10709517SBill.Taylor@Sun.COM {
10719517SBill.Taylor@Sun.COM /*
10729517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
10739517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
10749517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
10759517SBill.Taylor@Sun.COM */
10769517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
10779517SBill.Taylor@Sun.COM }
10789517SBill.Taylor@Sun.COM
10799517SBill.Taylor@Sun.COM
10809517SBill.Taylor@Sun.COM /*
10819517SBill.Taylor@Sun.COM * hermon_ci_modify_eec()
10829517SBill.Taylor@Sun.COM * Modify an End-to-End context
10839517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
10849517SBill.Taylor@Sun.COM */
10859517SBill.Taylor@Sun.COM /* ARGSUSED */
10869517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_eec(ibc_hca_hdl_t hca,ibc_eec_hdl_t eec,ibt_cep_modify_flags_t flags,ibt_eec_info_t * info_p)10879517SBill.Taylor@Sun.COM hermon_ci_modify_eec(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
10889517SBill.Taylor@Sun.COM ibt_cep_modify_flags_t flags, ibt_eec_info_t *info_p)
10899517SBill.Taylor@Sun.COM {
10909517SBill.Taylor@Sun.COM /*
10919517SBill.Taylor@Sun.COM * This is an unsupported interface for the Hermon driver. This
10929517SBill.Taylor@Sun.COM * interface is necessary to support Reliable Datagram (RD)
10939517SBill.Taylor@Sun.COM * operations. Hermon does not support RD.
10949517SBill.Taylor@Sun.COM */
10959517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
10969517SBill.Taylor@Sun.COM }
10979517SBill.Taylor@Sun.COM
10989517SBill.Taylor@Sun.COM
10999517SBill.Taylor@Sun.COM /*
11009517SBill.Taylor@Sun.COM * hermon_ci_register_mr()
11019517SBill.Taylor@Sun.COM * Prepare a virtually addressed Memory Region for use by an HCA
11029517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
11039517SBill.Taylor@Sun.COM */
11049517SBill.Taylor@Sun.COM /* ARGSUSED */
11059517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_register_mr(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_mr_attr_t * mr_attr,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_mr_desc_t * mr_desc)11069517SBill.Taylor@Sun.COM hermon_ci_register_mr(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
11079517SBill.Taylor@Sun.COM ibt_mr_attr_t *mr_attr, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
11089517SBill.Taylor@Sun.COM ibt_mr_desc_t *mr_desc)
11099517SBill.Taylor@Sun.COM {
11109517SBill.Taylor@Sun.COM hermon_mr_options_t op;
11119517SBill.Taylor@Sun.COM hermon_state_t *state;
11129517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
11139517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
11149517SBill.Taylor@Sun.COM int status;
11159517SBill.Taylor@Sun.COM
11169517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
11179517SBill.Taylor@Sun.COM
11189517SBill.Taylor@Sun.COM ASSERT(mr_attr != NULL);
11199517SBill.Taylor@Sun.COM ASSERT(mr_p != NULL);
11209517SBill.Taylor@Sun.COM ASSERT(mr_desc != NULL);
11219517SBill.Taylor@Sun.COM
11229517SBill.Taylor@Sun.COM /*
11239517SBill.Taylor@Sun.COM * Validate the access flags. Both Remote Write and Remote Atomic
11249517SBill.Taylor@Sun.COM * require the Local Write flag to be set
11259517SBill.Taylor@Sun.COM */
11269517SBill.Taylor@Sun.COM if (((mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
11279517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC)) &&
11289517SBill.Taylor@Sun.COM !(mr_attr->mr_flags & IBT_MR_ENABLE_LOCAL_WRITE)) {
11299517SBill.Taylor@Sun.COM return (IBT_MR_ACCESS_REQ_INVALID);
11309517SBill.Taylor@Sun.COM }
11319517SBill.Taylor@Sun.COM
11329517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and PD handle */
11339517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
11349517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
11359517SBill.Taylor@Sun.COM
11369517SBill.Taylor@Sun.COM /* Register the memory region */
11379517SBill.Taylor@Sun.COM op.mro_bind_type = state->hs_cfg_profile->cp_iommu_bypass;
11389517SBill.Taylor@Sun.COM op.mro_bind_dmahdl = NULL;
11399517SBill.Taylor@Sun.COM op.mro_bind_override_addr = 0;
11409517SBill.Taylor@Sun.COM status = hermon_mr_register(state, pdhdl, mr_attr, &mrhdl,
11419517SBill.Taylor@Sun.COM &op, HERMON_MPT_DMPT);
11429517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
11439517SBill.Taylor@Sun.COM return (status);
11449517SBill.Taylor@Sun.COM }
11459517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl))
11469517SBill.Taylor@Sun.COM
11479517SBill.Taylor@Sun.COM /* Fill in the mr_desc structure */
11489517SBill.Taylor@Sun.COM mr_desc->md_vaddr = mrhdl->mr_bindinfo.bi_addr;
11499517SBill.Taylor@Sun.COM mr_desc->md_lkey = mrhdl->mr_lkey;
11509517SBill.Taylor@Sun.COM /* Only set RKey if remote access was requested */
11519517SBill.Taylor@Sun.COM if ((mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
11529517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
11539517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_READ)) {
11549517SBill.Taylor@Sun.COM mr_desc->md_rkey = mrhdl->mr_rkey;
11559517SBill.Taylor@Sun.COM }
11569517SBill.Taylor@Sun.COM
11579517SBill.Taylor@Sun.COM /*
11589517SBill.Taylor@Sun.COM * If region is mapped for streaming (i.e. noncoherent), then set
11599517SBill.Taylor@Sun.COM * sync is required
11609517SBill.Taylor@Sun.COM */
11619517SBill.Taylor@Sun.COM mr_desc->md_sync_required = (mrhdl->mr_bindinfo.bi_flags &
11629517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
11639517SBill.Taylor@Sun.COM
11649517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
11659517SBill.Taylor@Sun.COM *mr_p = (ibc_mr_hdl_t)mrhdl;
11669517SBill.Taylor@Sun.COM
11679517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
11689517SBill.Taylor@Sun.COM }
11699517SBill.Taylor@Sun.COM
11709517SBill.Taylor@Sun.COM
11719517SBill.Taylor@Sun.COM /*
11729517SBill.Taylor@Sun.COM * hermon_ci_register_buf()
11739517SBill.Taylor@Sun.COM * Prepare a Memory Region specified by buf structure for use by an HCA
11749517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
11759517SBill.Taylor@Sun.COM */
11769517SBill.Taylor@Sun.COM /* ARGSUSED */
11779517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_register_buf(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_smr_attr_t * attrp,struct buf * buf,void * ibtl_reserved,ibt_mr_hdl_t * mr_p,ibt_mr_desc_t * mr_desc)11789517SBill.Taylor@Sun.COM hermon_ci_register_buf(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
11799517SBill.Taylor@Sun.COM ibt_smr_attr_t *attrp, struct buf *buf, void *ibtl_reserved,
11809517SBill.Taylor@Sun.COM ibt_mr_hdl_t *mr_p, ibt_mr_desc_t *mr_desc)
11819517SBill.Taylor@Sun.COM {
11829517SBill.Taylor@Sun.COM hermon_mr_options_t op;
11839517SBill.Taylor@Sun.COM hermon_state_t *state;
11849517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
11859517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
11869517SBill.Taylor@Sun.COM int status;
11879517SBill.Taylor@Sun.COM ibt_mr_flags_t flags = attrp->mr_flags;
11889517SBill.Taylor@Sun.COM
11899517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
11909517SBill.Taylor@Sun.COM
11919517SBill.Taylor@Sun.COM ASSERT(mr_p != NULL);
11929517SBill.Taylor@Sun.COM ASSERT(mr_desc != NULL);
11939517SBill.Taylor@Sun.COM
11949517SBill.Taylor@Sun.COM /*
11959517SBill.Taylor@Sun.COM * Validate the access flags. Both Remote Write and Remote Atomic
11969517SBill.Taylor@Sun.COM * require the Local Write flag to be set
11979517SBill.Taylor@Sun.COM */
11989517SBill.Taylor@Sun.COM if (((flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
11999517SBill.Taylor@Sun.COM (flags & IBT_MR_ENABLE_REMOTE_ATOMIC)) &&
12009517SBill.Taylor@Sun.COM !(flags & IBT_MR_ENABLE_LOCAL_WRITE)) {
12019517SBill.Taylor@Sun.COM return (IBT_MR_ACCESS_REQ_INVALID);
12029517SBill.Taylor@Sun.COM }
12039517SBill.Taylor@Sun.COM
12049517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and PD handle */
12059517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
12069517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
12079517SBill.Taylor@Sun.COM
12089517SBill.Taylor@Sun.COM /* Register the memory region */
12099517SBill.Taylor@Sun.COM op.mro_bind_type = state->hs_cfg_profile->cp_iommu_bypass;
12109517SBill.Taylor@Sun.COM op.mro_bind_dmahdl = NULL;
12119517SBill.Taylor@Sun.COM op.mro_bind_override_addr = 0;
12129517SBill.Taylor@Sun.COM status = hermon_mr_register_buf(state, pdhdl, attrp, buf,
12139517SBill.Taylor@Sun.COM &mrhdl, &op, HERMON_MPT_DMPT);
12149517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
12159517SBill.Taylor@Sun.COM return (status);
12169517SBill.Taylor@Sun.COM }
12179517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl))
12189517SBill.Taylor@Sun.COM
12199517SBill.Taylor@Sun.COM /* Fill in the mr_desc structure */
12209517SBill.Taylor@Sun.COM mr_desc->md_vaddr = mrhdl->mr_bindinfo.bi_addr;
12219517SBill.Taylor@Sun.COM mr_desc->md_lkey = mrhdl->mr_lkey;
12229517SBill.Taylor@Sun.COM /* Only set RKey if remote access was requested */
12239517SBill.Taylor@Sun.COM if ((flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
12249517SBill.Taylor@Sun.COM (flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
12259517SBill.Taylor@Sun.COM (flags & IBT_MR_ENABLE_REMOTE_READ)) {
12269517SBill.Taylor@Sun.COM mr_desc->md_rkey = mrhdl->mr_rkey;
12279517SBill.Taylor@Sun.COM }
12289517SBill.Taylor@Sun.COM
12299517SBill.Taylor@Sun.COM /*
12309517SBill.Taylor@Sun.COM * If region is mapped for streaming (i.e. noncoherent), then set
12319517SBill.Taylor@Sun.COM * sync is required
12329517SBill.Taylor@Sun.COM */
12339517SBill.Taylor@Sun.COM mr_desc->md_sync_required = (mrhdl->mr_bindinfo.bi_flags &
12349517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
12359517SBill.Taylor@Sun.COM
12369517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
12379517SBill.Taylor@Sun.COM *mr_p = (ibc_mr_hdl_t)mrhdl;
12389517SBill.Taylor@Sun.COM
12399517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
12409517SBill.Taylor@Sun.COM }
12419517SBill.Taylor@Sun.COM
12429517SBill.Taylor@Sun.COM
12439517SBill.Taylor@Sun.COM /*
12449517SBill.Taylor@Sun.COM * hermon_ci_deregister_mr()
12459517SBill.Taylor@Sun.COM * Deregister a Memory Region from an HCA translation table
12469517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
12479517SBill.Taylor@Sun.COM */
12489517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_deregister_mr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr)12499517SBill.Taylor@Sun.COM hermon_ci_deregister_mr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr)
12509517SBill.Taylor@Sun.COM {
12519517SBill.Taylor@Sun.COM hermon_state_t *state;
12529517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
12539517SBill.Taylor@Sun.COM int status;
12549517SBill.Taylor@Sun.COM
12559517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
12569517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
12579517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
12589517SBill.Taylor@Sun.COM
12599517SBill.Taylor@Sun.COM /*
12609517SBill.Taylor@Sun.COM * Deregister the memory region.
12619517SBill.Taylor@Sun.COM */
12629517SBill.Taylor@Sun.COM status = hermon_mr_deregister(state, &mrhdl, HERMON_MR_DEREG_ALL,
12639517SBill.Taylor@Sun.COM HERMON_NOSLEEP);
12649517SBill.Taylor@Sun.COM return (status);
12659517SBill.Taylor@Sun.COM }
12669517SBill.Taylor@Sun.COM
12679517SBill.Taylor@Sun.COM
12689517SBill.Taylor@Sun.COM /*
12699517SBill.Taylor@Sun.COM * hermon_ci_query_mr()
12709517SBill.Taylor@Sun.COM * Retrieve information about a specified Memory Region
12719517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
12729517SBill.Taylor@Sun.COM */
12739517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_mr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr,ibt_mr_query_attr_t * mr_attr)12749517SBill.Taylor@Sun.COM hermon_ci_query_mr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
12759517SBill.Taylor@Sun.COM ibt_mr_query_attr_t *mr_attr)
12769517SBill.Taylor@Sun.COM {
12779517SBill.Taylor@Sun.COM hermon_state_t *state;
12789517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
12799517SBill.Taylor@Sun.COM int status;
12809517SBill.Taylor@Sun.COM
12819517SBill.Taylor@Sun.COM ASSERT(mr_attr != NULL);
12829517SBill.Taylor@Sun.COM
12839517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and MR handle */
12849517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
12859517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
12869517SBill.Taylor@Sun.COM
12879517SBill.Taylor@Sun.COM /* Query the memory region */
12889517SBill.Taylor@Sun.COM status = hermon_mr_query(state, mrhdl, mr_attr);
12899517SBill.Taylor@Sun.COM return (status);
12909517SBill.Taylor@Sun.COM }
12919517SBill.Taylor@Sun.COM
12929517SBill.Taylor@Sun.COM
12939517SBill.Taylor@Sun.COM /*
12949517SBill.Taylor@Sun.COM * hermon_ci_register_shared_mr()
12959517SBill.Taylor@Sun.COM * Create a shared memory region matching an existing Memory Region
12969517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
12979517SBill.Taylor@Sun.COM */
12989517SBill.Taylor@Sun.COM /* ARGSUSED */
12999517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_register_shared_mr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr,ibc_pd_hdl_t pd,ibt_smr_attr_t * mr_attr,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_mr_desc_t * mr_desc)13009517SBill.Taylor@Sun.COM hermon_ci_register_shared_mr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
13019517SBill.Taylor@Sun.COM ibc_pd_hdl_t pd, ibt_smr_attr_t *mr_attr, void *ibtl_reserved,
13029517SBill.Taylor@Sun.COM ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mr_desc)
13039517SBill.Taylor@Sun.COM {
13049517SBill.Taylor@Sun.COM hermon_state_t *state;
13059517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
13069517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl, mrhdl_new;
13079517SBill.Taylor@Sun.COM int status;
13089517SBill.Taylor@Sun.COM
13099517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
13109517SBill.Taylor@Sun.COM
13119517SBill.Taylor@Sun.COM ASSERT(mr_attr != NULL);
13129517SBill.Taylor@Sun.COM ASSERT(mr_p != NULL);
13139517SBill.Taylor@Sun.COM ASSERT(mr_desc != NULL);
13149517SBill.Taylor@Sun.COM
13159517SBill.Taylor@Sun.COM /*
13169517SBill.Taylor@Sun.COM * Validate the access flags. Both Remote Write and Remote Atomic
13179517SBill.Taylor@Sun.COM * require the Local Write flag to be set
13189517SBill.Taylor@Sun.COM */
13199517SBill.Taylor@Sun.COM if (((mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
13209517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC)) &&
13219517SBill.Taylor@Sun.COM !(mr_attr->mr_flags & IBT_MR_ENABLE_LOCAL_WRITE)) {
13229517SBill.Taylor@Sun.COM return (IBT_MR_ACCESS_REQ_INVALID);
13239517SBill.Taylor@Sun.COM }
13249517SBill.Taylor@Sun.COM
13259517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and handles */
13269517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
13279517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
13289517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
13299517SBill.Taylor@Sun.COM
13309517SBill.Taylor@Sun.COM /* Register the shared memory region */
13319517SBill.Taylor@Sun.COM status = hermon_mr_register_shared(state, mrhdl, pdhdl, mr_attr,
13329517SBill.Taylor@Sun.COM &mrhdl_new);
13339517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
13349517SBill.Taylor@Sun.COM return (status);
13359517SBill.Taylor@Sun.COM }
13369517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl_new))
13379517SBill.Taylor@Sun.COM
13389517SBill.Taylor@Sun.COM /* Fill in the mr_desc structure */
13399517SBill.Taylor@Sun.COM mr_desc->md_vaddr = mrhdl_new->mr_bindinfo.bi_addr;
13409517SBill.Taylor@Sun.COM mr_desc->md_lkey = mrhdl_new->mr_lkey;
13419517SBill.Taylor@Sun.COM /* Only set RKey if remote access was requested */
13429517SBill.Taylor@Sun.COM if ((mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
13439517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
13449517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_READ)) {
13459517SBill.Taylor@Sun.COM mr_desc->md_rkey = mrhdl_new->mr_rkey;
13469517SBill.Taylor@Sun.COM }
13479517SBill.Taylor@Sun.COM
13489517SBill.Taylor@Sun.COM /*
13499517SBill.Taylor@Sun.COM * If shared region is mapped for streaming (i.e. noncoherent), then
13509517SBill.Taylor@Sun.COM * set sync is required
13519517SBill.Taylor@Sun.COM */
13529517SBill.Taylor@Sun.COM mr_desc->md_sync_required = (mrhdl_new->mr_bindinfo.bi_flags &
13539517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
13549517SBill.Taylor@Sun.COM
13559517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
13569517SBill.Taylor@Sun.COM *mr_p = (ibc_mr_hdl_t)mrhdl_new;
13579517SBill.Taylor@Sun.COM
13589517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
13599517SBill.Taylor@Sun.COM }
13609517SBill.Taylor@Sun.COM
13619517SBill.Taylor@Sun.COM
13629517SBill.Taylor@Sun.COM /*
13639517SBill.Taylor@Sun.COM * hermon_ci_reregister_mr()
13649517SBill.Taylor@Sun.COM * Modify the attributes of an existing Memory Region
13659517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
13669517SBill.Taylor@Sun.COM */
13679517SBill.Taylor@Sun.COM /* ARGSUSED */
13689517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_reregister_mr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr,ibc_pd_hdl_t pd,ibt_mr_attr_t * mr_attr,void * ibtl_reserved,ibc_mr_hdl_t * mr_new,ibt_mr_desc_t * mr_desc)13699517SBill.Taylor@Sun.COM hermon_ci_reregister_mr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr, ibc_pd_hdl_t pd,
13709517SBill.Taylor@Sun.COM ibt_mr_attr_t *mr_attr, void *ibtl_reserved, ibc_mr_hdl_t *mr_new,
13719517SBill.Taylor@Sun.COM ibt_mr_desc_t *mr_desc)
13729517SBill.Taylor@Sun.COM {
13739517SBill.Taylor@Sun.COM hermon_mr_options_t op;
13749517SBill.Taylor@Sun.COM hermon_state_t *state;
13759517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
13769517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl, mrhdl_new;
13779517SBill.Taylor@Sun.COM int status;
13789517SBill.Taylor@Sun.COM
13799517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
13809517SBill.Taylor@Sun.COM
13819517SBill.Taylor@Sun.COM ASSERT(mr_attr != NULL);
13829517SBill.Taylor@Sun.COM ASSERT(mr_new != NULL);
13839517SBill.Taylor@Sun.COM ASSERT(mr_desc != NULL);
13849517SBill.Taylor@Sun.COM
13859517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer, mrhdl, and pdhdl */
13869517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
13879517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
13889517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
13899517SBill.Taylor@Sun.COM
13909517SBill.Taylor@Sun.COM /* Reregister the memory region */
13919517SBill.Taylor@Sun.COM op.mro_bind_type = state->hs_cfg_profile->cp_iommu_bypass;
13929517SBill.Taylor@Sun.COM status = hermon_mr_reregister(state, mrhdl, pdhdl, mr_attr,
13939517SBill.Taylor@Sun.COM &mrhdl_new, &op);
13949517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
13959517SBill.Taylor@Sun.COM return (status);
13969517SBill.Taylor@Sun.COM }
13979517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl_new))
13989517SBill.Taylor@Sun.COM
13999517SBill.Taylor@Sun.COM /* Fill in the mr_desc structure */
14009517SBill.Taylor@Sun.COM mr_desc->md_vaddr = mrhdl_new->mr_bindinfo.bi_addr;
14019517SBill.Taylor@Sun.COM mr_desc->md_lkey = mrhdl_new->mr_lkey;
14029517SBill.Taylor@Sun.COM /* Only set RKey if remote access was requested */
14039517SBill.Taylor@Sun.COM if ((mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
14049517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
14059517SBill.Taylor@Sun.COM (mr_attr->mr_flags & IBT_MR_ENABLE_REMOTE_READ)) {
14069517SBill.Taylor@Sun.COM mr_desc->md_rkey = mrhdl_new->mr_rkey;
14079517SBill.Taylor@Sun.COM }
14089517SBill.Taylor@Sun.COM
14099517SBill.Taylor@Sun.COM /*
14109517SBill.Taylor@Sun.COM * If region is mapped for streaming (i.e. noncoherent), then set
14119517SBill.Taylor@Sun.COM * sync is required
14129517SBill.Taylor@Sun.COM */
14139517SBill.Taylor@Sun.COM mr_desc->md_sync_required = (mrhdl_new->mr_bindinfo.bi_flags &
14149517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
14159517SBill.Taylor@Sun.COM
14169517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
14179517SBill.Taylor@Sun.COM *mr_new = (ibc_mr_hdl_t)mrhdl_new;
14189517SBill.Taylor@Sun.COM
14199517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
14209517SBill.Taylor@Sun.COM }
14219517SBill.Taylor@Sun.COM
14229517SBill.Taylor@Sun.COM
14239517SBill.Taylor@Sun.COM /*
14249517SBill.Taylor@Sun.COM * hermon_ci_reregister_buf()
14259517SBill.Taylor@Sun.COM * Modify the attributes of an existing Memory Region
14269517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
14279517SBill.Taylor@Sun.COM */
14289517SBill.Taylor@Sun.COM /* ARGSUSED */
14299517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_reregister_buf(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr,ibc_pd_hdl_t pd,ibt_smr_attr_t * attrp,struct buf * buf,void * ibtl_reserved,ibc_mr_hdl_t * mr_new,ibt_mr_desc_t * mr_desc)14309517SBill.Taylor@Sun.COM hermon_ci_reregister_buf(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr, ibc_pd_hdl_t pd,
14319517SBill.Taylor@Sun.COM ibt_smr_attr_t *attrp, struct buf *buf, void *ibtl_reserved,
14329517SBill.Taylor@Sun.COM ibc_mr_hdl_t *mr_new, ibt_mr_desc_t *mr_desc)
14339517SBill.Taylor@Sun.COM {
14349517SBill.Taylor@Sun.COM hermon_mr_options_t op;
14359517SBill.Taylor@Sun.COM hermon_state_t *state;
14369517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
14379517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl, mrhdl_new;
14389517SBill.Taylor@Sun.COM int status;
14399517SBill.Taylor@Sun.COM ibt_mr_flags_t flags = attrp->mr_flags;
14409517SBill.Taylor@Sun.COM
14419517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
14429517SBill.Taylor@Sun.COM
14439517SBill.Taylor@Sun.COM ASSERT(mr_new != NULL);
14449517SBill.Taylor@Sun.COM ASSERT(mr_desc != NULL);
14459517SBill.Taylor@Sun.COM
14469517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer, mrhdl, and pdhdl */
14479517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
14489517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
14499517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
14509517SBill.Taylor@Sun.COM
14519517SBill.Taylor@Sun.COM /* Reregister the memory region */
14529517SBill.Taylor@Sun.COM op.mro_bind_type = state->hs_cfg_profile->cp_iommu_bypass;
14539517SBill.Taylor@Sun.COM status = hermon_mr_reregister_buf(state, mrhdl, pdhdl, attrp, buf,
14549517SBill.Taylor@Sun.COM &mrhdl_new, &op);
14559517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
14569517SBill.Taylor@Sun.COM return (status);
14579517SBill.Taylor@Sun.COM }
14589517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl_new))
14599517SBill.Taylor@Sun.COM
14609517SBill.Taylor@Sun.COM /* Fill in the mr_desc structure */
14619517SBill.Taylor@Sun.COM mr_desc->md_vaddr = mrhdl_new->mr_bindinfo.bi_addr;
14629517SBill.Taylor@Sun.COM mr_desc->md_lkey = mrhdl_new->mr_lkey;
14639517SBill.Taylor@Sun.COM /* Only set RKey if remote access was requested */
14649517SBill.Taylor@Sun.COM if ((flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
14659517SBill.Taylor@Sun.COM (flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
14669517SBill.Taylor@Sun.COM (flags & IBT_MR_ENABLE_REMOTE_READ)) {
14679517SBill.Taylor@Sun.COM mr_desc->md_rkey = mrhdl_new->mr_rkey;
14689517SBill.Taylor@Sun.COM }
14699517SBill.Taylor@Sun.COM
14709517SBill.Taylor@Sun.COM /*
14719517SBill.Taylor@Sun.COM * If region is mapped for streaming (i.e. noncoherent), then set
14729517SBill.Taylor@Sun.COM * sync is required
14739517SBill.Taylor@Sun.COM */
14749517SBill.Taylor@Sun.COM mr_desc->md_sync_required = (mrhdl_new->mr_bindinfo.bi_flags &
14759517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
14769517SBill.Taylor@Sun.COM
14779517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
14789517SBill.Taylor@Sun.COM *mr_new = (ibc_mr_hdl_t)mrhdl_new;
14799517SBill.Taylor@Sun.COM
14809517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
14819517SBill.Taylor@Sun.COM }
14829517SBill.Taylor@Sun.COM
14839517SBill.Taylor@Sun.COM /*
14849517SBill.Taylor@Sun.COM * hermon_ci_sync_mr()
14859517SBill.Taylor@Sun.COM * Synchronize access to a Memory Region
14869517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
14879517SBill.Taylor@Sun.COM */
14889517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_sync_mr(ibc_hca_hdl_t hca,ibt_mr_sync_t * mr_segs,size_t num_segs)14899517SBill.Taylor@Sun.COM hermon_ci_sync_mr(ibc_hca_hdl_t hca, ibt_mr_sync_t *mr_segs, size_t num_segs)
14909517SBill.Taylor@Sun.COM {
14919517SBill.Taylor@Sun.COM hermon_state_t *state;
14929517SBill.Taylor@Sun.COM int status;
14939517SBill.Taylor@Sun.COM
14949517SBill.Taylor@Sun.COM ASSERT(mr_segs != NULL);
14959517SBill.Taylor@Sun.COM
14969517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
14979517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
14989517SBill.Taylor@Sun.COM
14999517SBill.Taylor@Sun.COM /* Sync the memory region */
15009517SBill.Taylor@Sun.COM status = hermon_mr_sync(state, mr_segs, num_segs);
15019517SBill.Taylor@Sun.COM return (status);
15029517SBill.Taylor@Sun.COM }
15039517SBill.Taylor@Sun.COM
15049517SBill.Taylor@Sun.COM
15059517SBill.Taylor@Sun.COM /*
15069517SBill.Taylor@Sun.COM * hermon_ci_alloc_mw()
15079517SBill.Taylor@Sun.COM * Allocate a Memory Window
15089517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
15099517SBill.Taylor@Sun.COM */
15109517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_mw(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_mw_flags_t flags,ibc_mw_hdl_t * mw_p,ibt_rkey_t * rkey_p)15119517SBill.Taylor@Sun.COM hermon_ci_alloc_mw(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, ibt_mw_flags_t flags,
15129517SBill.Taylor@Sun.COM ibc_mw_hdl_t *mw_p, ibt_rkey_t *rkey_p)
15139517SBill.Taylor@Sun.COM {
15149517SBill.Taylor@Sun.COM hermon_state_t *state;
15159517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
15169517SBill.Taylor@Sun.COM hermon_mwhdl_t mwhdl;
15179517SBill.Taylor@Sun.COM int status;
15189517SBill.Taylor@Sun.COM
15199517SBill.Taylor@Sun.COM ASSERT(mw_p != NULL);
15209517SBill.Taylor@Sun.COM ASSERT(rkey_p != NULL);
15219517SBill.Taylor@Sun.COM
15229517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and PD handle */
15239517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
15249517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
15259517SBill.Taylor@Sun.COM
15269517SBill.Taylor@Sun.COM /* Allocate the memory window */
15279517SBill.Taylor@Sun.COM status = hermon_mw_alloc(state, pdhdl, flags, &mwhdl);
15289517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
15299517SBill.Taylor@Sun.COM return (status);
15309517SBill.Taylor@Sun.COM }
15319517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mwhdl))
15329517SBill.Taylor@Sun.COM
15339517SBill.Taylor@Sun.COM /* Return the MW handle and RKey */
15349517SBill.Taylor@Sun.COM *mw_p = (ibc_mw_hdl_t)mwhdl;
15359517SBill.Taylor@Sun.COM *rkey_p = mwhdl->mr_rkey;
15369517SBill.Taylor@Sun.COM
15379517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
15389517SBill.Taylor@Sun.COM }
15399517SBill.Taylor@Sun.COM
15409517SBill.Taylor@Sun.COM
15419517SBill.Taylor@Sun.COM /*
15429517SBill.Taylor@Sun.COM * hermon_ci_free_mw()
15439517SBill.Taylor@Sun.COM * Free a Memory Window
15449517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
15459517SBill.Taylor@Sun.COM */
15469517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_mw(ibc_hca_hdl_t hca,ibc_mw_hdl_t mw)15479517SBill.Taylor@Sun.COM hermon_ci_free_mw(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw)
15489517SBill.Taylor@Sun.COM {
15499517SBill.Taylor@Sun.COM hermon_state_t *state;
15509517SBill.Taylor@Sun.COM hermon_mwhdl_t mwhdl;
15519517SBill.Taylor@Sun.COM int status;
15529517SBill.Taylor@Sun.COM
15539517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and MW handle */
15549517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
15559517SBill.Taylor@Sun.COM mwhdl = (hermon_mwhdl_t)mw;
15569517SBill.Taylor@Sun.COM
15579517SBill.Taylor@Sun.COM /* Free the memory window */
15589517SBill.Taylor@Sun.COM status = hermon_mw_free(state, &mwhdl, HERMON_NOSLEEP);
15599517SBill.Taylor@Sun.COM return (status);
15609517SBill.Taylor@Sun.COM }
15619517SBill.Taylor@Sun.COM
15629517SBill.Taylor@Sun.COM
15639517SBill.Taylor@Sun.COM /*
15649517SBill.Taylor@Sun.COM * hermon_ci_query_mw()
15659517SBill.Taylor@Sun.COM * Return the attributes of the specified Memory Window
15669517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
15679517SBill.Taylor@Sun.COM */
1568*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
15699517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_mw(ibc_hca_hdl_t hca,ibc_mw_hdl_t mw,ibt_mw_query_attr_t * mw_attr_p)15709517SBill.Taylor@Sun.COM hermon_ci_query_mw(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw,
15719517SBill.Taylor@Sun.COM ibt_mw_query_attr_t *mw_attr_p)
15729517SBill.Taylor@Sun.COM {
15739517SBill.Taylor@Sun.COM hermon_mwhdl_t mwhdl;
15749517SBill.Taylor@Sun.COM
15759517SBill.Taylor@Sun.COM ASSERT(mw_attr_p != NULL);
15769517SBill.Taylor@Sun.COM
15779517SBill.Taylor@Sun.COM /* Query the memory window pointer and fill in the return values */
15789517SBill.Taylor@Sun.COM mwhdl = (hermon_mwhdl_t)mw;
15799517SBill.Taylor@Sun.COM mutex_enter(&mwhdl->mr_lock);
15809517SBill.Taylor@Sun.COM mw_attr_p->mw_pd = (ibc_pd_hdl_t)mwhdl->mr_pdhdl;
15819517SBill.Taylor@Sun.COM mw_attr_p->mw_rkey = mwhdl->mr_rkey;
15829517SBill.Taylor@Sun.COM mutex_exit(&mwhdl->mr_lock);
15839517SBill.Taylor@Sun.COM
15849517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
15859517SBill.Taylor@Sun.COM }
15869517SBill.Taylor@Sun.COM
15879517SBill.Taylor@Sun.COM
15889517SBill.Taylor@Sun.COM /*
1589*12965SWilliam.Taylor@Oracle.COM * hermon_ci_register_dma_mr()
1590*12965SWilliam.Taylor@Oracle.COM * Allocate a memory region that maps physical addresses.
1591*12965SWilliam.Taylor@Oracle.COM * Context: Can be called only from user or kernel context.
1592*12965SWilliam.Taylor@Oracle.COM */
1593*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
1594*12965SWilliam.Taylor@Oracle.COM static ibt_status_t
hermon_ci_register_dma_mr(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_dmr_attr_t * mr_attr,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_mr_desc_t * mr_desc)1595*12965SWilliam.Taylor@Oracle.COM hermon_ci_register_dma_mr(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
1596*12965SWilliam.Taylor@Oracle.COM ibt_dmr_attr_t *mr_attr, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
1597*12965SWilliam.Taylor@Oracle.COM ibt_mr_desc_t *mr_desc)
1598*12965SWilliam.Taylor@Oracle.COM {
1599*12965SWilliam.Taylor@Oracle.COM hermon_state_t *state;
1600*12965SWilliam.Taylor@Oracle.COM hermon_pdhdl_t pdhdl;
1601*12965SWilliam.Taylor@Oracle.COM hermon_mrhdl_t mrhdl;
1602*12965SWilliam.Taylor@Oracle.COM int status;
1603*12965SWilliam.Taylor@Oracle.COM
1604*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_desc))
1605*12965SWilliam.Taylor@Oracle.COM
1606*12965SWilliam.Taylor@Oracle.COM ASSERT(mr_attr != NULL);
1607*12965SWilliam.Taylor@Oracle.COM ASSERT(mr_p != NULL);
1608*12965SWilliam.Taylor@Oracle.COM ASSERT(mr_desc != NULL);
1609*12965SWilliam.Taylor@Oracle.COM
1610*12965SWilliam.Taylor@Oracle.COM /*
1611*12965SWilliam.Taylor@Oracle.COM * Validate the access flags. Both Remote Write and Remote Atomic
1612*12965SWilliam.Taylor@Oracle.COM * require the Local Write flag to be set
1613*12965SWilliam.Taylor@Oracle.COM */
1614*12965SWilliam.Taylor@Oracle.COM if (((mr_attr->dmr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
1615*12965SWilliam.Taylor@Oracle.COM (mr_attr->dmr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC)) &&
1616*12965SWilliam.Taylor@Oracle.COM !(mr_attr->dmr_flags & IBT_MR_ENABLE_LOCAL_WRITE)) {
1617*12965SWilliam.Taylor@Oracle.COM return (IBT_MR_ACCESS_REQ_INVALID);
1618*12965SWilliam.Taylor@Oracle.COM }
1619*12965SWilliam.Taylor@Oracle.COM
1620*12965SWilliam.Taylor@Oracle.COM /* Grab the Hermon softstate pointer and PD handle */
1621*12965SWilliam.Taylor@Oracle.COM state = (hermon_state_t *)hca;
1622*12965SWilliam.Taylor@Oracle.COM pdhdl = (hermon_pdhdl_t)pd;
1623*12965SWilliam.Taylor@Oracle.COM
1624*12965SWilliam.Taylor@Oracle.COM status = hermon_dma_mr_register(state, pdhdl, mr_attr, &mrhdl);
1625*12965SWilliam.Taylor@Oracle.COM if (status != DDI_SUCCESS) {
1626*12965SWilliam.Taylor@Oracle.COM return (status);
1627*12965SWilliam.Taylor@Oracle.COM }
1628*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl))
1629*12965SWilliam.Taylor@Oracle.COM
1630*12965SWilliam.Taylor@Oracle.COM /* Fill in the mr_desc structure */
1631*12965SWilliam.Taylor@Oracle.COM mr_desc->md_vaddr = mr_attr->dmr_paddr;
1632*12965SWilliam.Taylor@Oracle.COM mr_desc->md_lkey = mrhdl->mr_lkey;
1633*12965SWilliam.Taylor@Oracle.COM /* Only set RKey if remote access was requested */
1634*12965SWilliam.Taylor@Oracle.COM if ((mr_attr->dmr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ||
1635*12965SWilliam.Taylor@Oracle.COM (mr_attr->dmr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
1636*12965SWilliam.Taylor@Oracle.COM (mr_attr->dmr_flags & IBT_MR_ENABLE_REMOTE_READ)) {
1637*12965SWilliam.Taylor@Oracle.COM mr_desc->md_rkey = mrhdl->mr_rkey;
1638*12965SWilliam.Taylor@Oracle.COM }
1639*12965SWilliam.Taylor@Oracle.COM
1640*12965SWilliam.Taylor@Oracle.COM /*
1641*12965SWilliam.Taylor@Oracle.COM * If region is mapped for streaming (i.e. noncoherent), then set
1642*12965SWilliam.Taylor@Oracle.COM * sync is required
1643*12965SWilliam.Taylor@Oracle.COM */
1644*12965SWilliam.Taylor@Oracle.COM mr_desc->md_sync_required = B_FALSE;
1645*12965SWilliam.Taylor@Oracle.COM
1646*12965SWilliam.Taylor@Oracle.COM /* Return the Hermon MR handle */
1647*12965SWilliam.Taylor@Oracle.COM *mr_p = (ibc_mr_hdl_t)mrhdl;
1648*12965SWilliam.Taylor@Oracle.COM
1649*12965SWilliam.Taylor@Oracle.COM return (IBT_SUCCESS);
1650*12965SWilliam.Taylor@Oracle.COM }
1651*12965SWilliam.Taylor@Oracle.COM
1652*12965SWilliam.Taylor@Oracle.COM
1653*12965SWilliam.Taylor@Oracle.COM /*
16549517SBill.Taylor@Sun.COM * hermon_ci_attach_mcg()
16559517SBill.Taylor@Sun.COM * Attach a Queue Pair to a Multicast Group
16569517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
16579517SBill.Taylor@Sun.COM */
16589517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_attach_mcg(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ib_gid_t gid,ib_lid_t lid)16599517SBill.Taylor@Sun.COM hermon_ci_attach_mcg(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, ib_gid_t gid,
16609517SBill.Taylor@Sun.COM ib_lid_t lid)
16619517SBill.Taylor@Sun.COM {
16629517SBill.Taylor@Sun.COM hermon_state_t *state;
16639517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
16649517SBill.Taylor@Sun.COM int status;
16659517SBill.Taylor@Sun.COM
16669517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handles */
16679517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
16689517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
16699517SBill.Taylor@Sun.COM
16709517SBill.Taylor@Sun.COM /* Attach the QP to the multicast group */
16719517SBill.Taylor@Sun.COM status = hermon_mcg_attach(state, qphdl, gid, lid);
16729517SBill.Taylor@Sun.COM return (status);
16739517SBill.Taylor@Sun.COM }
16749517SBill.Taylor@Sun.COM
16759517SBill.Taylor@Sun.COM
16769517SBill.Taylor@Sun.COM /*
16779517SBill.Taylor@Sun.COM * hermon_ci_detach_mcg()
16789517SBill.Taylor@Sun.COM * Detach a Queue Pair to a Multicast Group
16799517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
16809517SBill.Taylor@Sun.COM */
16819517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_detach_mcg(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ib_gid_t gid,ib_lid_t lid)16829517SBill.Taylor@Sun.COM hermon_ci_detach_mcg(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, ib_gid_t gid,
16839517SBill.Taylor@Sun.COM ib_lid_t lid)
16849517SBill.Taylor@Sun.COM {
16859517SBill.Taylor@Sun.COM hermon_state_t *state;
16869517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
16879517SBill.Taylor@Sun.COM int status;
16889517SBill.Taylor@Sun.COM
16899517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
16909517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
16919517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
16929517SBill.Taylor@Sun.COM
16939517SBill.Taylor@Sun.COM /* Detach the QP from the multicast group */
16949517SBill.Taylor@Sun.COM status = hermon_mcg_detach(state, qphdl, gid, lid);
16959517SBill.Taylor@Sun.COM return (status);
16969517SBill.Taylor@Sun.COM }
16979517SBill.Taylor@Sun.COM
16989517SBill.Taylor@Sun.COM
16999517SBill.Taylor@Sun.COM /*
17009517SBill.Taylor@Sun.COM * hermon_ci_post_send()
17019517SBill.Taylor@Sun.COM * Post send work requests to the send queue on the specified QP
17029517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
17039517SBill.Taylor@Sun.COM */
17049517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_post_send(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ibt_send_wr_t * wr_p,uint_t num_wr,uint_t * num_posted_p)17059517SBill.Taylor@Sun.COM hermon_ci_post_send(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, ibt_send_wr_t *wr_p,
17069517SBill.Taylor@Sun.COM uint_t num_wr, uint_t *num_posted_p)
17079517SBill.Taylor@Sun.COM {
17089517SBill.Taylor@Sun.COM hermon_state_t *state;
17099517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
17109517SBill.Taylor@Sun.COM int status;
17119517SBill.Taylor@Sun.COM
17129517SBill.Taylor@Sun.COM ASSERT(wr_p != NULL);
17139517SBill.Taylor@Sun.COM ASSERT(num_wr != 0);
17149517SBill.Taylor@Sun.COM
17159517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and QP handle */
17169517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
17179517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
17189517SBill.Taylor@Sun.COM
17199517SBill.Taylor@Sun.COM /* Post the send WQEs */
17209517SBill.Taylor@Sun.COM status = hermon_post_send(state, qphdl, wr_p, num_wr, num_posted_p);
17219517SBill.Taylor@Sun.COM return (status);
17229517SBill.Taylor@Sun.COM }
17239517SBill.Taylor@Sun.COM
17249517SBill.Taylor@Sun.COM
17259517SBill.Taylor@Sun.COM /*
17269517SBill.Taylor@Sun.COM * hermon_ci_post_recv()
17279517SBill.Taylor@Sun.COM * Post receive work requests to the receive queue on the specified QP
17289517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
17299517SBill.Taylor@Sun.COM */
17309517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_post_recv(ibc_hca_hdl_t hca,ibc_qp_hdl_t qp,ibt_recv_wr_t * wr_p,uint_t num_wr,uint_t * num_posted_p)17319517SBill.Taylor@Sun.COM hermon_ci_post_recv(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, ibt_recv_wr_t *wr_p,
17329517SBill.Taylor@Sun.COM uint_t num_wr, uint_t *num_posted_p)
17339517SBill.Taylor@Sun.COM {
17349517SBill.Taylor@Sun.COM hermon_state_t *state;
17359517SBill.Taylor@Sun.COM hermon_qphdl_t qphdl;
17369517SBill.Taylor@Sun.COM int status;
17379517SBill.Taylor@Sun.COM
17389517SBill.Taylor@Sun.COM ASSERT(wr_p != NULL);
17399517SBill.Taylor@Sun.COM ASSERT(num_wr != 0);
17409517SBill.Taylor@Sun.COM
17419517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
17429517SBill.Taylor@Sun.COM qphdl = (hermon_qphdl_t)qp;
17439517SBill.Taylor@Sun.COM
17449517SBill.Taylor@Sun.COM /* Post the receive WQEs */
17459517SBill.Taylor@Sun.COM status = hermon_post_recv(state, qphdl, wr_p, num_wr, num_posted_p);
17469517SBill.Taylor@Sun.COM return (status);
17479517SBill.Taylor@Sun.COM }
17489517SBill.Taylor@Sun.COM
17499517SBill.Taylor@Sun.COM
17509517SBill.Taylor@Sun.COM /*
17519517SBill.Taylor@Sun.COM * hermon_ci_poll_cq()
17529517SBill.Taylor@Sun.COM * Poll for a work request completion
17539517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
17549517SBill.Taylor@Sun.COM */
17559517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_poll_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq,ibt_wc_t * wc_p,uint_t num_wc,uint_t * num_polled)17569517SBill.Taylor@Sun.COM hermon_ci_poll_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, ibt_wc_t *wc_p,
17579517SBill.Taylor@Sun.COM uint_t num_wc, uint_t *num_polled)
17589517SBill.Taylor@Sun.COM {
17599517SBill.Taylor@Sun.COM hermon_state_t *state;
17609517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
17619517SBill.Taylor@Sun.COM int status;
17629517SBill.Taylor@Sun.COM
17639517SBill.Taylor@Sun.COM ASSERT(wc_p != NULL);
17649517SBill.Taylor@Sun.COM
17659517SBill.Taylor@Sun.COM /* Check for valid num_wc field */
17669517SBill.Taylor@Sun.COM if (num_wc == 0) {
17679517SBill.Taylor@Sun.COM return (IBT_INVALID_PARAM);
17689517SBill.Taylor@Sun.COM }
17699517SBill.Taylor@Sun.COM
17709517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and CQ handle */
17719517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
17729517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq;
17739517SBill.Taylor@Sun.COM
17749517SBill.Taylor@Sun.COM /* Poll for work request completions */
17759517SBill.Taylor@Sun.COM status = hermon_cq_poll(state, cqhdl, wc_p, num_wc, num_polled);
17769517SBill.Taylor@Sun.COM return (status);
17779517SBill.Taylor@Sun.COM }
17789517SBill.Taylor@Sun.COM
17799517SBill.Taylor@Sun.COM
17809517SBill.Taylor@Sun.COM /*
17819517SBill.Taylor@Sun.COM * hermon_ci_notify_cq()
17829517SBill.Taylor@Sun.COM * Enable notification events on the specified CQ
17839517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
17849517SBill.Taylor@Sun.COM */
17859517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_notify_cq(ibc_hca_hdl_t hca,ibc_cq_hdl_t cq_hdl,ibt_cq_notify_flags_t flags)17869517SBill.Taylor@Sun.COM hermon_ci_notify_cq(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq_hdl,
17879517SBill.Taylor@Sun.COM ibt_cq_notify_flags_t flags)
17889517SBill.Taylor@Sun.COM {
17899517SBill.Taylor@Sun.COM hermon_state_t *state;
17909517SBill.Taylor@Sun.COM hermon_cqhdl_t cqhdl;
17919517SBill.Taylor@Sun.COM int status;
17929517SBill.Taylor@Sun.COM
17939517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and CQ handle */
17949517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
17959517SBill.Taylor@Sun.COM cqhdl = (hermon_cqhdl_t)cq_hdl;
17969517SBill.Taylor@Sun.COM
17979517SBill.Taylor@Sun.COM /* Enable the CQ notification */
17989517SBill.Taylor@Sun.COM status = hermon_cq_notify(state, cqhdl, flags);
17999517SBill.Taylor@Sun.COM return (status);
18009517SBill.Taylor@Sun.COM }
18019517SBill.Taylor@Sun.COM
18029517SBill.Taylor@Sun.COM /*
18039517SBill.Taylor@Sun.COM * hermon_ci_ci_data_in()
18049517SBill.Taylor@Sun.COM * Exchange CI-specific data.
18059517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
18069517SBill.Taylor@Sun.COM */
18079517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_ci_data_in(ibc_hca_hdl_t hca,ibt_ci_data_flags_t flags,ibt_object_type_t object,void * ibc_object_handle,void * data_p,size_t data_sz)18089517SBill.Taylor@Sun.COM hermon_ci_ci_data_in(ibc_hca_hdl_t hca, ibt_ci_data_flags_t flags,
18099517SBill.Taylor@Sun.COM ibt_object_type_t object, void *ibc_object_handle, void *data_p,
18109517SBill.Taylor@Sun.COM size_t data_sz)
18119517SBill.Taylor@Sun.COM {
18129517SBill.Taylor@Sun.COM hermon_state_t *state;
18139517SBill.Taylor@Sun.COM int status;
18149517SBill.Taylor@Sun.COM
18159517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
18169517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
18179517SBill.Taylor@Sun.COM
18189517SBill.Taylor@Sun.COM /* Get the Hermon userland mapping information */
18199517SBill.Taylor@Sun.COM status = hermon_umap_ci_data_in(state, flags, object,
18209517SBill.Taylor@Sun.COM ibc_object_handle, data_p, data_sz);
18219517SBill.Taylor@Sun.COM return (status);
18229517SBill.Taylor@Sun.COM }
18239517SBill.Taylor@Sun.COM
18249517SBill.Taylor@Sun.COM /*
18259517SBill.Taylor@Sun.COM * hermon_ci_ci_data_out()
18269517SBill.Taylor@Sun.COM * Exchange CI-specific data.
18279517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context.
18289517SBill.Taylor@Sun.COM */
18299517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_ci_data_out(ibc_hca_hdl_t hca,ibt_ci_data_flags_t flags,ibt_object_type_t object,void * ibc_object_handle,void * data_p,size_t data_sz)18309517SBill.Taylor@Sun.COM hermon_ci_ci_data_out(ibc_hca_hdl_t hca, ibt_ci_data_flags_t flags,
18319517SBill.Taylor@Sun.COM ibt_object_type_t object, void *ibc_object_handle, void *data_p,
18329517SBill.Taylor@Sun.COM size_t data_sz)
18339517SBill.Taylor@Sun.COM {
18349517SBill.Taylor@Sun.COM hermon_state_t *state;
18359517SBill.Taylor@Sun.COM int status;
18369517SBill.Taylor@Sun.COM
18379517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
18389517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
18399517SBill.Taylor@Sun.COM
18409517SBill.Taylor@Sun.COM /* Get the Hermon userland mapping information */
18419517SBill.Taylor@Sun.COM status = hermon_umap_ci_data_out(state, flags, object,
18429517SBill.Taylor@Sun.COM ibc_object_handle, data_p, data_sz);
18439517SBill.Taylor@Sun.COM return (status);
18449517SBill.Taylor@Sun.COM }
18459517SBill.Taylor@Sun.COM
18469517SBill.Taylor@Sun.COM
18479517SBill.Taylor@Sun.COM /*
18489517SBill.Taylor@Sun.COM * hermon_ci_alloc_srq()
18499517SBill.Taylor@Sun.COM * Allocate a Shared Receive Queue (SRQ)
18509517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context
18519517SBill.Taylor@Sun.COM */
18529517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_srq(ibc_hca_hdl_t hca,ibt_srq_flags_t flags,ibt_srq_hdl_t ibt_srq,ibc_pd_hdl_t pd,ibt_srq_sizes_t * sizes,ibc_srq_hdl_t * ibc_srq_p,ibt_srq_sizes_t * ret_sizes_p)18539517SBill.Taylor@Sun.COM hermon_ci_alloc_srq(ibc_hca_hdl_t hca, ibt_srq_flags_t flags,
18549517SBill.Taylor@Sun.COM ibt_srq_hdl_t ibt_srq, ibc_pd_hdl_t pd, ibt_srq_sizes_t *sizes,
18559517SBill.Taylor@Sun.COM ibc_srq_hdl_t *ibc_srq_p, ibt_srq_sizes_t *ret_sizes_p)
18569517SBill.Taylor@Sun.COM {
18579517SBill.Taylor@Sun.COM hermon_state_t *state;
18589517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
18599517SBill.Taylor@Sun.COM hermon_srqhdl_t srqhdl;
18609517SBill.Taylor@Sun.COM hermon_srq_info_t srqinfo;
18619517SBill.Taylor@Sun.COM int status;
18629517SBill.Taylor@Sun.COM
18639517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
18649517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
18659517SBill.Taylor@Sun.COM
18669517SBill.Taylor@Sun.COM srqinfo.srqi_ibt_srqhdl = ibt_srq;
18679517SBill.Taylor@Sun.COM srqinfo.srqi_pd = pdhdl;
18689517SBill.Taylor@Sun.COM srqinfo.srqi_sizes = sizes;
18699517SBill.Taylor@Sun.COM srqinfo.srqi_real_sizes = ret_sizes_p;
18709517SBill.Taylor@Sun.COM srqinfo.srqi_srqhdl = &srqhdl;
18719517SBill.Taylor@Sun.COM srqinfo.srqi_flags = flags;
18729517SBill.Taylor@Sun.COM
18739517SBill.Taylor@Sun.COM status = hermon_srq_alloc(state, &srqinfo, HERMON_NOSLEEP);
18749517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
18759517SBill.Taylor@Sun.COM return (status);
18769517SBill.Taylor@Sun.COM }
18779517SBill.Taylor@Sun.COM
18789517SBill.Taylor@Sun.COM *ibc_srq_p = (ibc_srq_hdl_t)srqhdl;
18799517SBill.Taylor@Sun.COM
18809517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
18819517SBill.Taylor@Sun.COM }
18829517SBill.Taylor@Sun.COM
18839517SBill.Taylor@Sun.COM /*
18849517SBill.Taylor@Sun.COM * hermon_ci_free_srq()
18859517SBill.Taylor@Sun.COM * Free a Shared Receive Queue (SRQ)
18869517SBill.Taylor@Sun.COM * Context: Can be called only from user or kernel context
18879517SBill.Taylor@Sun.COM */
18889517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_srq(ibc_hca_hdl_t hca,ibc_srq_hdl_t srq)18899517SBill.Taylor@Sun.COM hermon_ci_free_srq(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq)
18909517SBill.Taylor@Sun.COM {
18919517SBill.Taylor@Sun.COM hermon_state_t *state;
18929517SBill.Taylor@Sun.COM hermon_srqhdl_t srqhdl;
18939517SBill.Taylor@Sun.COM int status;
18949517SBill.Taylor@Sun.COM
18959517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
18969517SBill.Taylor@Sun.COM
18979517SBill.Taylor@Sun.COM /* Check for valid SRQ handle pointer */
18989517SBill.Taylor@Sun.COM if (srq == NULL) {
18999517SBill.Taylor@Sun.COM return (IBT_SRQ_HDL_INVALID);
19009517SBill.Taylor@Sun.COM }
19019517SBill.Taylor@Sun.COM
19029517SBill.Taylor@Sun.COM srqhdl = (hermon_srqhdl_t)srq;
19039517SBill.Taylor@Sun.COM
19049517SBill.Taylor@Sun.COM /* Free the SRQ */
19059517SBill.Taylor@Sun.COM status = hermon_srq_free(state, &srqhdl, HERMON_NOSLEEP);
19069517SBill.Taylor@Sun.COM return (status);
19079517SBill.Taylor@Sun.COM }
19089517SBill.Taylor@Sun.COM
19099517SBill.Taylor@Sun.COM /*
19109517SBill.Taylor@Sun.COM * hermon_ci_query_srq()
19119517SBill.Taylor@Sun.COM * Query properties of a Shared Receive Queue (SRQ)
19129517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
19139517SBill.Taylor@Sun.COM */
1914*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
19159517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_query_srq(ibc_hca_hdl_t hca,ibc_srq_hdl_t srq,ibc_pd_hdl_t * pd_p,ibt_srq_sizes_t * sizes_p,uint_t * limit_p)19169517SBill.Taylor@Sun.COM hermon_ci_query_srq(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq, ibc_pd_hdl_t *pd_p,
19179517SBill.Taylor@Sun.COM ibt_srq_sizes_t *sizes_p, uint_t *limit_p)
19189517SBill.Taylor@Sun.COM {
19199517SBill.Taylor@Sun.COM hermon_srqhdl_t srqhdl;
19209517SBill.Taylor@Sun.COM
19219517SBill.Taylor@Sun.COM srqhdl = (hermon_srqhdl_t)srq;
19229517SBill.Taylor@Sun.COM
19239517SBill.Taylor@Sun.COM mutex_enter(&srqhdl->srq_lock);
19249517SBill.Taylor@Sun.COM if (srqhdl->srq_state == HERMON_SRQ_STATE_ERROR) {
19259517SBill.Taylor@Sun.COM mutex_exit(&srqhdl->srq_lock);
19269517SBill.Taylor@Sun.COM return (IBT_SRQ_ERROR_STATE);
19279517SBill.Taylor@Sun.COM }
19289517SBill.Taylor@Sun.COM
19299517SBill.Taylor@Sun.COM *pd_p = (ibc_pd_hdl_t)srqhdl->srq_pdhdl;
19309517SBill.Taylor@Sun.COM sizes_p->srq_wr_sz = srqhdl->srq_real_sizes.srq_wr_sz - 1;
19319517SBill.Taylor@Sun.COM sizes_p->srq_sgl_sz = srqhdl->srq_real_sizes.srq_sgl_sz;
19329517SBill.Taylor@Sun.COM mutex_exit(&srqhdl->srq_lock);
19339517SBill.Taylor@Sun.COM *limit_p = 0;
19349517SBill.Taylor@Sun.COM
19359517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
19369517SBill.Taylor@Sun.COM }
19379517SBill.Taylor@Sun.COM
19389517SBill.Taylor@Sun.COM /*
19399517SBill.Taylor@Sun.COM * hermon_ci_modify_srq()
19409517SBill.Taylor@Sun.COM * Modify properties of a Shared Receive Queue (SRQ)
19419517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
19429517SBill.Taylor@Sun.COM */
19439517SBill.Taylor@Sun.COM /* ARGSUSED */
19449517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_modify_srq(ibc_hca_hdl_t hca,ibc_srq_hdl_t srq,ibt_srq_modify_flags_t flags,uint_t size,uint_t limit,uint_t * ret_size_p)19459517SBill.Taylor@Sun.COM hermon_ci_modify_srq(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
19469517SBill.Taylor@Sun.COM ibt_srq_modify_flags_t flags, uint_t size, uint_t limit, uint_t *ret_size_p)
19479517SBill.Taylor@Sun.COM {
19489517SBill.Taylor@Sun.COM hermon_state_t *state;
19499517SBill.Taylor@Sun.COM hermon_srqhdl_t srqhdl;
19509517SBill.Taylor@Sun.COM uint_t resize_supported, cur_srq_size;
19519517SBill.Taylor@Sun.COM int status;
19529517SBill.Taylor@Sun.COM
19539517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
19549517SBill.Taylor@Sun.COM srqhdl = (hermon_srqhdl_t)srq;
19559517SBill.Taylor@Sun.COM
19569517SBill.Taylor@Sun.COM /*
19579517SBill.Taylor@Sun.COM * Check Error State of SRQ.
19589517SBill.Taylor@Sun.COM * Also, while we are holding the lock we save away the current SRQ
19599517SBill.Taylor@Sun.COM * size for later use.
19609517SBill.Taylor@Sun.COM */
19619517SBill.Taylor@Sun.COM mutex_enter(&srqhdl->srq_lock);
19629517SBill.Taylor@Sun.COM cur_srq_size = srqhdl->srq_wq_bufsz;
19639517SBill.Taylor@Sun.COM if (srqhdl->srq_state == HERMON_SRQ_STATE_ERROR) {
19649517SBill.Taylor@Sun.COM mutex_exit(&srqhdl->srq_lock);
19659517SBill.Taylor@Sun.COM return (IBT_SRQ_ERROR_STATE);
19669517SBill.Taylor@Sun.COM }
19679517SBill.Taylor@Sun.COM mutex_exit(&srqhdl->srq_lock);
19689517SBill.Taylor@Sun.COM
19699517SBill.Taylor@Sun.COM /*
19709517SBill.Taylor@Sun.COM * Setting the limit watermark is not currently supported. This is a
19719517SBill.Taylor@Sun.COM * hermon hardware (firmware) limitation. We return NOT_SUPPORTED here,
19729517SBill.Taylor@Sun.COM * and have the limit code commented out for now.
19739517SBill.Taylor@Sun.COM *
19749517SBill.Taylor@Sun.COM * XXX If we enable the limit watermark support, we need to do checks
19759517SBill.Taylor@Sun.COM * and set the 'srq->srq_wr_limit' here, instead of returning not
19769517SBill.Taylor@Sun.COM * supported. The 'hermon_srq_modify' operation below is for resizing
19779517SBill.Taylor@Sun.COM * the SRQ only, the limit work should be done here. If this is
19789517SBill.Taylor@Sun.COM * changed to use the 'limit' field, the 'ARGSUSED' comment for this
19799517SBill.Taylor@Sun.COM * function should also be removed at that time.
19809517SBill.Taylor@Sun.COM */
19819517SBill.Taylor@Sun.COM if (flags & IBT_SRQ_SET_LIMIT) {
19829517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
19839517SBill.Taylor@Sun.COM }
19849517SBill.Taylor@Sun.COM
19859517SBill.Taylor@Sun.COM /*
19869517SBill.Taylor@Sun.COM * Check the SET_SIZE flag. If not set, we simply return success here.
19879517SBill.Taylor@Sun.COM * However if it is set, we check if resize is supported and only then
19889517SBill.Taylor@Sun.COM * do we continue on with our resize processing.
19899517SBill.Taylor@Sun.COM */
19909517SBill.Taylor@Sun.COM if (!(flags & IBT_SRQ_SET_SIZE)) {
19919517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
19929517SBill.Taylor@Sun.COM }
19939517SBill.Taylor@Sun.COM
19949517SBill.Taylor@Sun.COM resize_supported = state->hs_ibtfinfo.hca_attr->hca_flags &
19959517SBill.Taylor@Sun.COM IBT_HCA_RESIZE_SRQ;
19969517SBill.Taylor@Sun.COM
19979517SBill.Taylor@Sun.COM if ((flags & IBT_SRQ_SET_SIZE) && !resize_supported) {
19989517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
19999517SBill.Taylor@Sun.COM }
20009517SBill.Taylor@Sun.COM
20019517SBill.Taylor@Sun.COM /*
20029517SBill.Taylor@Sun.COM * We do not support resizing an SRQ to be smaller than it's current
20039517SBill.Taylor@Sun.COM * size. If a smaller (or equal) size is requested, then we simply
20049517SBill.Taylor@Sun.COM * return success, and do nothing.
20059517SBill.Taylor@Sun.COM */
20069517SBill.Taylor@Sun.COM if (size <= cur_srq_size) {
20079517SBill.Taylor@Sun.COM *ret_size_p = cur_srq_size;
20089517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
20099517SBill.Taylor@Sun.COM }
20109517SBill.Taylor@Sun.COM
20119517SBill.Taylor@Sun.COM status = hermon_srq_modify(state, srqhdl, size, ret_size_p,
20129517SBill.Taylor@Sun.COM HERMON_NOSLEEP);
20139517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
20149517SBill.Taylor@Sun.COM /* Set return value to current SRQ size */
20159517SBill.Taylor@Sun.COM *ret_size_p = cur_srq_size;
20169517SBill.Taylor@Sun.COM return (status);
20179517SBill.Taylor@Sun.COM }
20189517SBill.Taylor@Sun.COM
20199517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
20209517SBill.Taylor@Sun.COM }
20219517SBill.Taylor@Sun.COM
20229517SBill.Taylor@Sun.COM /*
20239517SBill.Taylor@Sun.COM * hermon_ci_post_srq()
20249517SBill.Taylor@Sun.COM * Post a Work Request to the specified Shared Receive Queue (SRQ)
20259517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
20269517SBill.Taylor@Sun.COM */
20279517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_post_srq(ibc_hca_hdl_t hca,ibc_srq_hdl_t srq,ibt_recv_wr_t * wr,uint_t num_wr,uint_t * num_posted_p)20289517SBill.Taylor@Sun.COM hermon_ci_post_srq(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
20299517SBill.Taylor@Sun.COM ibt_recv_wr_t *wr, uint_t num_wr, uint_t *num_posted_p)
20309517SBill.Taylor@Sun.COM {
20319517SBill.Taylor@Sun.COM hermon_state_t *state;
20329517SBill.Taylor@Sun.COM hermon_srqhdl_t srqhdl;
20339517SBill.Taylor@Sun.COM int status;
20349517SBill.Taylor@Sun.COM
20359517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
20369517SBill.Taylor@Sun.COM srqhdl = (hermon_srqhdl_t)srq;
20379517SBill.Taylor@Sun.COM
20389517SBill.Taylor@Sun.COM status = hermon_post_srq(state, srqhdl, wr, num_wr, num_posted_p);
20399517SBill.Taylor@Sun.COM return (status);
20409517SBill.Taylor@Sun.COM }
20419517SBill.Taylor@Sun.COM
20429517SBill.Taylor@Sun.COM /* Address translation */
204311972SBill.Taylor@Sun.COM
204411972SBill.Taylor@Sun.COM struct ibc_ma_s {
204511972SBill.Taylor@Sun.COM int h_ma_addr_list_len;
204611972SBill.Taylor@Sun.COM void *h_ma_addr_list;
204711972SBill.Taylor@Sun.COM ddi_dma_handle_t h_ma_dmahdl;
204811972SBill.Taylor@Sun.COM ddi_dma_handle_t h_ma_list_hdl;
204911972SBill.Taylor@Sun.COM ddi_acc_handle_t h_ma_list_acc_hdl;
205011972SBill.Taylor@Sun.COM size_t h_ma_real_len;
205111972SBill.Taylor@Sun.COM caddr_t h_ma_kaddr;
205211972SBill.Taylor@Sun.COM ibt_phys_addr_t h_ma_list_cookie;
205311972SBill.Taylor@Sun.COM };
205411972SBill.Taylor@Sun.COM
205511972SBill.Taylor@Sun.COM static ibt_status_t
hermon_map_mem_area_fmr(ibc_hca_hdl_t hca,ibt_va_attr_t * va_attrs,uint_t list_len,ibt_pmr_attr_t * pmr,ibc_ma_hdl_t * ma_hdl_p)205611972SBill.Taylor@Sun.COM hermon_map_mem_area_fmr(ibc_hca_hdl_t hca, ibt_va_attr_t *va_attrs,
205711972SBill.Taylor@Sun.COM uint_t list_len, ibt_pmr_attr_t *pmr, ibc_ma_hdl_t *ma_hdl_p)
205811972SBill.Taylor@Sun.COM {
205911972SBill.Taylor@Sun.COM int status;
206011972SBill.Taylor@Sun.COM ibt_status_t ibt_status;
206111972SBill.Taylor@Sun.COM ibc_ma_hdl_t ma_hdl;
206211972SBill.Taylor@Sun.COM ib_memlen_t len;
206311972SBill.Taylor@Sun.COM ddi_dma_attr_t dma_attr;
206411972SBill.Taylor@Sun.COM uint_t cookie_cnt;
206511972SBill.Taylor@Sun.COM ddi_dma_cookie_t dmacookie;
206611972SBill.Taylor@Sun.COM hermon_state_t *state;
206711972SBill.Taylor@Sun.COM uint64_t *kaddr;
206811972SBill.Taylor@Sun.COM uint64_t addr, endaddr, pagesize;
206911972SBill.Taylor@Sun.COM int i, kmflag;
207011972SBill.Taylor@Sun.COM int (*callback)(caddr_t);
207111972SBill.Taylor@Sun.COM
207211972SBill.Taylor@Sun.COM if ((va_attrs->va_flags & IBT_VA_BUF) == 0) {
207311972SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED); /* XXX - not yet implemented */
207411972SBill.Taylor@Sun.COM }
207511972SBill.Taylor@Sun.COM
207611972SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
207711972SBill.Taylor@Sun.COM hermon_dma_attr_init(state, &dma_attr);
207811972SBill.Taylor@Sun.COM if (va_attrs->va_flags & IBT_VA_NOSLEEP) {
207911972SBill.Taylor@Sun.COM kmflag = KM_NOSLEEP;
208011972SBill.Taylor@Sun.COM callback = DDI_DMA_DONTWAIT;
208111972SBill.Taylor@Sun.COM } else {
208211972SBill.Taylor@Sun.COM kmflag = KM_SLEEP;
208311972SBill.Taylor@Sun.COM callback = DDI_DMA_SLEEP;
208411972SBill.Taylor@Sun.COM }
208511972SBill.Taylor@Sun.COM
208611972SBill.Taylor@Sun.COM ma_hdl = kmem_zalloc(sizeof (*ma_hdl), kmflag);
208711972SBill.Taylor@Sun.COM if (ma_hdl == NULL) {
208811972SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
208911972SBill.Taylor@Sun.COM }
209011972SBill.Taylor@Sun.COM #ifdef __sparc
209111972SBill.Taylor@Sun.COM if (state->hs_cfg_profile->cp_iommu_bypass == HERMON_BINDMEM_BYPASS)
209211972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags = DDI_DMA_FORCE_PHYSICAL;
209311972SBill.Taylor@Sun.COM
209411972SBill.Taylor@Sun.COM if (hermon_kernel_data_ro == HERMON_RO_ENABLED)
209511972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags |= DDI_DMA_RELAXED_ORDERING;
209611972SBill.Taylor@Sun.COM #endif
209711972SBill.Taylor@Sun.COM
209811972SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ma_hdl))
209911972SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr,
210011972SBill.Taylor@Sun.COM callback, NULL, &ma_hdl->h_ma_dmahdl);
210111972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
210211972SBill.Taylor@Sun.COM kmem_free(ma_hdl, sizeof (*ma_hdl));
210311972SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
210411972SBill.Taylor@Sun.COM }
210511972SBill.Taylor@Sun.COM status = ddi_dma_buf_bind_handle(ma_hdl->h_ma_dmahdl,
210611972SBill.Taylor@Sun.COM va_attrs->va_buf, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
210711972SBill.Taylor@Sun.COM callback, NULL, &dmacookie, &cookie_cnt);
210811972SBill.Taylor@Sun.COM if (status != DDI_DMA_MAPPED) {
210911972SBill.Taylor@Sun.COM status = ibc_get_ci_failure(0);
211011972SBill.Taylor@Sun.COM goto marea_fail3;
211111972SBill.Taylor@Sun.COM }
211211972SBill.Taylor@Sun.COM
211311972SBill.Taylor@Sun.COM ma_hdl->h_ma_real_len = list_len * sizeof (ibt_phys_addr_t);
211411972SBill.Taylor@Sun.COM ma_hdl->h_ma_kaddr = kmem_zalloc(ma_hdl->h_ma_real_len, kmflag);
211511972SBill.Taylor@Sun.COM if (ma_hdl->h_ma_kaddr == NULL) {
211611972SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
211711972SBill.Taylor@Sun.COM goto marea_fail4;
211811972SBill.Taylor@Sun.COM }
211911972SBill.Taylor@Sun.COM
212011972SBill.Taylor@Sun.COM i = 0;
212111972SBill.Taylor@Sun.COM len = 0;
212211972SBill.Taylor@Sun.COM pagesize = PAGESIZE;
212311972SBill.Taylor@Sun.COM kaddr = (uint64_t *)(void *)ma_hdl->h_ma_kaddr;
212411972SBill.Taylor@Sun.COM while (cookie_cnt-- > 0) {
212511972SBill.Taylor@Sun.COM addr = dmacookie.dmac_laddress;
212611972SBill.Taylor@Sun.COM len += dmacookie.dmac_size;
212711972SBill.Taylor@Sun.COM endaddr = addr + (dmacookie.dmac_size - 1);
212811972SBill.Taylor@Sun.COM addr = addr & ~(pagesize - 1);
212911972SBill.Taylor@Sun.COM while (addr <= endaddr) {
213011972SBill.Taylor@Sun.COM if (i >= list_len) {
213111972SBill.Taylor@Sun.COM status = IBT_PBL_TOO_SMALL;
213211972SBill.Taylor@Sun.COM goto marea_fail5;
213311972SBill.Taylor@Sun.COM }
213411972SBill.Taylor@Sun.COM kaddr[i] = htonll(addr | HERMON_MTT_ENTRY_PRESENT);
213511972SBill.Taylor@Sun.COM i++;
213611972SBill.Taylor@Sun.COM addr += pagesize;
213711972SBill.Taylor@Sun.COM if (addr == 0) {
213811972SBill.Taylor@Sun.COM static int do_once = 1;
213911972SBill.Taylor@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
214011972SBill.Taylor@Sun.COM do_once))
214111972SBill.Taylor@Sun.COM if (do_once) {
214211972SBill.Taylor@Sun.COM do_once = 0;
214311972SBill.Taylor@Sun.COM cmn_err(CE_NOTE, "probable error in "
214411972SBill.Taylor@Sun.COM "dma_cookie address: map_mem_area");
214511972SBill.Taylor@Sun.COM }
214611972SBill.Taylor@Sun.COM break;
214711972SBill.Taylor@Sun.COM }
214811972SBill.Taylor@Sun.COM }
214911972SBill.Taylor@Sun.COM if (cookie_cnt != 0)
215011972SBill.Taylor@Sun.COM ddi_dma_nextcookie(ma_hdl->h_ma_dmahdl, &dmacookie);
215111972SBill.Taylor@Sun.COM }
215211972SBill.Taylor@Sun.COM
215311972SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*pmr))
215411972SBill.Taylor@Sun.COM pmr->pmr_addr_list = (ibt_phys_addr_t *)(void *)ma_hdl->h_ma_kaddr;
215511972SBill.Taylor@Sun.COM pmr->pmr_iova = va_attrs->va_vaddr;
215611972SBill.Taylor@Sun.COM pmr->pmr_len = len;
215711972SBill.Taylor@Sun.COM pmr->pmr_offset = va_attrs->va_vaddr & PAGEOFFSET;
215811972SBill.Taylor@Sun.COM pmr->pmr_buf_sz = PAGESHIFT; /* PRM says "Page Sice", but... */
215911972SBill.Taylor@Sun.COM pmr->pmr_num_buf = i;
216011972SBill.Taylor@Sun.COM pmr->pmr_ma = ma_hdl;
216111972SBill.Taylor@Sun.COM
216211972SBill.Taylor@Sun.COM *ma_hdl_p = ma_hdl;
216311972SBill.Taylor@Sun.COM return (IBT_SUCCESS);
216411972SBill.Taylor@Sun.COM
216511972SBill.Taylor@Sun.COM marea_fail5:
216611972SBill.Taylor@Sun.COM kmem_free(ma_hdl->h_ma_kaddr, ma_hdl->h_ma_real_len);
216711972SBill.Taylor@Sun.COM marea_fail4:
216811972SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(ma_hdl->h_ma_dmahdl);
216911972SBill.Taylor@Sun.COM marea_fail3:
217011972SBill.Taylor@Sun.COM ddi_dma_free_handle(&ma_hdl->h_ma_dmahdl);
217111972SBill.Taylor@Sun.COM kmem_free(ma_hdl, sizeof (*ma_hdl));
217211972SBill.Taylor@Sun.COM *ma_hdl_p = NULL;
217311972SBill.Taylor@Sun.COM return (ibt_status);
217411972SBill.Taylor@Sun.COM }
217511972SBill.Taylor@Sun.COM
21769517SBill.Taylor@Sun.COM /*
21779517SBill.Taylor@Sun.COM * hermon_ci_map_mem_area()
2178*12965SWilliam.Taylor@Oracle.COM * Context: Can be called from user or base context.
217911972SBill.Taylor@Sun.COM *
218011972SBill.Taylor@Sun.COM * Creates the memory mapping suitable for a subsequent posting of an
218111972SBill.Taylor@Sun.COM * FRWR work request. All the info about the memory area for the
218211972SBill.Taylor@Sun.COM * FRWR work request (wr member of "union ibt_reg_req_u") is filled
218311972SBill.Taylor@Sun.COM * such that the client only needs to point wr.rc.rcwr.reg_pmr to it,
218411972SBill.Taylor@Sun.COM * and then fill in the additional information only it knows.
218511972SBill.Taylor@Sun.COM *
218611972SBill.Taylor@Sun.COM * Alternatively, creates the memory mapping for FMR.
21879517SBill.Taylor@Sun.COM */
21889517SBill.Taylor@Sun.COM /* ARGSUSED */
21899517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_map_mem_area(ibc_hca_hdl_t hca,ibt_va_attr_t * va_attrs,void * ibtl_reserved,uint_t list_len,ibt_reg_req_t * reg_req,ibc_ma_hdl_t * ma_hdl_p)21909517SBill.Taylor@Sun.COM hermon_ci_map_mem_area(ibc_hca_hdl_t hca, ibt_va_attr_t *va_attrs,
219111972SBill.Taylor@Sun.COM void *ibtl_reserved, uint_t list_len, ibt_reg_req_t *reg_req,
219211972SBill.Taylor@Sun.COM ibc_ma_hdl_t *ma_hdl_p)
21939517SBill.Taylor@Sun.COM {
219411972SBill.Taylor@Sun.COM ibt_status_t ibt_status;
21959517SBill.Taylor@Sun.COM int status;
219611972SBill.Taylor@Sun.COM ibc_ma_hdl_t ma_hdl;
219711972SBill.Taylor@Sun.COM ibt_wr_reg_pmr_t *pmr;
219811972SBill.Taylor@Sun.COM ib_memlen_t len;
219911972SBill.Taylor@Sun.COM ddi_dma_attr_t dma_attr;
220011972SBill.Taylor@Sun.COM ddi_dma_handle_t khdl;
220111972SBill.Taylor@Sun.COM uint_t cookie_cnt;
220211972SBill.Taylor@Sun.COM ddi_dma_cookie_t dmacookie, kcookie;
220311972SBill.Taylor@Sun.COM hermon_state_t *state;
220411972SBill.Taylor@Sun.COM uint64_t *kaddr;
220511972SBill.Taylor@Sun.COM uint64_t addr, endaddr, pagesize, kcookie_paddr;
220611972SBill.Taylor@Sun.COM int i, j, kmflag;
220711972SBill.Taylor@Sun.COM int (*callback)(caddr_t);
220811972SBill.Taylor@Sun.COM
220911972SBill.Taylor@Sun.COM if (va_attrs->va_flags & (IBT_VA_FMR | IBT_VA_REG_FN)) {
221011972SBill.Taylor@Sun.COM /* delegate FMR and Physical Register to other function */
221111972SBill.Taylor@Sun.COM return (hermon_map_mem_area_fmr(hca, va_attrs, list_len,
221211972SBill.Taylor@Sun.COM ®_req->fn_arg, ma_hdl_p));
22139517SBill.Taylor@Sun.COM }
22149517SBill.Taylor@Sun.COM
221511972SBill.Taylor@Sun.COM /* FRWR */
22169517SBill.Taylor@Sun.COM
22179517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
2218*12965SWilliam.Taylor@Oracle.COM if (!(state->hs_ibtfinfo.hca_attr->hca_flags2 & IBT_HCA2_MEM_MGT_EXT))
2219*12965SWilliam.Taylor@Oracle.COM return (IBT_NOT_SUPPORTED);
222011972SBill.Taylor@Sun.COM hermon_dma_attr_init(state, &dma_attr);
222111972SBill.Taylor@Sun.COM #ifdef __sparc
222211972SBill.Taylor@Sun.COM if (state->hs_cfg_profile->cp_iommu_bypass == HERMON_BINDMEM_BYPASS)
222311972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags = DDI_DMA_FORCE_PHYSICAL;
222411972SBill.Taylor@Sun.COM
222511972SBill.Taylor@Sun.COM if (hermon_kernel_data_ro == HERMON_RO_ENABLED)
222611972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags |= DDI_DMA_RELAXED_ORDERING;
222711972SBill.Taylor@Sun.COM #endif
222811972SBill.Taylor@Sun.COM if (va_attrs->va_flags & IBT_VA_NOSLEEP) {
222911972SBill.Taylor@Sun.COM kmflag = KM_NOSLEEP;
223011972SBill.Taylor@Sun.COM callback = DDI_DMA_DONTWAIT;
223111972SBill.Taylor@Sun.COM } else {
223211972SBill.Taylor@Sun.COM kmflag = KM_SLEEP;
223311972SBill.Taylor@Sun.COM callback = DDI_DMA_SLEEP;
223411972SBill.Taylor@Sun.COM }
223511972SBill.Taylor@Sun.COM
223611972SBill.Taylor@Sun.COM ma_hdl = kmem_zalloc(sizeof (*ma_hdl), kmflag);
223711972SBill.Taylor@Sun.COM if (ma_hdl == NULL) {
223811972SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
223911972SBill.Taylor@Sun.COM }
224011972SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ma_hdl))
224111972SBill.Taylor@Sun.COM
224211972SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr,
224311972SBill.Taylor@Sun.COM callback, NULL, &ma_hdl->h_ma_dmahdl);
22449517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
224511972SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
224611972SBill.Taylor@Sun.COM goto marea_fail0;
22479517SBill.Taylor@Sun.COM }
224811972SBill.Taylor@Sun.COM dma_attr.dma_attr_align = 64; /* as per PRM */
224911972SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr,
225011972SBill.Taylor@Sun.COM callback, NULL, &ma_hdl->h_ma_list_hdl);
225111972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
225211972SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
225311972SBill.Taylor@Sun.COM goto marea_fail1;
225411972SBill.Taylor@Sun.COM }
22559517SBill.Taylor@Sun.COM /*
225611972SBill.Taylor@Sun.COM * Entries in the list in the last slot on each page cannot be used,
225711972SBill.Taylor@Sun.COM * so 1 extra ibt_phys_addr_t is allocated per page. We add 1 more
225811972SBill.Taylor@Sun.COM * to deal with the possibility of a less than 1 page allocation
225911972SBill.Taylor@Sun.COM * across a page boundary.
22609517SBill.Taylor@Sun.COM */
226111972SBill.Taylor@Sun.COM status = ddi_dma_mem_alloc(ma_hdl->h_ma_list_hdl, (list_len + 1 +
226211972SBill.Taylor@Sun.COM list_len / (HERMON_PAGESIZE / sizeof (ibt_phys_addr_t))) *
226311972SBill.Taylor@Sun.COM sizeof (ibt_phys_addr_t),
226411972SBill.Taylor@Sun.COM &state->hs_reg_accattr, DDI_DMA_CONSISTENT, callback, NULL,
226511972SBill.Taylor@Sun.COM &ma_hdl->h_ma_kaddr, &ma_hdl->h_ma_real_len,
226611972SBill.Taylor@Sun.COM &ma_hdl->h_ma_list_acc_hdl);
226711972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
226811972SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
226911972SBill.Taylor@Sun.COM goto marea_fail2;
227011972SBill.Taylor@Sun.COM }
227111972SBill.Taylor@Sun.COM status = ddi_dma_addr_bind_handle(ma_hdl->h_ma_list_hdl, NULL,
227211972SBill.Taylor@Sun.COM ma_hdl->h_ma_kaddr, ma_hdl->h_ma_real_len, DDI_DMA_RDWR |
227311972SBill.Taylor@Sun.COM DDI_DMA_CONSISTENT, callback, NULL,
227411972SBill.Taylor@Sun.COM &kcookie, &cookie_cnt);
22759517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
227611972SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
227711972SBill.Taylor@Sun.COM goto marea_fail3;
227811972SBill.Taylor@Sun.COM }
227911972SBill.Taylor@Sun.COM if ((kcookie.dmac_laddress & 0x3f) != 0) {
228011972SBill.Taylor@Sun.COM cmn_err(CE_NOTE, "64-byte alignment assumption wrong");
228111972SBill.Taylor@Sun.COM ibt_status = ibc_get_ci_failure(0);
228211972SBill.Taylor@Sun.COM goto marea_fail4;
228311972SBill.Taylor@Sun.COM }
228411972SBill.Taylor@Sun.COM ma_hdl->h_ma_list_cookie.p_laddr = kcookie.dmac_laddress;
228511972SBill.Taylor@Sun.COM
228611972SBill.Taylor@Sun.COM if (va_attrs->va_flags & IBT_VA_BUF) {
228711972SBill.Taylor@Sun.COM status = ddi_dma_buf_bind_handle(ma_hdl->h_ma_dmahdl,
228811972SBill.Taylor@Sun.COM va_attrs->va_buf, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
228911972SBill.Taylor@Sun.COM callback, NULL, &dmacookie, &cookie_cnt);
229011972SBill.Taylor@Sun.COM } else {
229111972SBill.Taylor@Sun.COM status = ddi_dma_addr_bind_handle(ma_hdl->h_ma_dmahdl,
229211972SBill.Taylor@Sun.COM va_attrs->va_as, (caddr_t)(uintptr_t)va_attrs->va_vaddr,
229311972SBill.Taylor@Sun.COM va_attrs->va_len, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
229411972SBill.Taylor@Sun.COM callback, NULL, &dmacookie, &cookie_cnt);
229511972SBill.Taylor@Sun.COM }
229611972SBill.Taylor@Sun.COM if (status != DDI_DMA_MAPPED) {
229711972SBill.Taylor@Sun.COM ibt_status = ibc_get_ci_failure(0);
229811972SBill.Taylor@Sun.COM goto marea_fail4;
22999517SBill.Taylor@Sun.COM }
230011972SBill.Taylor@Sun.COM i = 0; /* count the number of pbl entries */
230111972SBill.Taylor@Sun.COM j = 0; /* count the number of links to next HERMON_PAGE */
230211972SBill.Taylor@Sun.COM len = 0;
230311972SBill.Taylor@Sun.COM pagesize = PAGESIZE;
230411972SBill.Taylor@Sun.COM kaddr = (uint64_t *)(void *)ma_hdl->h_ma_kaddr;
2305*12965SWilliam.Taylor@Oracle.COM kcookie.dmac_size += kcookie.dmac_laddress & HERMON_PAGEOFFSET;
2306*12965SWilliam.Taylor@Oracle.COM kcookie_paddr = kcookie.dmac_laddress & HERMON_PAGEMASK;
230711972SBill.Taylor@Sun.COM khdl = ma_hdl->h_ma_list_hdl;
230811972SBill.Taylor@Sun.COM while (cookie_cnt-- > 0) {
230911972SBill.Taylor@Sun.COM addr = dmacookie.dmac_laddress;
231011972SBill.Taylor@Sun.COM len += dmacookie.dmac_size;
231111972SBill.Taylor@Sun.COM endaddr = addr + (dmacookie.dmac_size - 1);
231211972SBill.Taylor@Sun.COM addr = addr & ~(pagesize - 1);
231311972SBill.Taylor@Sun.COM while (addr <= endaddr) {
231411972SBill.Taylor@Sun.COM if (i >= list_len) {
231511972SBill.Taylor@Sun.COM ibt_status = IBT_PBL_TOO_SMALL;
231611972SBill.Taylor@Sun.COM goto marea_fail5;
231711972SBill.Taylor@Sun.COM }
231811972SBill.Taylor@Sun.COM /* Deal with last entry on page. */
231911972SBill.Taylor@Sun.COM if (!((uintptr_t)&kaddr[i+j+1] & HERMON_PAGEOFFSET)) {
232011972SBill.Taylor@Sun.COM if (kcookie.dmac_size > HERMON_PAGESIZE) {
232111972SBill.Taylor@Sun.COM kcookie_paddr += HERMON_PAGESIZE;
232211972SBill.Taylor@Sun.COM kcookie.dmac_size -= HERMON_PAGESIZE;
232311972SBill.Taylor@Sun.COM } else {
232411972SBill.Taylor@Sun.COM ddi_dma_nextcookie(khdl, &kcookie);
232511972SBill.Taylor@Sun.COM kcookie_paddr = kcookie.dmac_laddress;
232611972SBill.Taylor@Sun.COM }
232711972SBill.Taylor@Sun.COM kaddr[i+j] = htonll(kcookie_paddr);
232811972SBill.Taylor@Sun.COM j++;
232911972SBill.Taylor@Sun.COM }
233011972SBill.Taylor@Sun.COM kaddr[i+j] = htonll(addr | HERMON_MTT_ENTRY_PRESENT);
233111972SBill.Taylor@Sun.COM i++;
233211972SBill.Taylor@Sun.COM addr += pagesize;
233311972SBill.Taylor@Sun.COM if (addr == 0) {
233411972SBill.Taylor@Sun.COM static int do_once = 1;
233511972SBill.Taylor@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
233611972SBill.Taylor@Sun.COM do_once))
233711972SBill.Taylor@Sun.COM if (do_once) {
233811972SBill.Taylor@Sun.COM do_once = 0;
233911972SBill.Taylor@Sun.COM cmn_err(CE_NOTE, "probable error in "
234011972SBill.Taylor@Sun.COM "dma_cookie address: map_mem_area");
234111972SBill.Taylor@Sun.COM }
234211972SBill.Taylor@Sun.COM break;
234311972SBill.Taylor@Sun.COM }
234411972SBill.Taylor@Sun.COM }
234511972SBill.Taylor@Sun.COM if (cookie_cnt != 0)
234611972SBill.Taylor@Sun.COM ddi_dma_nextcookie(ma_hdl->h_ma_dmahdl, &dmacookie);
234711972SBill.Taylor@Sun.COM }
234811972SBill.Taylor@Sun.COM
234911972SBill.Taylor@Sun.COM pmr = ®_req->wr;
235011972SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*pmr))
235111972SBill.Taylor@Sun.COM pmr->pmr_len = len;
235211972SBill.Taylor@Sun.COM pmr->pmr_offset = va_attrs->va_vaddr & PAGEOFFSET;
235311972SBill.Taylor@Sun.COM pmr->pmr_buf_sz = PAGESHIFT; /* PRM says "Page Size", but... */
235411972SBill.Taylor@Sun.COM pmr->pmr_num_buf = i;
235511972SBill.Taylor@Sun.COM pmr->pmr_addr_list = &ma_hdl->h_ma_list_cookie;
235611972SBill.Taylor@Sun.COM
235711972SBill.Taylor@Sun.COM *ma_hdl_p = ma_hdl;
23589517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
235911972SBill.Taylor@Sun.COM
236011972SBill.Taylor@Sun.COM marea_fail5:
236111972SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(ma_hdl->h_ma_dmahdl);
236211972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
236311972SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
236411972SBill.Taylor@Sun.COM marea_fail4:
236511972SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(ma_hdl->h_ma_list_hdl);
236611972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
236711972SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
236811972SBill.Taylor@Sun.COM marea_fail3:
236911972SBill.Taylor@Sun.COM ddi_dma_mem_free(&ma_hdl->h_ma_list_acc_hdl);
237011972SBill.Taylor@Sun.COM marea_fail2:
237111972SBill.Taylor@Sun.COM ddi_dma_free_handle(&ma_hdl->h_ma_list_hdl);
237211972SBill.Taylor@Sun.COM marea_fail1:
237311972SBill.Taylor@Sun.COM ddi_dma_free_handle(&ma_hdl->h_ma_dmahdl);
237411972SBill.Taylor@Sun.COM marea_fail0:
237511972SBill.Taylor@Sun.COM kmem_free(ma_hdl, sizeof (*ma_hdl));
237611972SBill.Taylor@Sun.COM *ma_hdl_p = NULL;
237711972SBill.Taylor@Sun.COM return (ibt_status);
23789517SBill.Taylor@Sun.COM }
23799517SBill.Taylor@Sun.COM
23809517SBill.Taylor@Sun.COM /*
23819517SBill.Taylor@Sun.COM * hermon_ci_unmap_mem_area()
23829517SBill.Taylor@Sun.COM * Unmap the memory area
23839517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
23849517SBill.Taylor@Sun.COM */
23859517SBill.Taylor@Sun.COM /* ARGSUSED */
23869517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_unmap_mem_area(ibc_hca_hdl_t hca,ibc_ma_hdl_t ma_hdl)23879517SBill.Taylor@Sun.COM hermon_ci_unmap_mem_area(ibc_hca_hdl_t hca, ibc_ma_hdl_t ma_hdl)
23889517SBill.Taylor@Sun.COM {
238911972SBill.Taylor@Sun.COM int status;
239011972SBill.Taylor@Sun.COM hermon_state_t *state;
23919517SBill.Taylor@Sun.COM
23929517SBill.Taylor@Sun.COM if (ma_hdl == NULL) {
239311972SBill.Taylor@Sun.COM return (IBT_MA_HDL_INVALID);
23949517SBill.Taylor@Sun.COM }
239511972SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
239611972SBill.Taylor@Sun.COM if (ma_hdl->h_ma_list_hdl != NULL) {
239711972SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(ma_hdl->h_ma_list_hdl);
239811972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
239911972SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
240011972SBill.Taylor@Sun.COM ddi_dma_mem_free(&ma_hdl->h_ma_list_acc_hdl);
240111972SBill.Taylor@Sun.COM ddi_dma_free_handle(&ma_hdl->h_ma_list_hdl);
240211972SBill.Taylor@Sun.COM } else {
240311972SBill.Taylor@Sun.COM kmem_free(ma_hdl->h_ma_kaddr, ma_hdl->h_ma_real_len);
24049517SBill.Taylor@Sun.COM }
240511972SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(ma_hdl->h_ma_dmahdl);
240611972SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
240711972SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
240811972SBill.Taylor@Sun.COM ddi_dma_free_handle(&ma_hdl->h_ma_dmahdl);
240911972SBill.Taylor@Sun.COM kmem_free(ma_hdl, sizeof (*ma_hdl));
24109517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
24119517SBill.Taylor@Sun.COM }
24129517SBill.Taylor@Sun.COM
24139517SBill.Taylor@Sun.COM struct ibc_mi_s {
24149517SBill.Taylor@Sun.COM int imh_len;
24159517SBill.Taylor@Sun.COM ddi_dma_handle_t imh_dmahandle[1];
24169517SBill.Taylor@Sun.COM };
24179517SBill.Taylor@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
24189517SBill.Taylor@Sun.COM ibc_mi_s::imh_len
24199517SBill.Taylor@Sun.COM ibc_mi_s::imh_dmahandle))
24209517SBill.Taylor@Sun.COM
24219517SBill.Taylor@Sun.COM
24229517SBill.Taylor@Sun.COM /*
24239517SBill.Taylor@Sun.COM * hermon_ci_map_mem_iov()
24249517SBill.Taylor@Sun.COM * Map the memory
24259517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
24269517SBill.Taylor@Sun.COM */
24279517SBill.Taylor@Sun.COM /* ARGSUSED */
24289517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_map_mem_iov(ibc_hca_hdl_t hca,ibt_iov_attr_t * iov_attr,ibt_all_wr_t * wr,ibc_mi_hdl_t * mi_hdl_p)24299517SBill.Taylor@Sun.COM hermon_ci_map_mem_iov(ibc_hca_hdl_t hca, ibt_iov_attr_t *iov_attr,
24309517SBill.Taylor@Sun.COM ibt_all_wr_t *wr, ibc_mi_hdl_t *mi_hdl_p)
24319517SBill.Taylor@Sun.COM {
24329517SBill.Taylor@Sun.COM int status;
243310852SBill.Taylor@Sun.COM int i, j, nds, max_nds;
24349517SBill.Taylor@Sun.COM uint_t len;
24359517SBill.Taylor@Sun.COM ibt_status_t ibt_status;
24369517SBill.Taylor@Sun.COM ddi_dma_handle_t dmahdl;
24379517SBill.Taylor@Sun.COM ddi_dma_cookie_t dmacookie;
24389517SBill.Taylor@Sun.COM ddi_dma_attr_t dma_attr;
24399517SBill.Taylor@Sun.COM uint_t cookie_cnt;
24409517SBill.Taylor@Sun.COM ibc_mi_hdl_t mi_hdl;
24419517SBill.Taylor@Sun.COM ibt_lkey_t rsvd_lkey;
24429517SBill.Taylor@Sun.COM ibt_wr_ds_t *sgl;
24439517SBill.Taylor@Sun.COM hermon_state_t *state;
24449517SBill.Taylor@Sun.COM int kmflag;
24459517SBill.Taylor@Sun.COM int (*callback)(caddr_t);
24469517SBill.Taylor@Sun.COM
24479517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*wr))
24489517SBill.Taylor@Sun.COM
24499517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
24509517SBill.Taylor@Sun.COM hermon_dma_attr_init(state, &dma_attr);
245111972SBill.Taylor@Sun.COM #ifdef __sparc
245211972SBill.Taylor@Sun.COM if (state->hs_cfg_profile->cp_iommu_bypass == HERMON_BINDMEM_BYPASS)
245311972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags = DDI_DMA_FORCE_PHYSICAL;
245411972SBill.Taylor@Sun.COM
245511972SBill.Taylor@Sun.COM if (hermon_kernel_data_ro == HERMON_RO_ENABLED)
245611972SBill.Taylor@Sun.COM dma_attr.dma_attr_flags |= DDI_DMA_RELAXED_ORDERING;
245711972SBill.Taylor@Sun.COM #endif
24589517SBill.Taylor@Sun.COM
24599517SBill.Taylor@Sun.COM nds = 0;
24609517SBill.Taylor@Sun.COM max_nds = iov_attr->iov_wr_nds;
24619517SBill.Taylor@Sun.COM if (iov_attr->iov_lso_hdr_sz)
24629517SBill.Taylor@Sun.COM max_nds -= (iov_attr->iov_lso_hdr_sz + sizeof (uint32_t) +
24639517SBill.Taylor@Sun.COM 0xf) >> 4; /* 0xf is for rounding up to a multiple of 16 */
2464*12965SWilliam.Taylor@Oracle.COM rsvd_lkey = (iov_attr->iov_flags & IBT_IOV_ALT_LKEY) ?
2465*12965SWilliam.Taylor@Oracle.COM iov_attr->iov_alt_lkey : state->hs_devlim.rsv_lkey;
246610852SBill.Taylor@Sun.COM if ((iov_attr->iov_flags & IBT_IOV_NOSLEEP) == 0) {
24679517SBill.Taylor@Sun.COM kmflag = KM_SLEEP;
24689517SBill.Taylor@Sun.COM callback = DDI_DMA_SLEEP;
24699517SBill.Taylor@Sun.COM } else {
24709517SBill.Taylor@Sun.COM kmflag = KM_NOSLEEP;
24719517SBill.Taylor@Sun.COM callback = DDI_DMA_DONTWAIT;
24729517SBill.Taylor@Sun.COM }
24739517SBill.Taylor@Sun.COM
24749517SBill.Taylor@Sun.COM if (iov_attr->iov_flags & IBT_IOV_BUF) {
24759517SBill.Taylor@Sun.COM mi_hdl = kmem_alloc(sizeof (*mi_hdl), kmflag);
24769517SBill.Taylor@Sun.COM if (mi_hdl == NULL)
24779517SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
24789517SBill.Taylor@Sun.COM sgl = wr->send.wr_sgl;
24799517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*sgl))
24809517SBill.Taylor@Sun.COM
24819517SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr,
24829517SBill.Taylor@Sun.COM callback, NULL, &dmahdl);
24839517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
24849517SBill.Taylor@Sun.COM kmem_free(mi_hdl, sizeof (*mi_hdl));
24859517SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
24869517SBill.Taylor@Sun.COM }
24879517SBill.Taylor@Sun.COM status = ddi_dma_buf_bind_handle(dmahdl, iov_attr->iov_buf,
24889517SBill.Taylor@Sun.COM DDI_DMA_RDWR | DDI_DMA_CONSISTENT, callback, NULL,
24899517SBill.Taylor@Sun.COM &dmacookie, &cookie_cnt);
24909517SBill.Taylor@Sun.COM if (status != DDI_DMA_MAPPED) {
24919517SBill.Taylor@Sun.COM ddi_dma_free_handle(&dmahdl);
24929517SBill.Taylor@Sun.COM kmem_free(mi_hdl, sizeof (*mi_hdl));
24939517SBill.Taylor@Sun.COM return (ibc_get_ci_failure(0));
24949517SBill.Taylor@Sun.COM }
24959517SBill.Taylor@Sun.COM while (cookie_cnt-- > 0) {
249611972SBill.Taylor@Sun.COM if (nds > max_nds) {
24979517SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(dmahdl);
24989517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
24999517SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to "
25009517SBill.Taylor@Sun.COM "unbind DMA mapping");
25019517SBill.Taylor@Sun.COM ddi_dma_free_handle(&dmahdl);
25029517SBill.Taylor@Sun.COM return (IBT_SGL_TOO_SMALL);
25039517SBill.Taylor@Sun.COM }
25049517SBill.Taylor@Sun.COM sgl[nds].ds_va = dmacookie.dmac_laddress;
25059517SBill.Taylor@Sun.COM sgl[nds].ds_key = rsvd_lkey;
25069517SBill.Taylor@Sun.COM sgl[nds].ds_len = (ib_msglen_t)dmacookie.dmac_size;
25079517SBill.Taylor@Sun.COM nds++;
25089517SBill.Taylor@Sun.COM if (cookie_cnt != 0)
25099517SBill.Taylor@Sun.COM ddi_dma_nextcookie(dmahdl, &dmacookie);
25109517SBill.Taylor@Sun.COM }
25119517SBill.Taylor@Sun.COM wr->send.wr_nds = nds;
25129517SBill.Taylor@Sun.COM mi_hdl->imh_len = 1;
25139517SBill.Taylor@Sun.COM mi_hdl->imh_dmahandle[0] = dmahdl;
25149517SBill.Taylor@Sun.COM *mi_hdl_p = mi_hdl;
25159517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
25169517SBill.Taylor@Sun.COM }
25179517SBill.Taylor@Sun.COM
25189517SBill.Taylor@Sun.COM if (iov_attr->iov_flags & IBT_IOV_RECV)
25199517SBill.Taylor@Sun.COM sgl = wr->recv.wr_sgl;
25209517SBill.Taylor@Sun.COM else
25219517SBill.Taylor@Sun.COM sgl = wr->send.wr_sgl;
25229517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*sgl))
25239517SBill.Taylor@Sun.COM
25249517SBill.Taylor@Sun.COM len = iov_attr->iov_list_len;
252510852SBill.Taylor@Sun.COM for (i = 0, j = 0; j < len; j++) {
252610852SBill.Taylor@Sun.COM if (iov_attr->iov[j].iov_len == 0)
252710852SBill.Taylor@Sun.COM continue;
252810852SBill.Taylor@Sun.COM i++;
252910852SBill.Taylor@Sun.COM }
25309517SBill.Taylor@Sun.COM mi_hdl = kmem_alloc(sizeof (*mi_hdl) +
253110852SBill.Taylor@Sun.COM (i - 1) * sizeof (ddi_dma_handle_t), kmflag);
25329517SBill.Taylor@Sun.COM if (mi_hdl == NULL)
25339517SBill.Taylor@Sun.COM return (IBT_INSUFF_RESOURCE);
253410852SBill.Taylor@Sun.COM mi_hdl->imh_len = i;
253510852SBill.Taylor@Sun.COM for (i = 0, j = 0; j < len; j++) {
253610852SBill.Taylor@Sun.COM if (iov_attr->iov[j].iov_len == 0)
253710852SBill.Taylor@Sun.COM continue;
25389517SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr,
25399517SBill.Taylor@Sun.COM callback, NULL, &dmahdl);
25409517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
25419517SBill.Taylor@Sun.COM ibt_status = IBT_INSUFF_RESOURCE;
25429517SBill.Taylor@Sun.COM goto fail2;
25439517SBill.Taylor@Sun.COM }
25449517SBill.Taylor@Sun.COM status = ddi_dma_addr_bind_handle(dmahdl, iov_attr->iov_as,
254510852SBill.Taylor@Sun.COM iov_attr->iov[j].iov_addr, iov_attr->iov[j].iov_len,
25469517SBill.Taylor@Sun.COM DDI_DMA_RDWR | DDI_DMA_CONSISTENT, callback, NULL,
25479517SBill.Taylor@Sun.COM &dmacookie, &cookie_cnt);
25489517SBill.Taylor@Sun.COM if (status != DDI_DMA_MAPPED) {
25499517SBill.Taylor@Sun.COM ibt_status = ibc_get_ci_failure(0);
25509517SBill.Taylor@Sun.COM goto fail1;
25519517SBill.Taylor@Sun.COM }
255211972SBill.Taylor@Sun.COM if (nds + cookie_cnt > max_nds) {
25539517SBill.Taylor@Sun.COM ibt_status = IBT_SGL_TOO_SMALL;
25549517SBill.Taylor@Sun.COM goto fail2;
25559517SBill.Taylor@Sun.COM }
25569517SBill.Taylor@Sun.COM while (cookie_cnt-- > 0) {
25579517SBill.Taylor@Sun.COM sgl[nds].ds_va = dmacookie.dmac_laddress;
25589517SBill.Taylor@Sun.COM sgl[nds].ds_key = rsvd_lkey;
25599517SBill.Taylor@Sun.COM sgl[nds].ds_len = (ib_msglen_t)dmacookie.dmac_size;
25609517SBill.Taylor@Sun.COM nds++;
25619517SBill.Taylor@Sun.COM if (cookie_cnt != 0)
25629517SBill.Taylor@Sun.COM ddi_dma_nextcookie(dmahdl, &dmacookie);
25639517SBill.Taylor@Sun.COM }
25649517SBill.Taylor@Sun.COM mi_hdl->imh_dmahandle[i] = dmahdl;
256510852SBill.Taylor@Sun.COM i++;
25669517SBill.Taylor@Sun.COM }
25679517SBill.Taylor@Sun.COM
25689517SBill.Taylor@Sun.COM if (iov_attr->iov_flags & IBT_IOV_RECV)
25699517SBill.Taylor@Sun.COM wr->recv.wr_nds = nds;
25709517SBill.Taylor@Sun.COM else
25719517SBill.Taylor@Sun.COM wr->send.wr_nds = nds;
25729517SBill.Taylor@Sun.COM *mi_hdl_p = mi_hdl;
25739517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
25749517SBill.Taylor@Sun.COM
25759517SBill.Taylor@Sun.COM fail1:
25769517SBill.Taylor@Sun.COM ddi_dma_free_handle(&dmahdl);
25779517SBill.Taylor@Sun.COM fail2:
25789517SBill.Taylor@Sun.COM while (--i >= 0) {
25799517SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(mi_hdl->imh_dmahandle[i]);
25809517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
25819517SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
25829517SBill.Taylor@Sun.COM ddi_dma_free_handle(&mi_hdl->imh_dmahandle[i]);
25839517SBill.Taylor@Sun.COM }
25849517SBill.Taylor@Sun.COM kmem_free(mi_hdl, sizeof (*mi_hdl) +
25859517SBill.Taylor@Sun.COM (len - 1) * sizeof (ddi_dma_handle_t));
25869517SBill.Taylor@Sun.COM *mi_hdl_p = NULL;
25879517SBill.Taylor@Sun.COM return (ibt_status);
25889517SBill.Taylor@Sun.COM }
25899517SBill.Taylor@Sun.COM
25909517SBill.Taylor@Sun.COM /*
25919517SBill.Taylor@Sun.COM * hermon_ci_unmap_mem_iov()
25929517SBill.Taylor@Sun.COM * Unmap the memory
25939517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
25949517SBill.Taylor@Sun.COM */
25959517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_unmap_mem_iov(ibc_hca_hdl_t hca,ibc_mi_hdl_t mi_hdl)25969517SBill.Taylor@Sun.COM hermon_ci_unmap_mem_iov(ibc_hca_hdl_t hca, ibc_mi_hdl_t mi_hdl)
25979517SBill.Taylor@Sun.COM {
25989517SBill.Taylor@Sun.COM int status, i;
25999517SBill.Taylor@Sun.COM hermon_state_t *state;
26009517SBill.Taylor@Sun.COM
26019517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
26029517SBill.Taylor@Sun.COM
260312574SWilliam.Taylor@Oracle.COM for (i = mi_hdl->imh_len; --i >= 0; ) {
26049517SBill.Taylor@Sun.COM status = ddi_dma_unbind_handle(mi_hdl->imh_dmahandle[i]);
26059517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS)
26069517SBill.Taylor@Sun.COM HERMON_WARNING(state, "failed to unbind DMA mapping");
26079517SBill.Taylor@Sun.COM ddi_dma_free_handle(&mi_hdl->imh_dmahandle[i]);
26089517SBill.Taylor@Sun.COM }
26099517SBill.Taylor@Sun.COM kmem_free(mi_hdl, sizeof (*mi_hdl) +
26109517SBill.Taylor@Sun.COM (mi_hdl->imh_len - 1) * sizeof (ddi_dma_handle_t));
26119517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
26129517SBill.Taylor@Sun.COM }
26139517SBill.Taylor@Sun.COM
26149517SBill.Taylor@Sun.COM /*
26159517SBill.Taylor@Sun.COM * hermon_ci_alloc_lkey()
2616*12965SWilliam.Taylor@Oracle.COM * Allocate an empty memory region for use with FRWR.
2617*12965SWilliam.Taylor@Oracle.COM * Context: Can be called from user or base context.
26189517SBill.Taylor@Sun.COM */
26199517SBill.Taylor@Sun.COM /* ARGSUSED */
26209517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_lkey(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_lkey_flags_t flags,uint_t list_sz,ibc_mr_hdl_t * mr_p,ibt_pmr_desc_t * mem_desc_p)26219517SBill.Taylor@Sun.COM hermon_ci_alloc_lkey(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
262211972SBill.Taylor@Sun.COM ibt_lkey_flags_t flags, uint_t list_sz, ibc_mr_hdl_t *mr_p,
26239517SBill.Taylor@Sun.COM ibt_pmr_desc_t *mem_desc_p)
26249517SBill.Taylor@Sun.COM {
2625*12965SWilliam.Taylor@Oracle.COM hermon_state_t *state;
2626*12965SWilliam.Taylor@Oracle.COM hermon_pdhdl_t pdhdl;
2627*12965SWilliam.Taylor@Oracle.COM hermon_mrhdl_t mrhdl;
2628*12965SWilliam.Taylor@Oracle.COM int status;
2629*12965SWilliam.Taylor@Oracle.COM
2630*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mem_desc_p))
2631*12965SWilliam.Taylor@Oracle.COM
2632*12965SWilliam.Taylor@Oracle.COM ASSERT(mr_p != NULL);
2633*12965SWilliam.Taylor@Oracle.COM ASSERT(mem_desc_p != NULL);
2634*12965SWilliam.Taylor@Oracle.COM
2635*12965SWilliam.Taylor@Oracle.COM state = (hermon_state_t *)hca;
2636*12965SWilliam.Taylor@Oracle.COM pdhdl = (hermon_pdhdl_t)pd;
2637*12965SWilliam.Taylor@Oracle.COM
2638*12965SWilliam.Taylor@Oracle.COM if (!(state->hs_ibtfinfo.hca_attr->hca_flags2 & IBT_HCA2_MEM_MGT_EXT))
2639*12965SWilliam.Taylor@Oracle.COM return (IBT_NOT_SUPPORTED);
2640*12965SWilliam.Taylor@Oracle.COM
2641*12965SWilliam.Taylor@Oracle.COM status = hermon_mr_alloc_lkey(state, pdhdl, flags, list_sz, &mrhdl);
2642*12965SWilliam.Taylor@Oracle.COM if (status != DDI_SUCCESS) {
2643*12965SWilliam.Taylor@Oracle.COM return (status);
2644*12965SWilliam.Taylor@Oracle.COM }
2645*12965SWilliam.Taylor@Oracle.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mrhdl))
2646*12965SWilliam.Taylor@Oracle.COM
2647*12965SWilliam.Taylor@Oracle.COM /* Fill in the mem_desc_p structure */
2648*12965SWilliam.Taylor@Oracle.COM mem_desc_p->pmd_iova = 0;
2649*12965SWilliam.Taylor@Oracle.COM mem_desc_p->pmd_phys_buf_list_sz = list_sz;
2650*12965SWilliam.Taylor@Oracle.COM mem_desc_p->pmd_lkey = mrhdl->mr_lkey;
2651*12965SWilliam.Taylor@Oracle.COM /* Only set RKey if remote access was requested */
2652*12965SWilliam.Taylor@Oracle.COM if (flags & IBT_KEY_REMOTE) {
2653*12965SWilliam.Taylor@Oracle.COM mem_desc_p->pmd_rkey = mrhdl->mr_rkey;
2654*12965SWilliam.Taylor@Oracle.COM }
2655*12965SWilliam.Taylor@Oracle.COM mem_desc_p->pmd_sync_required = B_FALSE;
2656*12965SWilliam.Taylor@Oracle.COM
2657*12965SWilliam.Taylor@Oracle.COM /* Return the Hermon MR handle */
2658*12965SWilliam.Taylor@Oracle.COM *mr_p = (ibc_mr_hdl_t)mrhdl;
2659*12965SWilliam.Taylor@Oracle.COM return (IBT_SUCCESS);
26609517SBill.Taylor@Sun.COM }
26619517SBill.Taylor@Sun.COM
26629517SBill.Taylor@Sun.COM /* Physical Register Memory Region */
26639517SBill.Taylor@Sun.COM /*
26649517SBill.Taylor@Sun.COM * hermon_ci_register_physical_mr()
26659517SBill.Taylor@Sun.COM */
26669517SBill.Taylor@Sun.COM /* ARGSUSED */
26679517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_register_physical_mr(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_pmr_attr_t * mem_pattrs,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_pmr_desc_t * mem_desc_p)26689517SBill.Taylor@Sun.COM hermon_ci_register_physical_mr(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
26699517SBill.Taylor@Sun.COM ibt_pmr_attr_t *mem_pattrs, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
26709517SBill.Taylor@Sun.COM ibt_pmr_desc_t *mem_desc_p)
26719517SBill.Taylor@Sun.COM {
26729517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
26739517SBill.Taylor@Sun.COM }
26749517SBill.Taylor@Sun.COM
26759517SBill.Taylor@Sun.COM /*
26769517SBill.Taylor@Sun.COM * hermon_ci_reregister_physical_mr()
26779517SBill.Taylor@Sun.COM */
26789517SBill.Taylor@Sun.COM /* ARGSUSED */
26799517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_reregister_physical_mr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr,ibc_pd_hdl_t pd,ibt_pmr_attr_t * mem_pattrs,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_pmr_desc_t * mr_desc_p)26809517SBill.Taylor@Sun.COM hermon_ci_reregister_physical_mr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
26819517SBill.Taylor@Sun.COM ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattrs, void *ibtl_reserved,
26829517SBill.Taylor@Sun.COM ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mr_desc_p)
26839517SBill.Taylor@Sun.COM {
26849517SBill.Taylor@Sun.COM return (IBT_NOT_SUPPORTED);
26859517SBill.Taylor@Sun.COM }
26869517SBill.Taylor@Sun.COM
26879517SBill.Taylor@Sun.COM /* Mellanox FMR Support */
26889517SBill.Taylor@Sun.COM /*
26899517SBill.Taylor@Sun.COM * hermon_ci_create_fmr_pool()
26909517SBill.Taylor@Sun.COM * Creates a pool of memory regions suitable for FMR registration
26919517SBill.Taylor@Sun.COM * Context: Can be called from base context only
26929517SBill.Taylor@Sun.COM */
26939517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_create_fmr_pool(ibc_hca_hdl_t hca,ibc_pd_hdl_t pd,ibt_fmr_pool_attr_t * params,ibc_fmr_pool_hdl_t * fmr_pool_p)26949517SBill.Taylor@Sun.COM hermon_ci_create_fmr_pool(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
26959517SBill.Taylor@Sun.COM ibt_fmr_pool_attr_t *params, ibc_fmr_pool_hdl_t *fmr_pool_p)
26969517SBill.Taylor@Sun.COM {
26979517SBill.Taylor@Sun.COM hermon_state_t *state;
26989517SBill.Taylor@Sun.COM hermon_pdhdl_t pdhdl;
26999517SBill.Taylor@Sun.COM hermon_fmrhdl_t fmrpoolhdl;
27009517SBill.Taylor@Sun.COM int status;
27019517SBill.Taylor@Sun.COM
27029517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
27039517SBill.Taylor@Sun.COM
27049517SBill.Taylor@Sun.COM /* Check for valid PD handle pointer */
27059517SBill.Taylor@Sun.COM if (pd == NULL) {
27069517SBill.Taylor@Sun.COM return (IBT_PD_HDL_INVALID);
27079517SBill.Taylor@Sun.COM }
27089517SBill.Taylor@Sun.COM
27099517SBill.Taylor@Sun.COM pdhdl = (hermon_pdhdl_t)pd;
27109517SBill.Taylor@Sun.COM
27119517SBill.Taylor@Sun.COM /*
27129517SBill.Taylor@Sun.COM * Validate the access flags. Both Remote Write and Remote Atomic
27139517SBill.Taylor@Sun.COM * require the Local Write flag to be set
27149517SBill.Taylor@Sun.COM */
27159517SBill.Taylor@Sun.COM if (((params->fmr_flags & IBT_MR_ENABLE_REMOTE_WRITE) ||
27169517SBill.Taylor@Sun.COM (params->fmr_flags & IBT_MR_ENABLE_REMOTE_ATOMIC)) &&
27179517SBill.Taylor@Sun.COM !(params->fmr_flags & IBT_MR_ENABLE_LOCAL_WRITE)) {
27189517SBill.Taylor@Sun.COM return (IBT_MR_ACCESS_REQ_INVALID);
27199517SBill.Taylor@Sun.COM }
27209517SBill.Taylor@Sun.COM
27219517SBill.Taylor@Sun.COM status = hermon_create_fmr_pool(state, pdhdl, params, &fmrpoolhdl);
27229517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
27239517SBill.Taylor@Sun.COM return (status);
27249517SBill.Taylor@Sun.COM }
27259517SBill.Taylor@Sun.COM
27269517SBill.Taylor@Sun.COM /* Set fmr_pool from hermon handle */
27279517SBill.Taylor@Sun.COM *fmr_pool_p = (ibc_fmr_pool_hdl_t)fmrpoolhdl;
27289517SBill.Taylor@Sun.COM
27299517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
27309517SBill.Taylor@Sun.COM }
27319517SBill.Taylor@Sun.COM
27329517SBill.Taylor@Sun.COM /*
27339517SBill.Taylor@Sun.COM * hermon_ci_destroy_fmr_pool()
27349517SBill.Taylor@Sun.COM * Free all resources associated with an FMR pool.
27359517SBill.Taylor@Sun.COM * Context: Can be called from base context only.
27369517SBill.Taylor@Sun.COM */
27379517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_destroy_fmr_pool(ibc_hca_hdl_t hca,ibc_fmr_pool_hdl_t fmr_pool)27389517SBill.Taylor@Sun.COM hermon_ci_destroy_fmr_pool(ibc_hca_hdl_t hca, ibc_fmr_pool_hdl_t fmr_pool)
27399517SBill.Taylor@Sun.COM {
27409517SBill.Taylor@Sun.COM hermon_state_t *state;
27419517SBill.Taylor@Sun.COM hermon_fmrhdl_t fmrpoolhdl;
27429517SBill.Taylor@Sun.COM int status;
27439517SBill.Taylor@Sun.COM
27449517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
27459517SBill.Taylor@Sun.COM fmrpoolhdl = (hermon_fmrhdl_t)fmr_pool;
27469517SBill.Taylor@Sun.COM
27479517SBill.Taylor@Sun.COM status = hermon_destroy_fmr_pool(state, fmrpoolhdl);
27489517SBill.Taylor@Sun.COM return (status);
27499517SBill.Taylor@Sun.COM }
27509517SBill.Taylor@Sun.COM
27519517SBill.Taylor@Sun.COM /*
27529517SBill.Taylor@Sun.COM * hermon_ci_flush_fmr_pool()
27539517SBill.Taylor@Sun.COM * Force a flush of the memory tables, cleaning up used FMR resources.
27549517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
27559517SBill.Taylor@Sun.COM */
27569517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_flush_fmr_pool(ibc_hca_hdl_t hca,ibc_fmr_pool_hdl_t fmr_pool)27579517SBill.Taylor@Sun.COM hermon_ci_flush_fmr_pool(ibc_hca_hdl_t hca, ibc_fmr_pool_hdl_t fmr_pool)
27589517SBill.Taylor@Sun.COM {
27599517SBill.Taylor@Sun.COM hermon_state_t *state;
27609517SBill.Taylor@Sun.COM hermon_fmrhdl_t fmrpoolhdl;
27619517SBill.Taylor@Sun.COM int status;
27629517SBill.Taylor@Sun.COM
27639517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
27649517SBill.Taylor@Sun.COM
27659517SBill.Taylor@Sun.COM fmrpoolhdl = (hermon_fmrhdl_t)fmr_pool;
27669517SBill.Taylor@Sun.COM status = hermon_flush_fmr_pool(state, fmrpoolhdl);
27679517SBill.Taylor@Sun.COM return (status);
27689517SBill.Taylor@Sun.COM }
27699517SBill.Taylor@Sun.COM
27709517SBill.Taylor@Sun.COM /*
27719517SBill.Taylor@Sun.COM * hermon_ci_register_physical_fmr()
27729517SBill.Taylor@Sun.COM * From the 'pool' of FMR regions passed in, performs register physical
27739517SBill.Taylor@Sun.COM * operation.
27749517SBill.Taylor@Sun.COM * Context: Can be called from interrupt or base context.
27759517SBill.Taylor@Sun.COM */
27769517SBill.Taylor@Sun.COM /* ARGSUSED */
27779517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_register_physical_fmr(ibc_hca_hdl_t hca,ibc_fmr_pool_hdl_t fmr_pool,ibt_pmr_attr_t * mem_pattr,void * ibtl_reserved,ibc_mr_hdl_t * mr_p,ibt_pmr_desc_t * mem_desc_p)27789517SBill.Taylor@Sun.COM hermon_ci_register_physical_fmr(ibc_hca_hdl_t hca,
27799517SBill.Taylor@Sun.COM ibc_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr,
27809517SBill.Taylor@Sun.COM void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p)
27819517SBill.Taylor@Sun.COM {
27829517SBill.Taylor@Sun.COM hermon_state_t *state;
27839517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
27849517SBill.Taylor@Sun.COM hermon_fmrhdl_t fmrpoolhdl;
27859517SBill.Taylor@Sun.COM int status;
27869517SBill.Taylor@Sun.COM
27879517SBill.Taylor@Sun.COM ASSERT(mem_pattr != NULL);
27889517SBill.Taylor@Sun.COM ASSERT(mr_p != NULL);
27899517SBill.Taylor@Sun.COM ASSERT(mem_desc_p != NULL);
27909517SBill.Taylor@Sun.COM
27919517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
27929517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
27939517SBill.Taylor@Sun.COM
27949517SBill.Taylor@Sun.COM fmrpoolhdl = (hermon_fmrhdl_t)fmr_pool;
27959517SBill.Taylor@Sun.COM
27969517SBill.Taylor@Sun.COM status = hermon_register_physical_fmr(state, fmrpoolhdl, mem_pattr,
27979517SBill.Taylor@Sun.COM &mrhdl, mem_desc_p);
27989517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
27999517SBill.Taylor@Sun.COM return (status);
28009517SBill.Taylor@Sun.COM }
28019517SBill.Taylor@Sun.COM
28029517SBill.Taylor@Sun.COM /*
28039517SBill.Taylor@Sun.COM * If region is mapped for streaming (i.e. noncoherent), then set
28049517SBill.Taylor@Sun.COM * sync is required
28059517SBill.Taylor@Sun.COM */
28069517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mem_desc_p))
28079517SBill.Taylor@Sun.COM mem_desc_p->pmd_sync_required = (mrhdl->mr_bindinfo.bi_flags &
28089517SBill.Taylor@Sun.COM IBT_MR_NONCOHERENT) ? B_TRUE : B_FALSE;
28099517SBill.Taylor@Sun.COM if (mem_desc_p->pmd_sync_required == B_TRUE) {
28109517SBill.Taylor@Sun.COM /* Fill in DMA handle for future sync operations */
28119517SBill.Taylor@Sun.COM _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(mrhdl->mr_bindinfo))
28129517SBill.Taylor@Sun.COM mrhdl->mr_bindinfo.bi_dmahdl =
28139517SBill.Taylor@Sun.COM (ddi_dma_handle_t)mem_pattr->pmr_ma;
28149517SBill.Taylor@Sun.COM }
28159517SBill.Taylor@Sun.COM
28169517SBill.Taylor@Sun.COM /* Return the Hermon MR handle */
28179517SBill.Taylor@Sun.COM *mr_p = (ibc_mr_hdl_t)mrhdl;
28189517SBill.Taylor@Sun.COM
28199517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
28209517SBill.Taylor@Sun.COM }
28219517SBill.Taylor@Sun.COM
28229517SBill.Taylor@Sun.COM /*
28239517SBill.Taylor@Sun.COM * hermon_ci_deregister_fmr()
28249517SBill.Taylor@Sun.COM * Moves an FMR (specified by 'mr') to the deregistered state.
28259517SBill.Taylor@Sun.COM * Context: Can be called from base context only.
28269517SBill.Taylor@Sun.COM */
28279517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_deregister_fmr(ibc_hca_hdl_t hca,ibc_mr_hdl_t mr)28289517SBill.Taylor@Sun.COM hermon_ci_deregister_fmr(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr)
28299517SBill.Taylor@Sun.COM {
28309517SBill.Taylor@Sun.COM hermon_state_t *state;
28319517SBill.Taylor@Sun.COM hermon_mrhdl_t mrhdl;
28329517SBill.Taylor@Sun.COM int status;
28339517SBill.Taylor@Sun.COM
28349517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer */
28359517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
28369517SBill.Taylor@Sun.COM mrhdl = (hermon_mrhdl_t)mr;
28379517SBill.Taylor@Sun.COM
28389517SBill.Taylor@Sun.COM /*
28399517SBill.Taylor@Sun.COM * Deregister the memory region, either "unmap" the FMR or deregister
28409517SBill.Taylor@Sun.COM * the normal memory region.
28419517SBill.Taylor@Sun.COM */
28429517SBill.Taylor@Sun.COM status = hermon_deregister_fmr(state, mrhdl);
28439517SBill.Taylor@Sun.COM return (status);
28449517SBill.Taylor@Sun.COM }
28459517SBill.Taylor@Sun.COM
28469517SBill.Taylor@Sun.COM static int
hermon_mem_alloc(hermon_state_t * state,size_t size,ibt_mr_flags_t flags,caddr_t * kaddrp,ibc_mem_alloc_hdl_t * mem_hdl)28479517SBill.Taylor@Sun.COM hermon_mem_alloc(hermon_state_t *state, size_t size, ibt_mr_flags_t flags,
28489517SBill.Taylor@Sun.COM caddr_t *kaddrp, ibc_mem_alloc_hdl_t *mem_hdl)
28499517SBill.Taylor@Sun.COM {
28509517SBill.Taylor@Sun.COM ddi_dma_handle_t dma_hdl;
28519517SBill.Taylor@Sun.COM ddi_dma_attr_t dma_attr;
28529517SBill.Taylor@Sun.COM ddi_acc_handle_t acc_hdl;
28539517SBill.Taylor@Sun.COM size_t real_len;
28549517SBill.Taylor@Sun.COM int status;
28559517SBill.Taylor@Sun.COM int (*ddi_cb)(caddr_t);
28569517SBill.Taylor@Sun.COM ibc_mem_alloc_hdl_t mem_alloc_hdl;
28579517SBill.Taylor@Sun.COM
28589517SBill.Taylor@Sun.COM hermon_dma_attr_init(state, &dma_attr);
28599517SBill.Taylor@Sun.COM
28609517SBill.Taylor@Sun.COM ddi_cb = (flags & IBT_MR_NOSLEEP) ? DDI_DMA_DONTWAIT : DDI_DMA_SLEEP;
28619517SBill.Taylor@Sun.COM
28629517SBill.Taylor@Sun.COM /* Allocate a DMA handle */
28639517SBill.Taylor@Sun.COM status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr, ddi_cb,
28649517SBill.Taylor@Sun.COM NULL, &dma_hdl);
28659517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
28669517SBill.Taylor@Sun.COM return (DDI_FAILURE);
28679517SBill.Taylor@Sun.COM }
28689517SBill.Taylor@Sun.COM
28699517SBill.Taylor@Sun.COM /* Allocate DMA memory */
28709517SBill.Taylor@Sun.COM status = ddi_dma_mem_alloc(dma_hdl, size,
28719517SBill.Taylor@Sun.COM &state->hs_reg_accattr, DDI_DMA_CONSISTENT, ddi_cb,
28729517SBill.Taylor@Sun.COM NULL, kaddrp, &real_len, &acc_hdl);
28739517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
28749517SBill.Taylor@Sun.COM ddi_dma_free_handle(&dma_hdl);
28759517SBill.Taylor@Sun.COM return (DDI_FAILURE);
28769517SBill.Taylor@Sun.COM }
28779517SBill.Taylor@Sun.COM
28789517SBill.Taylor@Sun.COM /* Package the hermon_dma_info contents and return */
28799517SBill.Taylor@Sun.COM mem_alloc_hdl = kmem_alloc(sizeof (**mem_hdl),
28809517SBill.Taylor@Sun.COM (flags & IBT_MR_NOSLEEP) ? KM_NOSLEEP : KM_SLEEP);
28819517SBill.Taylor@Sun.COM if (mem_alloc_hdl == NULL) {
28829517SBill.Taylor@Sun.COM ddi_dma_mem_free(&acc_hdl);
28839517SBill.Taylor@Sun.COM ddi_dma_free_handle(&dma_hdl);
28849517SBill.Taylor@Sun.COM return (DDI_FAILURE);
28859517SBill.Taylor@Sun.COM }
28869517SBill.Taylor@Sun.COM mem_alloc_hdl->ibc_dma_hdl = dma_hdl;
28879517SBill.Taylor@Sun.COM mem_alloc_hdl->ibc_acc_hdl = acc_hdl;
28889517SBill.Taylor@Sun.COM
28899517SBill.Taylor@Sun.COM *mem_hdl = mem_alloc_hdl;
28909517SBill.Taylor@Sun.COM
28919517SBill.Taylor@Sun.COM return (DDI_SUCCESS);
28929517SBill.Taylor@Sun.COM }
28939517SBill.Taylor@Sun.COM
28949517SBill.Taylor@Sun.COM /*
28959517SBill.Taylor@Sun.COM * hermon_ci_alloc_io_mem()
28969517SBill.Taylor@Sun.COM * Allocate dma-able memory
28979517SBill.Taylor@Sun.COM *
28989517SBill.Taylor@Sun.COM */
28999517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_alloc_io_mem(ibc_hca_hdl_t hca,size_t size,ibt_mr_flags_t mr_flag,caddr_t * kaddrp,ibc_mem_alloc_hdl_t * mem_alloc_hdl_p)29009517SBill.Taylor@Sun.COM hermon_ci_alloc_io_mem(ibc_hca_hdl_t hca, size_t size, ibt_mr_flags_t mr_flag,
29019517SBill.Taylor@Sun.COM caddr_t *kaddrp, ibc_mem_alloc_hdl_t *mem_alloc_hdl_p)
29029517SBill.Taylor@Sun.COM {
29039517SBill.Taylor@Sun.COM hermon_state_t *state;
29049517SBill.Taylor@Sun.COM int status;
29059517SBill.Taylor@Sun.COM
29069517SBill.Taylor@Sun.COM /* Grab the Hermon softstate pointer and mem handle */
29079517SBill.Taylor@Sun.COM state = (hermon_state_t *)hca;
29089517SBill.Taylor@Sun.COM
29099517SBill.Taylor@Sun.COM /* Allocate the memory and handles */
29109517SBill.Taylor@Sun.COM status = hermon_mem_alloc(state, size, mr_flag, kaddrp,
29119517SBill.Taylor@Sun.COM mem_alloc_hdl_p);
29129517SBill.Taylor@Sun.COM
29139517SBill.Taylor@Sun.COM if (status != DDI_SUCCESS) {
29149517SBill.Taylor@Sun.COM *mem_alloc_hdl_p = NULL;
29159517SBill.Taylor@Sun.COM *kaddrp = NULL;
29169517SBill.Taylor@Sun.COM return (status);
29179517SBill.Taylor@Sun.COM }
29189517SBill.Taylor@Sun.COM
29199517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
29209517SBill.Taylor@Sun.COM }
29219517SBill.Taylor@Sun.COM
29229517SBill.Taylor@Sun.COM
29239517SBill.Taylor@Sun.COM /*
29249517SBill.Taylor@Sun.COM * hermon_ci_free_io_mem()
29259517SBill.Taylor@Sun.COM * Unbind handl and free the memory
29269517SBill.Taylor@Sun.COM */
2927*12965SWilliam.Taylor@Oracle.COM /* ARGSUSED */
29289517SBill.Taylor@Sun.COM static ibt_status_t
hermon_ci_free_io_mem(ibc_hca_hdl_t hca,ibc_mem_alloc_hdl_t mem_alloc_hdl)29299517SBill.Taylor@Sun.COM hermon_ci_free_io_mem(ibc_hca_hdl_t hca, ibc_mem_alloc_hdl_t mem_alloc_hdl)
29309517SBill.Taylor@Sun.COM {
29319517SBill.Taylor@Sun.COM /* Unbind the handles and free the memory */
29329517SBill.Taylor@Sun.COM (void) ddi_dma_unbind_handle(mem_alloc_hdl->ibc_dma_hdl);
29339517SBill.Taylor@Sun.COM ddi_dma_mem_free(&mem_alloc_hdl->ibc_acc_hdl);
29349517SBill.Taylor@Sun.COM ddi_dma_free_handle(&mem_alloc_hdl->ibc_dma_hdl);
29359517SBill.Taylor@Sun.COM kmem_free(mem_alloc_hdl, sizeof (*mem_alloc_hdl));
29369517SBill.Taylor@Sun.COM
29379517SBill.Taylor@Sun.COM return (IBT_SUCCESS);
29389517SBill.Taylor@Sun.COM }
2939