Patchwork [Open-FCoE,RFC] fcping: allow pings using FC_BSG_RPT_ELS

login
register
mail settings
Submitter Johannes Thumshirn
Date Oct. 19, 2016, 5:20 p.m.
Message ID <20161019172059.4931-1-jthumshirn@suse.de>
Download mbox | patch
Permalink /patch/363/
State New
Headers show

Comments

Johannes Thumshirn - Oct. 19, 2016, 5:20 p.m.
fcping uses FC-ELS to perform pings. FC ELS is a host as well as rport
service, so allow the rport version of the BSG ioctl() as well as the
host version.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 fcping.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Patch

diff --git a/fcping.c b/fcping.c
index bf2bc0f..3bc7fe6 100644
--- a/fcping.c
+++ b/fcping.c
@@ -471,6 +471,7 @@  fp_find_hba(void)
 	char *endptr;
 	uint32_t fcid;
 	int hba_cnt;
+	int hostno, chan, num;
 
 	hba_cnt = get_number_of_adapters();
 	if (!hba_cnt)
@@ -495,6 +496,16 @@  fp_find_hba(void)
 		if (*endptr != '\0')
 			SA_LOG_EXIT("invalid hba name %s", fp_hba);
 		host = strdup(fp_hba);
+	} else if (sscanf(fp_hba, "rport-%d:%d-%d", &hostno, &chan, &num)) {
+		char *rport = strdup(fp_hba);
+		port_attrs = get_rport_attribs(rport);
+		if (!port_attrs) {
+			free(rport);
+			return 0;
+		}
+		strncpy(fp_dev, rport, sizeof(fp_dev));
+		free(rport);
+		return 1;
 	} else if (strstr(fp_hba, ":")) {
 		if (strlen(fp_hba) == strlen("xx:yy:aa:bb:cc:dd:ee:ff")) {
 			fc_wwn_t wwn1;
@@ -826,10 +837,16 @@  send_els_echo(int fp_fd, void *fp_buf, uint32_t fp_len,
 {
 	struct fc_bsg_request cdb;
 	char sense[MAX_SENSE_LEN];
+	char *rport;
 	struct sg_io_v4 sg_io;
 	int rc;
 
-	cdb.msgcode = FC_BSG_HST_ELS_NOLOGIN;
+	rport = get_rport_by_fcid(fp_did);
+	if (rport)
+		cdb.msgcode = FC_BSG_RPT_ELS;
+	else
+		cdb.msgcode = FC_BSG_HST_ELS_NOLOGIN;
+
 	cdb.rqst_data.h_els.command_code = ELS_ECHO;
 	hton24(cdb.rqst_data.h_els.port_id, fp_did);