user_verbs.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. USERSPACE VERBS ACCESS
  2. The ib_uverbs module, built by enabling CONFIG_INFINIBAND_USER_VERBS,
  3. enables direct userspace access to IB hardware via "verbs," as
  4. described in chapter 11 of the InfiniBand Architecture Specification.
  5. To use the verbs, the libibverbs library, available from
  6. <http://openib.org/>, is required. libibverbs contains a
  7. device-independent API for using the ib_uverbs interface.
  8. libibverbs also requires appropriate device-dependent kernel and
  9. userspace driver for your InfiniBand hardware. For example, to use
  10. a Mellanox HCA, you will need the ib_mthca kernel module and the
  11. libmthca userspace driver be installed.
  12. User-kernel communication
  13. Userspace communicates with the kernel for slow path, resource
  14. management operations via the /dev/infiniband/uverbsN character
  15. devices. Fast path operations are typically performed by writing
  16. directly to hardware registers mmap()ed into userspace, with no
  17. system call or context switch into the kernel.
  18. Commands are sent to the kernel via write()s on these device files.
  19. The ABI is defined in drivers/infiniband/include/ib_user_verbs.h.
  20. The structs for commands that require a response from the kernel
  21. contain a 64-bit field used to pass a pointer to an output buffer.
  22. Status is returned to userspace as the return value of the write()
  23. system call.
  24. Resource management
  25. Since creation and destruction of all IB resources is done by
  26. commands passed through a file descriptor, the kernel can keep track
  27. of which resources are attached to a given userspace context. The
  28. ib_uverbs module maintains idr tables that are used to translate
  29. between kernel pointers and opaque userspace handles, so that kernel
  30. pointers are never exposed to userspace and userspace cannot trick
  31. the kernel into following a bogus pointer.
  32. This also allows the kernel to clean up when a process exits and
  33. prevent one process from touching another process's resources.
  34. Memory pinning
  35. Direct userspace I/O requires that memory regions that are potential
  36. I/O targets be kept resident at the same physical address. The
  37. ib_uverbs module manages pinning and unpinning memory regions via
  38. get_user_pages() and put_page() calls. It also accounts for the
  39. amount of memory pinned in the process's locked_vm, and checks that
  40. unprivileged processes do not exceed their RLIMIT_MEMLOCK limit.
  41. Pages that are pinned multiple times are counted each time they are
  42. pinned, so the value of locked_vm may be an overestimate of the
  43. number of pages pinned by a process.
  44. /dev files
  45. To create the appropriate character device files automatically with
  46. udev, a rule like
  47. KERNEL="uverbs*", NAME="infiniband/%k"
  48. can be used. This will create device nodes named
  49. /dev/infiniband/uverbs0
  50. and so on. Since the InfiniBand userspace verbs should be safe for
  51. use by non-privileged processes, it may be useful to add an
  52. appropriate MODE or GROUP to the udev rule.