.. | .. |
---|
1 | 1 | /* |
---|
2 | | - * Copyright(c) 2016 Intel Corporation. |
---|
| 2 | + * Copyright(c) 2016 - 2019 Intel Corporation. |
---|
3 | 3 | * |
---|
4 | 4 | * This file is provided under a dual BSD/GPLv2 license. When using or |
---|
5 | 5 | * redistributing this file, you may do so under either license. |
---|
.. | .. |
---|
89 | 89 | |
---|
90 | 90 | /** |
---|
91 | 91 | * rvt_create_ah - create an address handle |
---|
92 | | - * @pd: the protection domain |
---|
93 | | - * @ah_attr: the attributes of the AH |
---|
| 92 | + * @ibah: the IB address handle |
---|
| 93 | + * @init_attr: the attributes of the AH |
---|
94 | 94 | * @udata: pointer to user's input output buffer information. |
---|
95 | 95 | * |
---|
96 | 96 | * This may be called from interrupt context. |
---|
97 | 97 | * |
---|
98 | | - * Return: newly allocated ah |
---|
| 98 | + * Return: 0 on success |
---|
99 | 99 | */ |
---|
100 | | -struct ib_ah *rvt_create_ah(struct ib_pd *pd, |
---|
101 | | - struct rdma_ah_attr *ah_attr, |
---|
102 | | - struct ib_udata *udata) |
---|
| 100 | +int rvt_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, |
---|
| 101 | + struct ib_udata *udata) |
---|
103 | 102 | { |
---|
104 | | - struct rvt_ah *ah; |
---|
105 | | - struct rvt_dev_info *dev = ib_to_rvt(pd->device); |
---|
| 103 | + struct rvt_ah *ah = ibah_to_rvtah(ibah); |
---|
| 104 | + struct rvt_dev_info *dev = ib_to_rvt(ibah->device); |
---|
106 | 105 | unsigned long flags; |
---|
107 | 106 | |
---|
108 | | - if (rvt_check_ah(pd->device, ah_attr)) |
---|
109 | | - return ERR_PTR(-EINVAL); |
---|
110 | | - |
---|
111 | | - ah = kmalloc(sizeof(*ah), GFP_ATOMIC); |
---|
112 | | - if (!ah) |
---|
113 | | - return ERR_PTR(-ENOMEM); |
---|
| 107 | + if (rvt_check_ah(ibah->device, init_attr->ah_attr)) |
---|
| 108 | + return -EINVAL; |
---|
114 | 109 | |
---|
115 | 110 | spin_lock_irqsave(&dev->n_ahs_lock, flags); |
---|
116 | 111 | if (dev->n_ahs_allocated == dev->dparms.props.max_ah) { |
---|
117 | 112 | spin_unlock_irqrestore(&dev->n_ahs_lock, flags); |
---|
118 | | - kfree(ah); |
---|
119 | | - return ERR_PTR(-ENOMEM); |
---|
| 113 | + return -ENOMEM; |
---|
120 | 114 | } |
---|
121 | 115 | |
---|
122 | 116 | dev->n_ahs_allocated++; |
---|
123 | 117 | spin_unlock_irqrestore(&dev->n_ahs_lock, flags); |
---|
124 | 118 | |
---|
125 | | - rdma_copy_ah_attr(&ah->attr, ah_attr); |
---|
126 | | - |
---|
127 | | - atomic_set(&ah->refcount, 0); |
---|
| 119 | + rdma_copy_ah_attr(&ah->attr, init_attr->ah_attr); |
---|
128 | 120 | |
---|
129 | 121 | if (dev->driver_f.notify_new_ah) |
---|
130 | | - dev->driver_f.notify_new_ah(pd->device, ah_attr, ah); |
---|
| 122 | + dev->driver_f.notify_new_ah(ibah->device, |
---|
| 123 | + init_attr->ah_attr, ah); |
---|
131 | 124 | |
---|
132 | | - return &ah->ibah; |
---|
| 125 | + return 0; |
---|
133 | 126 | } |
---|
134 | 127 | |
---|
135 | 128 | /** |
---|
136 | 129 | * rvt_destory_ah - Destory an address handle |
---|
137 | 130 | * @ibah: address handle |
---|
| 131 | + * @destroy_flags: destroy address handle flags (see enum rdma_destroy_ah_flags) |
---|
138 | 132 | * |
---|
139 | 133 | * Return: 0 on success |
---|
140 | 134 | */ |
---|
141 | | -int rvt_destroy_ah(struct ib_ah *ibah) |
---|
| 135 | +int rvt_destroy_ah(struct ib_ah *ibah, u32 destroy_flags) |
---|
142 | 136 | { |
---|
143 | 137 | struct rvt_dev_info *dev = ib_to_rvt(ibah->device); |
---|
144 | 138 | struct rvt_ah *ah = ibah_to_rvtah(ibah); |
---|
145 | 139 | unsigned long flags; |
---|
146 | | - |
---|
147 | | - if (atomic_read(&ah->refcount) != 0) |
---|
148 | | - return -EBUSY; |
---|
149 | 140 | |
---|
150 | 141 | spin_lock_irqsave(&dev->n_ahs_lock, flags); |
---|
151 | 142 | dev->n_ahs_allocated--; |
---|
152 | 143 | spin_unlock_irqrestore(&dev->n_ahs_lock, flags); |
---|
153 | 144 | |
---|
154 | 145 | rdma_destroy_ah_attr(&ah->attr); |
---|
155 | | - kfree(ah); |
---|
156 | | - |
---|
157 | 146 | return 0; |
---|
158 | 147 | } |
---|
159 | 148 | |
---|