Browse Source

[fcoe] Create Fibre Channel port only when we have selected an FCF

Create the Fibre Channel port only when the FCoE port has selected a
Fibre Channel Forwarder to use.  This avoids the confusion of having
an FC port created for the network device on which only VLAN discovery
is performed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
d17e87da7d
1 changed files with 21 additions and 10 deletions
  1. 21
    10
      src/net/fcoe.c

+ 21
- 10
src/net/fcoe.c View File

180
  */
180
  */
181
 static void fcoe_reset ( struct fcoe_port *fcoe ) {
181
 static void fcoe_reset ( struct fcoe_port *fcoe ) {
182
 
182
 
183
+	/* Detach FC port, if any */
184
+	intf_restart ( &fcoe->transport, -ECANCELED );
185
+
183
 	/* Reset any FIP state */
186
 	/* Reset any FIP state */
184
 	stop_timer ( &fcoe->timer );
187
 	stop_timer ( &fcoe->timer );
185
 	fcoe->timeouts = 0;
188
 	fcoe->timeouts = 0;
995
 static void fcoe_expired ( struct retry_timer *timer, int over __unused ) {
998
 static void fcoe_expired ( struct retry_timer *timer, int over __unused ) {
996
 	struct fcoe_port *fcoe =
999
 	struct fcoe_port *fcoe =
997
 		container_of ( timer, struct fcoe_port, timer );
1000
 		container_of ( timer, struct fcoe_port, timer );
1001
+	int rc;
998
 
1002
 
999
 	/* Sanity check */
1003
 	/* Sanity check */
1000
 	assert ( fcoe->flags & FCOE_HAVE_NETWORK );
1004
 	assert ( fcoe->flags & FCOE_HAVE_NETWORK );
1043
 		 * and we have not yet timed out and given up on
1047
 		 * and we have not yet timed out and given up on
1044
 		 * finding one, then send a FIP solicitation and wait.
1048
 		 * finding one, then send a FIP solicitation and wait.
1045
 		 */
1049
 		 */
1050
+		start_timer_fixed ( &fcoe->timer, FCOE_FIP_RETRY_DELAY );
1046
 		if ( ( ! ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) &&
1051
 		if ( ( ! ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) &&
1047
 		     ( fcoe->timeouts <= FCOE_MAX_FIP_SOLICITATIONS ) ) {
1052
 		     ( fcoe->timeouts <= FCOE_MAX_FIP_SOLICITATIONS ) ) {
1048
-			start_timer_fixed ( &fcoe->timer,
1049
-					    FCOE_FIP_RETRY_DELAY );
1050
 			fcoe_fip_tx_solicitation ( fcoe );
1053
 			fcoe_fip_tx_solicitation ( fcoe );
1051
 			return;
1054
 			return;
1052
 		}
1055
 		}
1053
 
1056
 
1057
+		/* Attach Fibre Channel port */
1058
+		if ( ( rc = fc_port_open ( &fcoe->transport, &fcoe->node_wwn.fc,
1059
+					   &fcoe->port_wwn.fc ) ) != 0 ) {
1060
+			DBGC ( fcoe, "FCoE %s could not create FC port: %s\n",
1061
+			       fcoe->netdev->name, strerror ( rc ) );
1062
+			/* We will try again on the next timer expiry */
1063
+			return;
1064
+		}
1065
+		stop_timer ( &fcoe->timer );
1066
+
1054
 		/* Either we have found a FIP-capable forwarder, or we
1067
 		/* Either we have found a FIP-capable forwarder, or we
1055
 		 * have timed out and will fall back to pre-FIP mode.
1068
 		 * have timed out and will fall back to pre-FIP mode.
1056
 		 */
1069
 		 */
1125
 	       fc_ntoa ( &fcoe->node_wwn.fc ) );
1138
 	       fc_ntoa ( &fcoe->node_wwn.fc ) );
1126
 	DBGC ( fcoe, " port %s\n", fc_ntoa ( &fcoe->port_wwn.fc ) );
1139
 	DBGC ( fcoe, " port %s\n", fc_ntoa ( &fcoe->port_wwn.fc ) );
1127
 
1140
 
1128
-	/* Attach Fibre Channel port */
1129
-	if ( ( rc = fc_port_open ( &fcoe->transport, &fcoe->node_wwn.fc,
1130
-				   &fcoe->port_wwn.fc ) ) != 0 )
1131
-		goto err_fc_create;
1132
-
1133
 	/* Transfer reference to port list */
1141
 	/* Transfer reference to port list */
1134
 	list_add ( &fcoe->list, &fcoe_ports );
1142
 	list_add ( &fcoe->list, &fcoe_ports );
1135
 	return 0;
1143
 	return 0;
1136
 
1144
 
1137
- err_fc_create:
1138
 	netdev_put ( fcoe->netdev );
1145
 	netdev_put ( fcoe->netdev );
1139
  err_zalloc:
1146
  err_zalloc:
1140
  err_non_ethernet:
1147
  err_non_ethernet:
1156
 		return;
1163
 		return;
1157
 	}
1164
 	}
1158
 
1165
 
1159
-	/* Reset the FCoE link */
1160
-	fcoe_reset ( fcoe );
1166
+	/* Reset the FCoE link if necessary */
1167
+	if ( ! ( netdev_is_open ( netdev ) &&
1168
+		 netdev_link_ok ( netdev ) &&
1169
+		 ( fcoe->flags & FCOE_HAVE_NETWORK ) ) ) {
1170
+		fcoe_reset ( fcoe );
1171
+	}
1161
 }
1172
 }
1162
 
1173
 
1163
 /**
1174
 /**

Loading…
Cancel
Save