11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (c) 2004 Topspin Communications. All rights reserved. 34885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. 42a1d9b7f09aaaacf235656cb32a40ba2c79590b3Roland Dreier * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This software is available to you under a choice of one of two 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * licenses. You may choose to be licensed under the terms of the GNU 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * General Public License (GPL) Version 2, available from the file 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * COPYING in the main directory of this source tree, or the 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OpenIB.org BSD license below: 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * without modification, are permitted provided that the following 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * conditions are met: 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - Redistributions of source code must retain the above 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * copyright notice, this list of conditions and the following 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * disclaimer. 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - Redistributions in binary form must reproduce the above 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * copyright notice, this list of conditions and the following 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * disclaimer in the documentation and/or other materials 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * provided with the distribution. 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * SOFTWARE. 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef MTHCA_PROVIDER_H 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_PROVIDER_H 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 38a4d61e84804f3b14cc35c5e2af768a07c0f64ef6Roland Dreier#include <rdma/ib_verbs.h> 39a4d61e84804f3b14cc35c5e2af768a07c0f64ef6Roland Dreier#include <rdma/ib_pack.h> 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_MPT_FLAG_ATOMIC (1 << 14) 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13) 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_MPT_FLAG_REMOTE_READ (1 << 12) 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_MPT_FLAG_LOCAL_WRITE (1 << 11) 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MTHCA_MPT_FLAG_LOCAL_READ (1 << 10) 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_buf_list { 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *buf; 493a2baff783497321e8322ce29f3a33a21c0d88f5FUJITA Tomonori DEFINE_DMA_UNMAP_ADDR(mapping); 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5287b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreierunion mthca_buf { 5387b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreier struct mthca_buf_list direct; 5487b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreier struct mthca_buf_list *page_list; 5587b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreier}; 5687b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreier 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_uar { 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long pfn; 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int index; 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 625e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreierstruct mthca_user_db_table; 635e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier 645e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreierstruct mthca_ucontext { 655e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier struct ib_ucontext ibucontext; 665e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier struct mthca_uar uar; 675e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier struct mthca_user_db_table *db_tab; 68baaad380c0aa955f7d62e846467316c94067f1a5Roland Dreier int reg_mr_warned; 695e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier}; 705e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier 71d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreierstruct mthca_mtt; 72d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_mr { 74d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier struct ib_mr ibmr; 75f7c6a7b5d59980b076abbf2ceeb8735591290285Roland Dreier struct ib_umem *umem; 76d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier struct mthca_mtt *mtt; 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 79e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkinstruct mthca_fmr { 80d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier struct ib_fmr ibmr; 81e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin struct ib_fmr_attr attr; 82d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier struct mthca_mtt *mtt; 83d56d6f9502a15ef64395cb3a6fc7bfdc365b1e3dRoland Dreier int maps; 84e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin union { 85e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin struct { 86e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin struct mthca_mpt_entry __iomem *mpt; 87e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin u64 __iomem *mtts; 88e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin } tavor; 89e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin struct { 90e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin struct mthca_mpt_entry *mpt; 91e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin __be64 *mtts; 92391e4dea7189eef32b0c2d121e7e047110c1b83cMichael S. Tsirkin dma_addr_t dma_handle; 93e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin } arbel; 94e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin } mem; 95e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin}; 96e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_pd { 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct ib_pd ibpd; 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 pd_num; 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds atomic_t sqp_count; 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_mr ntmr; 10299264c1ee2ce908f95c075cce97698758a793b58Roland Dreier int privileged; 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_eq { 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_dev *dev; 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int eqn; 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 eqn_mask; 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 cons_index; 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 msi_x_vector; 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 msi_x_entry; 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int have_irq; 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int nent; 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_buf_list *page_list; 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_mr mr; 116d94a86890137fabcc97eaa324bfef3f1827744c8Arputham Benjamin char irq_name[IB_DEVICE_NAME_MAX]; 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_av; 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsenum mthca_ah_type { 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds MTHCA_AH_ON_HCA, 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds MTHCA_AH_PCI_POOL, 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds MTHCA_AH_KMALLOC 1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_ah { 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct ib_ah ibah; 1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds enum mthca_ah_type type; 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 key; 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_av *av; 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dma_addr_t avdma; 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Quick description of our CQ/QP locking scheme: 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * We have one global lock that protects dev->cq/qp_table. Each 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * struct mthca_cq/qp also has its own lock. An individual qp lock 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * may be taken inside of an individual cq lock. Both cqs attached to 141a19aa5c5fdda8b556ab238177ee27c5ef7873c94Roland Dreier * a qp may be locked, with the cq with the lower cqn locked first. 142a19aa5c5fdda8b556ab238177ee27c5ef7873c94Roland Dreier * No other nesting should be done. 1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 144a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * Each struct mthca_cq/qp also has an ref count, protected by the 145a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * corresponding table lock. The pointer from the cq/qp_table to the 146a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * struct counts as one reference. This reference also is good for 147a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * access through the consumer API, so modifying the CQ/QP etc doesn't 148a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * need to take another reference. Access to a QP because of a 149a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * completion being polled does not need a reference either. 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * destroy function to sleep on. 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This means that access from the consumer API requires nothing but 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * taking the struct's lock. 1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Access because of a completion event should go as follows: 1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - lock cq/qp_table and look up struct 1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - increment ref count in struct 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - drop cq/qp_table lock 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - lock struct, do your thing, and unlock struct 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - decrement ref count; if zero, wake up waiters 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * To destroy a CQ/QP, we can do the following: 165a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * - lock cq/qp_table 166a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * - remove pointer and decrement ref count 167a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier * - unlock cq/qp_table lock 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - wait_event until ref count is zero 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * It is the consumer's responsibilty to make sure that no QP 1714885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier * operations (WQE posting or state modification) are pending when a 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * QP is destroyed. Also, the consumer must make sure that calls to 1734885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier * qp_modify are serialized. Similarly, the consumer is responsible 1744885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier * for ensuring that no CQ resize operations are pending when a CQ 1754885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier * is destroyed. 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Possible optimizations (wait for profile data to see if/where we 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * have locks bouncing between CPUs): 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - split cq/qp table lock into n separate (cache-aligned) locks, 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * indexed (say) by the page in the table 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - split QP struct lock into three (one for common info, one for the 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * send queue and one for the receive queue) 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1854885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreierstruct mthca_cq_buf { 1864885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier union mthca_buf queue; 1874885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier struct mthca_mr mr; 1884885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int is_direct; 1894885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier}; 1904885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier 1914885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreierstruct mthca_cq_resize { 1924885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier struct mthca_cq_buf buf; 1934885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int cqe; 1944885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier enum { 1954885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier CQ_RESIZE_ALLOC, 1964885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier CQ_RESIZE_READY, 1974885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier CQ_RESIZE_SWAPPED 1984885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier } state; 1994885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier}; 2004885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_cq { 2024885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier struct ib_cq ibcq; 2034885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier spinlock_t lock; 204a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier int refcount; 2054885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int cqn; 2064885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier u32 cons_index; 2074885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier struct mthca_cq_buf buf; 2084885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier struct mthca_cq_resize *resize_buf; 2094885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int is_kernel; 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Next fields are Arbel only */ 2124885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int set_ci_db_index; 2134885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier __be32 *set_ci_db; 2144885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int arm_db_index; 2154885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier __be32 *arm_db; 2164885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier int arm_sn; 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2184885bf64bc2eb242ebebe67077cfe3688283b586Roland Dreier wait_queue_head_t wait; 219c93b6fbaa99bb3a1552e14317296be14dde51dfbRoland Dreier struct mutex mutex; 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 222ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreierstruct mthca_srq { 223ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier struct ib_srq ibsrq; 224ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier spinlock_t lock; 225a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier int refcount; 226ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int srqn; 227ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int max; 228ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int max_gs; 229ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int wqe_shift; 230ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int first_free; 231ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int last_free; 232ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier u16 counter; /* Arbel only */ 233ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int db_index; /* Arbel only */ 234ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier __be32 *db; /* Arbel only */ 235ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier void *last; 236ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier 237ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier int is_direct; 238ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier u64 *wrid; 239ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier union mthca_buf queue; 240ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier struct mthca_mr mr; 241ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier 242ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier wait_queue_head_t wait; 243c93b6fbaa99bb3a1552e14317296be14dde51dfbRoland Dreier struct mutex mutex; 244ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier}; 245ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier 2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_wq { 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spinlock_t lock; 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int max; 2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned next_ind; 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned last_comp; 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned head; 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned tail; 2531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *last; 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int max_gs; 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int wqe_shift; 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int db_index; /* Arbel only */ 25897f52eb438be7caebe026421545619d8a0c1398aSean Hefty __be32 *db; 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_qp { 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct ib_qp ibqp; 263a3285aa4eecd722508dab01c4932b11b4ba80134Roland Dreier int refcount; 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 qpn; 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int is_direct; 266bf6a9e31cfa768ce0a8e18474b3ca808641d9243Jack Morgenstein u8 port; /* for SQP and memfree use only */ 267bf6a9e31cfa768ce0a8e18474b3ca808641d9243Jack Morgenstein u8 alt_port; /* for memfree use only */ 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 transport; 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 state; 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 atomic_rd_en; 2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 resp_depth; 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_mr mr; 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_wq rq; 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_wq sq; 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds enum ib_sig_type sq_policy; 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int send_wqe_offset; 27977369ed31daac51f4827c50d30f233c45480235aJack Morgenstein int max_inline_data; 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u64 *wrid; 28287b816706bb2b79fbaff8e0b8e279e783273383eRoland Dreier union mthca_buf queue; 2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds wait_queue_head_t wait; 285c93b6fbaa99bb3a1552e14317296be14dde51dfbRoland Dreier struct mutex mutex; 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mthca_sqp { 2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct mthca_qp qp; 2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int pkey_index; 2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 qkey; 2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 send_psn; 2931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct ib_ud_header ud_header; 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int header_buf_size; 2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *header_buf; 2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dma_addr_t header_dma; 2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2995e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreierstatic inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext) 3005e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier{ 3015e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier return container_of(ibucontext, struct mthca_ucontext, ibucontext); 3025e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier} 3035e0b537c7d94efe3fea0fee8e2533c3231a8af75Roland Dreier 304e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkinstatic inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr) 305e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin{ 306e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin return container_of(ibmr, struct mthca_fmr, ibmr); 307e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin} 308e0f5fdca1ca9d1659b920827e5cf6dbad20e5391Michael S. Tsirkin 3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_mr *to_mmr(struct ib_mr *ibmr) 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(ibmr, struct mthca_mr, ibmr); 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_pd *to_mpd(struct ib_pd *ibpd) 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(ibpd, struct mthca_pd, ibpd); 3171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_ah *to_mah(struct ib_ah *ibah) 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(ibah, struct mthca_ah, ibah); 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_cq *to_mcq(struct ib_cq *ibcq) 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(ibcq, struct mthca_cq, ibcq); 3271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 329ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreierstatic inline struct mthca_srq *to_msrq(struct ib_srq *ibsrq) 330ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier{ 331ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier return container_of(ibsrq, struct mthca_srq, ibsrq); 332ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier} 333ec34a922d243c3401a694450734e9effb2bafbfeRoland Dreier 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_qp *to_mqp(struct ib_qp *ibqp) 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(ibqp, struct mthca_qp, ibqp); 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct mthca_sqp *to_msqp(struct mthca_qp *qp) 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of(qp, struct mthca_sqp, qp); 3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* MTHCA_PROVIDER_H */ 345