Bläddra i källkod

[hermon] Work around missing mport support in current BOFM implementations

Current BOFM versions are unable to create entries with mport>1, which
means that only the port 1 MAC address can be explicitly specified.

Work around this by using the provided MAC address as a base address
for all subsequent ports.  For example, if BOFM assigns the address

   00:1A:64:76:00:09 for port 1

then we will assign the addresses

   00:1A:64:76:00:09 for port 1
   00:1A:64:76:00:0a for port 2

Future BOFM versions that may correctly support mport will work with
this scheme without modification provided that the BOFM entries are
created in increasing order of mport.  Since BOFM tools tend to
generate entries in increasing order (of slot, port, etc), this is not
an unreasonable compromise.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 år sedan
förälder
incheckning
15c120041d
1 ändrade filer med 39 tillägg och 15 borttagningar
  1. 39
    15
      src/drivers/infiniband/hermon.c

+ 39
- 15
src/drivers/infiniband/hermon.c Visa fil

@@ -3382,31 +3382,55 @@ static int hermon_bofm_update ( struct bofm_device *bofm, unsigned int mport,
3382 3382
 	union {
3383 3383
 		uint8_t bytes[8];
3384 3384
 		uint32_t dwords[2];
3385
+		uint64_t qword;
3385 3386
 	} buf;
3387
+	uint8_t *mac_copy = &buf.bytes[ sizeof ( buf.bytes ) - ETH_ALEN ];
3386 3388
 	int rc;
3387 3389
 
3388 3390
 	/* Prepare MAC address */
3389 3391
 	memset ( &buf, 0, sizeof ( buf ) );
3390
-	memcpy ( &buf.bytes[ sizeof ( buf.bytes ) - ETH_ALEN ], mac,
3391
-		 ETH_ALEN );
3392
+	memcpy ( mac_copy, mac, ETH_ALEN );
3392 3393
 
3393
-	/* Modify static configuration */
3394
-	memset ( &stat_cfg, 0, sizeof ( stat_cfg ) );
3395
-	MLX_FILL_2 ( &stat_cfg, 36,
3396
-		     mac_m, 1,
3397
-		     mac_high, ntohl ( buf.dwords[0] ) );
3398
-	MLX_FILL_1 ( &stat_cfg, 37, mac_low, ntohl ( buf.dwords[1] ) );
3399
-	if ( ( rc = hermon_mod_stat_cfg ( hermon, mport,
3394
+	/* Current BOFM versions are unable to create entries with
3395
+	 * mport>1, which means that only the port 1 MAC address can
3396
+	 * be explicitly specified.  Work around this by using the
3397
+	 * provided MAC address as a base address for all subsequent
3398
+	 * ports.  For example, if BOFM assigns the address
3399
+	 *
3400
+	 *    00:1A:64:76:00:09 for port 1
3401
+	 *
3402
+	 * then we will assign the addresses
3403
+	 *
3404
+	 *    00:1A:64:76:00:09 for port 1
3405
+	 *    00:1A:64:76:00:0a for port 2
3406
+	 *
3407
+	 * Note that hermon->cap.num_ports is not yet defined at this
3408
+	 * point.
3409
+	 */
3410
+	for ( ; mport <= HERMON_MAX_PORTS ; mport++ ) {
3411
+
3412
+		/* Modify static configuration */
3413
+		memset ( &stat_cfg, 0, sizeof ( stat_cfg ) );
3414
+		MLX_FILL_2 ( &stat_cfg, 36,
3415
+			     mac_m, 1,
3416
+			     mac_high, ntohl ( buf.dwords[0] ) );
3417
+		MLX_FILL_1 ( &stat_cfg, 37, mac_low, ntohl ( buf.dwords[1] ) );
3418
+		if ( ( rc = hermon_mod_stat_cfg ( hermon, mport,
3400 3419
 					  HERMON_MOD_STAT_CFG_SET,
3401 3420
 					  HERMON_MOD_STAT_CFG_OFFSET ( mac_m ),
3402 3421
 					  &stat_cfg ) ) != 0 ) {
3403
-		DBGC ( hermon, "Hermon %p port %d could not modify "
3404
-		       "configuration: %s\n", hermon, mport, strerror ( rc ) );
3405
-		return rc;
3406
-	}
3422
+			DBGC ( hermon, "Hermon %p port %d could not modify "
3423
+			       "configuration: %s\n",
3424
+			       hermon, mport, strerror ( rc ) );
3425
+			return rc;
3426
+		}
3407 3427
 
3408
-	DBGC ( hermon, "Hermon %p port %d updated MAC address to %s\n",
3409
-	       hermon, mport, eth_ntoa ( mac ) );
3428
+		DBGC ( hermon, "Hermon %p port %d updated MAC address to %s\n",
3429
+		       hermon, mport, eth_ntoa ( mac_copy ) );
3430
+
3431
+		/* Increment MAC address */
3432
+		buf.qword = cpu_to_be64 ( be64_to_cpu ( buf.qword ) + 1 );
3433
+	}
3410 3434
 
3411 3435
 	return 0;
3412 3436
 }

Laddar…
Avbryt
Spara