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)
93 usnic_ib_dump_vf(vf, buf, sizeof(buf));
94 usnic_dbg("%s\n", buf);
97 /* Start of netdev section */
98 static void usnic_ib_qp_grp_modify_active_to_err(struct usnic_ib_dev *us_ibdev)
100 struct usnic_ib_ucontext *ctx;
101 struct usnic_ib_qp_grp *qp_grp;
102 enum ib_qp_state cur_state;
105 BUG_ON(!mutex_is_locked(&us_ibdev->usdev_lock));
107 list_for_each_entry(ctx, &us_ibdev->ctx_list, link) {
108 list_for_each_entry(qp_grp, &ctx->qp_grp_list, link) {
109 cur_state = qp_grp->state;
110 if (cur_state == IB_QPS_INIT ||
111 cur_state == IB_QPS_RTR ||
112 cur_state == IB_QPS_RTS) {
113 status = usnic_ib_qp_grp_modify(qp_grp,
117 usnic_err("Failed to transistion qp grp %u from %s to %s\n",
119 usnic_ib_qp_grp_state_to_string
121 usnic_ib_qp_grp_state_to_string
129 static void usnic_ib_handle_usdev_event(struct usnic_ib_dev *us_ibdev,
132 struct net_device *netdev;
133 struct ib_event ib_event;
135 memset(&ib_event, 0, sizeof(ib_event));
137 mutex_lock(&us_ibdev->usdev_lock);
138 netdev = us_ibdev->netdev;
141 usnic_info("PF Reset on %s\n", dev_name(&us_ibdev->ib_dev.dev));
142 usnic_ib_qp_grp_modify_active_to_err(us_ibdev);
143 ib_event.event = IB_EVENT_PORT_ERR;
144 ib_event.device = &us_ibdev->ib_dev;
145 ib_event.element.port_num = 1;
146 ib_dispatch_event(&ib_event);
151 if (!us_ibdev->ufdev->link_up &&
152 netif_carrier_ok(netdev)) {
153 usnic_fwd_carrier_up(us_ibdev->ufdev);
154 usnic_info("Link UP on %s\n",
155 dev_name(&us_ibdev->ib_dev.dev));
156 ib_event.event = IB_EVENT_PORT_ACTIVE;
157 ib_event.device = &us_ibdev->ib_dev;
158 ib_event.element.port_num = 1;
159 ib_dispatch_event(&ib_event);
160 } else if (us_ibdev->ufdev->link_up &&
161 !netif_carrier_ok(netdev)) {
162 usnic_fwd_carrier_down(us_ibdev->ufdev);
163 usnic_info("Link DOWN on %s\n",
164 dev_name(&us_ibdev->ib_dev.dev));
165 usnic_ib_qp_grp_modify_active_to_err(us_ibdev);
166 ib_event.event = IB_EVENT_PORT_ERR;
167 ib_event.device = &us_ibdev->ib_dev;
168 ib_event.element.port_num = 1;
169 ib_dispatch_event(&ib_event);
171 usnic_dbg("Ignoring %s on %s\n",
172 netdev_cmd_to_name(event),
173 dev_name(&us_ibdev->ib_dev.dev));
176 case NETDEV_CHANGEADDR:
177 if (!memcmp(us_ibdev->ufdev->mac, netdev->dev_addr,
178 sizeof(us_ibdev->ufdev->mac))) {
179 usnic_dbg("Ignoring addr change on %s\n",
180 dev_name(&us_ibdev->ib_dev.dev));
182 usnic_info(" %s old mac: %pM new mac: %pM\n",
183 dev_name(&us_ibdev->ib_dev.dev),
184 us_ibdev->ufdev->mac,
186 usnic_fwd_set_mac(us_ibdev->ufdev, netdev->dev_addr);
187 usnic_ib_qp_grp_modify_active_to_err(us_ibdev);
188 ib_event.event = IB_EVENT_GID_CHANGE;
189 ib_event.device = &us_ibdev->ib_dev;
190 ib_event.element.port_num = 1;
191 ib_dispatch_event(&ib_event);
195 case NETDEV_CHANGEMTU:
196 if (us_ibdev->ufdev->mtu != netdev->mtu) {
197 usnic_info("MTU Change on %s old: %u new: %u\n",
198 dev_name(&us_ibdev->ib_dev.dev),
199 us_ibdev->ufdev->mtu, netdev->mtu);
200 usnic_fwd_set_mtu(us_ibdev->ufdev, netdev->mtu);
201 usnic_ib_qp_grp_modify_active_to_err(us_ibdev);
203 usnic_dbg("Ignoring MTU change on %s\n",
204 dev_name(&us_ibdev->ib_dev.dev));
208 usnic_dbg("Ignoring event %s on %s",
209 netdev_cmd_to_name(event),
210 dev_name(&us_ibdev->ib_dev.dev));
212 mutex_unlock(&us_ibdev->usdev_lock);
215 static int usnic_ib_netdevice_event(struct notifier_block *notifier,
216 unsigned long event, void *ptr)
218 struct usnic_ib_dev *us_ibdev;
219 struct ib_device *ibdev;
221 struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
223 ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_USNIC);
227 us_ibdev = container_of(ibdev, struct usnic_ib_dev, ib_dev);
228 usnic_ib_handle_usdev_event(us_ibdev, event);
229 ib_device_put(ibdev);
233 static struct notifier_block usnic_ib_netdevice_notifier = {
234 .notifier_call = usnic_ib_netdevice_event
236 /* End of netdev section */
238 /* Start of inet section */
239 static int usnic_ib_handle_inet_event(struct usnic_ib_dev *us_ibdev,
240 unsigned long event, void *ptr)
242 struct in_ifaddr *ifa = ptr;
243 struct ib_event ib_event;
245 mutex_lock(&us_ibdev->usdev_lock);
249 usnic_info("%s via ip notifiers",
250 netdev_cmd_to_name(event));
251 usnic_fwd_del_ipaddr(us_ibdev->ufdev);
252 usnic_ib_qp_grp_modify_active_to_err(us_ibdev);
253 ib_event.event = IB_EVENT_GID_CHANGE;
254 ib_event.device = &us_ibdev->ib_dev;
255 ib_event.element.port_num = 1;
256 ib_dispatch_event(&ib_event);
259 usnic_fwd_add_ipaddr(us_ibdev->ufdev, ifa->ifa_address);
260 usnic_info("%s via ip notifiers: ip %pI4",
261 netdev_cmd_to_name(event),
262 &us_ibdev->ufdev->inaddr);
263 ib_event.event = IB_EVENT_GID_CHANGE;
264 ib_event.device = &us_ibdev->ib_dev;
265 ib_event.element.port_num = 1;
266 ib_dispatch_event(&ib_event);
269 usnic_info("Ignoring event %s on %s",
270 netdev_cmd_to_name(event),
271 dev_name(&us_ibdev->ib_dev.dev));
273 mutex_unlock(&us_ibdev->usdev_lock);
278 static int usnic_ib_inetaddr_event(struct notifier_block *notifier,
279 unsigned long event, void *ptr)
281 struct usnic_ib_dev *us_ibdev;
282 struct in_ifaddr *ifa = ptr;
283 struct net_device *netdev = ifa->ifa_dev->dev;
284 struct ib_device *ibdev;
286 ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_USNIC);
290 us_ibdev = container_of(ibdev, struct usnic_ib_dev, ib_dev);
291 usnic_ib_handle_inet_event(us_ibdev, event, ptr);
292 ib_device_put(ibdev);
295 static struct notifier_block usnic_ib_inetaddr_notifier = {
296 .notifier_call = usnic_ib_inetaddr_event
298 /* End of inet section*/
300 static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num,
301 struct ib_port_immutable *immutable)
303 struct ib_port_attr attr;
306 immutable->core_cap_flags = RDMA_CORE_PORT_USNIC;
308 err = ib_query_port(ibdev, port_num, &attr);
312 immutable->pkey_tbl_len = attr.pkey_tbl_len;
313 immutable->gid_tbl_len = attr.gid_tbl_len;
318 static void usnic_get_dev_fw_str(struct ib_device *device, char *str)
320 struct usnic_ib_dev *us_ibdev =
321 container_of(device, struct usnic_ib_dev, ib_dev);
322 struct ethtool_drvinfo info;
324 mutex_lock(&us_ibdev->usdev_lock);
325 us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
326 mutex_unlock(&us_ibdev->usdev_lock);
328 snprintf(str, IB_FW_VERSION_NAME_MAX, "%s", info.fw_version);
331 static const struct ib_device_ops usnic_dev_ops = {
332 .alloc_pd = usnic_ib_alloc_pd,
333 .alloc_ucontext = usnic_ib_alloc_ucontext,
334 .create_cq = usnic_ib_create_cq,
335 .create_qp = usnic_ib_create_qp,
336 .dealloc_pd = usnic_ib_dealloc_pd,
337 .dealloc_ucontext = usnic_ib_dealloc_ucontext,
338 .dereg_mr = usnic_ib_dereg_mr,
339 .destroy_cq = usnic_ib_destroy_cq,
340 .destroy_qp = usnic_ib_destroy_qp,
341 .get_dev_fw_str = usnic_get_dev_fw_str,
342 .get_link_layer = usnic_ib_port_link_layer,
343 .get_port_immutable = usnic_port_immutable,
344 .mmap = usnic_ib_mmap,
345 .modify_qp = usnic_ib_modify_qp,
346 .query_device = usnic_ib_query_device,
347 .query_gid = usnic_ib_query_gid,
348 .query_pkey = usnic_ib_query_pkey,
349 .query_port = usnic_ib_query_port,
350 .query_qp = usnic_ib_query_qp,
351 .reg_user_mr = usnic_ib_reg_mr,
352 INIT_RDMA_OBJ_SIZE(ib_pd, usnic_ib_pd, ibpd),
353 INIT_RDMA_OBJ_SIZE(ib_ucontext, usnic_ib_ucontext, ibucontext),
356 /* Start of PF discovery section */
357 static void *usnic_ib_device_add(struct pci_dev *dev)
359 struct usnic_ib_dev *us_ibdev;
361 struct in_device *ind;
362 struct net_device *netdev;
366 netdev = pci_get_drvdata(dev);
368 us_ibdev = ib_alloc_device(usnic_ib_dev, ib_dev);
370 usnic_err("Device %s context alloc failed\n",
371 netdev_name(pci_get_drvdata(dev)));
372 return ERR_PTR(-EFAULT);
375 us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
376 if (!us_ibdev->ufdev) {
377 usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev));
381 mutex_init(&us_ibdev->usdev_lock);
382 INIT_LIST_HEAD(&us_ibdev->vf_dev_list);
383 INIT_LIST_HEAD(&us_ibdev->ctx_list);
385 us_ibdev->pdev = dev;
386 us_ibdev->netdev = pci_get_drvdata(dev);
387 us_ibdev->ib_dev.owner = THIS_MODULE;
388 us_ibdev->ib_dev.node_type = RDMA_NODE_USNIC_UDP;
389 us_ibdev->ib_dev.phys_port_cnt = USNIC_IB_PORT_CNT;
390 us_ibdev->ib_dev.num_comp_vectors = USNIC_IB_NUM_COMP_VECTORS;
391 us_ibdev->ib_dev.dev.parent = &dev->dev;
392 us_ibdev->ib_dev.uverbs_abi_ver = USNIC_UVERBS_ABI_VERSION;
394 us_ibdev->ib_dev.uverbs_cmd_mask =
395 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
396 (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
397 (1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
398 (1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
399 (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
400 (1ull << IB_USER_VERBS_CMD_REG_MR) |
401 (1ull << IB_USER_VERBS_CMD_DEREG_MR) |
402 (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
403 (1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
404 (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
405 (1ull << IB_USER_VERBS_CMD_CREATE_QP) |
406 (1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
407 (1ull << IB_USER_VERBS_CMD_QUERY_QP) |
408 (1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
409 (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
410 (1ull << IB_USER_VERBS_CMD_DETACH_MCAST) |
411 (1ull << IB_USER_VERBS_CMD_OPEN_QP);
413 ib_set_device_ops(&us_ibdev->ib_dev, &usnic_dev_ops);
415 us_ibdev->ib_dev.driver_id = RDMA_DRIVER_USNIC;
416 rdma_set_device_sysfs_group(&us_ibdev->ib_dev, &usnic_attr_group);
418 ret = ib_device_set_netdev(&us_ibdev->ib_dev, us_ibdev->netdev, 1);
420 goto err_fwd_dealloc;
422 if (ib_register_device(&us_ibdev->ib_dev, "usnic_%d"))
423 goto err_fwd_dealloc;
425 usnic_fwd_set_mtu(us_ibdev->ufdev, us_ibdev->netdev->mtu);
426 usnic_fwd_set_mac(us_ibdev->ufdev, us_ibdev->netdev->dev_addr);
427 if (netif_carrier_ok(us_ibdev->netdev))
428 usnic_fwd_carrier_up(us_ibdev->ufdev);
431 ind = __in_dev_get_rcu(netdev);
433 const struct in_ifaddr *ifa;
435 ifa = rcu_dereference(ind->ifa_list);
437 usnic_fwd_add_ipaddr(us_ibdev->ufdev, ifa->ifa_address);
441 usnic_mac_ip_to_gid(us_ibdev->netdev->perm_addr,
442 us_ibdev->ufdev->inaddr, &gid.raw[0]);
443 memcpy(&us_ibdev->ib_dev.node_guid, &gid.global.interface_id,
444 sizeof(gid.global.interface_id));
445 kref_init(&us_ibdev->vf_cnt);
447 usnic_info("Added ibdev: %s netdev: %s with mac %pM Link: %u MTU: %u\n",
448 dev_name(&us_ibdev->ib_dev.dev),
449 netdev_name(us_ibdev->netdev), us_ibdev->ufdev->mac,
450 us_ibdev->ufdev->link_up, us_ibdev->ufdev->mtu);
454 usnic_fwd_dev_free(us_ibdev->ufdev);
456 usnic_err("failed -- deallocing device\n");
457 ib_dealloc_device(&us_ibdev->ib_dev);
461 static void usnic_ib_device_remove(struct usnic_ib_dev *us_ibdev)
463 usnic_info("Unregistering %s\n", dev_name(&us_ibdev->ib_dev.dev));
464 usnic_ib_sysfs_unregister_usdev(us_ibdev);
465 usnic_fwd_dev_free(us_ibdev->ufdev);
466 ib_unregister_device(&us_ibdev->ib_dev);
467 ib_dealloc_device(&us_ibdev->ib_dev);
470 static void usnic_ib_undiscover_pf(struct kref *kref)
472 struct usnic_ib_dev *us_ibdev, *tmp;
476 dev = container_of(kref, struct usnic_ib_dev, vf_cnt)->pdev;
477 mutex_lock(&usnic_ib_ibdev_list_lock);
478 list_for_each_entry_safe(us_ibdev, tmp,
479 &usnic_ib_ibdev_list, ib_dev_link) {
480 if (us_ibdev->pdev == dev) {
481 list_del(&us_ibdev->ib_dev_link);
488 mutex_unlock(&usnic_ib_ibdev_list_lock);
490 usnic_ib_device_remove(us_ibdev);
492 WARN(1, "Failed to remove PF %s\n", pci_name(dev));
495 static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic)
497 struct usnic_ib_dev *us_ibdev;
498 struct pci_dev *parent_pci, *vf_pci;
501 vf_pci = usnic_vnic_get_pdev(vnic);
502 parent_pci = pci_physfn(vf_pci);
506 mutex_lock(&usnic_ib_ibdev_list_lock);
507 list_for_each_entry(us_ibdev, &usnic_ib_ibdev_list, ib_dev_link) {
508 if (us_ibdev->pdev == parent_pci) {
509 kref_get(&us_ibdev->vf_cnt);
514 us_ibdev = usnic_ib_device_add(parent_pci);
515 if (IS_ERR_OR_NULL(us_ibdev)) {
516 us_ibdev = us_ibdev ? us_ibdev : ERR_PTR(-EFAULT);
520 err = usnic_ib_sysfs_register_usdev(us_ibdev);
522 usnic_ib_device_remove(us_ibdev);
523 us_ibdev = ERR_PTR(err);
527 list_add(&us_ibdev->ib_dev_link, &usnic_ib_ibdev_list);
529 mutex_unlock(&usnic_ib_ibdev_list_lock);
532 /* End of PF discovery section */
534 /* Start of PCI section */
536 static const struct pci_device_id usnic_ib_pci_ids[] = {
537 {PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_VIC_USPACE_NIC)},
541 static int usnic_ib_pci_probe(struct pci_dev *pdev,
542 const struct pci_device_id *id)
545 struct usnic_ib_dev *pf;
546 struct usnic_ib_vf *vf;
547 enum usnic_vnic_res_type res_type;
549 vf = kzalloc(sizeof(*vf), GFP_KERNEL);
553 err = pci_enable_device(pdev);
555 usnic_err("Failed to enable %s with err %d\n",
556 pci_name(pdev), err);
560 err = pci_request_regions(pdev, DRV_NAME);
562 usnic_err("Failed to request region for %s with err %d\n",
563 pci_name(pdev), err);
564 goto out_disable_device;
567 pci_set_master(pdev);
568 pci_set_drvdata(pdev, vf);
570 vf->vnic = usnic_vnic_alloc(pdev);
571 if (IS_ERR_OR_NULL(vf->vnic)) {
572 err = vf->vnic ? PTR_ERR(vf->vnic) : -ENOMEM;
573 usnic_err("Failed to alloc vnic for %s with err %d\n",
574 pci_name(pdev), err);
575 goto out_release_regions;
578 pf = usnic_ib_discover_pf(vf->vnic);
579 if (IS_ERR_OR_NULL(pf)) {
580 usnic_err("Failed to discover pf of vnic %s with err%ld\n",
581 pci_name(pdev), PTR_ERR(pf));
582 err = pf ? PTR_ERR(pf) : -EFAULT;
587 spin_lock_init(&vf->lock);
588 mutex_lock(&pf->usdev_lock);
589 list_add_tail(&vf->link, &pf->vf_dev_list);
591 * Save max settings (will be same for each VF, easier to re-write than
592 * to say "if (!set) { set_values(); set=1; }
594 for (res_type = USNIC_VNIC_RES_TYPE_EOL+1;
595 res_type < USNIC_VNIC_RES_TYPE_MAX;
597 pf->vf_res_cnt[res_type] = usnic_vnic_res_cnt(vf->vnic,
601 mutex_unlock(&pf->usdev_lock);
603 usnic_info("Registering usnic VF %s into PF %s\n", pci_name(pdev),
604 dev_name(&pf->ib_dev.dev));
609 usnic_vnic_free(vf->vnic);
611 pci_set_drvdata(pdev, NULL);
612 pci_clear_master(pdev);
613 pci_release_regions(pdev);
615 pci_disable_device(pdev);
621 static void usnic_ib_pci_remove(struct pci_dev *pdev)
623 struct usnic_ib_vf *vf = pci_get_drvdata(pdev);
624 struct usnic_ib_dev *pf = vf->pf;
626 mutex_lock(&pf->usdev_lock);
628 mutex_unlock(&pf->usdev_lock);
630 kref_put(&pf->vf_cnt, usnic_ib_undiscover_pf);
631 usnic_vnic_free(vf->vnic);
632 pci_set_drvdata(pdev, NULL);
633 pci_clear_master(pdev);
634 pci_release_regions(pdev);
635 pci_disable_device(pdev);
638 usnic_info("Removed VF %s\n", pci_name(pdev));
641 /* PCI driver entry points */
642 static struct pci_driver usnic_ib_pci_driver = {
644 .id_table = usnic_ib_pci_ids,
645 .probe = usnic_ib_pci_probe,
646 .remove = usnic_ib_pci_remove,
648 /* End of PCI section */
650 /* Start of module section */
651 static int __init usnic_ib_init(void)
655 printk_once(KERN_INFO "%s", usnic_version);
657 err = usnic_uiom_init(DRV_NAME);
659 usnic_err("Unable to initialize umem with err %d\n", err);
663 err = pci_register_driver(&usnic_ib_pci_driver);
665 usnic_err("Unable to register with PCI\n");
669 err = register_netdevice_notifier(&usnic_ib_netdevice_notifier);
671 usnic_err("Failed to register netdev notifier\n");
675 err = register_inetaddr_notifier(&usnic_ib_inetaddr_notifier);
677 usnic_err("Failed to register inet addr notifier\n");
678 goto out_unreg_netdev_notifier;
681 err = usnic_transport_init();
683 usnic_err("Failed to initialize transport\n");
684 goto out_unreg_inetaddr_notifier;
687 usnic_debugfs_init();
691 out_unreg_inetaddr_notifier:
692 unregister_inetaddr_notifier(&usnic_ib_inetaddr_notifier);
693 out_unreg_netdev_notifier:
694 unregister_netdevice_notifier(&usnic_ib_netdevice_notifier);
696 pci_unregister_driver(&usnic_ib_pci_driver);
702 static void __exit usnic_ib_destroy(void)
705 usnic_debugfs_exit();
706 usnic_transport_fini();
707 unregister_inetaddr_notifier(&usnic_ib_inetaddr_notifier);
708 unregister_netdevice_notifier(&usnic_ib_netdevice_notifier);
709 pci_unregister_driver(&usnic_ib_pci_driver);
712 MODULE_DESCRIPTION("Cisco VIC (usNIC) Verbs Driver");
713 MODULE_AUTHOR("Upinder Malhi <umalhi@cisco.com>");
714 MODULE_LICENSE("Dual BSD/GPL");
715 module_param(usnic_log_lvl, uint, S_IRUGO | S_IWUSR);
716 module_param(usnic_ib_share_vf, uint, S_IRUGO | S_IWUSR);
717 MODULE_PARM_DESC(usnic_log_lvl, " Off=0, Err=1, Info=2, Debug=3");
718 MODULE_PARM_DESC(usnic_ib_share_vf, "Off=0, On=1 VF sharing amongst QPs");
719 MODULE_DEVICE_TABLE(pci, usnic_ib_pci_ids);
721 module_init(usnic_ib_init);
722 module_exit(usnic_ib_destroy);
723 /* End of module section */