Don't treat DSM commands as NFIT specific
PATCH 1/1 Don't treat DSM commands as NFIT specific
The DSM commands are treated exclusively as NFIT commands, remove NFIT dependency on using DSM commands.
Signed-off-by Santosh Sivaraj <[email protected]>
--- ndctl/lib/inject.c | 6 +++--- ndctl/lib/libndctl.c | 29 ++++++++++++++++++++++------- ndctl/lib/libndctl.sym | 4 ++++ ndctl/lib/nfit.c | 35 +++++++++-------------------------- ndctl/lib/private.h | 2 +- ndctl/libndctl-nfit.h | 8 -------- ndctl/libndctl.h | 9 +++++++++ 7 files changed, 48 insertions(+), 45 deletions(-)
ndctl/lib/inject.c +3 -3
@@ -26,9 +26,9 @@ NDCTL_EXPORT int ndctl_bus_has_error_injection(struct ndctl_bus *bus)if (!bus || !ndctl_bus_has_nfit (bus))return 0 ; -if (ndctl_bus_is_nfit_cmd_supported (bus,NFIT_CMD_ARS_INJECT_SET ) && -ndctl_bus_is_nfit_cmd_supported (bus,NFIT_CMD_ARS_INJECT_GET ) && -ndctl_bus_is_nfit_cmd_supported (bus,NFIT_CMD_ARS_INJECT_CLEAR )) +if (ndctl_bus_is_dsm_supported (bus,DSM_CMD_ARS_INJECT_SET ) && +ndctl_bus_is_dsm_supported (bus,DSM_CMD_ARS_INJECT_GET ) && +ndctl_bus_is_dsm_supported (bus,DSM_CMD_ARS_INJECT_CLEAR ))return 1 ;return 0 ;
ndctl/lib/libndctl.c +22 -7
@@ -884,12 +884,6 @@ static void *add_bus(void *parent, int id, const char *ctl_base)else bus->has_of_node =1 ; -sprintf (path,"%s/device/nfit/dsm_mask" , ctl_base); -if (sysfs_read_attr (ctx, path, buf) <0 ) - bus->nfit_dsm_mask =0 ; -else - bus->nfit_dsm_mask =strtoul (buf,NULL ,0 ); -sprintf (path,"%s/device/provider" , ctl_base);if (sysfs_read_attr (ctx, path, buf) <0 ) goto err_read;
@@ -898,12 +892,20 @@ static void *add_bus(void *parent, int id, const char *ctl_base)if (!bus->provider) goto err_read; +sprintf (path,"%s/device/%s/dsm_mask" , ctl_base, +ndctl_bus_has_nfit (bus) ?"nfit" : bus->provider); +if (sysfs_read_attr (ctx, path, buf) <0 ) + bus->dsm_mask =0 ; +else + bus->dsm_mask =strtoul (buf,NULL ,0 ); +sprintf (path,"%s/device/wait_probe" , ctl_base); bus->wait_probe_path =strdup (path);if (!bus->wait_probe_path) goto err_read; -sprintf (path,"%s/device/nfit/scrub" , ctl_base); +sprintf (path,"%s/device/%s/scrub" , ctl_base, +ndctl_bus_has_nfit (bus) ?"nfit" : bus->provider); bus->scrub_path =strdup (path);if (!bus->scrub_path) goto err_read;
@@ -1236,6 +1238,19 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,return !!(bus->cmd_mask & (1ULL << cmd)); } +/** +* ndctl_bus_is_cmd_supported - ask if command is supported on @bus. +* @bus: ndctl_bus instance +* @cmd: command number (defined as NFIT_CMD_XXX in libndctl-nfit.h) +* +* Return 1: command is supported. Return 0: command is not supported. +* +*/ +NDCTL_EXPORT int ndctl_bus_is_dsm_supported(struct ndctl_bus *bus, int cmd) +{ +return !!(bus->dsm_mask & (1ULL << cmd)); +} + NDCTL_EXPORT unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus) {return bus->revision;
ndctl/lib/libndctl.sym +4 -0
@@ -437,3 +437,7 @@ LIBNDCTL_24 { ndctl_bus_is_papr_scm; ndctl_region_has_numa; } LIBNDCTL_23; + +LIBNDCTL_25 { + ndctl_bus_is_dsm_supported; +} LIBNDCTL_24;
ndctl/lib/nfit.c +9 -26
@@ -20,39 +20,22 @@ static u32 bus_get_firmware_status(struct ndctl_cmd *cmd)struct nd_cmd_bus *cmd_bus = cmd->cmd_bus;switch (cmd_bus->gen.nd_command) { -case NFIT_CMD_TRANSLATE_SPA : +case DSM_CMD_TRANSLATE_SPA :return cmd_bus->xlat_spa.status; -case NFIT_CMD_ARS_INJECT_SET : +case DSM_CMD_ARS_INJECT_SET :return cmd_bus->err_inj.status; -case NFIT_CMD_ARS_INJECT_CLEAR : +case DSM_CMD_ARS_INJECT_CLEAR :return cmd_bus->err_inj_clr.status; -case NFIT_CMD_ARS_INJECT_GET : +case DSM_CMD_ARS_INJECT_GET :return cmd_bus->err_inj_stat.status; }return -1U ; } -/** -* ndctl_bus_is_nfit_cmd_supported - ask nfit command is supported on @bus. -* @bus: ndctl_bus instance -* @cmd: nfit command number (defined as NFIT_CMD_XXX in libndctl-nfit.h) -* -* Return 1: command is supported. Return 0: command is not supported. -* -*/ -NDCTL_EXPORT int ndctl_bus_is_nfit_cmd_supported(struct ndctl_bus *bus, -int cmd) -{ -return !!(bus->nfit_dsm_mask & (1ULL << cmd)); -} -static int bus_has_translate_spa (struct ndctl_bus *bus) { -if (!ndctl_bus_has_nfit (bus)) -return 0 ; - -return ndctl_bus_is_nfit_cmd_supported (bus,NFIT_CMD_TRANSLATE_SPA ); +return ndctl_bus_is_dsm_supported (bus,DSM_CMD_TRANSLATE_SPA ); }static struct ndctl_cmd *ndctl_bus_cmd_new_translate_spa (struct ndctl_bus *bus)
@@ -76,7 +59,7 @@ static struct ndctl_cmd *ndctl_bus_cmd_new_translate_spa(struct ndctl_bus *bus) cmd->size = size; cmd->status =1 ; pkg = &cmd->cmd_bus->gen; - pkg->nd_command =NFIT_CMD_TRANSLATE_SPA ; + pkg->nd_command =DSM_CMD_TRANSLATE_SPA ; pkg->nd_size_in =sizeof (unsigned long long ); pkg->nd_size_out = spa_length; pkg->nd_fw_size = spa_length;
@@ -181,7 +164,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj(struct ndctl_bus *bus) cmd->size = size; cmd->status =1 ; pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0 ]; - pkg->nd_command =NFIT_CMD_ARS_INJECT_SET ; + pkg->nd_command =DSM_CMD_ARS_INJECT_SET ; pkg->nd_size_in = offsetof(struct nd_cmd_ars_err_inj , status); pkg->nd_size_out = cmd_length - pkg->nd_size_in; pkg->nd_fw_size = pkg->nd_size_out;
@@ -208,7 +191,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_clr(struct ndctl_bus *bus) cmd->size = size; cmd->status =1 ; pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0 ]; - pkg->nd_command =NFIT_CMD_ARS_INJECT_CLEAR ; + pkg->nd_command =DSM_CMD_ARS_INJECT_CLEAR ; pkg->nd_size_in = offsetof(struct nd_cmd_ars_err_inj_clr , status); pkg->nd_size_out = cmd_length - pkg->nd_size_in; pkg->nd_fw_size = pkg->nd_size_out;
@@ -237,7 +220,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_stat(struct ndctl_bus *bus, cmd->size = size; cmd->status =1 ; pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0 ]; - pkg->nd_command =NFIT_CMD_ARS_INJECT_GET ; + pkg->nd_command =DSM_CMD_ARS_INJECT_GET ; pkg->nd_size_in =0 ; pkg->nd_size_out = cmd_length + buf_size; pkg->nd_fw_size = pkg->nd_size_out;
ndctl/lib/private.h +1 -1
@@ -175,7 +175,7 @@ struct ndctl_bus {char *wait_probe_path;char *scrub_path;unsigned long cmd_mask; -unsigned long nfit_dsm_mask; +unsigned long dsm_mask; };/**
ndctl/libndctl-nfit.h +0 -8
@@ -23,14 +23,6 @@* libndctl-nfit.h : definitions for NFIT related commands/functions. */ -/* nfit command numbers which are called via ND_CMD_CALL */ -enum { -NFIT_CMD_TRANSLATE_SPA =5 , -NFIT_CMD_ARS_INJECT_SET =7 , -NFIT_CMD_ARS_INJECT_CLEAR =8 , -NFIT_CMD_ARS_INJECT_GET =9 , -}; -/* error number of Translate SPA by firmware */ #define ND_TRANSLATE_SPA_STATUS_INVALID_SPA 2
ndctl/libndctl.h +9 -0
@@ -128,6 +128,7 @@ struct ndctl_bus *ndctl_bus_get_by_provider(struct ndctl_ctx *ctx, const char *provider);const char *ndctl_bus_get_cmd_name (struct ndctl_bus *bus,int cmd);int ndctl_bus_is_cmd_supported (struct ndctl_bus *bus,int cmd); +int ndctl_bus_is_dsm_supported (struct ndctl_bus *bus,int cmd);unsigned int ndctl_bus_get_revision (struct ndctl_bus *bus);unsigned int ndctl_bus_get_id (struct ndctl_bus *bus);const char *ndctl_bus_get_provider (struct ndctl_bus *bus);
@@ -740,6 +741,14 @@ int ndctl_dimm_master_secure_erase(struct ndctl_dimm *dimm, long key);#define NUMA_NO_NODE (-1)#define NUMA_NO_ATTR (-2) +/* DSM numbers which are called via ND_CMD_CALL */ +enum { +DSM_CMD_TRANSLATE_SPA =5 , +DSM_CMD_ARS_INJECT_SET =7 , +DSM_CMD_ARS_INJECT_CLEAR =8 , +DSM_CMD_ARS_INJECT_GET =9 , +}; + #ifdef __cplusplus }/* extern "C" */ #endif
Signature · 4 lines
2.26.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]