2 * Copyright (c) 2009-2010 Chelsio, Inc. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 #include <linux/module.h>
33 #include <linux/moduleparam.h>
34 #include <linux/device.h>
35 #include <linux/netdevice.h>
36 #include <linux/etherdevice.h>
37 #include <linux/delay.h>
38 #include <linux/errno.h>
39 #include <linux/list.h>
40 #include <linux/spinlock.h>
41 #include <linux/ethtool.h>
42 #include <linux/rtnetlink.h>
43 #include <linux/inetdevice.h>
47 #include <asm/byteorder.h>
49 #include <rdma/iw_cm.h>
50 #include <rdma/ib_verbs.h>
51 #include <rdma/ib_smi.h>
52 #include <rdma/ib_umem.h>
53 #include <rdma/ib_user_verbs.h>
57 static int fastreg_support
= 1;
58 module_param(fastreg_support
, int, 0644);
59 MODULE_PARM_DESC(fastreg_support
, "Advertise fastreg support (default=1)");
61 static void c4iw_dealloc_ucontext(struct ib_ucontext
*context
)
63 struct c4iw_ucontext
*ucontext
= to_c4iw_ucontext(context
);
65 struct c4iw_mm_entry
*mm
, *tmp
;
67 pr_debug("context %p\n", context
);
68 rhp
= to_c4iw_dev(ucontext
->ibucontext
.device
);
70 list_for_each_entry_safe(mm
, tmp
, &ucontext
->mmaps
, entry
)
72 c4iw_release_dev_ucontext(&rhp
->rdev
, &ucontext
->uctx
);
75 static int c4iw_alloc_ucontext(struct ib_ucontext
*ucontext
,
76 struct ib_udata
*udata
)
78 struct ib_device
*ibdev
= ucontext
->device
;
79 struct c4iw_ucontext
*context
= to_c4iw_ucontext(ucontext
);
80 struct c4iw_dev
*rhp
= to_c4iw_dev(ibdev
);
81 struct c4iw_alloc_ucontext_resp uresp
;
83 struct c4iw_mm_entry
*mm
= NULL
;
85 pr_debug("ibdev %p\n", ibdev
);
86 c4iw_init_dev_ucontext(&rhp
->rdev
, &context
->uctx
);
87 INIT_LIST_HEAD(&context
->mmaps
);
88 spin_lock_init(&context
->mmap_lock
);
90 if (udata
->outlen
< sizeof(uresp
) - sizeof(uresp
.reserved
)) {
91 pr_err_once("Warning - downlevel libcxgb4 (non-fatal), device status page disabled\n");
92 rhp
->rdev
.flags
|= T4_STATUS_PAGE_DISABLED
;
94 mm
= kmalloc(sizeof(*mm
), GFP_KERNEL
);
100 uresp
.status_page_size
= PAGE_SIZE
;
102 spin_lock(&context
->mmap_lock
);
103 uresp
.status_page_key
= context
->key
;
104 context
->key
+= PAGE_SIZE
;
105 spin_unlock(&context
->mmap_lock
);
107 ret
= ib_copy_to_udata(udata
, &uresp
,
108 sizeof(uresp
) - sizeof(uresp
.reserved
));
112 mm
->key
= uresp
.status_page_key
;
113 mm
->addr
= virt_to_phys(rhp
->rdev
.status_page
);
115 insert_mmap(context
, mm
);
124 static int c4iw_mmap(struct ib_ucontext
*context
, struct vm_area_struct
*vma
)
126 int len
= vma
->vm_end
- vma
->vm_start
;
127 u32 key
= vma
->vm_pgoff
<< PAGE_SHIFT
;
128 struct c4iw_rdev
*rdev
;
130 struct c4iw_mm_entry
*mm
;
131 struct c4iw_ucontext
*ucontext
;
134 pr_debug("pgoff 0x%lx key 0x%x len %d\n", vma
->vm_pgoff
,
137 if (vma
->vm_start
& (PAGE_SIZE
-1))
140 rdev
= &(to_c4iw_dev(context
->device
)->rdev
);
141 ucontext
= to_c4iw_ucontext(context
);
143 mm
= remove_mmap(ucontext
, key
, len
);
149 if ((addr
>= pci_resource_start(rdev
->lldi
.pdev
, 0)) &&
150 (addr
< (pci_resource_start(rdev
->lldi
.pdev
, 0) +
151 pci_resource_len(rdev
->lldi
.pdev
, 0)))) {
154 * MA_SYNC register...
156 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
157 ret
= io_remap_pfn_range(vma
, vma
->vm_start
,
159 len
, vma
->vm_page_prot
);
160 } else if ((addr
>= pci_resource_start(rdev
->lldi
.pdev
, 2)) &&
161 (addr
< (pci_resource_start(rdev
->lldi
.pdev
, 2) +
162 pci_resource_len(rdev
->lldi
.pdev
, 2)))) {
165 * Map user DB or OCQP memory...
167 if (addr
>= rdev
->oc_mw_pa
)
168 vma
->vm_page_prot
= t4_pgprot_wc(vma
->vm_page_prot
);
170 if (!is_t4(rdev
->lldi
.adapter_type
))
172 t4_pgprot_wc(vma
->vm_page_prot
);
175 pgprot_noncached(vma
->vm_page_prot
);
177 ret
= io_remap_pfn_range(vma
, vma
->vm_start
,
179 len
, vma
->vm_page_prot
);
183 * Map WQ or CQ contig dma memory...
185 ret
= remap_pfn_range(vma
, vma
->vm_start
,
187 len
, vma
->vm_page_prot
);
193 static void c4iw_deallocate_pd(struct ib_pd
*pd
, struct ib_udata
*udata
)
195 struct c4iw_dev
*rhp
;
198 php
= to_c4iw_pd(pd
);
200 pr_debug("ibpd %p pdid 0x%x\n", pd
, php
->pdid
);
201 c4iw_put_resource(&rhp
->rdev
.resource
.pdid_table
, php
->pdid
);
202 mutex_lock(&rhp
->rdev
.stats
.lock
);
203 rhp
->rdev
.stats
.pd
.cur
--;
204 mutex_unlock(&rhp
->rdev
.stats
.lock
);
207 static int c4iw_allocate_pd(struct ib_pd
*pd
, struct ib_ucontext
*context
,
208 struct ib_udata
*udata
)
210 struct c4iw_pd
*php
= to_c4iw_pd(pd
);
211 struct ib_device
*ibdev
= pd
->device
;
213 struct c4iw_dev
*rhp
;
215 pr_debug("ibdev %p\n", ibdev
);
216 rhp
= (struct c4iw_dev
*) ibdev
;
217 pdid
= c4iw_get_resource(&rhp
->rdev
.resource
.pdid_table
);
224 struct c4iw_alloc_pd_resp uresp
= {.pdid
= php
->pdid
};
226 if (ib_copy_to_udata(udata
, &uresp
, sizeof(uresp
))) {
227 c4iw_deallocate_pd(&php
->ibpd
, udata
);
231 mutex_lock(&rhp
->rdev
.stats
.lock
);
232 rhp
->rdev
.stats
.pd
.cur
++;
233 if (rhp
->rdev
.stats
.pd
.cur
> rhp
->rdev
.stats
.pd
.max
)
234 rhp
->rdev
.stats
.pd
.max
= rhp
->rdev
.stats
.pd
.cur
;
235 mutex_unlock(&rhp
->rdev
.stats
.lock
);
236 pr_debug("pdid 0x%0x ptr 0x%p\n", pdid
, php
);
240 static int c4iw_query_pkey(struct ib_device
*ibdev
, u8 port
, u16 index
,
243 pr_debug("ibdev %p\n", ibdev
);
248 static int c4iw_query_gid(struct ib_device
*ibdev
, u8 port
, int index
,
251 struct c4iw_dev
*dev
;
253 pr_debug("ibdev %p, port %d, index %d, gid %p\n",
254 ibdev
, port
, index
, gid
);
257 dev
= to_c4iw_dev(ibdev
);
258 memset(&(gid
->raw
[0]), 0, sizeof(gid
->raw
));
259 memcpy(&(gid
->raw
[0]), dev
->rdev
.lldi
.ports
[port
-1]->dev_addr
, 6);
263 static int c4iw_query_device(struct ib_device
*ibdev
, struct ib_device_attr
*props
,
264 struct ib_udata
*uhw
)
267 struct c4iw_dev
*dev
;
269 pr_debug("ibdev %p\n", ibdev
);
271 if (uhw
->inlen
|| uhw
->outlen
)
274 dev
= to_c4iw_dev(ibdev
);
275 memset(props
, 0, sizeof *props
);
276 memcpy(&props
->sys_image_guid
, dev
->rdev
.lldi
.ports
[0]->dev_addr
, 6);
277 props
->hw_ver
= CHELSIO_CHIP_RELEASE(dev
->rdev
.lldi
.adapter_type
);
278 props
->fw_ver
= dev
->rdev
.lldi
.fw_vers
;
279 props
->device_cap_flags
= dev
->device_cap_flags
;
280 props
->page_size_cap
= T4_PAGESIZE_MASK
;
281 props
->vendor_id
= (u32
)dev
->rdev
.lldi
.pdev
->vendor
;
282 props
->vendor_part_id
= (u32
)dev
->rdev
.lldi
.pdev
->device
;
283 props
->max_mr_size
= T4_MAX_MR_SIZE
;
284 props
->max_qp
= dev
->rdev
.lldi
.vr
->qp
.size
/ 2;
285 props
->max_srq
= dev
->rdev
.lldi
.vr
->srq
.size
;
286 props
->max_qp_wr
= dev
->rdev
.hw_queue
.t4_max_qp_depth
;
287 props
->max_srq_wr
= dev
->rdev
.hw_queue
.t4_max_qp_depth
;
288 props
->max_send_sge
= min(T4_MAX_SEND_SGE
, T4_MAX_WRITE_SGE
);
289 props
->max_recv_sge
= T4_MAX_RECV_SGE
;
290 props
->max_srq_sge
= T4_MAX_RECV_SGE
;
291 props
->max_sge_rd
= 1;
292 props
->max_res_rd_atom
= dev
->rdev
.lldi
.max_ird_adapter
;
293 props
->max_qp_rd_atom
= min(dev
->rdev
.lldi
.max_ordird_qp
,
294 c4iw_max_read_depth
);
295 props
->max_qp_init_rd_atom
= props
->max_qp_rd_atom
;
296 props
->max_cq
= dev
->rdev
.lldi
.vr
->qp
.size
;
297 props
->max_cqe
= dev
->rdev
.hw_queue
.t4_max_cq_depth
;
298 props
->max_mr
= c4iw_num_stags(&dev
->rdev
);
299 props
->max_pd
= T4_MAX_NUM_PD
;
300 props
->local_ca_ack_delay
= 0;
301 props
->max_fast_reg_page_list_len
=
302 t4_max_fr_depth(dev
->rdev
.lldi
.ulptx_memwrite_dsgl
&& use_dsgl
);
307 static int c4iw_query_port(struct ib_device
*ibdev
, u8 port
,
308 struct ib_port_attr
*props
)
310 struct c4iw_dev
*dev
;
311 struct net_device
*netdev
;
312 struct in_device
*inetdev
;
314 pr_debug("ibdev %p\n", ibdev
);
316 dev
= to_c4iw_dev(ibdev
);
317 netdev
= dev
->rdev
.lldi
.ports
[port
-1];
318 /* props being zeroed by the caller, avoid zeroing it here */
319 props
->max_mtu
= IB_MTU_4096
;
320 props
->active_mtu
= ib_mtu_int_to_enum(netdev
->mtu
);
322 if (!netif_carrier_ok(netdev
))
323 props
->state
= IB_PORT_DOWN
;
325 inetdev
= in_dev_get(netdev
);
327 if (inetdev
->ifa_list
)
328 props
->state
= IB_PORT_ACTIVE
;
330 props
->state
= IB_PORT_INIT
;
333 props
->state
= IB_PORT_INIT
;
336 props
->port_cap_flags
=
338 IB_PORT_SNMP_TUNNEL_SUP
|
340 IB_PORT_DEVICE_MGMT_SUP
|
341 IB_PORT_VENDOR_CLASS_SUP
| IB_PORT_BOOT_MGMT_SUP
;
342 props
->gid_tbl_len
= 1;
343 props
->pkey_tbl_len
= 1;
344 props
->active_width
= 2;
345 props
->active_speed
= IB_SPEED_DDR
;
346 props
->max_msg_sz
= -1;
351 static ssize_t
hw_rev_show(struct device
*dev
,
352 struct device_attribute
*attr
, char *buf
)
354 struct c4iw_dev
*c4iw_dev
=
355 rdma_device_to_drv_device(dev
, struct c4iw_dev
, ibdev
);
357 pr_debug("dev 0x%p\n", dev
);
358 return sprintf(buf
, "%d\n",
359 CHELSIO_CHIP_RELEASE(c4iw_dev
->rdev
.lldi
.adapter_type
));
361 static DEVICE_ATTR_RO(hw_rev
);
363 static ssize_t
hca_type_show(struct device
*dev
,
364 struct device_attribute
*attr
, char *buf
)
366 struct c4iw_dev
*c4iw_dev
=
367 rdma_device_to_drv_device(dev
, struct c4iw_dev
, ibdev
);
368 struct ethtool_drvinfo info
;
369 struct net_device
*lldev
= c4iw_dev
->rdev
.lldi
.ports
[0];
371 pr_debug("dev 0x%p\n", dev
);
372 lldev
->ethtool_ops
->get_drvinfo(lldev
, &info
);
373 return sprintf(buf
, "%s\n", info
.driver
);
375 static DEVICE_ATTR_RO(hca_type
);
377 static ssize_t
board_id_show(struct device
*dev
, struct device_attribute
*attr
,
380 struct c4iw_dev
*c4iw_dev
=
381 rdma_device_to_drv_device(dev
, struct c4iw_dev
, ibdev
);
383 pr_debug("dev 0x%p\n", dev
);
384 return sprintf(buf
, "%x.%x\n", c4iw_dev
->rdev
.lldi
.pdev
->vendor
,
385 c4iw_dev
->rdev
.lldi
.pdev
->device
);
387 static DEVICE_ATTR_RO(board_id
);
401 static const char * const names
[] = {
402 [IP4INSEGS
] = "ip4InSegs",
403 [IP4OUTSEGS
] = "ip4OutSegs",
404 [IP4RETRANSSEGS
] = "ip4RetransSegs",
405 [IP4OUTRSTS
] = "ip4OutRsts",
406 [IP6INSEGS
] = "ip6InSegs",
407 [IP6OUTSEGS
] = "ip6OutSegs",
408 [IP6RETRANSSEGS
] = "ip6RetransSegs",
409 [IP6OUTRSTS
] = "ip6OutRsts"
412 static struct rdma_hw_stats
*c4iw_alloc_stats(struct ib_device
*ibdev
,
415 BUILD_BUG_ON(ARRAY_SIZE(names
) != NR_COUNTERS
);
420 return rdma_alloc_hw_stats_struct(names
, NR_COUNTERS
,
421 RDMA_HW_STATS_DEFAULT_LIFESPAN
);
424 static int c4iw_get_mib(struct ib_device
*ibdev
,
425 struct rdma_hw_stats
*stats
,
428 struct tp_tcp_stats v4
, v6
;
429 struct c4iw_dev
*c4iw_dev
= to_c4iw_dev(ibdev
);
431 cxgb4_get_tcp_stats(c4iw_dev
->rdev
.lldi
.pdev
, &v4
, &v6
);
432 stats
->value
[IP4INSEGS
] = v4
.tcp_in_segs
;
433 stats
->value
[IP4OUTSEGS
] = v4
.tcp_out_segs
;
434 stats
->value
[IP4RETRANSSEGS
] = v4
.tcp_retrans_segs
;
435 stats
->value
[IP4OUTRSTS
] = v4
.tcp_out_rsts
;
436 stats
->value
[IP6INSEGS
] = v6
.tcp_in_segs
;
437 stats
->value
[IP6OUTSEGS
] = v6
.tcp_out_segs
;
438 stats
->value
[IP6RETRANSSEGS
] = v6
.tcp_retrans_segs
;
439 stats
->value
[IP6OUTRSTS
] = v6
.tcp_out_rsts
;
441 return stats
->num_counters
;
444 static struct attribute
*c4iw_class_attributes
[] = {
445 &dev_attr_hw_rev
.attr
,
446 &dev_attr_hca_type
.attr
,
447 &dev_attr_board_id
.attr
,
451 static const struct attribute_group c4iw_attr_group
= {
452 .attrs
= c4iw_class_attributes
,
455 static int c4iw_port_immutable(struct ib_device
*ibdev
, u8 port_num
,
456 struct ib_port_immutable
*immutable
)
458 struct ib_port_attr attr
;
461 immutable
->core_cap_flags
= RDMA_CORE_PORT_IWARP
;
463 err
= ib_query_port(ibdev
, port_num
, &attr
);
467 immutable
->pkey_tbl_len
= attr
.pkey_tbl_len
;
468 immutable
->gid_tbl_len
= attr
.gid_tbl_len
;
473 static void get_dev_fw_str(struct ib_device
*dev
, char *str
)
475 struct c4iw_dev
*c4iw_dev
= container_of(dev
, struct c4iw_dev
,
477 pr_debug("dev 0x%p\n", dev
);
479 snprintf(str
, IB_FW_VERSION_NAME_MAX
, "%u.%u.%u.%u",
480 FW_HDR_FW_VER_MAJOR_G(c4iw_dev
->rdev
.lldi
.fw_vers
),
481 FW_HDR_FW_VER_MINOR_G(c4iw_dev
->rdev
.lldi
.fw_vers
),
482 FW_HDR_FW_VER_MICRO_G(c4iw_dev
->rdev
.lldi
.fw_vers
),
483 FW_HDR_FW_VER_BUILD_G(c4iw_dev
->rdev
.lldi
.fw_vers
));
486 static struct net_device
*get_netdev(struct ib_device
*dev
, u8 port
)
488 struct c4iw_dev
*c4iw_dev
= container_of(dev
, struct c4iw_dev
, ibdev
);
489 struct c4iw_rdev
*rdev
= &c4iw_dev
->rdev
;
490 struct net_device
*ndev
;
492 if (!port
|| port
> rdev
->lldi
.nports
)
496 ndev
= rdev
->lldi
.ports
[port
- 1];
504 static int fill_res_entry(struct sk_buff
*msg
, struct rdma_restrack_entry
*res
)
506 return (res
->type
< ARRAY_SIZE(c4iw_restrack_funcs
) &&
507 c4iw_restrack_funcs
[res
->type
]) ?
508 c4iw_restrack_funcs
[res
->type
](msg
, res
) : 0;
511 static const struct ib_device_ops c4iw_dev_ops
= {
512 .alloc_hw_stats
= c4iw_alloc_stats
,
513 .alloc_mr
= c4iw_alloc_mr
,
514 .alloc_mw
= c4iw_alloc_mw
,
515 .alloc_pd
= c4iw_allocate_pd
,
516 .alloc_ucontext
= c4iw_alloc_ucontext
,
517 .create_cq
= c4iw_create_cq
,
518 .create_qp
= c4iw_create_qp
,
519 .create_srq
= c4iw_create_srq
,
520 .dealloc_mw
= c4iw_dealloc_mw
,
521 .dealloc_pd
= c4iw_deallocate_pd
,
522 .dealloc_ucontext
= c4iw_dealloc_ucontext
,
523 .dereg_mr
= c4iw_dereg_mr
,
524 .destroy_cq
= c4iw_destroy_cq
,
525 .destroy_qp
= c4iw_destroy_qp
,
526 .destroy_srq
= c4iw_destroy_srq
,
527 .fill_res_entry
= fill_res_entry
,
528 .get_dev_fw_str
= get_dev_fw_str
,
529 .get_dma_mr
= c4iw_get_dma_mr
,
530 .get_hw_stats
= c4iw_get_mib
,
531 .get_netdev
= get_netdev
,
532 .get_port_immutable
= c4iw_port_immutable
,
533 .map_mr_sg
= c4iw_map_mr_sg
,
535 .modify_qp
= c4iw_ib_modify_qp
,
536 .modify_srq
= c4iw_modify_srq
,
537 .poll_cq
= c4iw_poll_cq
,
538 .post_recv
= c4iw_post_receive
,
539 .post_send
= c4iw_post_send
,
540 .post_srq_recv
= c4iw_post_srq_recv
,
541 .query_device
= c4iw_query_device
,
542 .query_gid
= c4iw_query_gid
,
543 .query_pkey
= c4iw_query_pkey
,
544 .query_port
= c4iw_query_port
,
545 .query_qp
= c4iw_ib_query_qp
,
546 .reg_user_mr
= c4iw_reg_user_mr
,
547 .req_notify_cq
= c4iw_arm_cq
,
548 INIT_RDMA_OBJ_SIZE(ib_pd
, c4iw_pd
, ibpd
),
549 INIT_RDMA_OBJ_SIZE(ib_ucontext
, c4iw_ucontext
, ibucontext
),
552 void c4iw_register_device(struct work_struct
*work
)
555 struct uld_ctx
*ctx
= container_of(work
, struct uld_ctx
, reg_work
);
556 struct c4iw_dev
*dev
= ctx
->dev
;
558 pr_debug("c4iw_dev %p\n", dev
);
559 memset(&dev
->ibdev
.node_guid
, 0, sizeof(dev
->ibdev
.node_guid
));
560 memcpy(&dev
->ibdev
.node_guid
, dev
->rdev
.lldi
.ports
[0]->dev_addr
, 6);
561 dev
->ibdev
.owner
= THIS_MODULE
;
562 dev
->device_cap_flags
= IB_DEVICE_LOCAL_DMA_LKEY
| IB_DEVICE_MEM_WINDOW
;
564 dev
->device_cap_flags
|= IB_DEVICE_MEM_MGT_EXTENSIONS
;
565 dev
->ibdev
.local_dma_lkey
= 0;
566 dev
->ibdev
.uverbs_cmd_mask
=
567 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT
) |
568 (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE
) |
569 (1ull << IB_USER_VERBS_CMD_QUERY_PORT
) |
570 (1ull << IB_USER_VERBS_CMD_ALLOC_PD
) |
571 (1ull << IB_USER_VERBS_CMD_DEALLOC_PD
) |
572 (1ull << IB_USER_VERBS_CMD_REG_MR
) |
573 (1ull << IB_USER_VERBS_CMD_DEREG_MR
) |
574 (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL
) |
575 (1ull << IB_USER_VERBS_CMD_CREATE_CQ
) |
576 (1ull << IB_USER_VERBS_CMD_DESTROY_CQ
) |
577 (1ull << IB_USER_VERBS_CMD_REQ_NOTIFY_CQ
) |
578 (1ull << IB_USER_VERBS_CMD_CREATE_QP
) |
579 (1ull << IB_USER_VERBS_CMD_MODIFY_QP
) |
580 (1ull << IB_USER_VERBS_CMD_QUERY_QP
) |
581 (1ull << IB_USER_VERBS_CMD_POLL_CQ
) |
582 (1ull << IB_USER_VERBS_CMD_DESTROY_QP
) |
583 (1ull << IB_USER_VERBS_CMD_POST_SEND
) |
584 (1ull << IB_USER_VERBS_CMD_POST_RECV
) |
585 (1ull << IB_USER_VERBS_CMD_CREATE_SRQ
) |
586 (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ
) |
587 (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ
);
588 dev
->ibdev
.node_type
= RDMA_NODE_RNIC
;
589 BUILD_BUG_ON(sizeof(C4IW_NODE_DESC
) > IB_DEVICE_NODE_DESC_MAX
);
590 memcpy(dev
->ibdev
.node_desc
, C4IW_NODE_DESC
, sizeof(C4IW_NODE_DESC
));
591 dev
->ibdev
.phys_port_cnt
= dev
->rdev
.lldi
.nports
;
592 dev
->ibdev
.num_comp_vectors
= dev
->rdev
.lldi
.nciq
;
593 dev
->ibdev
.dev
.parent
= &dev
->rdev
.lldi
.pdev
->dev
;
594 dev
->ibdev
.uverbs_abi_ver
= C4IW_UVERBS_ABI_VERSION
;
596 dev
->ibdev
.iwcm
= kzalloc(sizeof(struct iw_cm_verbs
), GFP_KERNEL
);
597 if (!dev
->ibdev
.iwcm
) {
599 goto err_dealloc_ctx
;
602 dev
->ibdev
.iwcm
->connect
= c4iw_connect
;
603 dev
->ibdev
.iwcm
->accept
= c4iw_accept_cr
;
604 dev
->ibdev
.iwcm
->reject
= c4iw_reject_cr
;
605 dev
->ibdev
.iwcm
->create_listen
= c4iw_create_listen
;
606 dev
->ibdev
.iwcm
->destroy_listen
= c4iw_destroy_listen
;
607 dev
->ibdev
.iwcm
->add_ref
= c4iw_qp_add_ref
;
608 dev
->ibdev
.iwcm
->rem_ref
= c4iw_qp_rem_ref
;
609 dev
->ibdev
.iwcm
->get_qp
= c4iw_get_qp
;
610 memcpy(dev
->ibdev
.iwcm
->ifname
, dev
->rdev
.lldi
.ports
[0]->name
,
611 sizeof(dev
->ibdev
.iwcm
->ifname
));
613 rdma_set_device_sysfs_group(&dev
->ibdev
, &c4iw_attr_group
);
614 dev
->ibdev
.driver_id
= RDMA_DRIVER_CXGB4
;
615 ib_set_device_ops(&dev
->ibdev
, &c4iw_dev_ops
);
616 ret
= ib_register_device(&dev
->ibdev
, "cxgb4_%d");
622 kfree(dev
->ibdev
.iwcm
);
624 pr_err("%s - Failed registering iwarp device: %d\n",
625 pci_name(ctx
->lldi
.pdev
), ret
);
630 void c4iw_unregister_device(struct c4iw_dev
*dev
)
632 pr_debug("c4iw_dev %p\n", dev
);
633 ib_unregister_device(&dev
->ibdev
);
634 kfree(dev
->ibdev
.iwcm
);