oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Hisilicon Limited. |
| 3 | * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. |
| 4 | * |
| 5 | * This software is available to you under a choice of one of two |
| 6 | * licenses. You may choose to be licensed under the terms of the GNU |
| 7 | * General Public License (GPL) Version 2, available from the file |
| 8 | * COPYING in the main directory of this source tree, or the |
| 9 | * OpenIB.org BSD license below: |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or |
| 12 | * without modification, are permitted provided that the following |
| 13 | * conditions are met: |
| 14 | * |
| 15 | * - Redistributions of source code must retain the above |
| 16 | * copyright notice, this list of conditions and the following |
| 17 | * disclaimer. |
| 18 | * |
| 19 | * - Redistributions in binary form must reproduce the above |
| 20 | * copyright notice, this list of conditions and the following |
| 21 | * disclaimer in the documentation and/or other materials |
| 22 | * provided with the distribution. |
| 23 | * |
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 | * SOFTWARE. |
| 32 | */ |
Salil | 528f1de | 2016-08-24 04:44:50 +0800 | [diff] [blame] | 33 | #include <linux/acpi.h> |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 34 | #include <linux/of_platform.h> |
Arnd Bergmann | 3ecc16c | 2017-02-17 15:38:26 +0100 | [diff] [blame] | 35 | #include <linux/module.h> |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 36 | #include <rdma/ib_addr.h> |
| 37 | #include <rdma/ib_smi.h> |
| 38 | #include <rdma/ib_user_verbs.h> |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 39 | #include <rdma/ib_cache.h> |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 40 | #include "hns_roce_common.h" |
| 41 | #include "hns_roce_device.h" |
Leon Romanovsky | 4d40995 | 2016-10-19 20:13:07 +0300 | [diff] [blame] | 42 | #include <rdma/hns-abi.h> |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 43 | #include "hns_roce_hem.h" |
| 44 | |
| 45 | /** |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 46 | * hns_get_gid_index - Get gid index. |
| 47 | * @hr_dev: pointer to structure hns_roce_dev. |
| 48 | * @port: port, value range: 0 ~ MAX |
| 49 | * @gid_index: gid_index, value range: 0 ~ MAX |
| 50 | * Description: |
| 51 | * N ports shared gids, allocation method as follow: |
| 52 | * GID[0][0], GID[1][0],.....GID[N - 1][0], |
| 53 | * GID[0][0], GID[1][0],.....GID[N - 1][0], |
| 54 | * And so on |
| 55 | */ |
| 56 | int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index) |
| 57 | { |
| 58 | return gid_index * hr_dev->caps.num_ports + port; |
| 59 | } |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 60 | EXPORT_SYMBOL_GPL(hns_get_gid_index); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 61 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 62 | static void hns_roce_set_mac(struct hns_roce_dev *hr_dev, u8 port, u8 *addr) |
| 63 | { |
| 64 | u8 phy_port; |
| 65 | u32 i = 0; |
| 66 | |
| 67 | if (!memcmp(hr_dev->dev_addr[port], addr, MAC_ADDR_OCTET_NUM)) |
| 68 | return; |
| 69 | |
| 70 | for (i = 0; i < MAC_ADDR_OCTET_NUM; i++) |
| 71 | hr_dev->dev_addr[port][i] = addr[i]; |
| 72 | |
| 73 | phy_port = hr_dev->iboe.phy_port[port]; |
| 74 | hr_dev->hw->set_mac(hr_dev, phy_port, addr); |
| 75 | } |
| 76 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 77 | static int hns_roce_add_gid(struct ib_device *device, u8 port_num, |
| 78 | unsigned int index, const union ib_gid *gid, |
| 79 | const struct ib_gid_attr *attr, void **context) |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 80 | { |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 81 | struct hns_roce_dev *hr_dev = to_hr_dev(device); |
| 82 | u8 port = port_num - 1; |
| 83 | unsigned long flags; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 84 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 85 | if (port >= hr_dev->caps.num_ports) |
| 86 | return -EINVAL; |
| 87 | |
| 88 | spin_lock_irqsave(&hr_dev->iboe.lock, flags); |
| 89 | |
| 90 | hr_dev->hw->set_gid(hr_dev, port, index, (union ib_gid *)gid); |
| 91 | |
| 92 | spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | static int hns_roce_del_gid(struct ib_device *device, u8 port_num, |
| 98 | unsigned int index, void **context) |
| 99 | { |
| 100 | struct hns_roce_dev *hr_dev = to_hr_dev(device); |
| 101 | union ib_gid zgid = { {0} }; |
| 102 | u8 port = port_num - 1; |
| 103 | unsigned long flags; |
| 104 | |
| 105 | if (port >= hr_dev->caps.num_ports) |
| 106 | return -EINVAL; |
| 107 | |
| 108 | spin_lock_irqsave(&hr_dev->iboe.lock, flags); |
| 109 | |
| 110 | hr_dev->hw->set_gid(hr_dev, port, index, &zgid); |
| 111 | |
| 112 | spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); |
| 113 | |
| 114 | return 0; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, |
| 118 | unsigned long event) |
| 119 | { |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 120 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 121 | struct net_device *netdev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 122 | |
| 123 | netdev = hr_dev->iboe.netdevs[port]; |
| 124 | if (!netdev) { |
| 125 | dev_err(dev, "port(%d) can't find netdev\n", port); |
| 126 | return -ENODEV; |
| 127 | } |
| 128 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 129 | switch (event) { |
| 130 | case NETDEV_UP: |
| 131 | case NETDEV_CHANGE: |
| 132 | case NETDEV_REGISTER: |
| 133 | case NETDEV_CHANGEADDR: |
| 134 | hns_roce_set_mac(hr_dev, port, netdev->dev_addr); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 135 | break; |
| 136 | case NETDEV_DOWN: |
| 137 | /* |
Salil | e84e40be | 2016-11-23 19:41:09 +0000 | [diff] [blame] | 138 | * In v1 engine, only support all ports closed together. |
| 139 | */ |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 140 | break; |
| 141 | default: |
| 142 | dev_dbg(dev, "NETDEV event = 0x%x!\n", (u32)(event)); |
| 143 | break; |
| 144 | } |
| 145 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 146 | return 0; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | static int hns_roce_netdev_event(struct notifier_block *self, |
| 150 | unsigned long event, void *ptr) |
| 151 | { |
| 152 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
| 153 | struct hns_roce_ib_iboe *iboe = NULL; |
| 154 | struct hns_roce_dev *hr_dev = NULL; |
| 155 | u8 port = 0; |
| 156 | int ret = 0; |
| 157 | |
| 158 | hr_dev = container_of(self, struct hns_roce_dev, iboe.nb); |
| 159 | iboe = &hr_dev->iboe; |
| 160 | |
| 161 | for (port = 0; port < hr_dev->caps.num_ports; port++) { |
| 162 | if (dev == iboe->netdevs[port]) { |
| 163 | ret = handle_en_event(hr_dev, port, event); |
| 164 | if (ret) |
| 165 | return NOTIFY_DONE; |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return NOTIFY_DONE; |
| 171 | } |
| 172 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 173 | static int hns_roce_setup_mtu_mac(struct hns_roce_dev *hr_dev) |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 174 | { |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 175 | u8 i; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 176 | |
| 177 | for (i = 0; i < hr_dev->caps.num_ports; i++) { |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 178 | if (hr_dev->hw->set_mtu) |
| 179 | hr_dev->hw->set_mtu(hr_dev, hr_dev->iboe.phy_port[i], |
| 180 | hr_dev->caps.max_mtu); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 181 | hns_roce_set_mac(hr_dev, i, hr_dev->iboe.netdevs[i]->dev_addr); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 182 | } |
| 183 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 184 | return 0; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | static int hns_roce_query_device(struct ib_device *ib_dev, |
| 188 | struct ib_device_attr *props, |
| 189 | struct ib_udata *uhw) |
| 190 | { |
| 191 | struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev); |
| 192 | |
| 193 | memset(props, 0, sizeof(*props)); |
| 194 | |
| 195 | props->sys_image_guid = hr_dev->sys_image_guid; |
| 196 | props->max_mr_size = (u64)(~(0ULL)); |
| 197 | props->page_size_cap = hr_dev->caps.page_size_cap; |
| 198 | props->vendor_id = hr_dev->vendor_id; |
| 199 | props->vendor_part_id = hr_dev->vendor_part_id; |
| 200 | props->hw_ver = hr_dev->hw_rev; |
| 201 | props->max_qp = hr_dev->caps.num_qps; |
| 202 | props->max_qp_wr = hr_dev->caps.max_wqes; |
| 203 | props->device_cap_flags = IB_DEVICE_PORT_ACTIVE_EVENT | |
Lijun Ou | a74aab6 | 2016-09-15 23:48:08 +0100 | [diff] [blame] | 204 | IB_DEVICE_RC_RNR_NAK_GEN; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 205 | props->max_sge = hr_dev->caps.max_sq_sg; |
| 206 | props->max_sge_rd = 1; |
| 207 | props->max_cq = hr_dev->caps.num_cqs; |
| 208 | props->max_cqe = hr_dev->caps.max_cqes; |
| 209 | props->max_mr = hr_dev->caps.num_mtpts; |
| 210 | props->max_pd = hr_dev->caps.num_pds; |
| 211 | props->max_qp_rd_atom = hr_dev->caps.max_qp_dest_rdma; |
| 212 | props->max_qp_init_rd_atom = hr_dev->caps.max_qp_init_rdma; |
| 213 | props->atomic_cap = IB_ATOMIC_NONE; |
| 214 | props->max_pkeys = 1; |
| 215 | props->local_ca_ack_delay = hr_dev->caps.local_ca_ack_delay; |
| 216 | |
| 217 | return 0; |
| 218 | } |
| 219 | |
Lijun Ou | 2eefca2 | 2016-09-15 23:48:06 +0100 | [diff] [blame] | 220 | static struct net_device *hns_roce_get_netdev(struct ib_device *ib_dev, |
| 221 | u8 port_num) |
| 222 | { |
| 223 | struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev); |
| 224 | struct net_device *ndev; |
| 225 | |
| 226 | if (port_num < 1 || port_num > hr_dev->caps.num_ports) |
| 227 | return NULL; |
| 228 | |
| 229 | rcu_read_lock(); |
| 230 | |
| 231 | ndev = hr_dev->iboe.netdevs[port_num - 1]; |
| 232 | if (ndev) |
| 233 | dev_hold(ndev); |
| 234 | |
| 235 | rcu_read_unlock(); |
| 236 | return ndev; |
| 237 | } |
| 238 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 239 | static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num, |
| 240 | struct ib_port_attr *props) |
| 241 | { |
| 242 | struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev); |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 243 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 244 | struct net_device *net_dev; |
| 245 | unsigned long flags; |
| 246 | enum ib_mtu mtu; |
| 247 | u8 port; |
| 248 | |
| 249 | assert(port_num > 0); |
| 250 | port = port_num - 1; |
| 251 | |
Or Gerlitz | c4550c6 | 2017-01-24 13:02:39 +0200 | [diff] [blame] | 252 | /* props being zeroed by the caller, avoid zeroing it here */ |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 253 | |
| 254 | props->max_mtu = hr_dev->caps.max_mtu; |
| 255 | props->gid_tbl_len = hr_dev->caps.gid_table_len[port]; |
| 256 | props->port_cap_flags = IB_PORT_CM_SUP | IB_PORT_REINIT_SUP | |
| 257 | IB_PORT_VENDOR_CLASS_SUP | |
| 258 | IB_PORT_BOOT_MGMT_SUP; |
| 259 | props->max_msg_sz = HNS_ROCE_MAX_MSG_LEN; |
| 260 | props->pkey_tbl_len = 1; |
| 261 | props->active_width = IB_WIDTH_4X; |
| 262 | props->active_speed = 1; |
| 263 | |
| 264 | spin_lock_irqsave(&hr_dev->iboe.lock, flags); |
| 265 | |
| 266 | net_dev = hr_dev->iboe.netdevs[port]; |
| 267 | if (!net_dev) { |
| 268 | spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); |
| 269 | dev_err(dev, "find netdev %d failed!\r\n", port); |
| 270 | return -EINVAL; |
| 271 | } |
| 272 | |
| 273 | mtu = iboe_get_mtu(net_dev->mtu); |
| 274 | props->active_mtu = mtu ? min(props->max_mtu, mtu) : IB_MTU_256; |
| 275 | props->state = (netif_running(net_dev) && netif_carrier_ok(net_dev)) ? |
| 276 | IB_PORT_ACTIVE : IB_PORT_DOWN; |
| 277 | props->phys_state = (props->state == IB_PORT_ACTIVE) ? 5 : 3; |
| 278 | |
| 279 | spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device, |
| 285 | u8 port_num) |
| 286 | { |
| 287 | return IB_LINK_LAYER_ETHERNET; |
| 288 | } |
| 289 | |
| 290 | static int hns_roce_query_gid(struct ib_device *ib_dev, u8 port_num, int index, |
| 291 | union ib_gid *gid) |
| 292 | { |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | static int hns_roce_query_pkey(struct ib_device *ib_dev, u8 port, u16 index, |
| 297 | u16 *pkey) |
| 298 | { |
| 299 | *pkey = PKEY_ID; |
| 300 | |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | static int hns_roce_modify_device(struct ib_device *ib_dev, int mask, |
| 305 | struct ib_device_modify *props) |
| 306 | { |
| 307 | unsigned long flags; |
| 308 | |
| 309 | if (mask & ~IB_DEVICE_MODIFY_NODE_DESC) |
| 310 | return -EOPNOTSUPP; |
| 311 | |
| 312 | if (mask & IB_DEVICE_MODIFY_NODE_DESC) { |
| 313 | spin_lock_irqsave(&to_hr_dev(ib_dev)->sm_lock, flags); |
| 314 | memcpy(ib_dev->node_desc, props->node_desc, NODE_DESC_SIZE); |
| 315 | spin_unlock_irqrestore(&to_hr_dev(ib_dev)->sm_lock, flags); |
| 316 | } |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | static int hns_roce_modify_port(struct ib_device *ib_dev, u8 port_num, int mask, |
| 322 | struct ib_port_modify *props) |
| 323 | { |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | static struct ib_ucontext *hns_roce_alloc_ucontext(struct ib_device *ib_dev, |
| 328 | struct ib_udata *udata) |
| 329 | { |
| 330 | int ret = 0; |
| 331 | struct hns_roce_ucontext *context; |
| 332 | struct hns_roce_ib_alloc_ucontext_resp resp; |
| 333 | struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev); |
| 334 | |
| 335 | resp.qp_tab_size = hr_dev->caps.num_qps; |
| 336 | |
| 337 | context = kmalloc(sizeof(*context), GFP_KERNEL); |
| 338 | if (!context) |
| 339 | return ERR_PTR(-ENOMEM); |
| 340 | |
| 341 | ret = hns_roce_uar_alloc(hr_dev, &context->uar); |
| 342 | if (ret) |
| 343 | goto error_fail_uar_alloc; |
| 344 | |
| 345 | ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); |
| 346 | if (ret) |
| 347 | goto error_fail_copy_to_udata; |
| 348 | |
| 349 | return &context->ibucontext; |
| 350 | |
| 351 | error_fail_copy_to_udata: |
| 352 | hns_roce_uar_free(hr_dev, &context->uar); |
| 353 | |
| 354 | error_fail_uar_alloc: |
| 355 | kfree(context); |
| 356 | |
| 357 | return ERR_PTR(ret); |
| 358 | } |
| 359 | |
| 360 | static int hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext) |
| 361 | { |
| 362 | struct hns_roce_ucontext *context = to_hr_ucontext(ibcontext); |
| 363 | |
| 364 | hns_roce_uar_free(to_hr_dev(ibcontext->device), &context->uar); |
| 365 | kfree(context); |
| 366 | |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | static int hns_roce_mmap(struct ib_ucontext *context, |
| 371 | struct vm_area_struct *vma) |
| 372 | { |
Wei Hu (Xavier) | 8f3e9f3 | 2016-11-23 19:41:00 +0000 | [diff] [blame] | 373 | struct hns_roce_dev *hr_dev = to_hr_dev(context->device); |
| 374 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 375 | if (((vma->vm_end - vma->vm_start) % PAGE_SIZE) != 0) |
| 376 | return -EINVAL; |
| 377 | |
| 378 | if (vma->vm_pgoff == 0) { |
| 379 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
| 380 | if (io_remap_pfn_range(vma, vma->vm_start, |
| 381 | to_hr_ucontext(context)->uar.pfn, |
| 382 | PAGE_SIZE, vma->vm_page_prot)) |
| 383 | return -EAGAIN; |
Wei Hu (Xavier) | 8f3e9f3 | 2016-11-23 19:41:00 +0000 | [diff] [blame] | 384 | } else if (vma->vm_pgoff == 1 && hr_dev->hw_rev == HNS_ROCE_HW_VER1) { |
| 385 | /* vm_pgoff: 1 -- TPTR */ |
| 386 | if (io_remap_pfn_range(vma, vma->vm_start, |
| 387 | hr_dev->tptr_dma_addr >> PAGE_SHIFT, |
| 388 | hr_dev->tptr_size, |
| 389 | vma->vm_page_prot)) |
| 390 | return -EAGAIN; |
| 391 | } else |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 392 | return -EINVAL; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 393 | |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | static int hns_roce_port_immutable(struct ib_device *ib_dev, u8 port_num, |
| 398 | struct ib_port_immutable *immutable) |
| 399 | { |
| 400 | struct ib_port_attr attr; |
| 401 | int ret; |
| 402 | |
Or Gerlitz | c4550c6 | 2017-01-24 13:02:39 +0200 | [diff] [blame] | 403 | immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE; |
| 404 | |
| 405 | ret = ib_query_port(ib_dev, port_num, &attr); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 406 | if (ret) |
| 407 | return ret; |
| 408 | |
| 409 | immutable->pkey_tbl_len = attr.pkey_tbl_len; |
| 410 | immutable->gid_tbl_len = attr.gid_tbl_len; |
| 411 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 412 | immutable->max_mad_size = IB_MGMT_MAD_SIZE; |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev) |
| 418 | { |
| 419 | struct hns_roce_ib_iboe *iboe = &hr_dev->iboe; |
| 420 | |
| 421 | unregister_inetaddr_notifier(&iboe->nb_inet); |
| 422 | unregister_netdevice_notifier(&iboe->nb); |
| 423 | ib_unregister_device(&hr_dev->ib_dev); |
| 424 | } |
| 425 | |
| 426 | static int hns_roce_register_device(struct hns_roce_dev *hr_dev) |
| 427 | { |
| 428 | int ret; |
| 429 | struct hns_roce_ib_iboe *iboe = NULL; |
| 430 | struct ib_device *ib_dev = NULL; |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 431 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 432 | |
| 433 | iboe = &hr_dev->iboe; |
Lijun Ou | 49fdf6b | 2016-09-20 17:07:02 +0100 | [diff] [blame] | 434 | spin_lock_init(&iboe->lock); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 435 | |
| 436 | ib_dev = &hr_dev->ib_dev; |
Lijun Ou | 3b5184b | 2016-11-29 23:10:30 +0000 | [diff] [blame] | 437 | strlcpy(ib_dev->name, "hns_%d", IB_DEVICE_NAME_MAX); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 438 | |
| 439 | ib_dev->owner = THIS_MODULE; |
| 440 | ib_dev->node_type = RDMA_NODE_IB_CA; |
Bart Van Assche | fecd02e | 2017-01-20 13:04:18 -0800 | [diff] [blame] | 441 | ib_dev->dev.parent = dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 442 | |
| 443 | ib_dev->phys_port_cnt = hr_dev->caps.num_ports; |
| 444 | ib_dev->local_dma_lkey = hr_dev->caps.reserved_lkey; |
| 445 | ib_dev->num_comp_vectors = hr_dev->caps.num_comp_vectors; |
| 446 | ib_dev->uverbs_abi_ver = 1; |
| 447 | ib_dev->uverbs_cmd_mask = |
| 448 | (1ULL << IB_USER_VERBS_CMD_GET_CONTEXT) | |
| 449 | (1ULL << IB_USER_VERBS_CMD_QUERY_DEVICE) | |
| 450 | (1ULL << IB_USER_VERBS_CMD_QUERY_PORT) | |
| 451 | (1ULL << IB_USER_VERBS_CMD_ALLOC_PD) | |
| 452 | (1ULL << IB_USER_VERBS_CMD_DEALLOC_PD) | |
| 453 | (1ULL << IB_USER_VERBS_CMD_REG_MR) | |
| 454 | (1ULL << IB_USER_VERBS_CMD_DEREG_MR) | |
| 455 | (1ULL << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) | |
| 456 | (1ULL << IB_USER_VERBS_CMD_CREATE_CQ) | |
| 457 | (1ULL << IB_USER_VERBS_CMD_DESTROY_CQ) | |
| 458 | (1ULL << IB_USER_VERBS_CMD_CREATE_QP) | |
| 459 | (1ULL << IB_USER_VERBS_CMD_MODIFY_QP) | |
| 460 | (1ULL << IB_USER_VERBS_CMD_QUERY_QP) | |
| 461 | (1ULL << IB_USER_VERBS_CMD_DESTROY_QP); |
| 462 | |
| 463 | /* HCA||device||port */ |
| 464 | ib_dev->modify_device = hns_roce_modify_device; |
| 465 | ib_dev->query_device = hns_roce_query_device; |
| 466 | ib_dev->query_port = hns_roce_query_port; |
| 467 | ib_dev->modify_port = hns_roce_modify_port; |
| 468 | ib_dev->get_link_layer = hns_roce_get_link_layer; |
Lijun Ou | 2eefca2 | 2016-09-15 23:48:06 +0100 | [diff] [blame] | 469 | ib_dev->get_netdev = hns_roce_get_netdev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 470 | ib_dev->query_gid = hns_roce_query_gid; |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 471 | ib_dev->add_gid = hns_roce_add_gid; |
| 472 | ib_dev->del_gid = hns_roce_del_gid; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 473 | ib_dev->query_pkey = hns_roce_query_pkey; |
| 474 | ib_dev->alloc_ucontext = hns_roce_alloc_ucontext; |
| 475 | ib_dev->dealloc_ucontext = hns_roce_dealloc_ucontext; |
| 476 | ib_dev->mmap = hns_roce_mmap; |
| 477 | |
| 478 | /* PD */ |
| 479 | ib_dev->alloc_pd = hns_roce_alloc_pd; |
| 480 | ib_dev->dealloc_pd = hns_roce_dealloc_pd; |
| 481 | |
| 482 | /* AH */ |
| 483 | ib_dev->create_ah = hns_roce_create_ah; |
| 484 | ib_dev->query_ah = hns_roce_query_ah; |
| 485 | ib_dev->destroy_ah = hns_roce_destroy_ah; |
| 486 | |
| 487 | /* QP */ |
| 488 | ib_dev->create_qp = hns_roce_create_qp; |
| 489 | ib_dev->modify_qp = hns_roce_modify_qp; |
| 490 | ib_dev->query_qp = hr_dev->hw->query_qp; |
| 491 | ib_dev->destroy_qp = hr_dev->hw->destroy_qp; |
| 492 | ib_dev->post_send = hr_dev->hw->post_send; |
| 493 | ib_dev->post_recv = hr_dev->hw->post_recv; |
| 494 | |
| 495 | /* CQ */ |
| 496 | ib_dev->create_cq = hns_roce_ib_create_cq; |
| 497 | ib_dev->destroy_cq = hns_roce_ib_destroy_cq; |
| 498 | ib_dev->req_notify_cq = hr_dev->hw->req_notify_cq; |
| 499 | ib_dev->poll_cq = hr_dev->hw->poll_cq; |
| 500 | |
| 501 | /* MR */ |
| 502 | ib_dev->get_dma_mr = hns_roce_get_dma_mr; |
| 503 | ib_dev->reg_user_mr = hns_roce_reg_user_mr; |
| 504 | ib_dev->dereg_mr = hns_roce_dereg_mr; |
| 505 | |
| 506 | /* OTHERS */ |
| 507 | ib_dev->get_port_immutable = hns_roce_port_immutable; |
| 508 | |
| 509 | ret = ib_register_device(ib_dev, NULL); |
| 510 | if (ret) { |
| 511 | dev_err(dev, "ib_register_device failed!\n"); |
| 512 | return ret; |
| 513 | } |
| 514 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 515 | ret = hns_roce_setup_mtu_mac(hr_dev); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 516 | if (ret) { |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 517 | dev_err(dev, "setup_mtu_mac failed!\n"); |
| 518 | goto error_failed_setup_mtu_mac; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 519 | } |
| 520 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 521 | iboe->nb.notifier_call = hns_roce_netdev_event; |
| 522 | ret = register_netdevice_notifier(&iboe->nb); |
| 523 | if (ret) { |
| 524 | dev_err(dev, "register_netdevice_notifier failed!\n"); |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 525 | goto error_failed_setup_mtu_mac; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | return 0; |
| 529 | |
Shaobo Xu | 8254746 | 2016-11-23 19:41:08 +0000 | [diff] [blame] | 530 | error_failed_setup_mtu_mac: |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 531 | ib_unregister_device(ib_dev); |
| 532 | |
| 533 | return ret; |
| 534 | } |
| 535 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 536 | static int hns_roce_init_hem(struct hns_roce_dev *hr_dev) |
| 537 | { |
| 538 | int ret; |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 539 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 540 | |
| 541 | ret = hns_roce_init_hem_table(hr_dev, &hr_dev->mr_table.mtt_table, |
| 542 | HEM_TYPE_MTT, hr_dev->caps.mtt_entry_sz, |
| 543 | hr_dev->caps.num_mtt_segs, 1); |
| 544 | if (ret) { |
| 545 | dev_err(dev, "Failed to init MTT context memory, aborting.\n"); |
| 546 | return ret; |
| 547 | } |
| 548 | |
| 549 | ret = hns_roce_init_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table, |
| 550 | HEM_TYPE_MTPT, hr_dev->caps.mtpt_entry_sz, |
| 551 | hr_dev->caps.num_mtpts, 1); |
| 552 | if (ret) { |
| 553 | dev_err(dev, "Failed to init MTPT context memory, aborting.\n"); |
| 554 | goto err_unmap_mtt; |
| 555 | } |
| 556 | |
| 557 | ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qp_table.qp_table, |
| 558 | HEM_TYPE_QPC, hr_dev->caps.qpc_entry_sz, |
| 559 | hr_dev->caps.num_qps, 1); |
| 560 | if (ret) { |
| 561 | dev_err(dev, "Failed to init QP context memory, aborting.\n"); |
| 562 | goto err_unmap_dmpt; |
| 563 | } |
| 564 | |
| 565 | ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qp_table.irrl_table, |
| 566 | HEM_TYPE_IRRL, |
| 567 | hr_dev->caps.irrl_entry_sz * |
| 568 | hr_dev->caps.max_qp_init_rdma, |
| 569 | hr_dev->caps.num_qps, 1); |
| 570 | if (ret) { |
| 571 | dev_err(dev, "Failed to init irrl_table memory, aborting.\n"); |
| 572 | goto err_unmap_qp; |
| 573 | } |
| 574 | |
| 575 | ret = hns_roce_init_hem_table(hr_dev, &hr_dev->cq_table.table, |
| 576 | HEM_TYPE_CQC, hr_dev->caps.cqc_entry_sz, |
| 577 | hr_dev->caps.num_cqs, 1); |
| 578 | if (ret) { |
| 579 | dev_err(dev, "Failed to init CQ context memory, aborting.\n"); |
| 580 | goto err_unmap_irrl; |
| 581 | } |
| 582 | |
| 583 | return 0; |
| 584 | |
| 585 | err_unmap_irrl: |
| 586 | hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.irrl_table); |
| 587 | |
| 588 | err_unmap_qp: |
| 589 | hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.qp_table); |
| 590 | |
| 591 | err_unmap_dmpt: |
| 592 | hns_roce_cleanup_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table); |
| 593 | |
| 594 | err_unmap_mtt: |
| 595 | hns_roce_cleanup_hem_table(hr_dev, &hr_dev->mr_table.mtt_table); |
| 596 | |
| 597 | return ret; |
| 598 | } |
| 599 | |
| 600 | /** |
Salil | e84e40be | 2016-11-23 19:41:09 +0000 | [diff] [blame] | 601 | * hns_roce_setup_hca - setup host channel adapter |
| 602 | * @hr_dev: pointer to hns roce device |
| 603 | * Return : int |
| 604 | */ |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 605 | static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) |
| 606 | { |
| 607 | int ret; |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 608 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 609 | |
| 610 | spin_lock_init(&hr_dev->sm_lock); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 611 | spin_lock_init(&hr_dev->bt_cmd_lock); |
| 612 | |
| 613 | ret = hns_roce_init_uar_table(hr_dev); |
| 614 | if (ret) { |
| 615 | dev_err(dev, "Failed to initialize uar table. aborting\n"); |
| 616 | return ret; |
| 617 | } |
| 618 | |
| 619 | ret = hns_roce_uar_alloc(hr_dev, &hr_dev->priv_uar); |
| 620 | if (ret) { |
| 621 | dev_err(dev, "Failed to allocate priv_uar.\n"); |
| 622 | goto err_uar_table_free; |
| 623 | } |
| 624 | |
| 625 | ret = hns_roce_init_pd_table(hr_dev); |
| 626 | if (ret) { |
| 627 | dev_err(dev, "Failed to init protected domain table.\n"); |
| 628 | goto err_uar_alloc_free; |
| 629 | } |
| 630 | |
| 631 | ret = hns_roce_init_mr_table(hr_dev); |
| 632 | if (ret) { |
| 633 | dev_err(dev, "Failed to init memory region table.\n"); |
| 634 | goto err_pd_table_free; |
| 635 | } |
| 636 | |
| 637 | ret = hns_roce_init_cq_table(hr_dev); |
| 638 | if (ret) { |
| 639 | dev_err(dev, "Failed to init completion queue table.\n"); |
| 640 | goto err_mr_table_free; |
| 641 | } |
| 642 | |
| 643 | ret = hns_roce_init_qp_table(hr_dev); |
| 644 | if (ret) { |
| 645 | dev_err(dev, "Failed to init queue pair table.\n"); |
| 646 | goto err_cq_table_free; |
| 647 | } |
| 648 | |
| 649 | return 0; |
| 650 | |
| 651 | err_cq_table_free: |
| 652 | hns_roce_cleanup_cq_table(hr_dev); |
| 653 | |
| 654 | err_mr_table_free: |
| 655 | hns_roce_cleanup_mr_table(hr_dev); |
| 656 | |
| 657 | err_pd_table_free: |
| 658 | hns_roce_cleanup_pd_table(hr_dev); |
| 659 | |
| 660 | err_uar_alloc_free: |
| 661 | hns_roce_uar_free(hr_dev, &hr_dev->priv_uar); |
| 662 | |
| 663 | err_uar_table_free: |
| 664 | hns_roce_cleanup_uar_table(hr_dev); |
| 665 | return ret; |
| 666 | } |
| 667 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 668 | int hns_roce_init(struct hns_roce_dev *hr_dev) |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 669 | { |
| 670 | int ret; |
Wei Hu(Xavier) | 13ca970 | 2017-08-30 17:23:02 +0800 | [diff] [blame] | 671 | struct device *dev = hr_dev->dev; |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 672 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 673 | if (hr_dev->hw->reset) { |
| 674 | ret = hr_dev->hw->reset(hr_dev, true); |
| 675 | if (ret) { |
| 676 | dev_err(dev, "Reset RoCE engine failed!\n"); |
| 677 | return ret; |
| 678 | } |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 679 | } |
| 680 | |
Wei Hu(Xavier) | a04ff73 | 2017-08-30 17:23:03 +0800 | [diff] [blame^] | 681 | if (hr_dev->hw->cmq_init) { |
| 682 | ret = hr_dev->hw->cmq_init(hr_dev); |
| 683 | if (ret) { |
| 684 | dev_err(dev, "Init RoCE Command Queue failed!\n"); |
| 685 | goto error_failed_cmq_init; |
| 686 | } |
| 687 | } |
| 688 | |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 689 | hr_dev->hw->hw_profile(hr_dev); |
| 690 | |
| 691 | ret = hns_roce_cmd_init(hr_dev); |
| 692 | if (ret) { |
| 693 | dev_err(dev, "cmd init failed!\n"); |
| 694 | goto error_failed_cmd_init; |
| 695 | } |
| 696 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 697 | if (hr_dev->cmd_mod) { |
| 698 | ret = hns_roce_init_eq_table(hr_dev); |
| 699 | if (ret) { |
| 700 | dev_err(dev, "eq init failed!\n"); |
| 701 | goto error_failed_eq_table; |
| 702 | } |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | if (hr_dev->cmd_mod) { |
| 706 | ret = hns_roce_cmd_use_events(hr_dev); |
| 707 | if (ret) { |
| 708 | dev_err(dev, "Switch to event-driven cmd failed!\n"); |
| 709 | goto error_failed_use_event; |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | ret = hns_roce_init_hem(hr_dev); |
| 714 | if (ret) { |
| 715 | dev_err(dev, "init HEM(Hardware Entry Memory) failed!\n"); |
| 716 | goto error_failed_init_hem; |
| 717 | } |
| 718 | |
| 719 | ret = hns_roce_setup_hca(hr_dev); |
| 720 | if (ret) { |
| 721 | dev_err(dev, "setup hca failed!\n"); |
| 722 | goto error_failed_setup_hca; |
| 723 | } |
| 724 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 725 | if (hr_dev->hw->hw_init) { |
| 726 | ret = hr_dev->hw->hw_init(hr_dev); |
| 727 | if (ret) { |
| 728 | dev_err(dev, "hw_init failed!\n"); |
| 729 | goto error_failed_engine_init; |
| 730 | } |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | ret = hns_roce_register_device(hr_dev); |
| 734 | if (ret) |
| 735 | goto error_failed_register_device; |
| 736 | |
| 737 | return 0; |
| 738 | |
| 739 | error_failed_register_device: |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 740 | if (hr_dev->hw->hw_exit) |
| 741 | hr_dev->hw->hw_exit(hr_dev); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 742 | |
| 743 | error_failed_engine_init: |
| 744 | hns_roce_cleanup_bitmap(hr_dev); |
| 745 | |
| 746 | error_failed_setup_hca: |
| 747 | hns_roce_cleanup_hem(hr_dev); |
| 748 | |
| 749 | error_failed_init_hem: |
| 750 | if (hr_dev->cmd_mod) |
| 751 | hns_roce_cmd_use_polling(hr_dev); |
| 752 | |
| 753 | error_failed_use_event: |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 754 | if (hr_dev->cmd_mod) |
| 755 | hns_roce_cleanup_eq_table(hr_dev); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 756 | |
| 757 | error_failed_eq_table: |
| 758 | hns_roce_cmd_cleanup(hr_dev); |
| 759 | |
| 760 | error_failed_cmd_init: |
Wei Hu(Xavier) | a04ff73 | 2017-08-30 17:23:03 +0800 | [diff] [blame^] | 761 | if (hr_dev->hw->cmq_exit) |
| 762 | hr_dev->hw->cmq_exit(hr_dev); |
| 763 | |
| 764 | error_failed_cmq_init: |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 765 | if (hr_dev->hw->reset) { |
| 766 | ret = hr_dev->hw->reset(hr_dev, false); |
| 767 | if (ret) |
| 768 | dev_err(dev, "Dereset RoCE engine failed!\n"); |
| 769 | } |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 770 | |
| 771 | return ret; |
| 772 | } |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 773 | EXPORT_SYMBOL_GPL(hns_roce_init); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 774 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 775 | void hns_roce_exit(struct hns_roce_dev *hr_dev) |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 776 | { |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 777 | hns_roce_unregister_device(hr_dev); |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 778 | if (hr_dev->hw->hw_exit) |
| 779 | hr_dev->hw->hw_exit(hr_dev); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 780 | hns_roce_cleanup_bitmap(hr_dev); |
| 781 | hns_roce_cleanup_hem(hr_dev); |
| 782 | |
| 783 | if (hr_dev->cmd_mod) |
| 784 | hns_roce_cmd_use_polling(hr_dev); |
| 785 | |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 786 | if (hr_dev->cmd_mod) |
| 787 | hns_roce_cleanup_eq_table(hr_dev); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 788 | hns_roce_cmd_cleanup(hr_dev); |
Wei Hu(Xavier) | a04ff73 | 2017-08-30 17:23:03 +0800 | [diff] [blame^] | 789 | if (hr_dev->hw->cmq_exit) |
| 790 | hr_dev->hw->cmq_exit(hr_dev); |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 791 | if (hr_dev->hw->reset) |
| 792 | hr_dev->hw->reset(hr_dev, false); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 793 | } |
Wei Hu(Xavier) | 08805fd | 2017-08-30 17:22:59 +0800 | [diff] [blame] | 794 | EXPORT_SYMBOL_GPL(hns_roce_exit); |
oulijun | 9a44353 | 2016-07-21 19:06:38 +0800 | [diff] [blame] | 795 | |
| 796 | MODULE_LICENSE("Dual BSD/GPL"); |
| 797 | MODULE_AUTHOR("Wei Hu <xavier.huwei@huawei.com>"); |
| 798 | MODULE_AUTHOR("Nenglong Zhao <zhaonenglong@hisilicon.com>"); |
| 799 | MODULE_AUTHOR("Lijun Ou <oulijun@huawei.com>"); |
| 800 | MODULE_DESCRIPTION("HNS RoCE Driver"); |