Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 1 | #ifndef DEF_RDMA_VT_H |
| 2 | #define DEF_RDMA_VT_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright(c) 2015 Intel Corporation. |
| 6 | * |
| 7 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 8 | * redistributing this file, you may do so under either license. |
| 9 | * |
| 10 | * GPL LICENSE SUMMARY |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of version 2 of the GNU General Public License as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, but |
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * BSD LICENSE |
| 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: |
| 26 | * |
| 27 | * - Redistributions of source code must retain the above copyright |
| 28 | * notice, this list of conditions and the following disclaimer. |
| 29 | * - Redistributions in binary form must reproduce the above copyright |
| 30 | * notice, this list of conditions and the following disclaimer in |
| 31 | * the documentation and/or other materials provided with the |
| 32 | * distribution. |
| 33 | * - Neither the name of Intel Corporation nor the names of its |
| 34 | * contributors may be used to endorse or promote products derived |
| 35 | * from this software without specific prior written permission. |
| 36 | * |
| 37 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 38 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 39 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 40 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 41 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 42 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 43 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 44 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 45 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 46 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 47 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 48 | * |
| 49 | */ |
| 50 | |
| 51 | /* |
| 52 | * Structure that low level drivers will populate in order to register with the |
| 53 | * rdmavt layer. |
| 54 | */ |
| 55 | |
| 56 | #include "ib_verbs.h" |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 57 | |
| 58 | /* |
| 59 | * Things that are driver specific, module parameters in hfi1 and qib |
| 60 | */ |
| 61 | struct rvt_driver_params { |
Dennis Dalessandro | b1070a7 | 2016-01-06 09:52:19 -0800 | [diff] [blame] | 62 | /* |
| 63 | * driver required fields: |
| 64 | * node_guid |
| 65 | * phys_port_cnt |
| 66 | * dma_device |
| 67 | * owner |
| 68 | * driver optional fields (rvt will provide generic value if blank): |
| 69 | * name |
| 70 | * node_desc |
| 71 | * rvt fields, driver value ignored: |
| 72 | * uverbs_abi_ver |
| 73 | * node_type |
| 74 | * num_comp_vectors |
| 75 | * uverbs_cmd_mask |
| 76 | */ |
| 77 | struct ib_device_attr props; |
| 78 | |
| 79 | /* |
| 80 | * Drivers will need to support a number of notifications to rvt in |
| 81 | * accordance with certain events. This structure should contain a mask |
| 82 | * of the supported events. Such events that the rvt may need to know |
| 83 | * about include: |
| 84 | * port errors |
| 85 | * port active |
| 86 | * lid change |
| 87 | * sm change |
| 88 | * client reregister |
| 89 | * pkey change |
| 90 | * |
| 91 | * There may also be other events that the rvt layers needs to know |
| 92 | * about this is not an exhaustive list. Some events though rvt does not |
| 93 | * need to rely on the driver for such as completion queue error. |
| 94 | */ |
| 95 | int rvt_signal_supported; |
| 96 | |
| 97 | /* |
| 98 | * Anything driver specific that is not covered by props |
| 99 | * For instance special module parameters. Goes here. |
| 100 | */ |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /* Protection domain */ |
| 104 | struct rvt_pd { |
| 105 | struct ib_pd ibpd; |
| 106 | int user; /* non-zero if created from user space */ |
| 107 | }; |
| 108 | |
Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 109 | struct rvt_dev_info { |
Dennis Dalessandro | b1070a7 | 2016-01-06 09:52:19 -0800 | [diff] [blame] | 110 | /* |
| 111 | * Prior to calling for registration the driver will be responsible for |
| 112 | * allocating space for this structure. |
| 113 | * |
| 114 | * The driver will also be responsible for filling in certain members of |
| 115 | * dparms.props |
| 116 | */ |
Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 117 | struct ib_device ibdev; |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 118 | |
Dennis Dalessandro | b1070a7 | 2016-01-06 09:52:19 -0800 | [diff] [blame] | 119 | /* Driver specific properties */ |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 120 | struct rvt_driver_params dparms; |
Dennis Dalessandro | b1070a7 | 2016-01-06 09:52:19 -0800 | [diff] [blame] | 121 | |
Dennis Dalessandro | 3058864 | 2016-01-06 09:54:16 -0800 | [diff] [blame^] | 122 | /* PKey Table goes here */ |
| 123 | |
Dennis Dalessandro | b1070a7 | 2016-01-06 09:52:19 -0800 | [diff] [blame] | 124 | /* |
| 125 | * The work to create port files in /sys/class Infiniband is different |
| 126 | * depending on the driver. This should not be extracted away and |
| 127 | * instead drivers are responsible for setting the correct callback for |
| 128 | * this. |
| 129 | */ |
Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 130 | int (*port_callback)(struct ib_device *, u8, struct kobject *); |
| 131 | |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 132 | /* Internal use */ |
| 133 | int n_pds_allocated; |
| 134 | spinlock_t n_pds_lock; /* Protect pd allocated count */ |
Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 135 | }; |
| 136 | |
Dennis Dalessandro | 8afd32e | 2016-01-06 09:51:48 -0800 | [diff] [blame] | 137 | static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd) |
| 138 | { |
| 139 | return container_of(ibpd, struct rvt_pd, ibpd); |
| 140 | } |
| 141 | |
| 142 | static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev) |
| 143 | { |
| 144 | return container_of(ibdev, struct rvt_dev_info, ibdev); |
| 145 | } |
| 146 | |
Dennis Dalessandro | 0194621 | 2016-01-06 09:50:24 -0800 | [diff] [blame] | 147 | int rvt_register_device(struct rvt_dev_info *rvd); |
| 148 | void rvt_unregister_device(struct rvt_dev_info *rvd); |
| 149 | |
| 150 | #endif /* DEF_RDMA_VT_H */ |