Skip to contentSkip to conversation

Updates to libfc, libfcoe, fcoe and fnic

PATCH New Robert Love 1 participant 13 messages Apr 9, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Updates to libfc, libfcoe, fcoe and fnic

The following series implements a few fixes to libfc, libfcoe and fcoe.

These patches were applied and tested against scsi-misc before submission.

---

Brian Uchino (2):
fnic: Change fnic_flush_tx() to flush tx instead of rx queue
fnic: Update version to 1.4.0.145

Chris Leech (4):
libfc, fcoe: normalize format specifies for world wide names
libfc: set both precision and field with when printing FC IDs
fcoe: check netif operstate instead of IFF_UP & link state
fcoe: reset FIP ctlr link state on disable/enable

Joe Eykholt (2):
libfc: fix hton24 macro to take expressions as args
libfc: remove unneeded variables in fc_exch_recv_req()

Robert Love (1):
libfcoe: Don't fill MAC desc in FLOGI if FIP negotiated FPMA

Vasu Dev (2):
fcoe, fnic, libfc: increased CDB size to 16 bytes for fcoe.
fcoe: removes unused shost in fcoe_shost_config

Yi Zou (1):
libfc: bug in erroring out upon FCP_RSP_LEN_VAL in fc_fcp_resp

 drivers/scsi/fcoe/fcoe.c      |   27 ++++++++++++++-------------
 drivers/scsi/fcoe/libfcoe.c   |   30 +++++++++++++++++++-----------
 drivers/scsi/fnic/fnic.h      |    4 ++--
 drivers/scsi/fnic/fnic_fcs.c  |    2 +-
 drivers/scsi/fnic/fnic_main.c |    2 +-
 drivers/scsi/libfc/fc_disc.c  |    6 +++---
 drivers/scsi/libfc/fc_exch.c  |    6 ------
 drivers/scsi/libfc/fc_fcp.c   |   19 +++++++++----------
 drivers/scsi/libfc/fc_libfc.h |    6 +++---
 drivers/scsi/libfc/fc_lport.c |   18 +++++++++---------
 include/scsi/libfc.h          |   17 +++++++++++------
 include/scsi/libfcoe.h        |    2 ++
 12 files changed, 74 insertions(+), 65 deletions(-)
Signature · 1 line
//Rob
#1 lore raw

PATCH 1/12 libfcoe: Don't fill MAC desc in FLOGI if FIP negotiated FPMA

FPMA indicates that the Fabric will provide the host's N_Port's MAC address. When sending a FLOGI/FDISC frame and FPMA was negotiated through FIP discovery we still need to provide the MAC descriptor, as per the specification, but the MAC should be zero'd out since the FCF will be providing it in the FLOGI/FDISC ACC.

In FC-BB-5 section 7.8.7.4.2 (Fabric login) it states:

The MAC address field in the MAC address descriptor of a FIP FLOGI Request operation or a FIP NPIV FDISC Request operation shall contain:
a) the proposed MAC address to use as VN_Port MAC address if the ENode is requesting to use SPMA (see table 27);
b) all zeroes to indicate no MAC address is proposed if the ENode is requesting to use FPMA (see table 27); or
c) the proposed MAC address to use as VN_Port MAC address if the ENode supports both SPMA and FPMA and leaves the decision of which addressing scheme to use to the FCF (i.e., if both the FP and SP bits are set to one, see table 27).

This patch fixes case B.

This patch also adds debug statements to illustrate whether a FPMA or SPMA MAC is added to a FLOGI/FDISC frame.

---

 drivers/scsi/fcoe/libfcoe.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/fcoe/libfcoe.c +7 -2
index ff5ccba..de5c329 100644
@@ -442,10 +442,15 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
 	memset(mac, 0, sizeof(mac));
 	mac->fd_desc.fip_dtype = FIP_DT_MAC;
 	mac->fd_desc.fip_dlen = sizeof(*mac) / FIP_BPW;
-	if (dtype != FIP_DT_FLOGI && dtype != FIP_DT_FDISC)
+	if (dtype != FIP_DT_FLOGI && dtype != FIP_DT_FDISC) {
 		memcpy(mac->fd_mac, fip->get_src_addr(lport), ETH_ALEN);
-	else if (fip->spma)
+	} else if (fip_flags & FIP_FL_SPMA) {
+		LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with SPMA\n");
 		memcpy(mac->fd_mac, fip->ctl_src_addr, ETH_ALEN);
+	} else {
+		LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with FPMA\n");
+		/* FPMA only FLOGI must leave the MAC desc set to all 0s */
+	}
 
 	skb->protocol = htons(ETH_P_FIP);
 	skb_reset_mac_header(skb);
#2 lore raw

PATCH 2/12 fcoe: reset FIP ctlr link state on disable/enable

In reply to Robert Love

From: Chris Leech <[email protected]>

The FIP controler state wasn't being reset on a disable. A disable/enable sequence should be treated as a link event. Otherwise, when using disable to mask a time when the link is up but unusable, FCF discovery would attempt to continue and login would jump directly to the non-FIP fallback on enable.

---

 drivers/scsi/fcoe/fcoe.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/fcoe/fcoe.c +7 -4
index 927b3e6..0d8127e 100644
@@ -1901,9 +1901,10 @@ static int fcoe_disable(const char *buffer, struct kernel_param *kp)
 	fcoe = fcoe_hostlist_lookup_port(netdev);
 	rtnl_unlock();
 
-	if (fcoe)
+	if (fcoe) {
 		fc_fabric_logoff(fcoe->ctlr.lp);
-	else
+		fcoe_ctlr_link_down(&fcoe->ctlr);
+	} else
 		rc = -ENODEV;
 
 	dev_put(netdev);
@@ -1950,9 +1951,11 @@ static int fcoe_enable(const char *buffer, struct kernel_param *kp)
 	fcoe = fcoe_hostlist_lookup_port(netdev);
 	rtnl_unlock();
 
-	if (fcoe)
+	if (fcoe) {
+		if (!fcoe_link_ok(fcoe->ctlr.lp))
+			fcoe_ctlr_link_up(&fcoe->ctlr);
 		rc = fc_fabric_login(fcoe->ctlr.lp);
-	else
+	} else
 		rc = -ENODEV;
 
 	dev_put(netdev);
#3 lore raw

PATCH 3/12 fcoe: check netif operstate instead of IFF_UP & link state

In reply to Robert Love

From: Chris Leech <[email protected]>

Allow for dormant states while link configuration completes. In the default link mode, this is equivalent to the old check.

---

 drivers/scsi/fcoe/fcoe.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/fcoe/fcoe.c +1 -2
index 0d8127e..d16dd12 100644
@@ -2148,8 +2148,7 @@ int fcoe_link_ok(struct fc_lport *lport)
 	struct net_device *netdev = port->fcoe->netdev;
 	struct ethtool_cmd ecmd = { ETHTOOL_GSET };
 
-	if ((netdev->flags & IFF_UP) && netif_carrier_ok(netdev) &&
-	    (!dev_ethtool_get_settings(netdev, &ecmd))) {
+	if (netif_oper_up(netdev) && !dev_ethtool_get_settings(netdev, &ecmd)) {
 		lport->link_supported_speeds &=
 			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
 		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
#4 lore raw

PATCH 4/12 libfc: remove unneeded variables in fc_exch_recv_req()

In reply to Robert Love

From: Joe Eykholt <[email protected]>

fc_exch_recv_req has variables eof, sof, and f_ctl, which are set but never used. Delete them.

---

 drivers/scsi/libfc/fc_exch.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/scsi/libfc/fc_exch.c +0 -6
index d0496da..daff880 100644
@@ -1241,9 +1241,6 @@ static void fc_exch_recv_req(struct fc_lport *lport, struct fc_exch_mgr *mp,
 	struct fc_frame_header *fh = fc_frame_header_get(fp);
 	struct fc_seq *sp = NULL;
 	struct fc_exch *ep = NULL;
-	enum fc_sof sof;
-	enum fc_eof eof;
-	u32 f_ctl;
 	enum fc_pf_rjt_reason reject;
 
 	/* We can have the wrong fc_lport at this point with NPIV, which is a
@@ -1260,9 +1257,6 @@ static void fc_exch_recv_req(struct fc_lport *lport, struct fc_exch_mgr *mp,
 	if (reject == FC_RJT_NONE) {
 		sp = fr_seq(fp);	/* sequence will be held */
 		ep = fc_seq_exch(sp);
-		sof = fr_sof(fp);
-		eof = fr_eof(fp);
-		f_ctl = ntoh24(fh->fh_f_ctl);
 		fc_seq_send_ack(sp, fp);
 
 		/*
#5 lore raw

PATCH 5/12 libfc: fix hton24 macro to take expressions as args

In reply to Robert Love

From: Joe Eykholt <[email protected]>

hton24(p + 3, value) would fail to compile because p + 3[0] is not a valid expression.

Went ahead and converted hton24 and ntoh24 to inline functions, which is better because the parameters are evalutated only once.

---

 include/scsi/libfc.h |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
include/scsi/libfc.h +11 -6
index 8d0d1b2..a26bb50 100644
@@ -47,13 +47,18 @@
 #define ntohll(x) be64_to_cpu(x)
 #define htonll(x) cpu_to_be64(x)
 
-#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
 
-#define hton24(p, v)	do {			\
-		p[0] = (((v) >> 16) & 0xFF);	\
-		p[1] = (((v) >> 8) & 0xFF);	\
-		p[2] = ((v) & 0xFF);		\
-	} while (0)
+static inline u32 ntoh24(const u8 *p)
+{
+	return (p[0] << 16) | (p[1] << 8) | p[2];
+}
+
+static inline void hton24(u8 *p, u32 v)
+{
+	p[0] = (v >> 16) & 0xff;
+	p[1] = (v >> 8) & 0xff;
+	p[2] = v & 0xff;
+}
 
 /**
  * enum fc_lport_state - Local port states
#6 lore raw

PATCH 6/12 fnic: Update version to 1.4.0.145

In reply to Robert Love

From: Brian Uchino <[email protected]>

New fnic version to mark inclusion of tx_flush bugfix.

---

 drivers/scsi/fnic/fnic.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index 3966c71..585cc9c 100644
@@ -36,7 +36,7 @@
 
 #define DRV_NAME		"fnic"
 #define DRV_DESCRIPTION		"Cisco FCoE HBA Driver"
-#define DRV_VERSION		"1.4.0.98"
+#define DRV_VERSION		"1.4.0.145"
 #define PFX			DRV_NAME ": "
 #define DFX                     DRV_NAME "%d: "
 
#7 lore raw

PATCH 7/12 fnic: Change fnic_flush_tx() to flush tx instead of rx queue

In reply to Robert Love

From: Brian Uchino <[email protected]>

fnic_flush_tx() is used to send frames held while fabric login is in progress. The frames are held in tx_queue, but fnic_flush_tx() was incorrectly flushing from recv_queue which is used for received frames.

---

 drivers/scsi/fnic/fnic_fcs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/fnic/fnic_fcs.c +1 -1
index 5259888..2b48d79 100644
@@ -617,7 +617,7 @@ void fnic_flush_tx(struct fnic *fnic)
 	struct sk_buff *skb;
 	struct fc_frame *fp;
 
-	while ((skb = skb_dequeue(&fnic->frame_queue))) {
+	while ((skb = skb_dequeue(&fnic->tx_queue))) {
 		fp = (struct fc_frame *)skb;
 		fnic_send_frame(fnic, fp);
 	}
#8 lore raw

PATCH 8/12 fcoe: removes unused shost in fcoe_shost_config

In reply to Robert Love

From: Vasu Dev <[email protected]>

---

 drivers/scsi/fcoe/fcoe.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/fcoe/fcoe.c +2 -6
index d16dd12..4d46b71 100644
@@ -655,15 +655,13 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
 /**
  * fcoe_shost_config() - Set up the SCSI host associated with a local port
  * @lport: The local port
- * @shost: The SCSI host to associate with the local port
  * @dev:   The device associated with the SCSI host
  *
  * Must be called after fcoe_lport_config() and fcoe_netdev_config()
  *
  * Returns: 0 for success
  */
-static int fcoe_shost_config(struct fc_lport *lport, struct Scsi_Host *shost,
-			     struct device *dev)
+static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
 {
 	int rc = 0;
 
@@ -899,7 +897,6 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 	struct net_device *netdev = fcoe->netdev;
 	struct fc_lport *lport = NULL;
 	struct fcoe_port *port;
-	struct Scsi_Host *shost;
 	int rc;
 	/*
 	 * parent is only a vport if npiv is 1,
@@ -921,7 +918,6 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 		rc = -ENOMEM;
 		goto out;
 	}
-	shost = lport->host;
 	port = lport_priv(lport);
 	port->lport = lport;
 	port->fcoe = fcoe;
@@ -951,7 +947,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 	}
 
 	/* configure lport scsi host properties */
-	rc = fcoe_shost_config(lport, shost, parent);
+	rc = fcoe_shost_config(lport, parent);
 	if (rc) {
 		FCOE_NETDEV_DBG(netdev, "Could not configure shost for the "
 				"interface\n");
#9 lore raw

PATCH 9/12 fcoe, fnic, libfc: increased CDB size to 16 bytes for fcoe.

In reply to Robert Love

From: Vasu Dev <[email protected]>

No reason to restrict CDB size to 12 bytes in fcoe, so increased to 16 so that 16 bytes SCSI CDB doesn't fail.

Uses common define to set max_cmd_len for fcoe and fnic, fnic is already setting max_cmd_len to 16.

sg_readcap -l fails without this fix.

---

 drivers/scsi/fcoe/fcoe.c      |    2 ++
 drivers/scsi/fnic/fnic.h      |    2 +-
 drivers/scsi/fnic/fnic_main.c |    2 +-
 include/scsi/libfcoe.h        |    2 ++
 4 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/fcoe/fcoe.c +2 -0
index 4d46b71..25a7ce5 100644
@@ -669,6 +669,8 @@ static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
 	lport->host->max_lun = FCOE_MAX_LUN;
 	lport->host->max_id = FCOE_MAX_FCP_TARGET;
 	lport->host->max_channel = 0;
+	lport->host->max_cmd_len = FCOE_MAX_CMD_LEN;
+
 	if (lport->vport)
 		lport->host->transportt = fcoe_vport_transport_template;
 	else
drivers/scsi/fnic/fnic.h +1 -1
index 585cc9c..19338e0 100644
@@ -45,7 +45,7 @@
 #define	FNIC_IO_LOCKS		64 /* IO locks: power of 2 */
 #define FNIC_DFLT_QUEUE_DEPTH	32
 #define	FNIC_STATS_RATE_LIMIT	4 /* limit rate at which stats are pulled up */
-#define FNIC_MAX_CMD_LEN        16 /* Supported CDB length */
+
 /*
  * Tag bits used for special requests.
  */
drivers/scsi/fnic/fnic_main.c +1 -1
index 97b2125..265e73d 100644
@@ -556,7 +556,7 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
 	}
 	host->max_lun = fnic->config.luns_per_tgt;
 	host->max_id = FNIC_MAX_FCP_TARGET;
-	host->max_cmd_len = FNIC_MAX_CMD_LEN;
+	host->max_cmd_len = FCOE_MAX_CMD_LEN;
 
 	fnic_get_res_counts(fnic);
 
include/scsi/libfcoe.h +2 -0
index 868ed26..ec13f51 100644
@@ -29,6 +29,8 @@
 #include <scsi/fc/fc_fcoe.h>
 #include <scsi/libfc.h>
 
+#define FCOE_MAX_CMD_LEN	16	/* Supported CDB length */
+
 /*
  * FIP tunable parameters.
  */
#10 lore raw

PATCH 10/12 libfc: bug in erroring out upon FCP_RSP_LEN_VAL in fc_fcp_resp

In reply to Robert Love

From: Yi Zou <[email protected]>

fc_fcp_resp is assuming when FCP_SNS_LEN_VAL is set, the FCP_RSP_LEN_VAL is not, which is not true. This leads to not copying the sense data and error out a valid FCP_RSP.

---

 drivers/scsi/libfc/fc_fcp.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/libfc/fc_fcp.c +1 -2
index 220c4bc..f99d66f 100644
@@ -844,8 +844,7 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 					 * exit here
 					 */
 					return;
-				} else
-					goto err;
+				}
 			}
 			if (flags & FCP_SNS_LEN_VAL) {
 				snsl = ntohl(rp_ex->fr_sns_len);
#11 lore raw

PATCH 11/12 libfc: set both precision and field with when printing FC IDs

In reply to Robert Love

From: Chris Leech <[email protected]>

Most of the prints of fabric IDs were specified as %6x, which will not print any leading 0s. It's nice to see leading 0s for identifiers like this, which are a fixed length. This patch sets the precision modifier as well, making the specifier %6.6x, which forces the printing of leading 0s.

---

 drivers/scsi/libfc/fc_disc.c  |    6 +++---
 drivers/scsi/libfc/fc_fcp.c   |   16 ++++++++--------
 drivers/scsi/libfc/fc_libfc.h |    6 +++---
 drivers/scsi/libfc/fc_lport.c |   14 +++++++-------
 4 files changed, 21 insertions(+), 21 deletions(-)
drivers/scsi/libfc/fc_disc.c +3 -3
index 1087a7f..83314a1 100644
@@ -132,7 +132,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
 		switch (fmt) {
 		case ELS_ADDR_FMT_PORT:
 			FC_DISC_DBG(disc, "Port address format for port "
-				    "(%6x)\n", ntoh24(pp->rscn_fid));
+				    "(%6.6x)\n", ntoh24(pp->rscn_fid));
 			dp = kzalloc(sizeof(*dp), GFP_KERNEL);
 			if (!dp) {
 				redisc = 1;
@@ -449,7 +449,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
 			} else {
 				printk(KERN_WARNING "libfc: Failed to allocate "
 				       "memory for the newly discovered port "
-				       "(%6x)\n", ids.port_id);
+				       "(%6.6x)\n", ids.port_id);
 				error = -ENOMEM;
 			}
 		}
@@ -607,7 +607,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
 			rdata->ids.port_name = port_name;
 		else if (rdata->ids.port_name != port_name) {
 			FC_DISC_DBG(disc, "GPN_ID accepted.  WWPN changed. "
-				    "Port-id %x wwpn %llx\n",
+				    "Port-id %6.6x wwpn %llx\n",
 				    rdata->ids.port_id, port_name);
 			lport->tt.rport_logoff(rdata);
 
drivers/scsi/libfc/fc_fcp.c +8 -8
index f99d66f..81a7c97 100644
@@ -489,7 +489,7 @@ crc_err:
 			/* per cpu count, not total count, but OK for limit */
 			if (stats->InvalidCRCCount++ < 5)
 				printk(KERN_WARNING "libfc: CRC error on data "
-				       "frame for port (%6x)\n",
+				       "frame for port (%6.6x)\n",
 				       fc_host_port_id(lport->host));
 			put_cpu();
 			/*
@@ -894,7 +894,7 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 			return;
 		}
 		fsp->status_code = FC_DATA_OVRRUN;
-		FC_FCP_DBG(fsp, "tgt %6x xfer len %zx greater than expected, "
+		FC_FCP_DBG(fsp, "tgt %6.6x xfer len %zx greater than expected, "
 			   "len %x, data len %x\n",
 			   fsp->rport->port_id,
 			   fsp->xfer_len, expected_len, fsp->data_len);
@@ -1562,7 +1562,7 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 		break;
 
 	default:
-		FC_FCP_DBG(fsp, "REC %p fid %x error unexpected error %d\n",
+		FC_FCP_DBG(fsp, "REC %p fid %6.6x error unexpected error %d\n",
 			   fsp, fsp->rport->port_id, error);
 		fsp->status_code = FC_CMD_PLOGO;
 		/* fall through */
@@ -1572,7 +1572,7 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 		 * Assume REC or LS_ACC was lost.
 		 * The exchange manager will have aborted REC, so retry.
 		 */
-		FC_FCP_DBG(fsp, "REC fid %x error error %d retry %d/%d\n",
+		FC_FCP_DBG(fsp, "REC fid %6.6x error error %d retry %d/%d\n",
 			   fsp->rport->port_id, error, fsp->recov_retry,
 			   FC_MAX_RECOV_RETRY);
 		if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY)
@@ -2053,7 +2053,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
 	if (lport->state != LPORT_ST_READY)
 		return rc;
 
-	FC_SCSI_DBG(lport, "Resetting rport (%6x)\n", rport->port_id);
+	FC_SCSI_DBG(lport, "Resetting rport (%6.6x)\n", rport->port_id);
 
 	fsp = fc_fcp_pkt_alloc(lport, GFP_NOIO);
 	if (fsp == NULL) {
@@ -2101,11 +2101,11 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
 
 	if (fc_fcp_lport_queue_ready(lport)) {
 		shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded "
-			     "on port (%6x)\n", fc_host_port_id(lport->host));
+			     "on port (%6.6x)\n", fc_host_port_id(lport->host));
 		return SUCCESS;
 	} else {
 		shost_printk(KERN_INFO, shost, "libfc: Host reset failed, "
-			     "port (%6x) is not ready.\n",
+			     "port (%6.6x) is not ready.\n",
 			     fc_host_port_id(lport->host));
 		return FAILED;
 	}
@@ -2191,7 +2191,7 @@ void fc_fcp_destroy(struct fc_lport *lport)
 
 	if (!list_empty(&si->scsi_pkt_queue))
 		printk(KERN_ERR "libfc: Leaked SCSI packets when destroying "
-		       "port (%6x)\n", fc_host_port_id(lport->host));
+		       "port (%6.6x)\n", fc_host_port_id(lport->host));
 
 	mempool_destroy(si->scsi_pkt_pool);
 	kfree(si);
drivers/scsi/libfc/fc_libfc.h +3 -3
index 741fd5c..efc6b3f 100644
@@ -45,7 +45,7 @@ extern unsigned int fc_debug_logging;
 
 #define FC_LPORT_DBG(lport, fmt, args...)				\
 	FC_CHECK_LOGGING(FC_LPORT_LOGGING,				\
-			 printk(KERN_INFO "host%u: lport %6x: " fmt,	\
+			 printk(KERN_INFO "host%u: lport %6.6x: " fmt,	\
 				(lport)->host->host_no,			\
 				fc_host_port_id((lport)->host), ##args))
 
@@ -57,7 +57,7 @@ extern unsigned int fc_debug_logging;
 
 #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...)			\
 	FC_CHECK_LOGGING(FC_RPORT_LOGGING,				\
-			 printk(KERN_INFO "host%u: rport %6x: " fmt,	\
+			 printk(KERN_INFO "host%u: rport %6.6x: " fmt,	\
 				(lport)->host->host_no,			\
 				(port_id), ##args))
 
@@ -66,7 +66,7 @@ extern unsigned int fc_debug_logging;
 
 #define FC_FCP_DBG(pkt, fmt, args...)					\
 	FC_CHECK_LOGGING(FC_FCP_LOGGING,				\
-			 printk(KERN_INFO "host%u: fcp: %6x: " fmt,	\
+			 printk(KERN_INFO "host%u: fcp: %6.6x: " fmt,	\
 				(pkt)->lp->host->host_no,		\
 				pkt->rport->port_id, ##args))
 
drivers/scsi/libfc/fc_lport.c +7 -7
index a6cf94d..e89bdd5 100644
@@ -172,7 +172,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
 				    struct fc_rport_priv *rdata,
 				    enum fc_rport_event event)
 {
-	FC_LPORT_DBG(lport, "Received a %d event for port (%6x)\n", event,
+	FC_LPORT_DBG(lport, "Received a %d event for port (%6.6x)\n", event,
 		     rdata->ids.port_id);
 
 	mutex_lock(&lport->lp_mutex);
@@ -183,7 +183,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
 			fc_lport_enter_ns(lport, LPORT_ST_RNN_ID);
 		} else {
 			FC_LPORT_DBG(lport, "Received an READY event "
-				     "on port (%6x) for the directory "
+				     "on port (%6.6x) for the directory "
 				     "server, but the lport is not "
 				     "in the DNS state, it's in the "
 				     "%d state", rdata->ids.port_id,
@@ -575,7 +575,7 @@ void __fc_linkup(struct fc_lport *lport)
  */
 void fc_linkup(struct fc_lport *lport)
 {
-	printk(KERN_INFO "host%d: libfc: Link up on port (%6x)\n",
+	printk(KERN_INFO "host%d: libfc: Link up on port (%6.6x)\n",
 	       lport->host->host_no, fc_host_port_id(lport->host));
 
 	mutex_lock(&lport->lp_mutex);
@@ -605,7 +605,7 @@ void __fc_linkdown(struct fc_lport *lport)
  */
 void fc_linkdown(struct fc_lport *lport)
 {
-	printk(KERN_INFO "host%d: libfc: Link down on port (%6x)\n",
+	printk(KERN_INFO "host%d: libfc: Link down on port (%6.6x)\n",
 	       lport->host->host_no, fc_host_port_id(lport->host));
 
 	mutex_lock(&lport->lp_mutex);
@@ -707,7 +707,7 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
 		break;
 	case DISC_EV_FAILED:
 		printk(KERN_ERR "host%d: libfc: "
-		       "Discovery failed for port (%6x)\n",
+		       "Discovery failed for port (%6.6x)\n",
 		       lport->host->host_no, fc_host_port_id(lport->host));
 		mutex_lock(&lport->lp_mutex);
 		fc_lport_enter_reset(lport);
@@ -753,7 +753,7 @@ static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id,
 				 struct fc_frame *fp)
 {
 	if (port_id)
-		printk(KERN_INFO "host%d: Assigned Port ID %6x\n",
+		printk(KERN_INFO "host%d: Assigned Port ID %6.6x\n",
 		       lport->host->host_no, port_id);
 
 	fc_host_port_id(lport->host) = port_id;
@@ -1499,7 +1499,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
 				lport->r_a_tov = 2 * e_d_tov;
 				fc_lport_set_port_id(lport, did, fp);
 				printk(KERN_INFO "host%d: libfc: "
-				       "Port (%6x) entered "
+				       "Port (%6.6x) entered "
 				       "point-to-point mode\n",
 				       lport->host->host_no, did);
 				fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id),
#12 lore raw

PATCH 12/12 libfc, fcoe: normalize format specifies for world wide names

In reply to Robert Love

From: Chris Leech <[email protected]>

Print all world wide node names (node, port and fabric) with the same format specifier of "%16.16llx". That makes sure they all print as a 16 character hex string, with lower case letters, no 0x prefix, and without stripping off any leading 0s.

---

 drivers/scsi/fcoe/fcoe.c      |    3 ++-
 drivers/scsi/fcoe/libfcoe.c   |   21 ++++++++++++---------
 drivers/scsi/libfc/fc_disc.c  |    2 +-
 drivers/scsi/libfc/fc_lport.c |    4 ++--
 4 files changed, 17 insertions(+), 13 deletions(-)
drivers/scsi/fcoe/fcoe.c +2 -1
index 25a7ce5..aba839e 100644
@@ -934,7 +934,8 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 	}
 
 	if (npiv) {
-		FCOE_NETDEV_DBG(netdev, "Setting vport names, 0x%llX 0x%llX\n",
+		FCOE_NETDEV_DBG(netdev, "Setting vport names, "
+				"%16.16llx %16.16llx\n",
 				vport->node_name, vport->port_name);
 		fc_set_wwnn(lport, vport->node_name);
 		fc_set_wwpn(lport, vport->port_name);
drivers/scsi/fcoe/libfcoe.c +12 -9
index de5c329..aadd249 100644
@@ -583,7 +583,7 @@ static void fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip)
 					    smp_processor_id());
 			stats->MissDiscAdvCount++;
 			printk(KERN_INFO "libfcoe: host%d: Missing Discovery "
-			       "Advertisement for fab %llx count %lld\n",
+			       "Advertisement for fab %16.16llx count %lld\n",
 			       fip->lp->host->host_no, fcf->fabric_name,
 			       stats->MissDiscAdvCount);
 		}
@@ -780,7 +780,8 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)
 	mtu_valid = fcoe_ctlr_mtu_valid(fcf);
 	fcf->time = jiffies;
 	if (!found) {
-		LIBFCOE_FIP_DBG(fip, "New FCF for fab %llx map %x val %d\n",
+		LIBFCOE_FIP_DBG(fip, "New FCF for fab %16.16llx "
+				"map %x val %d\n",
 				fcf->fabric_name, fcf->fc_map, mtu_valid);
 	}
 
@@ -1108,15 +1109,17 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
 	struct fcoe_fcf *best = NULL;
 
 	list_for_each_entry(fcf, &fip->fcfs, list) {
-		LIBFCOE_FIP_DBG(fip, "consider FCF for fab %llx VFID %d map %x "
-				"val %d\n", fcf->fabric_name, fcf->vfid,
+		LIBFCOE_FIP_DBG(fip, "consider FCF for fab %16.16llx "
+				"VFID %d map %x val %d\n",
+				fcf->fabric_name, fcf->vfid,
 				fcf->fc_map, fcoe_ctlr_mtu_valid(fcf));
 		if (!fcoe_ctlr_fcf_usable(fcf)) {
-			LIBFCOE_FIP_DBG(fip, "FCF for fab %llx map %x %svalid "
-					"%savailable\n", fcf->fabric_name,
-					fcf->fc_map, (fcf->flags & FIP_FL_SOL)
-					? "" : "in", (fcf->flags & FIP_FL_AVAIL)
-					? "" : "un");
+			LIBFCOE_FIP_DBG(fip, "FCF for fab %16.16llx "
+					"map %x %svalid %savailable\n",
+					fcf->fabric_name, fcf->fc_map,
+					(fcf->flags & FIP_FL_SOL) ? "" : "in",
+					(fcf->flags & FIP_FL_AVAIL) ?
+					"" : "un");
 			continue;
 		}
 		if (!best) {
drivers/scsi/libfc/fc_disc.c +1 -1
index 83314a1..b292272 100644
@@ -607,7 +607,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
 			rdata->ids.port_name = port_name;
 		else if (rdata->ids.port_name != port_name) {
 			FC_DISC_DBG(disc, "GPN_ID accepted.  WWPN changed. "
-				    "Port-id %6.6x wwpn %llx\n",
+				    "Port-id %6.6x wwpn %16.16llx\n",
 				    rdata->ids.port_id, port_name);
 			lport->tt.rport_logoff(rdata);
 
drivers/scsi/libfc/fc_lport.c +2 -2
index e89bdd5..ef25e11 100644
@@ -800,11 +800,11 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in,
 	remote_wwpn = get_unaligned_be64(&flp->fl_wwpn);
 	if (remote_wwpn == lport->wwpn) {
 		printk(KERN_WARNING "host%d: libfc: Received FLOGI from port "
-		       "with same WWPN %llx\n",
+		       "with same WWPN %16.16llx\n",
 		       lport->host->host_no, remote_wwpn);
 		goto out;
 	}
-	FC_LPORT_DBG(lport, "FLOGI from port WWPN %llx\n", remote_wwpn);
+	FC_LPORT_DBG(lport, "FLOGI from port WWPN %16.16llx\n", remote_wwpn);
 
 	/*
 	 * XXX what is the right thing to do for FIDs?