Skip to content

Commit 53921ee

Browse files
authored
Merge pull request #157 from Arunpandian15/Media_Unit_Status_Log_Page
nvme: Add Media Unit Status log page(LID: 0x10)
2 parents 5aea021 + 781b910 commit 53921ee

4 files changed

Lines changed: 85 additions & 0 deletions

File tree

doc/libnvme.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,9 @@ otherwise.
921921
``NVME_LOG_LID_ENDURANCE_GRP_EVT``
922922
*undescribed*
923923
924+
``NVME_LOG_LID_MEDIA_UNIT_STATUS``
925+
*undescribed*
926+
924927
``NVME_LOG_LID_DISCOVER``
925928
*undescribed*
926929

doc/man/enum nvme_cmd_get_log_lid.2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ enum nvme_cmd_get_log_lid {
6464
,
6565
.br
6666
.br
67+
.BI " NVME_LOG_LID_MEDIA_UNIT_STATUS"
68+
,
69+
.br
70+
.br
6771
.BI " NVME_LOG_LID_DISCOVER"
6872
,
6973
.br
@@ -106,6 +110,8 @@ enum nvme_cmd_get_log_lid {
106110
-- undescribed --
107111
.IP "NVME_LOG_LID_ENDURANCE_GRP_EVT" 12
108112
-- undescribed --
113+
.IP "NVME_LOG_LID_MEDIA_UNIT_STATUS" 12
114+
-- undescribed --
109115
.IP "NVME_LOG_LID_DISCOVER" 12
110116
-- undescribed --
111117
.IP "NVME_LOG_LID_RESERVATION" 12

src/nvme/ioctl.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ static inline int nvme_zns_identify_ctrl(int fd, struct nvme_zns_id_ctrl *id)
11241124
* @csi: Command set identifier, see &enum nvme_csi for known values
11251125
* @lsp: Log specific field
11261126
* @lsi: Endurance group information
1127+
* @domid: Domain Identifier selection, if supported
11271128
* @uuidx: UUID selection, if supported
11281129
* @rae: Retain asynchronous events
11291130
* @ot: Offset Type; if set @lpo specifies the index into the list
@@ -1143,6 +1144,7 @@ struct nvme_get_log_args {
11431144
enum nvme_csi csi;
11441145
__u16 lsi;
11451146
__u8 lsp;
1147+
__u16 domid;
11461148
__u8 uuidx;
11471149
bool rae;
11481150
bool ot;
@@ -1174,6 +1176,7 @@ static inline int nvme_get_nsid_log(int fd, bool rae,
11741176
.csi = NVME_CSI_NVM,
11751177
.lsi = NVME_LOG_LSI_NONE,
11761178
.lsp = NVME_LOG_LSP_NONE,
1179+
.domid = NVME_DOMID_NONE,
11771180
.uuidx = NVME_UUID_NONE,
11781181
.rae = false,
11791182
.ot = false,
@@ -1741,6 +1744,39 @@ static inline int nvme_get_log_discovery(int fd, bool rae,
17411744
}
17421745

17431746

1747+
/**
1748+
* nvme_get_log_media_unit_stat() -
1749+
* @fd: File descriptor of nvme device
1750+
* @domid: Domain Identifier selection, if supported
1751+
*
1752+
* Return: The nvme command status if a response was received (see
1753+
* &enum nvme_status_field) or -1 with errno set otherwise
1754+
*/
1755+
static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid,
1756+
struct nvme_media_unit_stat_log *mus)
1757+
{
1758+
struct nvme_get_log_args args = {
1759+
.args_size = sizeof(args),
1760+
.fd = fd,
1761+
.result = NULL,
1762+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1763+
.lid = NVME_LOG_LID_MEDIA_UNIT_STATUS,
1764+
.lpo = 0,
1765+
.log = mus,
1766+
.len = sizeof(*mus),
1767+
.nsid = NVME_NSID_NONE,
1768+
.csi = NVME_CSI_NVM,
1769+
.lsi = NVME_LOG_LSI_NONE,
1770+
.lsp = NVME_LOG_LSP_NONE,
1771+
.domid = domid,
1772+
.uuidx = NVME_UUID_NONE,
1773+
.rae = false,
1774+
.ot = false,
1775+
};
1776+
return nvme_get_log(&args);
1777+
}
1778+
1779+
17441780
/**
17451781
* nvme_get_log_reservation() -
17461782
* @fd: File descriptor of nvme device

src/nvme/types.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,6 +3281,44 @@ struct nvme_boot_partition {
32813281
__u8 boot_partition_data[];
32823282
};
32833283

3284+
/**
3285+
* struct nvme_media_unit_stat_desc -
3286+
* @muid: Media Unit Identifier
3287+
* @domainid: Domain Identifier
3288+
* @endgid: Endurance Group Identifier
3289+
* @nvmsetid: NVM Set Identifier
3290+
* @cap_adj_fctr: Capacity Adjustment Factor
3291+
* @avl_spare: Available Spare
3292+
* @percent_used: Percentage Used
3293+
* @mucs: Number of Channels attached to media units
3294+
* @cio: Channel Identifiers Offset
3295+
*/
3296+
struct nvme_media_unit_stat_desc {
3297+
__le16 muid;
3298+
__le16 domainid;
3299+
__le16 endgid;
3300+
__le16 nvmsetid;
3301+
__le16 cap_adj_fctr;
3302+
__u8 avl_spare;
3303+
__u8 percent_used;
3304+
__u8 mucs;
3305+
__u8 cio;
3306+
};
3307+
3308+
/**
3309+
* struct nvme_media_unit_stat_log -
3310+
* @nmu: Number unit status descriptor
3311+
* @cchans: Number of Channels
3312+
* @sel_config: Selected Configuration
3313+
*/
3314+
struct nvme_media_unit_stat_log {
3315+
__le16 nmu;
3316+
__le16 cchans;
3317+
__le16 sel_config;
3318+
__u8 rsvd6[10];
3319+
struct nvme_media_unit_stat_desc mus_desc[];
3320+
};
3321+
32843322
/**
32853323
* struct nvme_resv_notification_log -
32863324
* @lpc:
@@ -5346,6 +5384,7 @@ enum nvme_identify_cns {
53465384
* @NVME_LOG_LID_PERSISTENT_EVENT:
53475385
* @NVME_LOG_LID_LBA_STATUS:
53485386
* @NVME_LOG_LID_ENDURANCE_GRP_EVT:
5387+
* @NVME_LOG_LID_MEDIA_UNIT_STATUS:
53495388
* @NVME_LOG_LID_FID_SUPPORTED_EFFECTS:
53505389
* @NVME_LOG_LID_BOOT_PARTITION:
53515390
* @NVME_LOG_LID_DISCOVER:
@@ -5370,6 +5409,7 @@ enum nvme_cmd_get_log_lid {
53705409
NVME_LOG_LID_PERSISTENT_EVENT = 0x0d,
53715410
NVME_LOG_LID_LBA_STATUS = 0x0e,
53725411
NVME_LOG_LID_ENDURANCE_GRP_EVT = 0x0f,
5412+
NVME_LOG_LID_MEDIA_UNIT_STATUS = 0x10,
53735413
NVME_LOG_LID_FID_SUPPORTED_EFFECTS = 0x12,
53745414
NVME_LOG_LID_BOOT_PARTITION = 0x15,
53755415
NVME_LOG_LID_DISCOVER = 0x70,

0 commit comments

Comments
 (0)