1. 22 Sep, 2017 7 commits
  2. 31 Aug, 2017 15 commits
    • Matan Barak's avatar
      IB/core: Expose ioctl interface through experimental Kconfig · 8eb19e8e
      Matan Barak authored
      Add CONFIG_INFINIBAND_EXP_USER_ACCESS that enables the ioctl
      interface. This interface is experimental and is subject to change.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      8eb19e8e
    • Matan Barak's avatar
      IB/core: Assign root to all drivers · 52427112
      Matan Barak authored
      In order to use the parsing tree, we need to assign the root
      to all drivers. Currently, we just assign the default parsing
      tree via ib_uverbs_add_one. The driver could override this by
      assigning a parsing tree prior to registering the device.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      52427112
    • Matan Barak's avatar
      IB/core: Add completion queue (cq) object actions · 9ee79fce
      Matan Barak authored
      Adding CQ ioctl actions:
      1. create_cq
      2. destroy_cq
      
      This requires adding the following:
      1. A specification describing the method
      	a. Handler
      	b. Attributes specification
      		Each attribute is one of the following:
      		a. PTR_IN - input data
      			    Note: This could be encoded inlined for
      				  data < 64bit
      		b. PTR_OUT - response data
      		c. IDR - idr based object
      		d. FD - fd based object
                      Blobs attributes (clauses a and b) contain their type,
      	        while objects specifications (clauses c and d)
                      contains the expected object type (for example, the
                      given id should be UVERBS_TYPE_PD) and the required
                      access (READ, WRITE, NEW or DESTROY). If a NEW is
                      required, the new object's id will be assigned to this
                      attribute. All attributes could get UA_FLAGS
                      attribute. Currently we support stating that an
      		attribute is mandatory or that the specification size
                      corresponds to a lower bound (and that this attribute
      		could be extended).
      		We currently add both default attributes and the two
      		generic UHW_IN and UHW_OUT driver specific attributes.
      2. Handler
         A handler gets a uverbs_attr_bundle. The handler developer uses
         uverbs_attr_get to fetch an attribute of a given id.
         Each of these attribute groups correspond to the specification
         group defined in the action (clauses 1.b and 1.c respectively).
         The indices of these arrays corresponds to the attribute ids
         declared in the specifications (clause 2).
      
         The handler is quite simple. It assumes the infrastructure fetched
         all objects and locked, created or destroyed them as required by
         the specification. Pointer (or blob) attributes were validated to
         match their required sizes. After the handler finished, the
         infrastructure commits or rollbacks the objects.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      9ee79fce
    • Matan Barak's avatar
      IB/core: Add legacy driver's user-data · d70724f1
      Matan Barak authored
      In this phase, we don't want to change all the drivers to use
      flexible driver's specific attributes. Therefore, we add two default
      attributes: UHW_IN and UHW_OUT. These attributes are optional in some
      methods and they encode the driver specific command data. We add
      a function that extract this data and creates the legacy udata over
      it.
      
      Driver's data should start from UVERBS_UDATA_DRIVER_DATA_FLAG. This
      turns on the first bit of the namespace, indicating this attribute
      belongs to the driver's namespace.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      d70724f1
    • Matan Barak's avatar
      IB/core: Export ioctl enum types to user-space · 64b19e13
      Matan Barak authored
      Add a new ib_user_ioctl_verbs.h which exports all required ABI
      enums and structs to the user-space.
      Export the default types to user-space through this file.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      64b19e13
    • Matan Barak's avatar
      IB/core: Explicitly destroy an object while keeping uobject · 4da70da2
      Matan Barak authored
      When some objects are destroyed, we need to extract their status at
      destruction. After object's destruction, this status
      (e.g. events_reported) relies in the uobject. In order to have the
      latest and correct status, the underlying object should be destroyed,
      but we should keep the uobject alive and read this information off the
      uobject. We introduce a rdma_explicit_destroy function. This function
      destroys the class type object (for example, the IDR class type which
      destroys the underlying object as well) and then convert the uobject
      to be of a null class type. This uobject will then be destroyed as any
      other uobject once uverbs_finalize_object[s] is called.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      4da70da2
    • Matan Barak's avatar
      IB/core: Add macros for declaring methods and attributes · 35410306
      Matan Barak authored
      This patch adds macros for declaring objects, methods and
      attributes. These definitions are later used by downstream patches
      to declare some of the default types.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      35410306
    • Matan Barak's avatar
      IB/core: Add uverbs merge trees functionality · 118620d3
      Matan Barak authored
      Different drivers support different features and even subset of the
      common uverbs implementation. Currently, this is handled as bitmask
      in every driver that represents which kind of methods it supports, but
      doesn't go down to attributes granularity. Moreover, drivers might
      want to add their specific types, methods and attributes to let
      their user-space counter-parts be exposed to some more efficient
      abstractions. It means that existence of different features is
      validated syntactically via the parsing infrastructure rather than
      using a complex in-handler logic.
      
      In order to do that, we allow defining features and abstractions
      as parsing trees. These per-feature parsing tree could be merged
      to an efficient (perfect-hash based) parsing tree, which is later
      used by the parsing infrastructure.
      
      To sum it up, this makes a parse tree unique for a device and
      represents only the features this particular device supports.
      This is done by having a root specification tree per feature.
      Before a device registers itself as an IB device, it merges
      all these trees into one parsing tree. This parsing tree
      is used to parse all user-space commands.
      
      A future user-space application could read this parse tree. This
      tree represents which objects, methods and attributes are
      supported by this device.
      
      This is based on the idea of
      Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      118620d3
    • Matan Barak's avatar
      IB/core: Add DEVICE object and root tree structure · 09e3ebf8
      Matan Barak authored
      This adds the DEVICE object. This object supports creating the context
      that all objects are created from. Moreover, it supports executing
      methods which are related to the device itself, such as QUERY_DEVICE.
      This is a singleton object (per file instance).
      
      All standard objects are put in the root structure. This root will later
      on be used in drivers as the source for their whole parsing tree.
      Later on, when new features are added, these drivers could mix this root
      with other customized objects.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      09e3ebf8
    • Matan Barak's avatar
      IB/core: Declare an object instead of declaring only type attributes · 5009010f
      Matan Barak authored
      Switch all uverbs_type_attrs_xxxx with DECLARE_UVERBS_OBJECT
      macros. This will be later used in order to embed the object
      specific methods in the objects as well.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      5009010f
    • Matan Barak's avatar
      IB/core: Add new ioctl interface · fac9658c
      Matan Barak authored
      In this ioctl interface, processing the command starts from
      properties of the command and fetching the appropriate user objects
      before calling the handler.
      
      Parsing and validation is done according to a specifier declared by
      the driver's code. In the driver, all supported objects are declared.
      These objects are separated to different object namepsaces. Dividing
      objects to namespaces is done at initialization by using the higher
      bits of the object ids. This initialization can mix objects declared
      in different places to one parsing tree using in this ioctl interface.
      
      For each object we list all supported methods. Similarly to objects,
      methods are separated to method namespaces too. Namespacing is done
      similarly to the objects case. This could be used in order to add
      methods to an existing object.
      
      Each method has a specific handler, which could be either a default
      handler or a driver specific handler.
      Along with the handler, a bunch of attributes are specified as well.
      Similarly to objects and method, attributes are namespaced and hashed
      by their ids at initialization too. All supported attributes are
      subject to automatic fetching and validation. These attributes include
      the command, response and the method's related objects' ids.
      
      When these entities (objects, methods and attributes) are used, the
      high bits of the entities ids are used in order to calculate the hash
      bucket index. Then, these high bits are masked out in order to have a
      zero based index. Since we use these high bits for both bucketing and
      namespacing, we get a compact representation and O(1) array access.
      This is mandatory for efficient dispatching.
      
      Each attribute has a type (PTR_IN, PTR_OUT, IDR and FD) and a length.
      Attributes could be validated through some attributes, like:
      (*) Minimum size / Exact size
      (*) Fops for FD
      (*) Object type for IDR
      
      If an IDR/fd attribute is specified, the kernel also states the object
      type and the required access (NEW, WRITE, READ or DESTROY).
      All uobject/fd management is done automatically by the infrastructure,
      meaning - the infrastructure will fail concurrent commands that at
      least one of them requires concurrent access (WRITE/DESTROY),
      synchronize actions with device removals (dissociate context events)
      and take care of reference counting (increase/decrease) for concurrent
      actions invocation. The reference counts on the actual kernel objects
      shall be handled by the handlers.
      
       objects
      +--------+
      |        |
      |        |   methods                                                                +--------+
      |        |   ns         method      method_spec                           +-----+   |len     |
      +--------+  +------+[d]+-------+   +----------------+[d]+------------+    |attr1+-> |type    |
      | object +> |method+-> | spec  +-> +  attr_buckets  +-> |default_chain+--> +-----+   |idr_type|
      +--------+  +------+   |handler|   |                |   +------------+    |attr2|   |access  |
      |        |  |      |   +-------+   +----------------+   |driver chain|    +-----+   +--------+
      |        |  |      |                                    +------------+
      |        |  +------+
      |        |
      |        |
      |        |
      |        |
      |        |
      |        |
      |        |
      |        |
      |        |
      |        |
      +--------+
      
      [d] = Hash ids to groups using the high order bits
      
      The right types table is also chosen by using the high bits from
      the ids. Currently we have either default or driver specific groups.
      
      Once validation and object fetching (or creation) completed, we call
      the handler:
      int (*handler)(struct ib_device *ib_dev, struct ib_uverbs_file *ufile,
                     struct uverbs_attr_bundle *ctx);
      
      ctx bundles attributes of different namespaces. Each element there
      is an array of attributes which corresponds to one namespaces of
      attributes. For example, in the usually used case:
      
       ctx                               core
      +----------------------------+     +------------+
      | core:                      +---> | valid      |
      +----------------------------+     | cmd_attr   |
      | driver:                    |     +------------+
      |----------------------------+--+  | valid      |
                                      |  | cmd_attr   |
                                      |  +------------+
                                      |  | valid      |
                                      |  | obj_attr   |
                                      |  +------------+
                                      |
                                      |  drivers
                                      |  +------------+
                                      +> | valid      |
                                         | cmd_attr   |
                                         +------------+
                                         | valid      |
                                         | cmd_attr   |
                                         +------------+
                                         | valid      |
                                         | obj_attr   |
                                         +------------+
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      fac9658c
    • Adit Ranadive's avatar
      RDMA/vmw_pvrdma: Fix a signedness · 14d6c3a8
      Adit Ranadive authored
      Fixes: 29c8d9eb ("IB: Add vmw_pvrdma driver")
      Signed-off-by: default avatarAdit Ranadive <aditr@vmware.com>
      Reviewed-by: default avatarYuval Shaia <yuval.shaia@oracle.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      14d6c3a8
    • Aditya Sarwade's avatar
      RDMA/vmw_pvrdma: Report network header type in WC · 72f9b089
      Aditya Sarwade authored
      We should report the network header type in the work completion so that
      the kernel can infer the right RoCE type headers.
      Reviewed-by: default avatarBryan Tan <bryantan@vmware.com>
      Signed-off-by: default avatarAditya Sarwade <asarwade@vmware.com>
      Signed-off-by: default avatarAdit Ranadive <aditr@vmware.com>
      Reviewed-by: default avatarYuval Shaia <yuval.shaia@oracle.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      72f9b089
    • Roland Dreier's avatar
      IB/core: Add might_sleep() annotation to ib_init_ah_from_wc() · 79364227
      Roland Dreier authored
      For RoCE, ib_init_ah_from_wc() can follow the path
      
          ib_init_ah_from_wc() ->
            rdma_addr_find_l2_eth_by_grh() ->
              rdma_resolve_ip()
      
      and rdma_resolve_ip() will sleep in kzalloc() and wait_for_completion().
      
      However, developers will not see any warnings if they use ib_init_ah_from_wc()
      in an atomic context and test only on IB, because the function doesn't
      sleep in that case.
      
      Add a might_sleep() so that lockdep will catch bugs no matter what hardware is
      used to test.
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      79364227
    • Roland Dreier's avatar
      IB/cm: Fix sleeping in atomic when RoCE is used · c7616118
      Roland Dreier authored
      A couple of places in the CM do
      
          spin_lock_irq(&cm_id_priv->lock);
          ...
          if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
      
      However when the underlying transport is RoCE, this leads to a sleeping function
      being called with the lock held - the callchain is
      
          cm_alloc_response_msg() ->
            ib_create_ah_from_wc() ->
              ib_init_ah_from_wc() ->
                rdma_addr_find_l2_eth_by_grh() ->
                  rdma_resolve_ip()
      
      and rdma_resolve_ip() starts out by doing
      
          req = kzalloc(sizeof *req, GFP_KERNEL);
      
      not to mention rdma_addr_find_l2_eth_by_grh() doing
      
          wait_for_completion(&ctx.comp);
      
      to wait for the task that rdma_resolve_ip() queues up.
      
      Fix this by moving the AH creation out of the lock.
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Reviewed-by: default avatarSean Hefty <sean.hefty@intel.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      c7616118
  3. 30 Aug, 2017 2 commits
    • Matan Barak's avatar
      IB/core: Add support to finalize objects in one transaction · f43dbebf
      Matan Barak authored
      The new ioctl based infrastructure either commits or rollbacks
      all objects of the method as one transaction. In order to do
      that, we introduce a notion of dealing with a collection of
      objects that are related to a specific method.
      
      This also requires adding a notion of a method and attribute.
      A method contains a hash of attributes, where each bucket
      contains several attributes. The attributes are hashed according
      to their namespace which resides in the four upper bits of the id.
      
      For example, an object could be a CQ, which has an action of CREATE_CQ.
      This action has multiple attributes. For example, the CQ's new handle
      and the comp_channel. Each layer in this hierarchy - objects, methods
      and attributes is split into namespaces. The basic example for that is
      one namespace representing the default entities and another one
      representing the driver specific entities.
      
      When declaring these methods and attributes, we actually declare
      their specifications. When a method is executed, we actually
      allocates some space to hold auxiliary information. This auxiliary
      information contains meta-data about the required objects, such
      as pointers to their type information, pointers to the uobjects
      themselves (if exist), etc.
      The specification, along with the auxiliary information we allocated
      and filled is given to the finalize_objects function.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      f43dbebf
    • Matan Barak's avatar
      IB/core: Add a generic way to execute an operation on a uobject · a0aa309c
      Matan Barak authored
      The ioctl infrastructure treats all user-objects in the same manner.
      It gets objects ids from the user-space and by using the object type
      and type attributes mentioned in the object specification, it executes
      this required method. Passing an object id from the user-space as
      an attribute is carried out in three stages. The first is carried out
      before the actual handler and the last is carried out afterwards.
      
      The different supported operations are read, write, destroy and create.
      In the first stage, the former three actions just fetches the object
      from the repository (by using its id) and locks it. The last action
      allocates a new uobject. Afterwards, the second stage is carried out
      when the handler itself carries out the required modification of the
      object. The last stage is carried out after the handler finishes and
      commits the result. The former two operations just unlock the object.
      Destroy calls the "free object" operation, taking into account the
      object's type and releases the uobject as well. Creation just adds the
      new uobject to the repository, making the object visible to the
      application.
      
      In order to abstract these details from the ioctl infrastructure
      layer, we add uverbs_get_uobject_from_context and
      uverbs_finalize_object functions which corresponds to the first
      and last stages respectively.
      Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      a0aa309c
  4. 29 Aug, 2017 11 commits
  5. 28 Aug, 2017 5 commits