Lines Matching defs:sdev
142 struct srpt_device *sdev =
148 dev_name(&sdev->device->dev));
153 if (port_num < sdev->device->phys_port_cnt) {
154 sport = &sdev->port[port_num];
160 sdev->device->phys_port_cnt);
171 if (port_num < sdev->device->phys_port_cnt) {
172 sport = &sdev->port[port_num];
178 sdev->device->phys_port_cnt);
327 struct srpt_device *sdev = sport->sdev;
345 if (sdev->use_srq)
346 send_queue_depth = sdev->srq_size;
349 sdev->device->attrs.max_qp_wr);
354 iocp->vendor_id = cpu_to_be32(sdev->device->attrs.vendor_id);
355 iocp->device_id = cpu_to_be32(sdev->device->attrs.vendor_part_id);
356 iocp->device_version = cpu_to_be16(sdev->device->attrs.hw_ver);
357 iocp->subsys_vendor_id = cpu_to_be32(sdev->device->attrs.vendor_id);
564 ret = ib_query_port(sport->sdev->device, sport->port, &port_attr);
571 ret = rdma_query_gid(sport->sdev->device, sport->port, 0, &sport->gid);
582 if (rdma_protocol_iwarp(sport->sdev->device, sport->port))
589 ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify);
592 dev_name(&sport->sdev->device->dev), sport->port, ret);
603 mad_agent = ib_register_mad_agent(sport->sdev->device,
612 dev_name(&sport->sdev->device->dev), sport->port,
617 ib_modify_port(sport->sdev->device, sport->port, 0,
630 * @sdev: SRPT HCA pointer.
635 static void srpt_unregister_mad_agent(struct srpt_device *sdev, int port_cnt)
644 sport = &sdev->port[i - 1];
647 ib_modify_port(sdev->device, i, 0, &port_modify);
656 * @sdev: SRPT HCA pointer.
661 static struct srpt_ioctx *srpt_alloc_ioctx(struct srpt_device *sdev,
676 ioctx->dma = ib_dma_map_single(sdev->device, ioctx->buf,
678 if (ib_dma_mapping_error(sdev->device, ioctx->dma))
693 * @sdev: SRPT HCA pointer.
698 static void srpt_free_ioctx(struct srpt_device *sdev, struct srpt_ioctx *ioctx,
705 ib_dma_unmap_single(sdev->device, ioctx->dma,
713 * @sdev: Device to allocate the I/O context ring for.
721 static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
737 ring[i] = srpt_alloc_ioctx(sdev, ioctx_size, buf_cache, dir);
747 srpt_free_ioctx(sdev, ring[i], buf_cache, dir);
757 * @sdev: SRPT HCA pointer.
763 struct srpt_device *sdev, int ring_size,
773 srpt_free_ioctx(sdev, ioctx_ring[i], buf_cache, dir);
824 * @sdev: SRPT HCA pointer.
828 static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
834 BUG_ON(!sdev);
837 list.lkey = sdev->lkey;
845 if (sdev->use_srq)
846 return ib_post_srq_recv(sdev->srq, &wr, NULL);
1132 ret = ib_find_cached_pkey(ch->sport->sdev->device, ch->sport->port,
1638 ib_dma_sync_single_for_cpu(ch->sport->sdev->device,
1681 srpt_post_recv(ch->sport->sdev, ch, recv_ioctx);
1792 struct srpt_device *sdev = sport->sdev;
1793 const struct ib_device_attr *attrs = &sdev->device->attrs;
1805 ch->cq = ib_cq_pool_get(sdev->device, ch->rq_size + sq_size, -1,
1833 if (sdev->use_srq)
1834 qp_init->srq = sdev->srq;
1839 ret = rdma_create_qp(ch->rdma_cm.cm_id, sdev->pd, qp_init);
1842 ch->qp = ib_create_qp(sdev->pd, qp_init);
1873 if (!sdev->use_srq)
1875 srpt_post_recv(sdev, ch, ch->ioctx_recv_ring[i]);
1997 dev_name(&sport->sdev->device->dev),
2084 struct srpt_device *sdev;
2091 sdev = ch->sport->sdev;
2092 BUG_ON(!sdev);
2119 ch->sport->sdev, ch->rq_size,
2125 sdev, ch->rq_size,
2135 * @sdev: HCA through which the login request was received.
2147 static int srpt_cm_req_recv(struct srpt_device *const sdev,
2154 struct srpt_port *sport = &sdev->port[port_num - 1];
2202 dev_name(&sport->sdev->device->dev), port_num);
2242 ch->rq_size = min(MAX_SRPT_RQ_SIZE, sdev->device->attrs.max_qp_wr);
2254 srpt_alloc_ioctx_ring(ch->sport->sdev, ch->rq_size,
2265 if (!sdev->use_srq) {
2289 srpt_alloc_ioctx_ring(ch->sport->sdev, ch->rq_size,
2392 dev_name(&sdev->device->dev), port_num);
2477 ch->sport->sdev, ch->rq_size,
2485 ch->sport->sdev, ch->rq_size,
2549 struct srpt_device *sdev;
2555 sdev = ib_get_client_data(cm_id->device, &srpt_client);
2556 if (!sdev)
2577 return srpt_cm_req_recv(sdev, NULL, cm_id, cm_id->port_num,
2817 struct srpt_device *sdev = ch->sport->sdev;
2873 ib_dma_sync_single_for_device(sdev->device, ioctx->ioctx.dma, resp_len,
2878 sge.lkey = sdev->lkey;
2972 dev_name(&sport->sdev->device->dev), sport->port,
3003 struct srpt_device *sdev;
3007 list_for_each_entry(sdev, &srpt_dev_list, list) {
3008 dev = sdev->device;
3013 sport = &sdev->port[i];
3016 kref_get(&sdev->refcnt);
3021 kref_get(&sdev->refcnt);
3049 static void srpt_free_srq(struct srpt_device *sdev)
3051 if (!sdev->srq)
3054 ib_destroy_srq(sdev->srq);
3055 srpt_free_ioctx_ring((struct srpt_ioctx **)sdev->ioctx_ring, sdev,
3056 sdev->srq_size, sdev->req_buf_cache,
3058 kmem_cache_destroy(sdev->req_buf_cache);
3059 sdev->srq = NULL;
3062 static int srpt_alloc_srq(struct srpt_device *sdev)
3066 .srq_context = (void *)sdev,
3067 .attr.max_wr = sdev->srq_size,
3071 struct ib_device *device = sdev->device;
3075 WARN_ON_ONCE(sdev->srq);
3076 srq = ib_create_srq(sdev->pd, &srq_attr);
3082 pr_debug("create SRQ #wr= %d max_allow=%d dev= %s\n", sdev->srq_size,
3083 sdev->device->attrs.max_srq_wr, dev_name(&device->dev));
3085 sdev->req_buf_cache = kmem_cache_create("srpt-srq-req-buf",
3087 if (!sdev->req_buf_cache)
3090 sdev->ioctx_ring = (struct srpt_recv_ioctx **)
3091 srpt_alloc_ioctx_ring(sdev, sdev->srq_size,
3092 sizeof(*sdev->ioctx_ring[0]),
3093 sdev->req_buf_cache, 0, DMA_FROM_DEVICE);
3094 if (!sdev->ioctx_ring)
3097 sdev->use_srq = true;
3098 sdev->srq = srq;
3100 for (i = 0; i < sdev->srq_size; ++i) {
3101 INIT_LIST_HEAD(&sdev->ioctx_ring[i]->wait_list);
3102 srpt_post_recv(sdev, NULL, sdev->ioctx_ring[i]);
3108 kmem_cache_destroy(sdev->req_buf_cache);
3115 static int srpt_use_srq(struct srpt_device *sdev, bool use_srq)
3117 struct ib_device *device = sdev->device;
3121 srpt_free_srq(sdev);
3122 sdev->use_srq = false;
3123 } else if (use_srq && !sdev->srq) {
3124 ret = srpt_alloc_srq(sdev);
3127 dev_name(&device->dev), sdev->use_srq, ret);
3133 struct srpt_device *sdev = container_of(refcnt, typeof(*sdev), refcnt);
3135 kfree(sdev);
3138 static void srpt_sdev_put(struct srpt_device *sdev)
3140 kref_put(&sdev->refcnt, srpt_free_sdev);
3149 struct srpt_device *sdev;
3156 sdev = kzalloc(struct_size(sdev, port, device->phys_port_cnt),
3158 if (!sdev)
3161 kref_init(&sdev->refcnt);
3162 sdev->device = device;
3163 mutex_init(&sdev->sdev_mutex);
3165 sdev->pd = ib_alloc_pd(device, 0);
3166 if (IS_ERR(sdev->pd)) {
3167 ret = PTR_ERR(sdev->pd);
3171 sdev->lkey = sdev->pd->local_dma_lkey;
3173 sdev->srq_size = min(srpt_srq_size, sdev->device->attrs.max_srq_wr);
3175 srpt_use_srq(sdev, sdev->port[0].port_attrib.use_srq);
3181 sdev->cm_id = ib_create_cm_id(device, srpt_cm_handler, sdev);
3182 if (IS_ERR(sdev->cm_id)) {
3184 PTR_ERR(sdev->cm_id));
3185 ret = PTR_ERR(sdev->cm_id);
3186 sdev->cm_id = NULL;
3201 ret = sdev->cm_id ?
3202 ib_cm_listen(sdev->cm_id, cpu_to_be64(srpt_service_guid)) :
3206 sdev->cm_id->state);
3210 INIT_IB_EVENT_HANDLER(&sdev->event_handler, sdev->device,
3213 for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
3214 sport = &sdev->port[i - 1];
3217 sport->sdev = sdev;
3228 dev_name(&sdev->device->dev), i);
3234 ib_register_event_handler(&sdev->event_handler);
3236 list_add_tail(&sdev->list, &srpt_dev_list);
3239 ib_set_client_data(device, &srpt_client, sdev);
3244 srpt_unregister_mad_agent(sdev, i);
3246 if (sdev->cm_id)
3247 ib_destroy_cm_id(sdev->cm_id);
3249 srpt_free_srq(sdev);
3250 ib_dealloc_pd(sdev->pd);
3252 srpt_sdev_put(sdev);
3264 struct srpt_device *sdev = client_data;
3267 srpt_unregister_mad_agent(sdev, sdev->device->phys_port_cnt);
3269 ib_unregister_event_handler(&sdev->event_handler);
3272 for (i = 0; i < sdev->device->phys_port_cnt; i++)
3273 cancel_work_sync(&sdev->port[i].work);
3275 if (sdev->cm_id)
3276 ib_destroy_cm_id(sdev->cm_id);
3281 * Unregistering a target must happen after destroying sdev->cm_id
3286 list_del(&sdev->list);
3289 for (i = 0; i < sdev->device->phys_port_cnt; i++)
3290 srpt_release_sport(&sdev->port[i]);
3292 srpt_free_srq(sdev);
3294 ib_dealloc_pd(sdev->pd);
3296 srpt_sdev_put(sdev);
3352 srpt_post_recv(ch->sport->sdev, ch, recv_ioctx);
3582 struct srpt_device *sdev = sport->sdev;
3593 ret = mutex_lock_interruptible(&sdev->sdev_mutex);
3603 srpt_use_srq(sdev, sport->port_attrib.use_srq);
3608 mutex_unlock(&sdev->sdev_mutex);
3797 srpt_sdev_put(sport->sdev);
3827 srpt_sdev_put(sport->sdev);