Lines Matching refs:dev
68 void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid) in ocrdma_get_guid() argument
72 memcpy(&mac_addr[0], &dev->nic_info.mac_addr[0], ETH_ALEN); in ocrdma_get_guid()
106 static int ocrdma_register_device(struct ocrdma_dev *dev) in ocrdma_register_device() argument
108 strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX); in ocrdma_register_device()
109 ocrdma_get_guid(dev, (u8 *)&dev->ibdev.node_guid); in ocrdma_register_device()
110 memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC, in ocrdma_register_device()
112 dev->ibdev.owner = THIS_MODULE; in ocrdma_register_device()
113 dev->ibdev.uverbs_abi_ver = OCRDMA_ABI_VERSION; in ocrdma_register_device()
114 dev->ibdev.uverbs_cmd_mask = in ocrdma_register_device()
135 dev->ibdev.uverbs_cmd_mask |= in ocrdma_register_device()
141 dev->ibdev.node_type = RDMA_NODE_IB_CA; in ocrdma_register_device()
142 dev->ibdev.phys_port_cnt = 1; in ocrdma_register_device()
143 dev->ibdev.num_comp_vectors = dev->eq_cnt; in ocrdma_register_device()
146 dev->ibdev.query_device = ocrdma_query_device; in ocrdma_register_device()
147 dev->ibdev.query_port = ocrdma_query_port; in ocrdma_register_device()
148 dev->ibdev.modify_port = ocrdma_modify_port; in ocrdma_register_device()
149 dev->ibdev.query_gid = ocrdma_query_gid; in ocrdma_register_device()
150 dev->ibdev.get_netdev = ocrdma_get_netdev; in ocrdma_register_device()
151 dev->ibdev.add_gid = ocrdma_add_gid; in ocrdma_register_device()
152 dev->ibdev.del_gid = ocrdma_del_gid; in ocrdma_register_device()
153 dev->ibdev.get_link_layer = ocrdma_link_layer; in ocrdma_register_device()
154 dev->ibdev.alloc_pd = ocrdma_alloc_pd; in ocrdma_register_device()
155 dev->ibdev.dealloc_pd = ocrdma_dealloc_pd; in ocrdma_register_device()
157 dev->ibdev.create_cq = ocrdma_create_cq; in ocrdma_register_device()
158 dev->ibdev.destroy_cq = ocrdma_destroy_cq; in ocrdma_register_device()
159 dev->ibdev.resize_cq = ocrdma_resize_cq; in ocrdma_register_device()
161 dev->ibdev.create_qp = ocrdma_create_qp; in ocrdma_register_device()
162 dev->ibdev.modify_qp = ocrdma_modify_qp; in ocrdma_register_device()
163 dev->ibdev.query_qp = ocrdma_query_qp; in ocrdma_register_device()
164 dev->ibdev.destroy_qp = ocrdma_destroy_qp; in ocrdma_register_device()
166 dev->ibdev.query_pkey = ocrdma_query_pkey; in ocrdma_register_device()
167 dev->ibdev.create_ah = ocrdma_create_ah; in ocrdma_register_device()
168 dev->ibdev.destroy_ah = ocrdma_destroy_ah; in ocrdma_register_device()
169 dev->ibdev.query_ah = ocrdma_query_ah; in ocrdma_register_device()
170 dev->ibdev.modify_ah = ocrdma_modify_ah; in ocrdma_register_device()
172 dev->ibdev.poll_cq = ocrdma_poll_cq; in ocrdma_register_device()
173 dev->ibdev.post_send = ocrdma_post_send; in ocrdma_register_device()
174 dev->ibdev.post_recv = ocrdma_post_recv; in ocrdma_register_device()
175 dev->ibdev.req_notify_cq = ocrdma_arm_cq; in ocrdma_register_device()
177 dev->ibdev.get_dma_mr = ocrdma_get_dma_mr; in ocrdma_register_device()
178 dev->ibdev.reg_phys_mr = ocrdma_reg_kernel_mr; in ocrdma_register_device()
179 dev->ibdev.dereg_mr = ocrdma_dereg_mr; in ocrdma_register_device()
180 dev->ibdev.reg_user_mr = ocrdma_reg_user_mr; in ocrdma_register_device()
182 dev->ibdev.alloc_mr = ocrdma_alloc_mr; in ocrdma_register_device()
183 dev->ibdev.map_mr_sg = ocrdma_map_mr_sg; in ocrdma_register_device()
186 dev->ibdev.alloc_ucontext = ocrdma_alloc_ucontext; in ocrdma_register_device()
187 dev->ibdev.dealloc_ucontext = ocrdma_dealloc_ucontext; in ocrdma_register_device()
188 dev->ibdev.mmap = ocrdma_mmap; in ocrdma_register_device()
189 dev->ibdev.dma_device = &dev->nic_info.pdev->dev; in ocrdma_register_device()
191 dev->ibdev.process_mad = ocrdma_process_mad; in ocrdma_register_device()
192 dev->ibdev.get_port_immutable = ocrdma_port_immutable; in ocrdma_register_device()
194 if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R) { in ocrdma_register_device()
195 dev->ibdev.uverbs_cmd_mask |= in ocrdma_register_device()
202 dev->ibdev.create_srq = ocrdma_create_srq; in ocrdma_register_device()
203 dev->ibdev.modify_srq = ocrdma_modify_srq; in ocrdma_register_device()
204 dev->ibdev.query_srq = ocrdma_query_srq; in ocrdma_register_device()
205 dev->ibdev.destroy_srq = ocrdma_destroy_srq; in ocrdma_register_device()
206 dev->ibdev.post_srq_recv = ocrdma_post_srq_recv; in ocrdma_register_device()
208 return ib_register_device(&dev->ibdev, NULL); in ocrdma_register_device()
211 static int ocrdma_alloc_resources(struct ocrdma_dev *dev) in ocrdma_alloc_resources() argument
213 mutex_init(&dev->dev_lock); in ocrdma_alloc_resources()
214 dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) * in ocrdma_alloc_resources()
216 if (!dev->cq_tbl) in ocrdma_alloc_resources()
219 if (dev->attr.max_qp) { in ocrdma_alloc_resources()
220 dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) * in ocrdma_alloc_resources()
222 if (!dev->qp_tbl) in ocrdma_alloc_resources()
226 dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL); in ocrdma_alloc_resources()
227 if (dev->stag_arr == NULL) in ocrdma_alloc_resources()
230 ocrdma_alloc_pd_pool(dev); in ocrdma_alloc_resources()
232 spin_lock_init(&dev->av_tbl.lock); in ocrdma_alloc_resources()
233 spin_lock_init(&dev->flush_q_lock); in ocrdma_alloc_resources()
236 pr_err("%s(%d) error.\n", __func__, dev->id); in ocrdma_alloc_resources()
240 static void ocrdma_free_resources(struct ocrdma_dev *dev) in ocrdma_free_resources() argument
242 kfree(dev->stag_arr); in ocrdma_free_resources()
243 kfree(dev->qp_tbl); in ocrdma_free_resources()
244 kfree(dev->cq_tbl); in ocrdma_free_resources()
251 struct ocrdma_dev *dev = dev_get_drvdata(device); in show_rev() local
253 return scnprintf(buf, PAGE_SIZE, "0x%x\n", dev->nic_info.pdev->vendor); in show_rev()
259 struct ocrdma_dev *dev = dev_get_drvdata(device); in show_fw_ver() local
261 return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->attr.fw_ver[0]); in show_fw_ver()
267 struct ocrdma_dev *dev = dev_get_drvdata(device); in show_hca_type() local
269 return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->model_number[0]); in show_hca_type()
282 static void ocrdma_remove_sysfiles(struct ocrdma_dev *dev) in ocrdma_remove_sysfiles() argument
287 device_remove_file(&dev->ibdev.dev, ocrdma_attributes[i]); in ocrdma_remove_sysfiles()
294 struct ocrdma_dev *dev; in ocrdma_add() local
296 dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev)); in ocrdma_add()
297 if (!dev) { in ocrdma_add()
301 dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL); in ocrdma_add()
302 if (!dev->mbx_cmd) in ocrdma_add()
305 memcpy(&dev->nic_info, dev_info, sizeof(*dev_info)); in ocrdma_add()
306 dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL); in ocrdma_add()
307 if (dev->id < 0) in ocrdma_add()
310 status = ocrdma_init_hw(dev); in ocrdma_add()
314 status = ocrdma_alloc_resources(dev); in ocrdma_add()
318 ocrdma_init_service_level(dev); in ocrdma_add()
319 status = ocrdma_register_device(dev); in ocrdma_add()
324 status = ocrdma_mbx_get_link_speed(dev, NULL, &lstate); in ocrdma_add()
326 ocrdma_update_link_state(dev, lstate); in ocrdma_add()
329 if (device_create_file(&dev->ibdev.dev, ocrdma_attributes[i])) in ocrdma_add()
332 ocrdma_add_port_stats(dev); in ocrdma_add()
334 INIT_DELAYED_WORK(&dev->eqd_work, ocrdma_eqd_set_task); in ocrdma_add()
335 schedule_delayed_work(&dev->eqd_work, msecs_to_jiffies(1000)); in ocrdma_add()
338 dev_name(&dev->nic_info.pdev->dev), hca_name(dev), in ocrdma_add()
339 port_speed_string(dev), dev->model_number, in ocrdma_add()
340 dev->hba_port_num); in ocrdma_add()
342 dev_name(&dev->nic_info.pdev->dev), dev->id); in ocrdma_add()
343 return dev; in ocrdma_add()
346 ocrdma_remove_sysfiles(dev); in ocrdma_add()
348 ocrdma_free_resources(dev); in ocrdma_add()
349 ocrdma_cleanup_hw(dev); in ocrdma_add()
351 idr_remove(&ocrdma_dev_id, dev->id); in ocrdma_add()
353 kfree(dev->mbx_cmd); in ocrdma_add()
354 ib_dealloc_device(&dev->ibdev); in ocrdma_add()
359 static void ocrdma_remove_free(struct ocrdma_dev *dev) in ocrdma_remove_free() argument
362 idr_remove(&ocrdma_dev_id, dev->id); in ocrdma_remove_free()
363 kfree(dev->mbx_cmd); in ocrdma_remove_free()
364 ib_dealloc_device(&dev->ibdev); in ocrdma_remove_free()
367 static void ocrdma_remove(struct ocrdma_dev *dev) in ocrdma_remove() argument
372 cancel_delayed_work_sync(&dev->eqd_work); in ocrdma_remove()
373 ocrdma_remove_sysfiles(dev); in ocrdma_remove()
374 ib_unregister_device(&dev->ibdev); in ocrdma_remove()
376 ocrdma_rem_port_stats(dev); in ocrdma_remove()
377 ocrdma_free_resources(dev); in ocrdma_remove()
378 ocrdma_cleanup_hw(dev); in ocrdma_remove()
379 ocrdma_remove_free(dev); in ocrdma_remove()
382 static int ocrdma_dispatch_port_active(struct ocrdma_dev *dev) in ocrdma_dispatch_port_active() argument
388 port_event.device = &dev->ibdev; in ocrdma_dispatch_port_active()
393 static int ocrdma_dispatch_port_error(struct ocrdma_dev *dev) in ocrdma_dispatch_port_error() argument
399 err_event.device = &dev->ibdev; in ocrdma_dispatch_port_error()
404 static void ocrdma_shutdown(struct ocrdma_dev *dev) in ocrdma_shutdown() argument
406 ocrdma_dispatch_port_error(dev); in ocrdma_shutdown()
407 ocrdma_remove(dev); in ocrdma_shutdown()
414 static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event) in ocrdma_event_handler() argument
418 ocrdma_shutdown(dev); in ocrdma_event_handler()
425 void ocrdma_update_link_state(struct ocrdma_dev *dev, u8 lstate) in ocrdma_update_link_state() argument
427 if (!(dev->flags & OCRDMA_FLAGS_LINK_STATUS_INIT)) { in ocrdma_update_link_state()
428 dev->flags |= OCRDMA_FLAGS_LINK_STATUS_INIT; in ocrdma_update_link_state()
434 ocrdma_dispatch_port_error(dev); in ocrdma_update_link_state()
436 ocrdma_dispatch_port_active(dev); in ocrdma_update_link_state()