Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Read Temperature of NVMe SSD Drive over PCIe (QNX7.0): (5 Items)
   
Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)  
Hi all, please forgive my ignorance on the subject. My issue is the following:
I am trying to read a vendor log page of an nvme ssd drive, in order to get temperature data from the device (over PCIe)
.

My knowledge of PCIe is very limited, but I've been going over the pci/pcie APIs provided by QNX7.0, and am a bit 
confused as to what set of function/s exactly I should focus on. So far I can attach and read basic information about 
the device such as different PCI and PCIe capabilities, VID, DID, etc. Which API should I use in order to send NVMe 
commands to the device?

Thanks for taking the time. Let me know if you need further clarification/s.
RE: Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)  
Hi Alex, 

We have specifically named API's to obtain the PCI specification defined area below 0x40. pci_device_read_vid(), 
pci_device_read_did(), and pci_device_read_cap() are a few of them.  
We have an API, pci_device_cfg_rd*(), which is used to read a 8/16/32/64-bit word from the device dependent portion of 
the 256/4096 bytes of PCI/PCIe configuration space from offset 0x40 to 0xFF/0xFFF respectively. So, if temperature data 
is in the device-specific PCI configuration space registers, then you can use this afore-mentioned API to read the 
temperature information.  Here is the link its documentation - http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.
pci_server/topic/pci_device_cfg_rd.html. 

I don't know how else would be read this info off the vendor log page.

Have you successfully launched devb-nvme driver, and mounted nvme device on your target?

Regards,
Itar

-----Original Message-----
From: Alex Martir <community-noreply@qnx.com> 
Sent: Sunday, November 1, 2020 10:28 PM
To: ostech-core_os <ostech-core_os@community.qnx.com>
Subject: Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)

Hi all, please forgive my ignorance on the subject. My issue is the following:
I am trying to read a vendor log page of an nvme ssd drive, in order to get temperature data from the device (over PCIe)
.

My knowledge of PCIe is very limited, but I've been going over the pci/pcie APIs provided by QNX7.0, and am a bit 
confused as to what set of function/s exactly I should focus on. So far I can attach and read basic information about 
the device such as different PCI and PCIe capabilities, VID, DID, etc. Which API should I use in order to send NVMe 
commands to the device?

Thanks for taking the time. Let me know if you need further clarification/s.




_______________________________________________

OSTech
http://community.qnx.com/sf/go/post121052
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Re: RE: Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)  
Alex,

The information you are after has nothing to do with PCI.
Instead this is device specific information which if available at all, would likely be through a devctl() or similar 
interface directly to the block device. I do not know whether we have such an interface for this but will alter someone 
who might to this request
Re: RE: Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)  
Hello there and thank you for the answers!

I am currently looking into devctl() per your suggestion. I found an interesting header for linux (nvme_ioctl.h) where 
they define ioctl's for NVME ADMIN commands (which is exactly what I need), but I am not sure if something analogous is 
supported in QNX. I am trying something like the following (with devctl)

// --> Pseudocode-ish

// Not sure about this define (I couldn't find a suitable device class, so chose _DCMD_CAM for now)
// 0x41 is opcode for ADMIN_CMD (according to NVME spec)
// nvme_admin_cmd structure is defined by NVME spec

#define NVME_IOCTL_ADMIN_CMD  __DIOTF(_DCMD_CAM, 0x41, struct nvme_admin_cmd)

// Open file descriptor to NVME SSD
int fd = open("/dev/hd0", O_RDWR);
if(fd < 0)
  return -1;

uint8_t buffer[512]; // This buffer will hold our device reply (expect 512 bytes for Vendor Log Page)
struct nvme_admin_cmd cmd;
memset(&cmd, 0, sizeof(cmd));

// Assemble ADMIN command
cmd.opcode = 0x02; // Get Vendor Log Page command
cmd.data_length = 512; // The SSD returns 512 bytes
cmd.addr = (int)buffer;

int error = devctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd, sizeof(cmd), nullptr);
if(error)
  cout << "Error sending ADMIN cmd to NVME drive";

// ...

. Am I heading in the right direction here? 
. Is there any NVMe command support for QNX? (Similar to Linux)
. Should the device class above be different (using CAM class, dcmd_cam.h)
. Any advise/suggestions is very appreciated!

Thanks!
Re: RE: Read Temperature of NVMe SSD Drive over PCIe (QNX7.0)  
Was pointed by someone at QNX to use the following DCMD: DCMD_SIM_NVME_PASS_THRU, which is defined in dcmd_sim_nvme.h

I am building the following passthrough command:

#include <hw/dcmd_sim_nvme.h>

struct nvme_pass_thru passthru{};

passthru.flags = NVME_PT_FLG_ADMIN_CMD;
passthru.dxfer_len = 512;
passthru.data_ptr = local_buffer;
passthru.cmd.opc = 0x02; // Get Log Page
passthru.cmd.nsid = 0xffffffff;
passthru.cmd.cdw10 = 0x007F0002;

int ret = devclt(fd_, DCMD_SIM_NVME_PASS_THRU, &passthru, sizeof(passthru), nullptr);

However, devctl returns Invalid Argument error. Would appreciate any suggestions on this