These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / infiniband / hw / usnic / usnic_ib_main.c
index 0d0f986..565c881 100644 (file)
@@ -1,9 +1,24 @@
 /*
  * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
  *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@@ -300,6 +315,22 @@ static struct notifier_block usnic_ib_inetaddr_notifier = {
 };
 /* End of inet section*/
 
+static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num,
+                               struct ib_port_immutable *immutable)
+{
+       struct ib_port_attr attr;
+       int err;
+
+       err = usnic_ib_query_port(ibdev, port_num, &attr);
+       if (err)
+               return err;
+
+       immutable->pkey_tbl_len = attr.pkey_tbl_len;
+       immutable->gid_tbl_len = attr.gid_tbl_len;
+
+       return 0;
+}
+
 /* Start of PF discovery section */
 static void *usnic_ib_device_add(struct pci_dev *dev)
 {
@@ -312,16 +343,15 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
        netdev = pci_get_drvdata(dev);
 
        us_ibdev = (struct usnic_ib_dev *)ib_alloc_device(sizeof(*us_ibdev));
-       if (IS_ERR_OR_NULL(us_ibdev)) {
+       if (!us_ibdev) {
                usnic_err("Device %s context alloc failed\n",
                                netdev_name(pci_get_drvdata(dev)));
-               return ERR_PTR(us_ibdev ? PTR_ERR(us_ibdev) : -EFAULT);
+               return ERR_PTR(-EFAULT);
        }
 
        us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
-       if (IS_ERR_OR_NULL(us_ibdev->ufdev)) {
-               usnic_err("Failed to alloc ufdev for %s with err %ld\n",
-                               pci_name(dev), PTR_ERR(us_ibdev->ufdev));
+       if (!us_ibdev->ufdev) {
+               usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev));
                goto err_dealloc;
        }
 
@@ -383,6 +413,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
        us_ibdev->ib_dev.poll_cq = usnic_ib_poll_cq;
        us_ibdev->ib_dev.req_notify_cq = usnic_ib_req_notify_cq;
        us_ibdev->ib_dev.get_dma_mr = usnic_ib_get_dma_mr;
+       us_ibdev->ib_dev.get_port_immutable = usnic_port_immutable;
 
 
        if (ib_register_device(&us_ibdev->ib_dev, NULL))