From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Changelog: v0->v1: * Removed accessing driver data, use ib_device to reach from device * Various coding style comments * Updated documentation to reflect new members of ib_core_device * Added lost ib_setup_port_attrs() patch >From Parav, ---------------------------------------------- Currently 'infiniband' class is registered as net namespace agnostic class due to which all rdma devices are visible in all net namespaces. Due to which net namespace filter needs to be applied on per sysfs entry such as GID or GID attribute for RoCE. This is fine as long as there is one rdma device shared among multiple net namespaces. However, when there are multiple rdma devices, it is desired to see only one or more rdma devices per net namespace. With different link layer types, there are various use case and mode exists. At minimum there are two use cases. (a) a shared rdma device among multiple net namespaces (b) rdma device bound to a particular net namespace In preparation to support backward compatibility to existing use cases and also to support future (rdma device bound to net namespace), 1. Prepare rdma infiniband class to be net namespace aware; So that when rdma device is bound to a net namespace in future, it can be restricted to a single net namespace. This requires a class to be net namespace aware. By doing so, a standard kernel framework of sysfs can be utilized to isolate devices in net namespaces. This is similar to how net class is net namespace aware following standard kernel architecture. 2. Replicate the sysfs tree in non init_net namespaces for backward compatibility, so that existing applications continue to operate in shared mode. This functionality is achieved by ib_core implementing a compat ib_core_device which replicates the device and sysfs entries in non init_net namespaces. It is desired to not create a full ib_device, therefore an internal ib_core_device object is created which represents only needed device tree and sysfs entries. A diagram, details and its objectives are captured in Documentation/infiniband/core_devices.txt. Thanks Parav Pandit (10): RDMA/core: Introduce and use ib_setup_port_attrs() RDMA: Introduce and use rdma_device_to_ibdev() RDMA/core: Introduce ib_core_device to hold device RDMA/core: Add Documentation for ib_core_device RDMA/core: Restrict sysfs entries view to init_net RDMA/core: Prefix ib_ to device_mutex, lists_rwsem, device_list RDMA/core: Implement compat device/sysfs tree in net namespace RDMA/core: Handle compat dev during device rename RDMA/core: Update core documentation for locking RDMA/core: Support core port attributes in non init_net Documentation/infiniband/core_devices.txt | 168 ++++++++++++++ drivers/infiniband/core/Makefile | 2 +- drivers/infiniband/core/compat_sysfs.c | 222 +++++++++++++++++++ drivers/infiniband/core/core_priv.h | 20 ++ drivers/infiniband/core/device.c | 181 +++++++++------ drivers/infiniband/core/sysfs.c | 106 +++++---- drivers/infiniband/hw/bnxt_re/main.c | 6 +- drivers/infiniband/hw/cxgb3/iwch_provider.c | 14 +- drivers/infiniband/hw/cxgb4/provider.c | 14 +- drivers/infiniband/hw/hfi1/sysfs.c | 16 +- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 5 +- drivers/infiniband/hw/mlx4/main.c | 7 +- drivers/infiniband/hw/mlx5/main.c | 13 +- drivers/infiniband/hw/mthca/mthca_provider.c | 9 +- drivers/infiniband/hw/nes/nes_verbs.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 6 +- drivers/infiniband/hw/qedr/main.c | 3 +- drivers/infiniband/hw/qib/qib_sysfs.c | 18 +- drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 26 +-- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +- include/rdma/ib_verbs.h | 60 ++++- 21 files changed, 715 insertions(+), 187 deletions(-) create mode 100644 Documentation/infiniband/core_devices.txt create mode 100644 drivers/infiniband/core/compat_sysfs.c -- 2.19.1