Skip to contentSkip to conversation

can call libcxl function outside ndctl tool?

DISCUSSION Li Qiang 2 participants 3 messages Oct 19, 2021 – Oct 20, 2021 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

Take cxl_cmd_new_identify as example.
There is CXL_EXPORT prefix, it seems can be called outside ndctl tool. While the intput and outpust struct cxl_memdev and cxl_cmd are private.

```

CXL_EXPORT struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev)
{
	return cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_IDENTIFY);
}

```

Thanks
Johnny

maintainer
#1 lore raw
Quoted 2 lines · Li Qiang

Take cxl_cmd_new_identify as example.
There is CXL_EXPORT prefix, it seems can be called outside ndctl tool.

Yes it can be linked to like any other library.

Quoted 10 lines

While the intput and outpust struct cxl_memdev and cxl_cmd are private.

```

CXL_EXPORT struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev)
{
	return cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_IDENTIFY);
}

```

Right - the intention is that those structs always remain private. Instead we provide accessor APIs to get fields out of the different command structures. e.g. for 'identify' we have cxl_cmd_identify_get_fw_rev, and so on. If there are other fields that lack these getter APIs, we can definitely add them. e.g. The health_info command has an exhaustive set of getter APIs.

Quoted 6 lines

Thanks
Johnny

author
#2 lore raw
Quoted 5 lines · Vishal L
Quoted 2 lines · Li Qiang

Take cxl_cmd_new_identify as example.
There is CXL_EXPORT prefix, it seems can be called outside ndctl tool.

Yes it can be linked to like any other library.

Thanks for your confirmation

Quoted 10 lines
Quoted 10 lines

While the intput and outpust struct cxl_memdev and cxl_cmd are private.

```

CXL_EXPORT struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev)

{
	return cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_IDENTIFY);
}
Quoted 8 lines
Quoted 1 line

```

Right - the intention is that those structs always remain private. Instead we provide accessor APIs to get fields out of the different command structures. e.g. for 'identify' we have cxl_cmd_identify_get_fw_rev, and so on. If there are other fields that lack these getter APIs, we can definitely add them. e.g. The health_info command has an exhaustive set of getter APIs.

These accessor getter APIs are used to decode output struct cxl_cmd. Is there any setter APIs can construct the input struct cxl_memdev?

Quoted 8 lines
Quoted 7 lines

Thanks
Johnny