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,6 +180,9 @@ static struct fcoe_port * fcoe_demux ( struct net_device *netdev ) {
180 180
  */
181 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 186
 	/* Reset any FIP state */
184 187
 	stop_timer ( &fcoe->timer );
185 188
 	fcoe->timeouts = 0;
@@ -995,6 +998,7 @@ static int fcoe_fip_rx ( struct io_buffer *iobuf,
995 998
 static void fcoe_expired ( struct retry_timer *timer, int over __unused ) {
996 999
 	struct fcoe_port *fcoe =
997 1000
 		container_of ( timer, struct fcoe_port, timer );
1001
+	int rc;
998 1002
 
999 1003
 	/* Sanity check */
1000 1004
 	assert ( fcoe->flags & FCOE_HAVE_NETWORK );
@@ -1043,14 +1047,23 @@ static void fcoe_expired ( struct retry_timer *timer, int over __unused ) {
1043 1047
 		 * and we have not yet timed out and given up on
1044 1048
 		 * finding one, then send a FIP solicitation and wait.
1045 1049
 		 */
1050
+		start_timer_fixed ( &fcoe->timer, FCOE_FIP_RETRY_DELAY );
1046 1051
 		if ( ( ! ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) &&
1047 1052
 		     ( fcoe->timeouts <= FCOE_MAX_FIP_SOLICITATIONS ) ) {
1048
-			start_timer_fixed ( &fcoe->timer,
1049
-					    FCOE_FIP_RETRY_DELAY );
1050 1053
 			fcoe_fip_tx_solicitation ( fcoe );
1051 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 1067
 		/* Either we have found a FIP-capable forwarder, or we
1055 1068
 		 * have timed out and will fall back to pre-FIP mode.
1056 1069
 		 */
@@ -1125,16 +1138,10 @@ static int fcoe_probe ( struct net_device *netdev ) {
1125 1138
 	       fc_ntoa ( &fcoe->node_wwn.fc ) );
1126 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 1141
 	/* Transfer reference to port list */
1134 1142
 	list_add ( &fcoe->list, &fcoe_ports );
1135 1143
 	return 0;
1136 1144
 
1137
- err_fc_create:
1138 1145
 	netdev_put ( fcoe->netdev );
1139 1146
  err_zalloc:
1140 1147
  err_non_ethernet:
@@ -1156,8 +1163,12 @@ static void fcoe_notify ( struct net_device *netdev ) {
1156 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