From: Neerav Parikh <[email protected]> Use HBA_PORTTYPE values instead of fc_port_type enum for the PortType member of HBA_PORTATTRIBUTES.
Signed-off-by: Neerav Parikh <[email protected]> Tested-by: Ross Brattain <[email protected]> --- adapt_impl.h | 25 ------------------------- lport.c | 29 ++++++++++++----------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/adapt_impl.h b/adapt_impl.h index 17875e5..d86c2f8 100644 --- a/adapt_impl.h +++ b/adapt_impl.h @@ -52,31 +52,6 @@ struct hba_info { #define MAX_DRIVER_NAME_LEN 20 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) -/* fc_port_type: copied from scsi_transport_fc.h */ -enum fc_port_type { - FC_PORTTYPE_UNKNOWN, - FC_PORTTYPE_OTHER, - FC_PORTTYPE_NOTPRESENT, - FC_PORTTYPE_NPORT, /* Attached to FPort */ - FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */ - FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */ - FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */ - FC_PORTTYPE_NPIV, /* VPORT based on NPIV */ -}; - -#define fc_enum_name_search(title, table_type, table) \ -static enum fc_port_type get_fc_##title##_value(const char *table_key) \ -{ \ - int i; enum fc_port_type value = 0; \ - for (i = 0; i < ARRAY_SIZE(table); i++) { \ - if (!strcmp(table[i].name, table_key)) { \ - value = table[i].value; \ - break; \ - } \ - } \ - return value; \ -} - HBA_STATUS sysfs_get_port_stats(char *dir, HBA_PORTSTATISTICS *sp); HBA_STATUS sysfs_get_port_fc4stats(char *dir, HBA_FC4STATISTICS *fc4sp); diff --git a/lport.c b/lport.c index 442502d..450f73d 100644 --- a/lport.c +++ b/lport.c @@ -34,24 +34,19 @@ #define HBA_VENDOR_SPECIFIC_ID 0 /* - * Convert fc_port_type values to ascii string name. - * (This table is copied from scsi_transport_fc.c). + * table of /sys port types strings to HBA-API values. */ -static struct { - enum fc_port_type value; - char *name; -} port_types_table[] = { - { FC_PORTTYPE_UNKNOWN, "Unknown" }, - { FC_PORTTYPE_OTHER, "Other" }, - { FC_PORTTYPE_NOTPRESENT, "Not Present" }, - { FC_PORTTYPE_NPORT, "NPort (fabric via point-to-point)" }, - { FC_PORTTYPE_NLPORT, "NLPort (fabric via loop)" }, - { FC_PORTTYPE_LPORT, "LPort (private loop)" }, - { FC_PORTTYPE_PTP, "Point-To-Point (direct nport connection)" }, - { FC_PORTTYPE_NPIV, "NPIV VPORT" }, +struct sa_nameval port_types_table[] = { + { "Unknown", HBA_PORTTYPE_UNKNOWN }, + { "Other", HBA_PORTTYPE_OTHER }, + { "Not Present", HBA_PORTTYPE_NOTPRESENT }, + { "NPort (fabric via point-to-point)", HBA_PORTTYPE_NPORT }, + { "NLPort (fabric via loop)", HBA_PORTTYPE_NLPORT }, + { "LPort (private loop)", HBA_PORTTYPE_LPORT }, + { "Point-To-Point (direct nport connection)", HBA_PORTTYPE_PTP }, + { "NPIV VPORT", HBA_PORTTYPE_NPORT }, + { NULL, 0 } }; -fc_enum_name_search(port_type, fc_port_type, port_types_table) -#define FC_PORTTYPE_MAX_NAMELEN 50 /* * table of /sys port state strings to HBA-API values. @@ -301,7 +296,7 @@ sysfs_scan(struct dirent *dp, void *arg) /* Get PortType */ rc = sa_sys_read_line(pp->host_dir, "port_type", buf, sizeof(buf)); - pap->PortType = get_fc_port_type_value(buf); + rc = sa_enum_encode(port_types_table, buf, &pap->PortType); /* Get PortState */ rc = sa_sys_read_line(pp->host_dir, "port_state", buf, sizeof(buf)); _______________________________________________ devel mailing list [email protected] https://lists.open-fcoe.org/mailman/listinfo/devel
