RDMA: Change ops->init_port to ops->port_groups
[linux-2.6-microblaze.git] / drivers / infiniband / hw / hfi1 / verbs.c
index 0dd4bb0..49c6ed2 100644 (file)
@@ -1407,7 +1407,7 @@ static inline u16 opa_width_to_ib(u16 in)
        }
 }
 
-static int query_port(struct rvt_dev_info *rdi, u8 port_num,
+static int query_port(struct rvt_dev_info *rdi, u32 port_num,
                      struct ib_port_attr *props)
 {
        struct hfi1_ibdev *verbs_dev = dev_from_rdi(rdi);
@@ -1485,7 +1485,7 @@ bail:
        return ret;
 }
 
-static int shut_down_port(struct rvt_dev_info *rdi, u8 port_num)
+static int shut_down_port(struct rvt_dev_info *rdi, u32 port_num)
 {
        struct hfi1_ibdev *verbs_dev = dev_from_rdi(rdi);
        struct hfi1_devdata *dd = dd_from_dev(verbs_dev);
@@ -1693,54 +1693,53 @@ static int init_cntr_names(const char *names_in,
        return 0;
 }
 
-static struct rdma_hw_stats *alloc_hw_stats(struct ib_device *ibdev,
-                                           u8 port_num)
+static int init_counters(struct ib_device *ibdev)
 {
-       int i, err;
+       struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
+       int i, err = 0;
 
        mutex_lock(&cntr_names_lock);
-       if (!cntr_names_initialized) {
-               struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
-
-               err = init_cntr_names(dd->cntrnames,
-                                     dd->cntrnameslen,
-                                     num_driver_cntrs,
-                                     &num_dev_cntrs,
-                                     &dev_cntr_names);
-               if (err) {
-                       mutex_unlock(&cntr_names_lock);
-                       return NULL;
-               }
-
-               for (i = 0; i < num_driver_cntrs; i++)
-                       dev_cntr_names[num_dev_cntrs + i] =
-                               driver_cntr_names[i];
-
-               err = init_cntr_names(dd->portcntrnames,
-                                     dd->portcntrnameslen,
-                                     0,
-                                     &num_port_cntrs,
-                                     &port_cntr_names);
-               if (err) {
-                       kfree(dev_cntr_names);
-                       dev_cntr_names = NULL;
-                       mutex_unlock(&cntr_names_lock);
-                       return NULL;
-               }
-               cntr_names_initialized = 1;
+       if (cntr_names_initialized)
+               goto out_unlock;
+
+       err = init_cntr_names(dd->cntrnames, dd->cntrnameslen, num_driver_cntrs,
+                             &num_dev_cntrs, &dev_cntr_names);
+       if (err)
+               goto out_unlock;
+
+       for (i = 0; i < num_driver_cntrs; i++)
+               dev_cntr_names[num_dev_cntrs + i] = driver_cntr_names[i];
+
+       err = init_cntr_names(dd->portcntrnames, dd->portcntrnameslen, 0,
+                             &num_port_cntrs, &port_cntr_names);
+       if (err) {
+               kfree(dev_cntr_names);
+               dev_cntr_names = NULL;
+               goto out_unlock;
        }
+       cntr_names_initialized = 1;
+
+out_unlock:
        mutex_unlock(&cntr_names_lock);
+       return err;
+}
 
-       if (!port_num)
-               return rdma_alloc_hw_stats_struct(
-                               dev_cntr_names,
-                               num_dev_cntrs + num_driver_cntrs,
-                               RDMA_HW_STATS_DEFAULT_LIFESPAN);
-       else
-               return rdma_alloc_hw_stats_struct(
-                               port_cntr_names,
-                               num_port_cntrs,
-                               RDMA_HW_STATS_DEFAULT_LIFESPAN);
+static struct rdma_hw_stats *hfi1_alloc_hw_device_stats(struct ib_device *ibdev)
+{
+       if (init_counters(ibdev))
+               return NULL;
+       return rdma_alloc_hw_stats_struct(dev_cntr_names,
+                                         num_dev_cntrs + num_driver_cntrs,
+                                         RDMA_HW_STATS_DEFAULT_LIFESPAN);
+}
+
+static struct rdma_hw_stats *hfi_alloc_hw_port_stats(struct ib_device *ibdev,
+                                                    u32 port_num)
+{
+       if (init_counters(ibdev))
+               return NULL;
+       return rdma_alloc_hw_stats_struct(port_cntr_names, num_port_cntrs,
+                                         RDMA_HW_STATS_DEFAULT_LIFESPAN);
 }
 
 static u64 hfi1_sps_ints(void)
@@ -1758,7 +1757,7 @@ static u64 hfi1_sps_ints(void)
 }
 
 static int get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
-                       u8 port, int index)
+                       u32 port, int index)
 {
        u64 *values;
        int count;
@@ -1787,12 +1786,13 @@ static const struct ib_device_ops hfi1_dev_ops = {
        .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_HFI1,
 
-       .alloc_hw_stats = alloc_hw_stats,
+       .alloc_hw_device_stats = hfi1_alloc_hw_device_stats,
+       .alloc_hw_port_stats = hfi_alloc_hw_port_stats,
        .alloc_rdma_netdev = hfi1_vnic_alloc_rn,
        .get_dev_fw_str = hfi1_get_dev_fw_str,
        .get_hw_stats = get_hw_stats,
-       .init_port = hfi1_create_port_files,
        .modify_device = modify_device,
+       .port_groups = hfi1_attr_port_groups,
        /* keep process mad in the driver */
        .process_mad = hfi1_process_mad,
        .rdma_netdev_get_params = hfi1_ipoib_rn_get_params,