Lines Matching refs:dev

75 	struct ocrdma_dev *dev;  in ocrdma_port_immutable()  local
78 dev = get_ocrdma_dev(ibdev); in ocrdma_port_immutable()
80 if (ocrdma_is_udp_encap_supported(dev)) in ocrdma_port_immutable()
96 struct ocrdma_dev *dev = get_ocrdma_dev(device); in get_dev_fw_str() local
98 snprintf(str, IB_FW_VERSION_NAME_MAX, "%s", &dev->attr.fw_ver[0]); in get_dev_fw_str()
105 struct ocrdma_dev *dev = in hw_rev_show() local
108 return sysfs_emit(buf, "0x%x\n", dev->nic_info.pdev->vendor); in hw_rev_show()
115 struct ocrdma_dev *dev = in hca_type_show() local
118 return sysfs_emit(buf, "%s\n", &dev->model_number[0]); in hca_type_show()
188 static int ocrdma_register_device(struct ocrdma_dev *dev) in ocrdma_register_device() argument
192 addrconf_addr_eui48((u8 *)&dev->ibdev.node_guid, in ocrdma_register_device()
193 dev->nic_info.mac_addr); in ocrdma_register_device()
195 memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC, in ocrdma_register_device()
198 dev->ibdev.node_type = RDMA_NODE_IB_CA; in ocrdma_register_device()
199 dev->ibdev.phys_port_cnt = 1; in ocrdma_register_device()
200 dev->ibdev.num_comp_vectors = dev->eq_cnt; in ocrdma_register_device()
203 dev->ibdev.dev.parent = &dev->nic_info.pdev->dev; in ocrdma_register_device()
205 ib_set_device_ops(&dev->ibdev, &ocrdma_dev_ops); in ocrdma_register_device()
207 if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R) in ocrdma_register_device()
208 ib_set_device_ops(&dev->ibdev, &ocrdma_dev_srq_ops); in ocrdma_register_device()
210 ret = ib_device_set_netdev(&dev->ibdev, dev->nic_info.netdev, 1); in ocrdma_register_device()
214 dma_set_max_seg_size(&dev->nic_info.pdev->dev, UINT_MAX); in ocrdma_register_device()
215 return ib_register_device(&dev->ibdev, "ocrdma%d", in ocrdma_register_device()
216 &dev->nic_info.pdev->dev); in ocrdma_register_device()
219 static int ocrdma_alloc_resources(struct ocrdma_dev *dev) in ocrdma_alloc_resources() argument
221 mutex_init(&dev->dev_lock); in ocrdma_alloc_resources()
222 dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(struct ocrdma_cq *), in ocrdma_alloc_resources()
224 if (!dev->cq_tbl) in ocrdma_alloc_resources()
227 if (dev->attr.max_qp) { in ocrdma_alloc_resources()
228 dev->qp_tbl = kcalloc(OCRDMA_MAX_QP, in ocrdma_alloc_resources()
231 if (!dev->qp_tbl) in ocrdma_alloc_resources()
235 dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(u64), GFP_KERNEL); in ocrdma_alloc_resources()
236 if (dev->stag_arr == NULL) in ocrdma_alloc_resources()
239 ocrdma_alloc_pd_pool(dev); in ocrdma_alloc_resources()
241 if (!ocrdma_alloc_stats_resources(dev)) { in ocrdma_alloc_resources()
246 spin_lock_init(&dev->av_tbl.lock); in ocrdma_alloc_resources()
247 spin_lock_init(&dev->flush_q_lock); in ocrdma_alloc_resources()
250 pr_err("%s(%d) error.\n", __func__, dev->id); in ocrdma_alloc_resources()
254 static void ocrdma_free_resources(struct ocrdma_dev *dev) in ocrdma_free_resources() argument
256 ocrdma_release_stats_resources(dev); in ocrdma_free_resources()
257 kfree(dev->stag_arr); in ocrdma_free_resources()
258 kfree(dev->qp_tbl); in ocrdma_free_resources()
259 kfree(dev->cq_tbl); in ocrdma_free_resources()
266 struct ocrdma_dev *dev; in ocrdma_add() local
268 dev = ib_alloc_device(ocrdma_dev, ibdev); in ocrdma_add()
269 if (!dev) { in ocrdma_add()
274 dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL); in ocrdma_add()
275 if (!dev->mbx_cmd) in ocrdma_add()
278 memcpy(&dev->nic_info, dev_info, sizeof(*dev_info)); in ocrdma_add()
279 dev->id = PCI_FUNC(dev->nic_info.pdev->devfn); in ocrdma_add()
280 status = ocrdma_init_hw(dev); in ocrdma_add()
284 status = ocrdma_alloc_resources(dev); in ocrdma_add()
288 ocrdma_init_service_level(dev); in ocrdma_add()
289 status = ocrdma_register_device(dev); in ocrdma_add()
294 status = ocrdma_mbx_get_link_speed(dev, NULL, &lstate); in ocrdma_add()
296 ocrdma_update_link_state(dev, lstate); in ocrdma_add()
299 ocrdma_add_port_stats(dev); in ocrdma_add()
301 INIT_DELAYED_WORK(&dev->eqd_work, ocrdma_eqd_set_task); in ocrdma_add()
302 schedule_delayed_work(&dev->eqd_work, msecs_to_jiffies(1000)); in ocrdma_add()
305 dev_name(&dev->nic_info.pdev->dev), hca_name(dev), in ocrdma_add()
306 port_speed_string(dev), dev->model_number, in ocrdma_add()
307 dev->hba_port_num); in ocrdma_add()
309 dev_name(&dev->nic_info.pdev->dev), dev->id); in ocrdma_add()
310 return dev; in ocrdma_add()
313 ocrdma_free_resources(dev); in ocrdma_add()
314 ocrdma_cleanup_hw(dev); in ocrdma_add()
316 kfree(dev->mbx_cmd); in ocrdma_add()
317 ib_dealloc_device(&dev->ibdev); in ocrdma_add()
322 static void ocrdma_remove_free(struct ocrdma_dev *dev) in ocrdma_remove_free() argument
325 kfree(dev->mbx_cmd); in ocrdma_remove_free()
326 ib_dealloc_device(&dev->ibdev); in ocrdma_remove_free()
329 static void ocrdma_remove(struct ocrdma_dev *dev) in ocrdma_remove() argument
334 cancel_delayed_work_sync(&dev->eqd_work); in ocrdma_remove()
335 ib_unregister_device(&dev->ibdev); in ocrdma_remove()
337 ocrdma_rem_port_stats(dev); in ocrdma_remove()
338 ocrdma_free_resources(dev); in ocrdma_remove()
339 ocrdma_cleanup_hw(dev); in ocrdma_remove()
340 ocrdma_remove_free(dev); in ocrdma_remove()
343 static int ocrdma_dispatch_port_active(struct ocrdma_dev *dev) in ocrdma_dispatch_port_active() argument
349 port_event.device = &dev->ibdev; in ocrdma_dispatch_port_active()
354 static int ocrdma_dispatch_port_error(struct ocrdma_dev *dev) in ocrdma_dispatch_port_error() argument
360 err_event.device = &dev->ibdev; in ocrdma_dispatch_port_error()
365 static void ocrdma_shutdown(struct ocrdma_dev *dev) in ocrdma_shutdown() argument
367 ocrdma_dispatch_port_error(dev); in ocrdma_shutdown()
368 ocrdma_remove(dev); in ocrdma_shutdown()
375 static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event) in ocrdma_event_handler() argument
379 ocrdma_shutdown(dev); in ocrdma_event_handler()
386 void ocrdma_update_link_state(struct ocrdma_dev *dev, u8 lstate) in ocrdma_update_link_state() argument
388 if (!(dev->flags & OCRDMA_FLAGS_LINK_STATUS_INIT)) { in ocrdma_update_link_state()
389 dev->flags |= OCRDMA_FLAGS_LINK_STATUS_INIT; in ocrdma_update_link_state()
395 ocrdma_dispatch_port_error(dev); in ocrdma_update_link_state()
397 ocrdma_dispatch_port_active(dev); in ocrdma_update_link_state()