Browse Source

[fc] Use port WWN rather than node WWN as the primary Fibre Channel name

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
60b690141e
4 changed files with 41 additions and 42 deletions
  1. 4
    4
      src/include/ipxe/fc.h
  2. 31
    31
      src/net/fc.c
  3. 1
    1
      src/net/fcels.c
  4. 5
    6
      src/usr/fcmgmt.c

+ 4
- 4
src/include/ipxe/fc.h View File

335
 	/** List of all peers */
335
 	/** List of all peers */
336
 	struct list_head list;
336
 	struct list_head list;
337
 
337
 
338
-	/** Node name */
339
-	struct fc_name node_wwn;
338
+	/** Port name */
339
+	struct fc_name port_wwn;
340
 
340
 
341
 	/** Link state monitor */
341
 	/** Link state monitor */
342
 	struct fc_link_state link;
342
 	struct fc_link_state link;
377
 
377
 
378
 extern struct list_head fc_peers;
378
 extern struct list_head fc_peers;
379
 
379
 
380
-extern struct fc_peer * fc_peer_get_wwn ( const struct fc_name *node_wwn );
380
+extern struct fc_peer * fc_peer_get_wwn ( const struct fc_name *port_wwn );
381
 extern struct fc_peer *
381
 extern struct fc_peer *
382
 fc_peer_get_port_id ( struct fc_port *port,
382
 fc_peer_get_port_id ( struct fc_port *port,
383
 		      const struct fc_port_id *peer_port_id );
383
 		      const struct fc_port_id *peer_port_id );
448
 	ref_put ( &ulp->refcnt );
448
 	ref_put ( &ulp->refcnt );
449
 }
449
 }
450
 
450
 
451
-extern struct fc_ulp * fc_ulp_get_wwn_type ( const struct fc_name *node_wwn,
451
+extern struct fc_ulp * fc_ulp_get_wwn_type ( const struct fc_name *port_wwn,
452
 					     unsigned int type );
452
 					     unsigned int type );
453
 extern struct fc_ulp *
453
 extern struct fc_ulp *
454
 fc_ulp_get_port_id_type ( struct fc_port *port,
454
 fc_ulp_get_port_id_type ( struct fc_port *port,

+ 31
- 31
src/net/fc.c View File

1159
 /**
1159
 /**
1160
  * Find Fibre Channel port by link node name
1160
  * Find Fibre Channel port by link node name
1161
  *
1161
  *
1162
- * @v link_node_wwn	Link node name
1162
+ * @v link_port_wwn	Link node name
1163
  * @ret port		Fibre Channel port, or NULL
1163
  * @ret port		Fibre Channel port, or NULL
1164
  */
1164
  */
1165
 static struct fc_port *
1165
 static struct fc_port *
1166
-fc_port_find_link_wwn ( struct fc_name *link_node_wwn ) {
1166
+fc_port_find_link_wwn ( struct fc_name *link_port_wwn ) {
1167
 	struct fc_port *port;
1167
 	struct fc_port *port;
1168
 
1168
 
1169
 	list_for_each_entry ( port, &fc_ports, list ) {
1169
 	list_for_each_entry ( port, &fc_ports, list ) {
1170
 		if ( fc_link_ok ( &port->link ) &&
1170
 		if ( fc_link_ok ( &port->link ) &&
1171
-		     ( memcmp ( &port->link_node_wwn, link_node_wwn,
1172
-				sizeof ( port->link_node_wwn ) ) == 0 ) ) {
1171
+		     ( memcmp ( &port->link_port_wwn, link_port_wwn,
1172
+				sizeof ( port->link_port_wwn ) ) == 0 ) ) {
1173
 			return port;
1173
 			return port;
1174
 		}
1174
 		}
1175
 	}
1175
 	}
1192
 static void fc_peer_close ( struct fc_peer *peer, int rc ) {
1192
 static void fc_peer_close ( struct fc_peer *peer, int rc ) {
1193
 
1193
 
1194
 	DBGC ( peer, "FCPEER %s closed: %s\n",
1194
 	DBGC ( peer, "FCPEER %s closed: %s\n",
1195
-	       fc_ntoa ( &peer->node_wwn ) , strerror ( rc ) );
1195
+	       fc_ntoa ( &peer->port_wwn ) , strerror ( rc ) );
1196
 
1196
 
1197
 	/* Sanity check */
1197
 	/* Sanity check */
1198
 	assert ( list_empty ( &peer->ulps ) );
1198
 	assert ( list_empty ( &peer->ulps ) );
1263
 		peer->port = fc_port_get ( port );
1263
 		peer->port = fc_port_get ( port );
1264
 		memcpy ( &peer->port_id, port_id, sizeof ( peer->port_id ) );
1264
 		memcpy ( &peer->port_id, port_id, sizeof ( peer->port_id ) );
1265
 		DBGC ( peer, "FCPEER %s logged in via %s as %s\n",
1265
 		DBGC ( peer, "FCPEER %s logged in via %s as %s\n",
1266
-		       fc_ntoa ( &peer->node_wwn ), peer->port->name,
1266
+		       fc_ntoa ( &peer->port_wwn ), peer->port->name,
1267
 		       fc_id_ntoa ( &peer->port_id ) );
1267
 		       fc_id_ntoa ( &peer->port_id ) );
1268
 
1268
 
1269
 		/* Add login reference */
1269
 		/* Add login reference */
1291
 	struct fc_ulp *tmp;
1291
 	struct fc_ulp *tmp;
1292
 
1292
 
1293
 	DBGC ( peer, "FCPEER %s logged out: %s\n",
1293
 	DBGC ( peer, "FCPEER %s logged out: %s\n",
1294
-	       fc_ntoa ( &peer->node_wwn ), strerror ( rc ) );
1294
+	       fc_ntoa ( &peer->port_wwn ), strerror ( rc ) );
1295
 
1295
 
1296
 	/* Drop login reference, if applicable */
1296
 	/* Drop login reference, if applicable */
1297
 	if ( fc_link_ok ( &peer->link ) )
1297
 	if ( fc_link_ok ( &peer->link ) )
1349
 		return;
1349
 		return;
1350
 
1350
 
1351
 	DBGC ( peer, "FCPEER %s attempting login\n",
1351
 	DBGC ( peer, "FCPEER %s attempting login\n",
1352
-	       fc_ntoa ( &peer->node_wwn ) );
1352
+	       fc_ntoa ( &peer->port_wwn ) );
1353
 
1353
 
1354
 	/* Sanity check */
1354
 	/* Sanity check */
1355
 	assert ( peer->port == NULL );
1355
 	assert ( peer->port == NULL );
1356
 
1356
 
1357
 	/* Look for a port with the peer attached via a point-to-point link */
1357
 	/* Look for a port with the peer attached via a point-to-point link */
1358
-	port = fc_port_find_link_wwn ( &peer->node_wwn );
1358
+	port = fc_port_find_link_wwn ( &peer->port_wwn );
1359
 	if ( ! port ) {
1359
 	if ( ! port ) {
1360
 		DBGC ( peer, "FCPEER %s could not find a point-to-point "
1360
 		DBGC ( peer, "FCPEER %s could not find a point-to-point "
1361
-		       "link\n", fc_ntoa ( &peer->node_wwn ) );
1361
+		       "link\n", fc_ntoa ( &peer->port_wwn ) );
1362
 		fc_peer_logout ( peer, -ENOENT );
1362
 		fc_peer_logout ( peer, -ENOENT );
1363
 		return;
1363
 		return;
1364
 	}
1364
 	}
1368
 	intf_restart ( &peer->plogi, -ECANCELED );
1368
 	intf_restart ( &peer->plogi, -ECANCELED );
1369
 	if ( ( rc = fc_els_plogi ( &peer->plogi, port, peer_port_id ) ) != 0 ) {
1369
 	if ( ( rc = fc_els_plogi ( &peer->plogi, port, peer_port_id ) ) != 0 ) {
1370
 		DBGC ( peer, "FCPEER %s could not initiate PLOGI: %s\n",
1370
 		DBGC ( peer, "FCPEER %s could not initiate PLOGI: %s\n",
1371
-		       fc_ntoa ( &peer->node_wwn ), strerror ( rc ) );
1371
+		       fc_ntoa ( &peer->port_wwn ), strerror ( rc ) );
1372
 		fc_peer_logout ( peer, rc );
1372
 		fc_peer_logout ( peer, rc );
1373
 		return;
1373
 		return;
1374
 	}
1374
 	}
1386
 /**
1386
 /**
1387
  * Create Fibre Channel peer
1387
  * Create Fibre Channel peer
1388
  *
1388
  *
1389
- * @v node_wwn		Node name
1389
+ * @v port_wwn		Node name
1390
  * @ret peer		Fibre Channel peer, or NULL
1390
  * @ret peer		Fibre Channel peer, or NULL
1391
  */
1391
  */
1392
-static struct fc_peer * fc_peer_create ( const struct fc_name *node_wwn ) {
1392
+static struct fc_peer * fc_peer_create ( const struct fc_name *port_wwn ) {
1393
 	struct fc_peer *peer;
1393
 	struct fc_peer *peer;
1394
 
1394
 
1395
 	/* Allocate and initialise structure */
1395
 	/* Allocate and initialise structure */
1400
 	fc_link_init ( &peer->link, fc_peer_examine, &peer->refcnt );
1400
 	fc_link_init ( &peer->link, fc_peer_examine, &peer->refcnt );
1401
 	intf_init ( &peer->plogi, &fc_peer_plogi_desc, &peer->refcnt );
1401
 	intf_init ( &peer->plogi, &fc_peer_plogi_desc, &peer->refcnt );
1402
 	list_add_tail ( &peer->list, &fc_peers );
1402
 	list_add_tail ( &peer->list, &fc_peers );
1403
-	memcpy ( &peer->node_wwn, node_wwn, sizeof ( peer->node_wwn ) );
1403
+	memcpy ( &peer->port_wwn, port_wwn, sizeof ( peer->port_wwn ) );
1404
 	INIT_LIST_HEAD ( &peer->ulps );
1404
 	INIT_LIST_HEAD ( &peer->ulps );
1405
 
1405
 
1406
 	/* Start link monitor */
1406
 	/* Start link monitor */
1407
 	fc_link_start ( &peer->link );
1407
 	fc_link_start ( &peer->link );
1408
 
1408
 
1409
-	DBGC ( peer, "FCPEER %s created\n", fc_ntoa ( &peer->node_wwn ) );
1409
+	DBGC ( peer, "FCPEER %s created\n", fc_ntoa ( &peer->port_wwn ) );
1410
 	return peer;
1410
 	return peer;
1411
 }
1411
 }
1412
 
1412
 
1413
 /**
1413
 /**
1414
  * Get Fibre Channel peer by node name
1414
  * Get Fibre Channel peer by node name
1415
  *
1415
  *
1416
- * @v node_wwn		Node name
1416
+ * @v port_wwn		Node name
1417
  * @ret peer		Fibre Channel peer, or NULL
1417
  * @ret peer		Fibre Channel peer, or NULL
1418
  */
1418
  */
1419
-struct fc_peer * fc_peer_get_wwn ( const struct fc_name *node_wwn ) {
1419
+struct fc_peer * fc_peer_get_wwn ( const struct fc_name *port_wwn ) {
1420
 	struct fc_peer *peer;
1420
 	struct fc_peer *peer;
1421
 
1421
 
1422
 	/* Look for an existing peer */
1422
 	/* Look for an existing peer */
1423
 	list_for_each_entry ( peer, &fc_peers, list ) {
1423
 	list_for_each_entry ( peer, &fc_peers, list ) {
1424
-		if ( memcmp ( &peer->node_wwn, node_wwn,
1425
-			      sizeof ( peer->node_wwn ) ) == 0 )
1424
+		if ( memcmp ( &peer->port_wwn, port_wwn,
1425
+			      sizeof ( peer->port_wwn ) ) == 0 )
1426
 			return fc_peer_get ( peer );
1426
 			return fc_peer_get ( peer );
1427
 	}
1427
 	}
1428
 
1428
 
1429
 	/* Create a new peer */
1429
 	/* Create a new peer */
1430
-	peer = fc_peer_create ( node_wwn );
1430
+	peer = fc_peer_create ( port_wwn );
1431
 	if ( ! peer )
1431
 	if ( ! peer )
1432
 		return NULL;
1432
 		return NULL;
1433
 
1433
 
1473
 static void fc_ulp_close ( struct fc_ulp *ulp, int rc ) {
1473
 static void fc_ulp_close ( struct fc_ulp *ulp, int rc ) {
1474
 
1474
 
1475
 	DBGC ( ulp, "FCULP %s/%02x closed: %s\n",
1475
 	DBGC ( ulp, "FCULP %s/%02x closed: %s\n",
1476
-	       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type, strerror ( rc ) );
1476
+	       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type, strerror ( rc ) );
1477
 
1477
 
1478
 	/* Sanity check */
1478
 	/* Sanity check */
1479
 	assert ( ulp->usage == 0 );
1479
 	assert ( ulp->usage == 0 );
1555
 		if ( ! ulp->param ) {
1555
 		if ( ! ulp->param ) {
1556
 			DBGC ( ulp, "FCULP %s/%02x could not record "
1556
 			DBGC ( ulp, "FCULP %s/%02x could not record "
1557
 			       "parameters\n",
1557
 			       "parameters\n",
1558
-			       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type );
1558
+			       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1559
 			return -ENOMEM;
1559
 			return -ENOMEM;
1560
 		}
1560
 		}
1561
 		memcpy ( ulp->param, param, param_len );
1561
 		memcpy ( ulp->param, param, param_len );
1562
 		ulp->param_len = param_len;
1562
 		ulp->param_len = param_len;
1563
 		DBGC ( ulp, "FCULP %s/%02x logged in with parameters:\n",
1563
 		DBGC ( ulp, "FCULP %s/%02x logged in with parameters:\n",
1564
-		       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type );
1564
+		       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1565
 		DBGC_HDA ( ulp, 0, ulp->param, ulp->param_len );
1565
 		DBGC_HDA ( ulp, 0, ulp->param, ulp->param_len );
1566
 
1566
 
1567
 		/* Add login reference */
1567
 		/* Add login reference */
1581
 	if ( ! ( ulp->flags & FC_ULP_ORIGINATED_LOGIN_OK ) ) {
1581
 	if ( ! ( ulp->flags & FC_ULP_ORIGINATED_LOGIN_OK ) ) {
1582
 		DBGC ( ulp, "FCULP %s/%02x sending extra PRLI to work around "
1582
 		DBGC ( ulp, "FCULP %s/%02x sending extra PRLI to work around "
1583
 		       "Linux bug\n",
1583
 		       "Linux bug\n",
1584
-		       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type );
1584
+		       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1585
 		fc_link_start ( &ulp->link );
1585
 		fc_link_start ( &ulp->link );
1586
 	}
1586
 	}
1587
 
1587
 
1597
 void fc_ulp_logout ( struct fc_ulp *ulp, int rc ) {
1597
 void fc_ulp_logout ( struct fc_ulp *ulp, int rc ) {
1598
 
1598
 
1599
 	DBGC ( ulp, "FCULP %s/%02x logged out: %s\n",
1599
 	DBGC ( ulp, "FCULP %s/%02x logged out: %s\n",
1600
-	       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type, strerror ( rc ) );
1600
+	       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type, strerror ( rc ) );
1601
 
1601
 
1602
 	/* Drop login reference, if applicable */
1602
 	/* Drop login reference, if applicable */
1603
 	if ( fc_link_ok ( &ulp->link ) )
1603
 	if ( fc_link_ok ( &ulp->link ) )
1652
 		return;
1652
 		return;
1653
 
1653
 
1654
 	DBGC ( ulp, "FCULP %s/%02x attempting login\n",
1654
 	DBGC ( ulp, "FCULP %s/%02x attempting login\n",
1655
-	       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type );
1655
+	       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1656
 
1656
 
1657
 	/* Try to create PRLI ELS */
1657
 	/* Try to create PRLI ELS */
1658
 	intf_restart ( &ulp->prli, -ECANCELED );
1658
 	intf_restart ( &ulp->prli, -ECANCELED );
1659
 	if ( ( rc = fc_els_prli ( &ulp->prli, ulp->peer->port,
1659
 	if ( ( rc = fc_els_prli ( &ulp->prli, ulp->peer->port,
1660
 				  &ulp->peer->port_id, ulp->type ) ) != 0 ) {
1660
 				  &ulp->peer->port_id, ulp->type ) ) != 0 ) {
1661
 		DBGC ( ulp, "FCULP %s/%02x could not initiate PRLI: %s\n",
1661
 		DBGC ( ulp, "FCULP %s/%02x could not initiate PRLI: %s\n",
1662
-		       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type,
1662
+		       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type,
1663
 		       strerror ( rc ) );
1663
 		       strerror ( rc ) );
1664
 		fc_ulp_logout ( ulp, rc );
1664
 		fc_ulp_logout ( ulp, rc );
1665
 		return;
1665
 		return;
1701
 	fc_link_start ( &ulp->link );
1701
 	fc_link_start ( &ulp->link );
1702
 
1702
 
1703
 	DBGC ( ulp, "FCULP %s/%02x created\n",
1703
 	DBGC ( ulp, "FCULP %s/%02x created\n",
1704
-	       fc_ntoa ( &ulp->peer->node_wwn ), ulp->type );
1704
+	       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1705
 	return ulp;
1705
 	return ulp;
1706
 }
1706
 }
1707
 
1707
 
1733
 /**
1733
 /**
1734
  * Get Fibre Channel upper-layer protocol by port name and type
1734
  * Get Fibre Channel upper-layer protocol by port name and type
1735
  *
1735
  *
1736
- * @v node_wwn		Port name
1736
+ * @v port_wwn		Port name
1737
  * @v type		Type
1737
  * @v type		Type
1738
  * @ret ulp		Fibre Channel upper-layer protocol, or NULL
1738
  * @ret ulp		Fibre Channel upper-layer protocol, or NULL
1739
  */
1739
  */
1740
-struct fc_ulp * fc_ulp_get_wwn_type ( const struct fc_name *node_wwn,
1740
+struct fc_ulp * fc_ulp_get_wwn_type ( const struct fc_name *port_wwn,
1741
 				      unsigned int type ) {
1741
 				      unsigned int type ) {
1742
 	struct fc_ulp *ulp;
1742
 	struct fc_ulp *ulp;
1743
 	struct fc_peer *peer;
1743
 	struct fc_peer *peer;
1744
 
1744
 
1745
 	/* Get peer */
1745
 	/* Get peer */
1746
-	peer = fc_peer_get_wwn ( node_wwn );
1746
+	peer = fc_peer_get_wwn ( port_wwn );
1747
 	if ( ! peer )
1747
 	if ( ! peer )
1748
 		goto err_peer_get_wwn;
1748
 		goto err_peer_get_wwn;
1749
 
1749
 

+ 1
- 1
src/net/fcels.c View File

677
 	       fc_id_ntoa ( &els->peer_port_id ) );
677
 	       fc_id_ntoa ( &els->peer_port_id ) );
678
 
678
 
679
 	/* Get peer */
679
 	/* Get peer */
680
-	peer = fc_peer_get_wwn ( &plogi->node_wwn );
680
+	peer = fc_peer_get_wwn ( &plogi->port_wwn );
681
 	if ( ! peer ) {
681
 	if ( ! peer ) {
682
 		DBGC ( els, FCELS_FMT " could not create peer\n",
682
 		DBGC ( els, FCELS_FMT " could not create peer\n",
683
 		       FCELS_ARGS ( els ) );
683
 		       FCELS_ARGS ( els ) );

+ 5
- 6
src/usr/fcmgmt.c View File

38
  * @v port		Fibre Channel port
38
  * @v port		Fibre Channel port
39
  */
39
  */
40
 void fcportstat ( struct fc_port *port ) {
40
 void fcportstat ( struct fc_port *port ) {
41
-	printf ( "%s: %s", port->name, fc_ntoa ( &port->node_wwn ) );
42
-	printf ( " port %s id %s\n  [Link:", fc_ntoa ( &port->port_wwn ),
41
+	printf ( "%s: %s id %s", port->name, fc_ntoa ( &port->port_wwn ),
43
 		 fc_id_ntoa ( &port->port_id ) );
42
 		 fc_id_ntoa ( &port->port_id ) );
43
+	printf ( " node %s\n  [Link:", fc_ntoa ( &port->node_wwn ) );
44
 	if ( fc_link_ok ( &port->link ) ) {
44
 	if ( fc_link_ok ( &port->link ) ) {
45
-		printf ( " up, %s", fc_ntoa ( &port->link_node_wwn ) );
46
-		printf ( " port %s", fc_ntoa ( &port->link_port_wwn ) );
45
+		printf ( " up, %s", fc_ntoa ( &port->link_port_wwn ) );
47
 		if ( ( port->flags & FC_PORT_HAS_FABRIC ) ) {
46
 		if ( ( port->flags & FC_PORT_HAS_FABRIC ) ) {
48
 			printf ( " fabric" );
47
 			printf ( " fabric" );
49
 		} else {
48
 		} else {
50
 			printf ( " id %s",
49
 			printf ( " id %s",
51
 				 fc_id_ntoa ( &port->ptp_link_port_id ) );
50
 				 fc_id_ntoa ( &port->ptp_link_port_id ) );
52
 		}
51
 		}
53
-		printf ( "]\n" );
52
+		printf ( " node %s]\n", fc_ntoa ( &port->link_node_wwn ) );
54
 	} else {
53
 	} else {
55
 		printf ( " down: %s]\n", strerror ( port->link.rc ) );
54
 		printf ( " down: %s]\n", strerror ( port->link.rc ) );
56
 	}
55
 	}
66
 	uint8_t *param;
65
 	uint8_t *param;
67
 	unsigned int i;
66
 	unsigned int i;
68
 
67
 
69
-	printf ( "%s:\n  [Link:", fc_ntoa ( &peer->node_wwn ) );
68
+	printf ( "%s:\n  [Link:", fc_ntoa ( &peer->port_wwn ) );
70
 	if ( fc_link_ok ( &peer->link ) ) {
69
 	if ( fc_link_ok ( &peer->link ) ) {
71
 		printf ( " up, port %s id %s]\n", peer->port->name,
70
 		printf ( " up, port %s id %s]\n", peer->port->name,
72
 			 fc_id_ntoa ( &peer->port_id ) );
71
 			 fc_id_ntoa ( &peer->port_id ) );

Loading…
Cancel
Save