2 * Copyright (c) 2013, Cisco Systems, 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
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 * Author: Upinder Malhi <umalhi@cisco.com>
33 * Author: Anant Deepak <anadeepa@cisco.com>
34 * Author: Cesare Cantu' <cantuc@cisco.com>
35 * Author: Jeff Squyres <jsquyres@cisco.com>
36 * Author: Kiran Thirumalai <kithirum@cisco.com>
37 * Author: Xuyang Wang <xuywang@cisco.com>
38 * Author: Reese Faucette <rfaucett@cisco.com>
42 #include <linux/module.h>
43 #include <linux/inetdevice.h>
44 #include <linux/init.h>
45 #include <linux/slab.h>
46 #include <linux/errno.h>
47 #include <linux/pci.h>
48 #include <linux/netdevice.h>
50 #include <rdma/ib_user_verbs.h>
51 #include <rdma/ib_addr.h>
53 #include "usnic_abi.h"
54 #include "usnic_common_util.h"
56 #include "usnic_ib_qp_grp.h"
57 #include "usnic_log.h"
58 #include "usnic_fwd.h"
59 #include "usnic_debugfs.h"
60 #include "usnic_ib_verbs.h"
61 #include "usnic_transport.h"
62 #include "usnic_uiom.h"
63 #include "usnic_ib_sysfs.h"
65 unsigned int usnic_log_lvl
= USNIC_LOG_LVL_ERR
;
66 unsigned int usnic_ib_share_vf
= 1;
68 static const char usnic_version
[] =
69 DRV_NAME
": Cisco VIC (USNIC) Verbs Driver v"
70 DRV_VERSION
" (" DRV_RELDATE
")\n";
72 static DEFINE_MUTEX(usnic_ib_ibdev_list_lock
);
73 static LIST_HEAD(usnic_ib_ibdev_list
);
75 /* Callback dump funcs */
76 static int usnic_ib_dump_vf_hdr(void *obj
, char *buf
, int buf_sz
)
78 struct usnic_ib_vf
*vf
= obj
;
79 return scnprintf(buf
, buf_sz
, "PF: %s ", dev_name(&vf
->pf
->ib_dev
.dev
));
81 /* End callback dump funcs */
83 static void usnic_ib_dump_vf(struct usnic_ib_vf
*vf
, char *buf
, int buf_sz
)
85 usnic_vnic_dump(vf
->vnic
, buf
, buf_sz
, vf
,
87 usnic_ib_qp_grp_dump_hdr
, usnic_ib_qp_grp_dump_rows
);
90 void usnic_ib_log_vf(struct usnic_ib_vf
*vf
)
92 char *buf
= kzalloc(1000, GFP_KERNEL
);
97 usnic_ib_dump_vf(vf
, buf
, 1000);
98 usnic_dbg("%s\n", buf
);
103 /* Start of netdev section */
104 static void usnic_ib_qp_grp_modify_active_to_err(struct usnic_ib_dev
*us_ibdev
)
106 struct usnic_ib_ucontext
*ctx
;
107 struct usnic_ib_qp_grp
*qp_grp
;
108 enum ib_qp_state cur_state
;
111 BUG_ON(!mutex_is_locked(&us_ibdev
->usdev_lock
));
113 list_for_each_entry(ctx
, &us_ibdev
->ctx_list
, link
) {
114 list_for_each_entry(qp_grp
, &ctx
->qp_grp_list
, link
) {
115 cur_state
= qp_grp
->state
;
116 if (cur_state
== IB_QPS_INIT
||
117 cur_state
== IB_QPS_RTR
||
118 cur_state
== IB_QPS_RTS
) {
119 status
= usnic_ib_qp_grp_modify(qp_grp
,
123 usnic_err("Failed to transition qp grp %u from %s to %s\n",
125 usnic_ib_qp_grp_state_to_string
127 usnic_ib_qp_grp_state_to_string
135 static void usnic_ib_handle_usdev_event(struct usnic_ib_dev
*us_ibdev
,
138 struct net_device
*netdev
;
139 struct ib_event ib_event
;
141 memset(&ib_event
, 0, sizeof(ib_event
));
143 mutex_lock(&us_ibdev
->usdev_lock
);
144 netdev
= us_ibdev
->netdev
;
147 usnic_info("PF Reset on %s\n", dev_name(&us_ibdev
->ib_dev
.dev
));
148 usnic_ib_qp_grp_modify_active_to_err(us_ibdev
);
149 ib_event
.event
= IB_EVENT_PORT_ERR
;
150 ib_event
.device
= &us_ibdev
->ib_dev
;
151 ib_event
.element
.port_num
= 1;
152 ib_dispatch_event(&ib_event
);
157 if (!us_ibdev
->ufdev
->link_up
&&
158 netif_carrier_ok(netdev
)) {
159 usnic_fwd_carrier_up(us_ibdev
->ufdev
);
160 usnic_info("Link UP on %s\n",
161 dev_name(&us_ibdev
->ib_dev
.dev
));
162 ib_event
.event
= IB_EVENT_PORT_ACTIVE
;
163 ib_event
.device
= &us_ibdev
->ib_dev
;
164 ib_event
.element
.port_num
= 1;
165 ib_dispatch_event(&ib_event
);
166 } else if (us_ibdev
->ufdev
->link_up
&&
167 !netif_carrier_ok(netdev
)) {
168 usnic_fwd_carrier_down(us_ibdev
->ufdev
);
169 usnic_info("Link DOWN on %s\n",
170 dev_name(&us_ibdev
->ib_dev
.dev
));
171 usnic_ib_qp_grp_modify_active_to_err(us_ibdev
);
172 ib_event
.event
= IB_EVENT_PORT_ERR
;
173 ib_event
.device
= &us_ibdev
->ib_dev
;
174 ib_event
.element
.port_num
= 1;
175 ib_dispatch_event(&ib_event
);
177 usnic_dbg("Ignoring %s on %s\n",
178 netdev_cmd_to_name(event
),
179 dev_name(&us_ibdev
->ib_dev
.dev
));
182 case NETDEV_CHANGEADDR
:
183 if (!memcmp(us_ibdev
->ufdev
->mac
, netdev
->dev_addr
,
184 sizeof(us_ibdev
->ufdev
->mac
))) {
185 usnic_dbg("Ignoring addr change on %s\n",
186 dev_name(&us_ibdev
->ib_dev
.dev
));
188 usnic_info(" %s old mac: %pM new mac: %pM\n",
189 dev_name(&us_ibdev
->ib_dev
.dev
),
190 us_ibdev
->ufdev
->mac
,
192 usnic_fwd_set_mac(us_ibdev
->ufdev
, netdev
->dev_addr
);
193 usnic_ib_qp_grp_modify_active_to_err(us_ibdev
);
194 ib_event
.event
= IB_EVENT_GID_CHANGE
;
195 ib_event
.device
= &us_ibdev
->ib_dev
;
196 ib_event
.element
.port_num
= 1;
197 ib_dispatch_event(&ib_event
);
201 case NETDEV_CHANGEMTU
:
202 if (us_ibdev
->ufdev
->mtu
!= netdev
->mtu
) {
203 usnic_info("MTU Change on %s old: %u new: %u\n",
204 dev_name(&us_ibdev
->ib_dev
.dev
),
205 us_ibdev
->ufdev
->mtu
, netdev
->mtu
);
206 usnic_fwd_set_mtu(us_ibdev
->ufdev
, netdev
->mtu
);
207 usnic_ib_qp_grp_modify_active_to_err(us_ibdev
);
209 usnic_dbg("Ignoring MTU change on %s\n",
210 dev_name(&us_ibdev
->ib_dev
.dev
));
214 usnic_dbg("Ignoring event %s on %s",
215 netdev_cmd_to_name(event
),
216 dev_name(&us_ibdev
->ib_dev
.dev
));
218 mutex_unlock(&us_ibdev
->usdev_lock
);
221 static int usnic_ib_netdevice_event(struct notifier_block
*notifier
,
222 unsigned long event
, void *ptr
)
224 struct usnic_ib_dev
*us_ibdev
;
225 struct ib_device
*ibdev
;
227 struct net_device
*netdev
= netdev_notifier_info_to_dev(ptr
);
229 ibdev
= ib_device_get_by_netdev(netdev
, RDMA_DRIVER_USNIC
);
233 us_ibdev
= container_of(ibdev
, struct usnic_ib_dev
, ib_dev
);
234 usnic_ib_handle_usdev_event(us_ibdev
, event
);
235 ib_device_put(ibdev
);
239 static struct notifier_block usnic_ib_netdevice_notifier
= {
240 .notifier_call
= usnic_ib_netdevice_event
242 /* End of netdev section */
244 /* Start of inet section */
245 static int usnic_ib_handle_inet_event(struct usnic_ib_dev
*us_ibdev
,
246 unsigned long event
, void *ptr
)
248 struct in_ifaddr
*ifa
= ptr
;
249 struct ib_event ib_event
;
251 mutex_lock(&us_ibdev
->usdev_lock
);
255 usnic_info("%s via ip notifiers",
256 netdev_cmd_to_name(event
));
257 usnic_fwd_del_ipaddr(us_ibdev
->ufdev
);
258 usnic_ib_qp_grp_modify_active_to_err(us_ibdev
);
259 ib_event
.event
= IB_EVENT_GID_CHANGE
;
260 ib_event
.device
= &us_ibdev
->ib_dev
;
261 ib_event
.element
.port_num
= 1;
262 ib_dispatch_event(&ib_event
);
265 usnic_fwd_add_ipaddr(us_ibdev
->ufdev
, ifa
->ifa_address
);
266 usnic_info("%s via ip notifiers: ip %pI4",
267 netdev_cmd_to_name(event
),
268 &us_ibdev
->ufdev
->inaddr
);
269 ib_event
.event
= IB_EVENT_GID_CHANGE
;
270 ib_event
.device
= &us_ibdev
->ib_dev
;
271 ib_event
.element
.port_num
= 1;
272 ib_dispatch_event(&ib_event
);
275 usnic_info("Ignoring event %s on %s",
276 netdev_cmd_to_name(event
),
277 dev_name(&us_ibdev
->ib_dev
.dev
));
279 mutex_unlock(&us_ibdev
->usdev_lock
);
284 static int usnic_ib_inetaddr_event(struct notifier_block
*notifier
,
285 unsigned long event
, void *ptr
)
287 struct usnic_ib_dev
*us_ibdev
;
288 struct in_ifaddr
*ifa
= ptr
;
289 struct net_device
*netdev
= ifa
->ifa_dev
->dev
;
290 struct ib_device
*ibdev
;
292 ibdev
= ib_device_get_by_netdev(netdev
, RDMA_DRIVER_USNIC
);
296 us_ibdev
= container_of(ibdev
, struct usnic_ib_dev
, ib_dev
);
297 usnic_ib_handle_inet_event(us_ibdev
, event
, ptr
);
298 ib_device_put(ibdev
);
301 static struct notifier_block usnic_ib_inetaddr_notifier
= {
302 .notifier_call
= usnic_ib_inetaddr_event
304 /* End of inet section*/
306 static int usnic_port_immutable(struct ib_device
*ibdev
, u8 port_num
,
307 struct ib_port_immutable
*immutable
)
309 struct ib_port_attr attr
;
312 immutable
->core_cap_flags
= RDMA_CORE_PORT_USNIC
;
314 err
= ib_query_port(ibdev
, port_num
, &attr
);
318 immutable
->gid_tbl_len
= attr
.gid_tbl_len
;
323 static void usnic_get_dev_fw_str(struct ib_device
*device
, char *str
)
325 struct usnic_ib_dev
*us_ibdev
=
326 container_of(device
, struct usnic_ib_dev
, ib_dev
);
327 struct ethtool_drvinfo info
;
329 mutex_lock(&us_ibdev
->usdev_lock
);
330 us_ibdev
->netdev
->ethtool_ops
->get_drvinfo(us_ibdev
->netdev
, &info
);
331 mutex_unlock(&us_ibdev
->usdev_lock
);
333 snprintf(str
, IB_FW_VERSION_NAME_MAX
, "%s", info
.fw_version
);
336 static const struct ib_device_ops usnic_dev_ops
= {
337 .owner
= THIS_MODULE
,
338 .driver_id
= RDMA_DRIVER_USNIC
,
339 .uverbs_abi_ver
= USNIC_UVERBS_ABI_VERSION
,
341 .alloc_pd
= usnic_ib_alloc_pd
,
342 .alloc_ucontext
= usnic_ib_alloc_ucontext
,
343 .create_cq
= usnic_ib_create_cq
,
344 .create_qp
= usnic_ib_create_qp
,
345 .dealloc_pd
= usnic_ib_dealloc_pd
,
346 .dealloc_ucontext
= usnic_ib_dealloc_ucontext
,
347 .dereg_mr
= usnic_ib_dereg_mr
,
348 .destroy_cq
= usnic_ib_destroy_cq
,
349 .destroy_qp
= usnic_ib_destroy_qp
,
350 .get_dev_fw_str
= usnic_get_dev_fw_str
,
351 .get_link_layer
= usnic_ib_port_link_layer
,
352 .get_port_immutable
= usnic_port_immutable
,
353 .mmap
= usnic_ib_mmap
,
354 .modify_qp
= usnic_ib_modify_qp
,
355 .query_device
= usnic_ib_query_device
,
356 .query_gid
= usnic_ib_query_gid
,
357 .query_port
= usnic_ib_query_port
,
358 .query_qp
= usnic_ib_query_qp
,
359 .reg_user_mr
= usnic_ib_reg_mr
,
360 INIT_RDMA_OBJ_SIZE(ib_pd
, usnic_ib_pd
, ibpd
),
361 INIT_RDMA_OBJ_SIZE(ib_cq
, usnic_ib_cq
, ibcq
),
362 INIT_RDMA_OBJ_SIZE(ib_ucontext
, usnic_ib_ucontext
, ibucontext
),
365 /* Start of PF discovery section */
366 static void *usnic_ib_device_add(struct pci_dev
*dev
)
368 struct usnic_ib_dev
*us_ibdev
;
370 struct in_device
*ind
;
371 struct net_device
*netdev
;
375 netdev
= pci_get_drvdata(dev
);
377 us_ibdev
= ib_alloc_device(usnic_ib_dev
, ib_dev
);
379 usnic_err("Device %s context alloc failed\n",
380 netdev_name(pci_get_drvdata(dev
)));
381 return ERR_PTR(-EFAULT
);
384 us_ibdev
->ufdev
= usnic_fwd_dev_alloc(dev
);
385 if (!us_ibdev
->ufdev
) {
386 usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev
));
390 mutex_init(&us_ibdev
->usdev_lock
);
391 INIT_LIST_HEAD(&us_ibdev
->vf_dev_list
);
392 INIT_LIST_HEAD(&us_ibdev
->ctx_list
);
394 us_ibdev
->pdev
= dev
;
395 us_ibdev
->netdev
= pci_get_drvdata(dev
);
396 us_ibdev
->ib_dev
.node_type
= RDMA_NODE_USNIC_UDP
;
397 us_ibdev
->ib_dev
.phys_port_cnt
= USNIC_IB_PORT_CNT
;
398 us_ibdev
->ib_dev
.num_comp_vectors
= USNIC_IB_NUM_COMP_VECTORS
;
399 us_ibdev
->ib_dev
.dev
.parent
= &dev
->dev
;
401 ib_set_device_ops(&us_ibdev
->ib_dev
, &usnic_dev_ops
);
403 rdma_set_device_sysfs_group(&us_ibdev
->ib_dev
, &usnic_attr_group
);
405 ret
= ib_device_set_netdev(&us_ibdev
->ib_dev
, us_ibdev
->netdev
, 1);
407 goto err_fwd_dealloc
;
409 dma_set_max_seg_size(&dev
->dev
, SZ_2G
);
410 if (ib_register_device(&us_ibdev
->ib_dev
, "usnic_%d", &dev
->dev
))
411 goto err_fwd_dealloc
;
413 usnic_fwd_set_mtu(us_ibdev
->ufdev
, us_ibdev
->netdev
->mtu
);
414 usnic_fwd_set_mac(us_ibdev
->ufdev
, us_ibdev
->netdev
->dev_addr
);
415 if (netif_carrier_ok(us_ibdev
->netdev
))
416 usnic_fwd_carrier_up(us_ibdev
->ufdev
);
419 ind
= __in_dev_get_rcu(netdev
);
421 const struct in_ifaddr
*ifa
;
423 ifa
= rcu_dereference(ind
->ifa_list
);
425 usnic_fwd_add_ipaddr(us_ibdev
->ufdev
, ifa
->ifa_address
);
429 usnic_mac_ip_to_gid(us_ibdev
->netdev
->perm_addr
,
430 us_ibdev
->ufdev
->inaddr
, &gid
.raw
[0]);
431 memcpy(&us_ibdev
->ib_dev
.node_guid
, &gid
.global
.interface_id
,
432 sizeof(gid
.global
.interface_id
));
433 kref_init(&us_ibdev
->vf_cnt
);
435 usnic_info("Added ibdev: %s netdev: %s with mac %pM Link: %u MTU: %u\n",
436 dev_name(&us_ibdev
->ib_dev
.dev
),
437 netdev_name(us_ibdev
->netdev
), us_ibdev
->ufdev
->mac
,
438 us_ibdev
->ufdev
->link_up
, us_ibdev
->ufdev
->mtu
);
442 usnic_fwd_dev_free(us_ibdev
->ufdev
);
444 usnic_err("failed -- deallocing device\n");
445 ib_dealloc_device(&us_ibdev
->ib_dev
);
449 static void usnic_ib_device_remove(struct usnic_ib_dev
*us_ibdev
)
451 usnic_info("Unregistering %s\n", dev_name(&us_ibdev
->ib_dev
.dev
));
452 usnic_ib_sysfs_unregister_usdev(us_ibdev
);
453 usnic_fwd_dev_free(us_ibdev
->ufdev
);
454 ib_unregister_device(&us_ibdev
->ib_dev
);
455 ib_dealloc_device(&us_ibdev
->ib_dev
);
458 static void usnic_ib_undiscover_pf(struct kref
*kref
)
460 struct usnic_ib_dev
*us_ibdev
, *tmp
;
464 dev
= container_of(kref
, struct usnic_ib_dev
, vf_cnt
)->pdev
;
465 mutex_lock(&usnic_ib_ibdev_list_lock
);
466 list_for_each_entry_safe(us_ibdev
, tmp
,
467 &usnic_ib_ibdev_list
, ib_dev_link
) {
468 if (us_ibdev
->pdev
== dev
) {
469 list_del(&us_ibdev
->ib_dev_link
);
476 mutex_unlock(&usnic_ib_ibdev_list_lock
);
478 usnic_ib_device_remove(us_ibdev
);
480 WARN(1, "Failed to remove PF %s\n", pci_name(dev
));
483 static struct usnic_ib_dev
*usnic_ib_discover_pf(struct usnic_vnic
*vnic
)
485 struct usnic_ib_dev
*us_ibdev
;
486 struct pci_dev
*parent_pci
, *vf_pci
;
489 vf_pci
= usnic_vnic_get_pdev(vnic
);
490 parent_pci
= pci_physfn(vf_pci
);
494 mutex_lock(&usnic_ib_ibdev_list_lock
);
495 list_for_each_entry(us_ibdev
, &usnic_ib_ibdev_list
, ib_dev_link
) {
496 if (us_ibdev
->pdev
== parent_pci
) {
497 kref_get(&us_ibdev
->vf_cnt
);
502 us_ibdev
= usnic_ib_device_add(parent_pci
);
503 if (IS_ERR_OR_NULL(us_ibdev
)) {
504 us_ibdev
= us_ibdev
? us_ibdev
: ERR_PTR(-EFAULT
);
508 err
= usnic_ib_sysfs_register_usdev(us_ibdev
);
510 usnic_ib_device_remove(us_ibdev
);
511 us_ibdev
= ERR_PTR(err
);
515 list_add(&us_ibdev
->ib_dev_link
, &usnic_ib_ibdev_list
);
517 mutex_unlock(&usnic_ib_ibdev_list_lock
);
520 /* End of PF discovery section */
522 /* Start of PCI section */
524 static const struct pci_device_id usnic_ib_pci_ids
[] = {
525 {PCI_DEVICE(PCI_VENDOR_ID_CISCO
, PCI_DEVICE_ID_CISCO_VIC_USPACE_NIC
)},
529 static int usnic_ib_pci_probe(struct pci_dev
*pdev
,
530 const struct pci_device_id
*id
)
533 struct usnic_ib_dev
*pf
;
534 struct usnic_ib_vf
*vf
;
535 enum usnic_vnic_res_type res_type
;
537 vf
= kzalloc(sizeof(*vf
), GFP_KERNEL
);
541 err
= pci_enable_device(pdev
);
543 usnic_err("Failed to enable %s with err %d\n",
544 pci_name(pdev
), err
);
548 err
= pci_request_regions(pdev
, DRV_NAME
);
550 usnic_err("Failed to request region for %s with err %d\n",
551 pci_name(pdev
), err
);
552 goto out_disable_device
;
555 pci_set_master(pdev
);
556 pci_set_drvdata(pdev
, vf
);
558 vf
->vnic
= usnic_vnic_alloc(pdev
);
559 if (IS_ERR_OR_NULL(vf
->vnic
)) {
560 err
= vf
->vnic
? PTR_ERR(vf
->vnic
) : -ENOMEM
;
561 usnic_err("Failed to alloc vnic for %s with err %d\n",
562 pci_name(pdev
), err
);
563 goto out_release_regions
;
566 pf
= usnic_ib_discover_pf(vf
->vnic
);
567 if (IS_ERR_OR_NULL(pf
)) {
568 usnic_err("Failed to discover pf of vnic %s with err%ld\n",
569 pci_name(pdev
), PTR_ERR(pf
));
570 err
= pf
? PTR_ERR(pf
) : -EFAULT
;
575 spin_lock_init(&vf
->lock
);
576 mutex_lock(&pf
->usdev_lock
);
577 list_add_tail(&vf
->link
, &pf
->vf_dev_list
);
579 * Save max settings (will be same for each VF, easier to re-write than
580 * to say "if (!set) { set_values(); set=1; }
582 for (res_type
= USNIC_VNIC_RES_TYPE_EOL
+1;
583 res_type
< USNIC_VNIC_RES_TYPE_MAX
;
585 pf
->vf_res_cnt
[res_type
] = usnic_vnic_res_cnt(vf
->vnic
,
589 mutex_unlock(&pf
->usdev_lock
);
591 usnic_info("Registering usnic VF %s into PF %s\n", pci_name(pdev
),
592 dev_name(&pf
->ib_dev
.dev
));
597 usnic_vnic_free(vf
->vnic
);
599 pci_set_drvdata(pdev
, NULL
);
600 pci_clear_master(pdev
);
601 pci_release_regions(pdev
);
603 pci_disable_device(pdev
);
609 static void usnic_ib_pci_remove(struct pci_dev
*pdev
)
611 struct usnic_ib_vf
*vf
= pci_get_drvdata(pdev
);
612 struct usnic_ib_dev
*pf
= vf
->pf
;
614 mutex_lock(&pf
->usdev_lock
);
616 mutex_unlock(&pf
->usdev_lock
);
618 kref_put(&pf
->vf_cnt
, usnic_ib_undiscover_pf
);
619 usnic_vnic_free(vf
->vnic
);
620 pci_set_drvdata(pdev
, NULL
);
621 pci_clear_master(pdev
);
622 pci_release_regions(pdev
);
623 pci_disable_device(pdev
);
626 usnic_info("Removed VF %s\n", pci_name(pdev
));
629 /* PCI driver entry points */
630 static struct pci_driver usnic_ib_pci_driver
= {
632 .id_table
= usnic_ib_pci_ids
,
633 .probe
= usnic_ib_pci_probe
,
634 .remove
= usnic_ib_pci_remove
,
636 /* End of PCI section */
638 /* Start of module section */
639 static int __init
usnic_ib_init(void)
643 printk_once(KERN_INFO
"%s", usnic_version
);
645 err
= usnic_uiom_init(DRV_NAME
);
647 usnic_err("Unable to initialize umem with err %d\n", err
);
651 err
= pci_register_driver(&usnic_ib_pci_driver
);
653 usnic_err("Unable to register with PCI\n");
657 err
= register_netdevice_notifier(&usnic_ib_netdevice_notifier
);
659 usnic_err("Failed to register netdev notifier\n");
663 err
= register_inetaddr_notifier(&usnic_ib_inetaddr_notifier
);
665 usnic_err("Failed to register inet addr notifier\n");
666 goto out_unreg_netdev_notifier
;
669 err
= usnic_transport_init();
671 usnic_err("Failed to initialize transport\n");
672 goto out_unreg_inetaddr_notifier
;
675 usnic_debugfs_init();
679 out_unreg_inetaddr_notifier
:
680 unregister_inetaddr_notifier(&usnic_ib_inetaddr_notifier
);
681 out_unreg_netdev_notifier
:
682 unregister_netdevice_notifier(&usnic_ib_netdevice_notifier
);
684 pci_unregister_driver(&usnic_ib_pci_driver
);
690 static void __exit
usnic_ib_destroy(void)
693 usnic_debugfs_exit();
694 usnic_transport_fini();
695 unregister_inetaddr_notifier(&usnic_ib_inetaddr_notifier
);
696 unregister_netdevice_notifier(&usnic_ib_netdevice_notifier
);
697 pci_unregister_driver(&usnic_ib_pci_driver
);
700 MODULE_DESCRIPTION("Cisco VIC (usNIC) Verbs Driver");
701 MODULE_AUTHOR("Upinder Malhi <umalhi@cisco.com>");
702 MODULE_LICENSE("Dual BSD/GPL");
703 module_param(usnic_log_lvl
, uint
, S_IRUGO
| S_IWUSR
);
704 module_param(usnic_ib_share_vf
, uint
, S_IRUGO
| S_IWUSR
);
705 MODULE_PARM_DESC(usnic_log_lvl
, " Off=0, Err=1, Info=2, Debug=3");
706 MODULE_PARM_DESC(usnic_ib_share_vf
, "Off=0, On=1 VF sharing amongst QPs");
707 MODULE_DEVICE_TABLE(pci
, usnic_ib_pci_ids
);
709 module_init(usnic_ib_init
);
710 module_exit(usnic_ib_destroy
);
711 /* End of module section */