* port_cleanup infrastructure is implemented, this limitation will be
* removed.
*/
- if (!dev->ops.disassociate_ucontext || dev->ops.init_port ||
+ if (!dev->ops.disassociate_ucontext || dev->ops.port_groups ||
ib_devices_shared_netns) {
ret = -EOPNOTSUPP;
goto ns_err;
SET_DEVICE_OP(dev_ops, get_vf_config);
SET_DEVICE_OP(dev_ops, get_vf_guid);
SET_DEVICE_OP(dev_ops, get_vf_stats);
- SET_DEVICE_OP(dev_ops, init_port);
SET_DEVICE_OP(dev_ops, iw_accept);
SET_DEVICE_OP(dev_ops, iw_add_ref);
SET_DEVICE_OP(dev_ops, iw_connect);
SET_DEVICE_OP(dev_ops, modify_wq);
SET_DEVICE_OP(dev_ops, peek_cq);
SET_DEVICE_OP(dev_ops, poll_cq);
+ SET_DEVICE_OP(dev_ops, port_groups);
SET_DEVICE_OP(dev_ops, post_recv);
SET_DEVICE_OP(dev_ops, post_send);
SET_DEVICE_OP(dev_ops, post_srq_recv);
return port_attr->store(p->ibdev, p->port_num, port_attr, buf, count);
}
-int ib_port_sysfs_create_groups(struct ib_device *ibdev, u32 port_num,
- const struct attribute_group **groups)
-{
- return sysfs_create_groups(&ibdev->port_data[port_num].sysfs->kobj,
- groups);
-}
-EXPORT_SYMBOL_GPL(ib_port_sysfs_create_groups);
-
-void ib_port_sysfs_remove_groups(struct ib_device *ibdev, u32 port_num,
- const struct attribute_group **groups)
-{
- return sysfs_remove_groups(&ibdev->port_data[port_num].sysfs->kobj,
- groups);
-}
-EXPORT_SYMBOL_GPL(ib_port_sysfs_remove_groups);
-
struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
u32 *port_num)
{
ret = sysfs_create_groups(&p->kobj, p->groups_list);
if (ret)
goto err_del;
+ if (is_full_dev) {
+ ret = sysfs_create_groups(&p->kobj, device->ops.port_groups);
+ if (ret)
+ goto err_groups;
+ }
list_add_tail(&p->kobj.entry, &coredev->port_list);
if (device->port_data && is_full_dev)
return p;
+err_groups:
+ sysfs_remove_groups(&p->kobj, p->groups_list);
err_del:
kobject_del(&p->kobj);
err_put:
return ERR_PTR(ret);
}
-static void destroy_port(struct ib_port *port)
+static void destroy_port(struct ib_core_device *coredev, struct ib_port *port)
{
+ bool is_full_dev = &port->ibdev->coredev == coredev;
+
if (port->ibdev->port_data &&
port->ibdev->port_data[port->port_num].sysfs == port)
port->ibdev->port_data[port->port_num].sysfs = NULL;
list_del(&port->kobj.entry);
+ if (is_full_dev)
+ sysfs_remove_groups(&port->kobj, port->ibdev->ops.port_groups);
sysfs_remove_groups(&port->kobj, port->groups_list);
kobject_del(&port->kobj);
kobject_put(&port->kobj);
struct ib_port *port = container_of(p, struct ib_port, kobj);
destroy_gid_attrs(port);
- destroy_port(port);
+ destroy_port(coredev, port);
}
kobject_put(coredev->ports_kobj);
int ib_setup_port_attrs(struct ib_core_device *coredev)
{
struct ib_device *device = rdma_device_to_ibdev(&coredev->dev);
- bool is_full_dev = &device->coredev == coredev;
u32 port_num;
int ret;
ret = setup_gid_attrs(port, &attr);
if (ret)
goto err_put;
-
- if (device->ops.init_port && is_full_dev) {
- ret = device->ops.init_port(device, port_num,
- &port->kobj);
- if (ret)
- goto err_put;
- }
}
return 0;
extern const char ib_hfi1_version[];
extern const struct attribute_group ib_hfi1_attr_group;
+extern const struct attribute_group *hfi1_attr_port_groups[];
int hfi1_device_create(struct hfi1_devdata *dd);
void hfi1_device_remove(struct hfi1_devdata *dd);
-int hfi1_create_port_files(struct ib_device *ibdev, u32 port_num,
- struct kobject *kobj);
int hfi1_verbs_register_sysfs(struct hfi1_devdata *dd);
void hfi1_verbs_unregister_sysfs(struct hfi1_devdata *dd);
/* Hook for sysfs read of QSFP */
.attrs = hfi1_attributes,
};
-static const struct attribute_group *hfi1_port_groups[] = {
+const struct attribute_group *hfi1_attr_port_groups[] = {
&port_cc_group,
&port_sc2vl_group,
&port_sl2sc_group,
NULL,
};
-int hfi1_create_port_files(struct ib_device *ibdev, u32 port_num,
- struct kobject *kobj)
-{
- return ib_port_sysfs_create_groups(ibdev, port_num, hfi1_port_groups);
-}
-
struct sde_attribute {
struct attribute attr;
ssize_t (*show)(struct sdma_engine *sde, char *buf);
/* Unwind operations in hfi1_verbs_register_sysfs() */
for (i = 0; i < dd->num_sdma; i++)
kobject_put(&dd->per_sdma[i].kobj);
-
- for (i = 0; i < dd->num_pports; i++)
- ib_port_sysfs_remove_groups(&dd->verbs_dev.rdi.ibdev, i + 1,
- hfi1_port_groups);
}
.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,
extern const char ib_qib_version[];
extern const struct attribute_group qib_attr_group;
+extern const struct attribute_group *qib_attr_port_groups[];
int qib_device_create(struct qib_devdata *);
void qib_device_remove(struct qib_devdata *);
-int qib_create_port_files(struct ib_device *ibdev, u32 port_num,
- struct kobject *kobj);
-void qib_verbs_unregister_sysfs(struct qib_devdata *);
/* Hook for sysfs read of QSFP */
extern int qib_qsfp_dump(struct qib_pportdata *ppd, char *buf, int len);
/* End diag_counters */
-static const struct attribute_group *qib_port_groups[] = {
+const struct attribute_group *qib_attr_port_groups[] = {
&port_linkcontrol_group,
&port_ccmgta_attribute_group,
&port_sl2vl_group,
const struct attribute_group qib_attr_group = {
.attrs = qib_attributes,
};
-
-int qib_create_port_files(struct ib_device *ibdev, u32 port_num,
- struct kobject *kobj)
-{
- return ib_port_sysfs_create_groups(ibdev, port_num, qib_port_groups);
-}
-
-/*
- * Unregister and remove our files in /sys/class/infiniband.
- */
-void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
-{
- int i;
-
- for (i = 0; i < dd->num_pports; i++)
- ib_port_sysfs_remove_groups(&dd->verbs_dev.rdi.ibdev, i,
- qib_port_groups);
-}
.owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_QIB,
- .init_port = qib_create_port_files,
+ .port_groups = qib_attr_port_groups,
.modify_device = qib_modify_device,
.process_mad = qib_process_mad,
};
{
struct qib_ibdev *dev = &dd->verbs_dev;
- qib_verbs_unregister_sysfs(dd);
-
rvt_unregister_device(&dd->verbs_dev.rdi);
if (!list_empty(&dev->piowait))
* These functions are not part of verbs specifically but are
* required for rdmavt to function.
*/
- if ((!rdi->ibdev.ops.init_port) ||
+ if ((!rdi->ibdev.ops.port_groups) ||
(!rdi->driver_f.get_pci_dev))
return -EINVAL;
break;
#define IB_PORT_ATTR_WO(_name) \
struct ib_port_attribute ib_port_attr_##_name = __ATTR_WO(_name)
-int ib_port_sysfs_create_groups(struct ib_device *ibdev, u32 port_num,
- const struct attribute_group **groups);
-void ib_port_sysfs_remove_groups(struct ib_device *ibdev, u32 port_num,
- const struct attribute_group **groups);
struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
u32 *port_num);
u32 uverbs_abi_ver;
unsigned int uverbs_no_driver_id_binding:1;
+ const struct attribute_group **port_groups;
+
int (*post_send)(struct ib_qp *qp, const struct ib_send_wr *send_wr,
const struct ib_send_wr **bad_send_wr);
int (*post_recv)(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
*/
int (*get_hw_stats)(struct ib_device *device,
struct rdma_hw_stats *stats, u32 port, int index);
- /*
- * This function is called once for each port when a ib device is
- * registered.
- */
- int (*init_port)(struct ib_device *device, u32 port_num,
- struct kobject *port_sysfs);
+
/**
* Allows rdma drivers to add their own restrack attributes.
*/