Skip to content

Commit ee2dd1b

Browse files
ankitvvsoniigaw
authored andcommitted
libnvme: add lockdown log page support(LID : 0x14)
adding command APIs for inband, out of band, structures and enums for lockdown log page (LID : 0x14). Signed-off-by: Ankit Soni <[email protected]>
1 parent 8cdd746 commit ee2dd1b

3 files changed

Lines changed: 116 additions & 0 deletions

File tree

src/nvme/ioctl.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,38 @@ static inline int nvme_get_log_persistent_event(int fd,
23122312
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
23132313
}
23142314

2315+
/**
2316+
* nvme_get_log_lockdown() - Retrieve lockdown Log
2317+
* @fd: File descriptor of nvme device
2318+
* @cnscp: Contents and Scope of Command and Feature Identifier Lists
2319+
* @lockdown_log: Buffer to store the lockdown log
2320+
*
2321+
* Return: The nvme command status if a response was received (see
2322+
* &enum nvme_status_field) or -1 with errno set otherwise.
2323+
*/
2324+
static inline int nvme_get_log_lockdown(int fd,
2325+
__u8 cnscp, struct nvme_lockdown_log *lockdown_log)
2326+
{
2327+
struct nvme_get_log_args args = {
2328+
.lpo = 0,
2329+
.result = NULL,
2330+
.log = lockdown_log,
2331+
.args_size = sizeof(args),
2332+
.fd = fd,
2333+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2334+
.lid = NVME_LOG_LID_CMD_AND_FEAT_LOCKDOWN,
2335+
.len = sizeof(*lockdown_log),
2336+
.nsid = NVME_NSID_ALL,
2337+
.csi = NVME_CSI_NVM,
2338+
.lsi = NVME_LOG_LSI_NONE,
2339+
.lsp = cnscp,
2340+
.uuidx = NVME_UUID_NONE,
2341+
.rae = false,
2342+
.ot = false,
2343+
};
2344+
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2345+
}
2346+
23152347
/**
23162348
* nvme_set_features() - Set a feature attribute
23172349
* @args: &struct nvme_set_features_args argument structure

src/nvme/mi.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,36 @@ static inline int nvme_mi_admin_get_log_persistent_event(nvme_mi_ctrl_t ctrl,
24322432
return nvme_mi_admin_get_log(ctrl, &args);
24332433
}
24342434

2435+
/**
2436+
* nvme_mi_admin_get_log_lockdown() - Retrieve lockdown Log
2437+
* @ctrl: Controller to query
2438+
* @cnscp: Contents and Scope of Command and Feature Identifier Lists
2439+
* @lockdown_log: Buffer to store the lockdown log
2440+
*
2441+
* Return: The nvme command status if a response was received (see
2442+
* &enum nvme_status_field) or -1 with errno set otherwise.
2443+
*/
2444+
static inline int nvme_mi_admin_get_log_lockdown(nvme_mi_ctrl_t ctrl,
2445+
__u8 cnscp, struct nvme_lockdown_log *lockdown_log)
2446+
{
2447+
struct nvme_get_log_args args = {
2448+
.lpo = 0,
2449+
.result = NULL,
2450+
.log = lockdown_log,
2451+
.args_size = sizeof(args),
2452+
.lid = NVME_LOG_LID_CMD_AND_FEAT_LOCKDOWN,
2453+
.len = sizeof(*lockdown_log),
2454+
.nsid = NVME_NSID_ALL,
2455+
.csi = NVME_CSI_NVM,
2456+
.lsi = NVME_LOG_LSI_NONE,
2457+
.lsp = cnscp,
2458+
.uuidx = NVME_UUID_NONE,
2459+
.rae = false,
2460+
.ot = false,
2461+
};
2462+
return nvme_mi_admin_get_log(ctrl, &args);
2463+
}
2464+
24352465
/**
24362466
* nvme_mi_admin_security_send() - Perform a Security Send command on a
24372467
* controller.

src/nvme/types.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,6 +4762,20 @@ struct nvme_supported_cap_config_list_log {
47624762
struct nvme_capacity_config_desc cap_config_desc[];
47634763
};
47644764

4765+
/**
4766+
* struct nvme_lockdown_log - Command and Feature Lockdown Log
4767+
* @cfila: Contents of the Command and Feature Identifier List field in the log page.
4768+
* @rsvd1: Reserved
4769+
* @lngth: Length of Command and Feature Identifier List field
4770+
* @cfil: Command and Feature Identifier List
4771+
*/
4772+
struct nvme_lockdown_log {
4773+
__u8 cfila;
4774+
__u8 rsvd1[2];
4775+
__u8 lngth;
4776+
__u8 cfil[508];
4777+
};
4778+
47654779
/**
47664780
* struct nvme_resv_notification_log - Reservation Notification Log
47674781
* @lpc: Log Page Count
@@ -5062,6 +5076,46 @@ enum nvme_fdp_config_fdpa {
50625076
NVME_FDP_CONFIG_FDPA_VALID_MASK = 0x1,
50635077
};
50645078

5079+
/**
5080+
* enum nvme_lockdown_log_scope - lockdown log page scope attributes
5081+
* @NVME_LOCKDOWN_ADMIN_CMD: Scope value for Admin commandS
5082+
* @NVME_LOCKDOWN_FEATURE_ID: Scope value for Feature ID
5083+
* @NVME_LOCKDOWN_MI_CMD_SET: Scope value for Management Interface commands
5084+
* @NVME_LOCKDOWN_PCI_CMD_SET: Scope value for PCI commands
5085+
*/
5086+
enum nvme_lockdown_log_scope {
5087+
NVME_LOCKDOWN_ADMIN_CMD = 0x0,
5088+
NVME_LOCKDOWN_FEATURE_ID = 0x2,
5089+
NVME_LOCKDOWN_MI_CMD_SET = 0x3,
5090+
NVME_LOCKDOWN_PCI_CMD_SET = 0x4,
5091+
};
5092+
5093+
/**
5094+
* enum nvme_lockdown_log_contents - lockdown log page content attributes
5095+
* @NVME_LOCKDOWN_SUPPORTED_CMD: Content value for Supported commands
5096+
* @NVME_LOCKDOWN_PROHIBITED_CMD: Content value for prohibited commands
5097+
* @NVME_LOCKDOWN_PROHIBITED_OUTOFBAND_CMD: Content value for prohibited side band commands
5098+
*/
5099+
enum nvme_lockdown_log_contents {
5100+
NVME_LOCKDOWN_SUPPORTED_CMD = 0x0,
5101+
NVME_LOCKDOWN_PROHIBITED_CMD = 0x1,
5102+
NVME_LOCKDOWN_PROHIBITED_OUTOFBAND_CMD = 0x2,
5103+
};
5104+
5105+
/**
5106+
* enum nvme_lockdown_scope_contents - Lockdown Log shift and mask
5107+
* @NVME_LOCKDOWN_SS_SHIFT: Lockdown log scope select Shift
5108+
* @NVME_LOCKDOWN_SS_MASK: Lockdown log scope select Mask
5109+
* @NVME_LOCKDOWN_CS_SHIFT: Lockdown log contents Shift
5110+
* @NVME_LOCKDOWN_CS_MASK: Lockdown log contents Mask
5111+
*/
5112+
enum nvme_lockdown_scope_contents {
5113+
NVME_LOCKDOWN_SS_SHIFT = 0,
5114+
NVME_LOCKDOWN_SS_MASK = 0xf,
5115+
NVME_LOCKDOWN_CS_SHIFT = 4,
5116+
NVME_LOCKDOWN_CS_MASK = 0x3,
5117+
};
5118+
50655119
/**
50665120
* struct nvme_fdp_config_desc - FDP Configuration Descriptor
50675121
* @size: Descriptor size

0 commit comments

Comments
 (0)