nvme.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2017 NXP Semiconductors
  4. * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
  5. */
  6. #ifndef __NVME_H__
  7. #define __NVME_H__
  8. struct nvme_dev;
  9. /**
  10. * nvme_identify - identify controller or namespace capabilities and status
  11. *
  12. * This issues an identify command to the NVMe controller to return a data
  13. * buffer that describes the controller or namespace capabilities and status.
  14. *
  15. * @dev: NVMe controller device
  16. * @nsid: 0 for controller, namespace id for namespace to identify
  17. * @cns: 1 for controller, 0 for namespace
  18. * @dma_addr: dma buffer address to store the identify result
  19. * @return: 0 on success, -ETIMEDOUT on command execution timeout,
  20. * -EIO on command execution fails
  21. */
  22. int nvme_identify(struct nvme_dev *dev, unsigned nsid,
  23. unsigned cns, dma_addr_t dma_addr);
  24. /**
  25. * nvme_get_features - retrieve the attributes of the feature specified
  26. *
  27. * This retrieves the attributes of the feature specified.
  28. *
  29. * @dev: NVMe controller device
  30. * @fid: feature id to provide data
  31. * @nsid: namespace id the command applies to
  32. * @dma_addr: data structure used as part of the specified feature
  33. * @result: command-specific result in the completion queue entry
  34. * @return: 0 on success, -ETIMEDOUT on command execution timeout,
  35. * -EIO on command execution fails
  36. */
  37. int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
  38. dma_addr_t dma_addr, u32 *result);
  39. /**
  40. * nvme_set_features - specify the attributes of the feature indicated
  41. *
  42. * This specifies the attributes of the feature indicated.
  43. *
  44. * @dev: NVMe controller device
  45. * @fid: feature id to provide data
  46. * @dword11: command-specific input parameter
  47. * @dma_addr: data structure used as part of the specified feature
  48. * @result: command-specific result in the completion queue entry
  49. * @return: 0 on success, -ETIMEDOUT on command execution timeout,
  50. * -EIO on command execution fails
  51. */
  52. int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
  53. dma_addr_t dma_addr, u32 *result);
  54. /**
  55. * nvme_scan_namespace - scan all namespaces attached to NVMe controllers
  56. *
  57. * This probes all registered NVMe uclass device drivers in the system,
  58. * and tries to find all namespaces attached to the NVMe controllers.
  59. *
  60. * @return: 0 on success, -ve on error
  61. */
  62. int nvme_scan_namespace(void);
  63. /**
  64. * nvme_print_info - print detailed NVMe controller and namespace information
  65. *
  66. * This prints out detailed human readable NVMe controller and namespace
  67. * information which is very useful for debugging.
  68. *
  69. * @udev: NVMe controller device
  70. * @return: 0 on success, -EIO if NVMe identify command fails
  71. */
  72. int nvme_print_info(struct udevice *udev);
  73. /**
  74. * nvme_get_namespace_id - return namespace identifier
  75. *
  76. * This returns the namespace identifier.
  77. *
  78. * @udev: NVMe controller device
  79. * @ns_id: Place where to put the name space identifier
  80. * @eui64: Place where to put the IEEE Extended Unique Identifier
  81. * @return: 0 on success, -ve on error
  82. */
  83. int nvme_get_namespace_id(struct udevice *udev, u32 *ns_id, u8 *eui64);
  84. #endif /* __NVME_H__ */