Explorar el Código

[infiniband] Split subnet management agent client out into ib_smc.c

Not all Infiniband cards have embedded subnet management agents.
Split out the code that communicates with such an embedded SMA into a
separate ib_smc.c file, and have drivers call ib_smc_update()
explicitly when they suspect that the answers given by the embedded
SMA may have changed.
tags/v0.9.6
Michael Brown hace 15 años
padre
commit
663904a7bc

+ 51
- 46
src/drivers/infiniband/arbel.c Ver fichero

@@ -33,6 +33,7 @@
33 33
 #include <gpxe/iobuf.h>
34 34
 #include <gpxe/netdevice.h>
35 35
 #include <gpxe/infiniband.h>
36
+#include <gpxe/ib_smc.h>
36 37
 #include "arbel.h"
37 38
 
38 39
 /**
@@ -482,6 +483,50 @@ arbel_cmd_map_fa ( struct arbel *arbel,
482 483
 			   0, map, 1, NULL );
483 484
 }
484 485
 
486
+/***************************************************************************
487
+ *
488
+ * MAD operations
489
+ *
490
+ ***************************************************************************
491
+ */
492
+
493
+/**
494
+ * Issue management datagram
495
+ *
496
+ * @v ibdev		Infiniband device
497
+ * @v mad		Management datagram
498
+ * @ret rc		Return status code
499
+ */
500
+static int arbel_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
501
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
502
+	union arbelprm_mad mad_ifc;
503
+	int rc;
504
+
505
+	linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
506
+			mad_size_mismatch );
507
+
508
+	/* Copy in request packet */
509
+	memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
510
+
511
+	/* Issue MAD */
512
+	if ( ( rc = arbel_cmd_mad_ifc ( arbel, ibdev->port,
513
+					&mad_ifc ) ) != 0 ) {
514
+		DBGC ( arbel, "Arbel %p could not issue MAD IFC: %s\n",
515
+		       arbel, strerror ( rc ) );
516
+		return rc;
517
+	}
518
+
519
+	/* Copy out reply packet */
520
+	memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
521
+
522
+	if ( mad->hdr.status != 0 ) {
523
+		DBGC ( arbel, "Arbel %p MAD IFC status %04x\n",
524
+		       arbel, ntohs ( mad->hdr.status ) );
525
+		return -EIO;
526
+	}
527
+	return 0;
528
+}
529
+
485 530
 /***************************************************************************
486 531
  *
487 532
  * Completion queue operations
@@ -1394,6 +1439,9 @@ static void arbel_event_port_state_change ( struct arbel *arbel,
1394 1439
 		return;
1395 1440
 	}
1396 1441
 
1442
+	/* Update MAD parameters */
1443
+	ib_smc_update ( arbel->ibdev[port], arbel_mad );
1444
+
1397 1445
 	/* Notify Infiniband core of link state change */
1398 1446
 	ib_link_state_changed ( arbel->ibdev[port] );
1399 1447
 }
@@ -1483,6 +1531,9 @@ static int arbel_open ( struct ib_device *ibdev ) {
1483 1531
 		return rc;
1484 1532
 	}
1485 1533
 
1534
+	/* Update MAD parameters */
1535
+	ib_smc_update ( ibdev, arbel_mad );
1536
+
1486 1537
 	return 0;
1487 1538
 }
1488 1539
 
@@ -1598,51 +1649,6 @@ static void arbel_mcast_detach ( struct ib_device *ibdev,
1598 1649
 	}
1599 1650
 }
1600 1651
 
1601
-/***************************************************************************
1602
- *
1603
- * MAD operations
1604
- *
1605
- ***************************************************************************
1606
- */
1607
-
1608
-/**
1609
- * Issue management datagram
1610
- *
1611
- * @v ibdev		Infiniband device
1612
- * @v mad		Management datagram
1613
- * @v len		Length of management datagram
1614
- * @ret rc		Return status code
1615
- */
1616
-static int arbel_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1617
-		       size_t len ) {
1618
-	struct arbel *arbel = ib_get_drvdata ( ibdev );
1619
-	union arbelprm_mad mad_ifc;
1620
-	int rc;
1621
-
1622
-	/* Copy in request packet */
1623
-	memset ( &mad_ifc, 0, sizeof ( mad_ifc ) );
1624
-	assert ( len <= sizeof ( mad_ifc.mad ) );
1625
-	memcpy ( &mad_ifc.mad, mad, len );
1626
-
1627
-	/* Issue MAD */
1628
-	if ( ( rc = arbel_cmd_mad_ifc ( arbel, ibdev->port,
1629
-					&mad_ifc ) ) != 0 ) {
1630
-		DBGC ( arbel, "Arbel %p could not issue MAD IFC: %s\n",
1631
-		       arbel, strerror ( rc ) );
1632
-		return rc;
1633
-	}
1634
-
1635
-	/* Copy out reply packet */
1636
-	memcpy ( mad, &mad_ifc.mad, len );
1637
-
1638
-	if ( mad->status != 0 ) {
1639
-		DBGC ( arbel, "Arbel %p MAD IFC status %04x\n",
1640
-		       arbel, ntohs ( mad->status ) );
1641
-		return -EIO;
1642
-	}
1643
-	return 0;
1644
-}
1645
-
1646 1652
 /** Arbel Infiniband operations */
1647 1653
 static struct ib_device_operations arbel_ib_operations = {
1648 1654
 	.create_cq	= arbel_create_cq,
@@ -1658,7 +1664,6 @@ static struct ib_device_operations arbel_ib_operations = {
1658 1664
 	.close		= arbel_close,
1659 1665
 	.mcast_attach	= arbel_mcast_attach,
1660 1666
 	.mcast_detach	= arbel_mcast_detach,
1661
-	.mad		= arbel_mad,
1662 1667
 };
1663 1668
 
1664 1669
 /***************************************************************************

+ 51
- 46
src/drivers/infiniband/hermon.c Ver fichero

@@ -31,6 +31,7 @@
31 31
 #include <gpxe/iobuf.h>
32 32
 #include <gpxe/netdevice.h>
33 33
 #include <gpxe/infiniband.h>
34
+#include <gpxe/ib_smc.h>
34 35
 #include "hermon.h"
35 36
 
36 37
 /**
@@ -608,6 +609,50 @@ static void hermon_free_mtt ( struct hermon *hermon,
608 609
 			      mtt->num_pages );
609 610
 }
610 611
 
612
+/***************************************************************************
613
+ *
614
+ * MAD operations
615
+ *
616
+ ***************************************************************************
617
+ */
618
+
619
+/**
620
+ * Issue management datagram
621
+ *
622
+ * @v ibdev		Infiniband device
623
+ * @v mad		Management datagram
624
+ * @ret rc		Return status code
625
+ */
626
+static int hermon_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
627
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
628
+	union hermonprm_mad mad_ifc;
629
+	int rc;
630
+
631
+	linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
632
+			mad_size_mismatch );
633
+
634
+	/* Copy in request packet */
635
+	memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
636
+
637
+	/* Issue MAD */
638
+	if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
639
+					 &mad_ifc ) ) != 0 ) {
640
+		DBGC ( hermon, "Hermon %p could not issue MAD IFC: %s\n",
641
+		       hermon, strerror ( rc ) );
642
+		return rc;
643
+	}
644
+
645
+	/* Copy out reply packet */
646
+	memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
647
+
648
+	if ( mad->hdr.status != 0 ) {
649
+		DBGC ( hermon, "Hermon %p MAD IFC status %04x\n",
650
+		       hermon, ntohs ( mad->hdr.status ) );
651
+		return -EIO;
652
+	}
653
+	return 0;
654
+}
655
+
611 656
 /***************************************************************************
612 657
  *
613 658
  * Completion queue operations
@@ -1377,6 +1422,9 @@ static void hermon_event_port_state_change ( struct hermon *hermon,
1377 1422
 		return;
1378 1423
 	}
1379 1424
 
1425
+	/* Update MAD parameters */
1426
+	ib_smc_update ( hermon->ibdev[port], hermon_mad );
1427
+
1380 1428
 	/* Notify Infiniband core of link state change */
1381 1429
 	ib_link_state_changed ( hermon->ibdev[port] );
1382 1430
 }
@@ -1465,6 +1513,9 @@ static int hermon_open ( struct ib_device *ibdev ) {
1465 1513
 		return rc;
1466 1514
 	}
1467 1515
 
1516
+	/* Update MAD parameters */
1517
+	ib_smc_update ( ibdev, hermon_mad );
1518
+
1468 1519
 	return 0;
1469 1520
 }
1470 1521
 
@@ -1579,51 +1630,6 @@ static void hermon_mcast_detach ( struct ib_device *ibdev,
1579 1630
 	}
1580 1631
 }
1581 1632
 
1582
-/***************************************************************************
1583
- *
1584
- * MAD operations
1585
- *
1586
- ***************************************************************************
1587
- */
1588
-
1589
-/**
1590
- * Issue management datagram
1591
- *
1592
- * @v ibdev		Infiniband device
1593
- * @v mad		Management datagram
1594
- * @v len		Length of management datagram
1595
- * @ret rc		Return status code
1596
- */
1597
-static int hermon_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1598
-			size_t len ) {
1599
-	struct hermon *hermon = ib_get_drvdata ( ibdev );
1600
-	union hermonprm_mad mad_ifc;
1601
-	int rc;
1602
-
1603
-	/* Copy in request packet */
1604
-	memset ( &mad_ifc, 0, sizeof ( mad_ifc ) );
1605
-	assert ( len <= sizeof ( mad_ifc.mad ) );
1606
-	memcpy ( &mad_ifc.mad, mad, len );
1607
-
1608
-	/* Issue MAD */
1609
-	if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
1610
-					 &mad_ifc ) ) != 0 ) {
1611
-		DBGC ( hermon, "Hermon %p could not issue MAD IFC: %s\n",
1612
-		       hermon, strerror ( rc ) );
1613
-		return rc;
1614
-	}
1615
-
1616
-	/* Copy out reply packet */
1617
-	memcpy ( mad, &mad_ifc.mad, len );
1618
-
1619
-	if ( mad->status != 0 ) {
1620
-		DBGC ( hermon, "Hermon %p MAD IFC status %04x\n",
1621
-		       hermon, ntohs ( mad->status ) );
1622
-		return -EIO;
1623
-	}
1624
-	return 0;
1625
-}
1626
-
1627 1633
 /** Hermon Infiniband operations */
1628 1634
 static struct ib_device_operations hermon_ib_operations = {
1629 1635
 	.create_cq	= hermon_create_cq,
@@ -1639,7 +1645,6 @@ static struct ib_device_operations hermon_ib_operations = {
1639 1645
 	.close		= hermon_close,
1640 1646
 	.mcast_attach	= hermon_mcast_attach,
1641 1647
 	.mcast_detach	= hermon_mcast_detach,
1642
-	.mad		= hermon_mad,
1643 1648
 };
1644 1649
 
1645 1650
 /***************************************************************************

+ 166
- 0
src/drivers/infiniband/ib_smc.c Ver fichero

@@ -0,0 +1,166 @@
1
+/*
2
+ * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <stdint.h>
20
+#include <stdlib.h>
21
+#include <string.h>
22
+#include <errno.h>
23
+#include <unistd.h>
24
+#include <byteswap.h>
25
+#include <gpxe/infiniband.h>
26
+#include <gpxe/ib_smc.h>
27
+
28
+/**
29
+ * @file
30
+ *
31
+ * Infiniband Subnet Management Client
32
+ *
33
+ */
34
+
35
+/**
36
+ * Get port information
37
+ *
38
+ * @v ibdev		Infiniband device
39
+ * @v local_mad		Method for issuing local MADs
40
+ * @v mad		Management datagram to fill in
41
+ * @ret rc		Return status code
42
+ */
43
+static int ib_smc_get_port_info ( struct ib_device *ibdev,
44
+				  ib_local_mad_t local_mad,
45
+				  union ib_mad *mad ) {
46
+	int rc;
47
+
48
+	/* Construct MAD */
49
+	memset ( mad, 0, sizeof ( *mad ) );
50
+	mad->hdr.base_version = IB_MGMT_BASE_VERSION;
51
+	mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
52
+	mad->hdr.class_version = 1;
53
+	mad->hdr.method = IB_MGMT_METHOD_GET;
54
+	mad->hdr.attr_id = htons ( IB_SMP_ATTR_PORT_INFO );
55
+	mad->hdr.attr_mod = htonl ( ibdev->port );
56
+
57
+	if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
58
+		DBGC ( ibdev, "IBDEV %p could not get port info: %s\n",
59
+		       ibdev, strerror ( rc ) );
60
+		return rc;
61
+	}
62
+	return 0;
63
+}
64
+
65
+/**
66
+ * Get GUID information
67
+ *
68
+ * @v ibdev		Infiniband device
69
+ * @v local_mad		Method for issuing local MADs
70
+ * @v mad		Management datagram to fill in
71
+ * @ret rc		Return status code
72
+ */
73
+static int ib_smc_get_guid_info ( struct ib_device *ibdev,
74
+				  ib_local_mad_t local_mad,
75
+				  union ib_mad *mad ) {
76
+	int rc;
77
+
78
+	/* Construct MAD */
79
+	memset ( mad, 0, sizeof ( *mad ) );
80
+	mad->hdr.base_version = IB_MGMT_BASE_VERSION;
81
+	mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
82
+	mad->hdr.class_version = 1;
83
+	mad->hdr.method = IB_MGMT_METHOD_GET;
84
+	mad->hdr.attr_id = htons ( IB_SMP_ATTR_GUID_INFO );
85
+
86
+	if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
87
+		DBGC ( ibdev, "IBDEV %p could not get GUID info: %s\n",
88
+		       ibdev, strerror ( rc ) );
89
+		return rc;
90
+	}
91
+	return 0;
92
+}
93
+
94
+/**
95
+ * Get partition key table
96
+ *
97
+ * @v ibdev		Infiniband device
98
+ * @v local_mad		Method for issuing local MADs
99
+ * @v mad		Management datagram to fill in
100
+ * @ret rc		Return status code
101
+ */
102
+static int ib_smc_get_pkey_table ( struct ib_device *ibdev,
103
+				   ib_local_mad_t local_mad,
104
+				   union ib_mad *mad ) {
105
+	int rc;
106
+
107
+	/* Construct MAD */
108
+	memset ( mad, 0, sizeof ( *mad ) );
109
+	mad->hdr.base_version = IB_MGMT_BASE_VERSION;
110
+	mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
111
+	mad->hdr.class_version = 1;
112
+	mad->hdr.method = IB_MGMT_METHOD_GET;
113
+	mad->hdr.attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE );
114
+
115
+	if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
116
+		DBGC ( ibdev, "IBDEV %p could not get pkey table: %s\n",
117
+		       ibdev, strerror ( rc ) );
118
+		return rc;
119
+	}
120
+	return 0;
121
+}
122
+
123
+/**
124
+ * Get MAD parameters
125
+ *
126
+ * @v ibdev		Infiniband device
127
+ * @v local_mad		Method for issuing local MADs
128
+ * @ret rc		Return status code
129
+ */
130
+int ib_smc_update ( struct ib_device *ibdev, ib_local_mad_t local_mad ) {
131
+	union ib_mad mad;
132
+	union ib_smp_data *smp = &mad.smp.smp_data;
133
+	int rc;
134
+
135
+	/* Port info gives us the link state, the first half of the
136
+	 * port GID and the SM LID.
137
+	 */
138
+	if ( ( rc = ib_smc_get_port_info ( ibdev, local_mad, &mad ) ) != 0 )
139
+		return rc;
140
+	ibdev->port_state =
141
+		( smp->port_info.link_speed_supported__port_state & 0x0f );
142
+	memcpy ( &ibdev->gid.u.half[0], smp->port_info.gid_prefix,
143
+		 sizeof ( ibdev->gid.u.half[0] ) );
144
+	ibdev->lid = ntohs ( smp->port_info.lid );
145
+	ibdev->sm_lid = ntohs ( smp->port_info.mastersm_lid );
146
+	ibdev->sm_sl = ( smp->port_info.neighbour_mtu__mastersm_sl & 0xf );
147
+
148
+	/* GUID info gives us the second half of the port GID */
149
+	if ( ( rc = ib_smc_get_guid_info ( ibdev, local_mad, &mad ) ) != 0 )
150
+		return rc;
151
+	memcpy ( &ibdev->gid.u.half[1], smp->guid_info.guid[0],
152
+		 sizeof ( ibdev->gid.u.half[1] ) );
153
+
154
+	/* Get partition key */
155
+	if ( ( rc = ib_smc_get_pkey_table ( ibdev, local_mad, &mad ) ) != 0 )
156
+		return rc;
157
+	ibdev->pkey = ntohs ( smp->pkey_table.pkey[0] );
158
+
159
+	DBGC ( ibdev, "IBDEV %p port GID is %08lx:%08lx:%08lx:%08lx\n", ibdev,
160
+	       htonl ( ibdev->gid.u.dwords[0] ),
161
+	       htonl ( ibdev->gid.u.dwords[1] ),
162
+	       htonl ( ibdev->gid.u.dwords[2] ),
163
+	       htonl ( ibdev->gid.u.dwords[3] ) );
164
+
165
+	return 0;
166
+}

+ 10
- 8
src/drivers/net/ipoib.c Ver fichero

@@ -383,12 +383,13 @@ static int ipoib_get_path_record ( struct ipoib_device *ipoib,
383 383
 	path_record->sa_hdr.comp_mask[1] =
384 384
 		htonl ( IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID );
385 385
 	memcpy ( &path_record->dgid, gid, sizeof ( path_record->dgid ) );
386
-	memcpy ( &path_record->sgid, &ibdev->port_gid,
386
+	memcpy ( &path_record->sgid, &ibdev->gid,
387 387
 		 sizeof ( path_record->sgid ) );
388 388
 
389 389
 	/* Construct address vector */
390 390
 	memset ( &av, 0, sizeof ( av ) );
391 391
 	av.lid = ibdev->sm_lid;
392
+	av.sl = ibdev->sm_sl;
392 393
 	av.qpn = IB_SA_QPN;
393 394
 	av.qkey = IB_GLOBAL_QKEY;
394 395
 
@@ -443,12 +444,13 @@ static int ipoib_mc_member_record ( struct ipoib_device *ipoib,
443 444
 	mc_member_record->scope__join_state = 1;
444 445
 	memcpy ( &mc_member_record->mgid, gid,
445 446
 		 sizeof ( mc_member_record->mgid ) );
446
-	memcpy ( &mc_member_record->port_gid, &ibdev->port_gid,
447
+	memcpy ( &mc_member_record->port_gid, &ibdev->gid,
447 448
 		 sizeof ( mc_member_record->port_gid ) );
448 449
 
449 450
 	/* Construct address vector */
450 451
 	memset ( &av, 0, sizeof ( av ) );
451 452
 	av.lid = ibdev->sm_lid;
453
+	av.sl = ibdev->sm_sl;
452 454
 	av.qpn = IB_SA_QPN;
453 455
 	av.qkey = IB_GLOBAL_QKEY;
454 456
 
@@ -491,7 +493,7 @@ static int ipoib_transmit ( struct net_device *netdev,
491 493
 	/* Attempting transmission while link is down will put the
492 494
 	 * queue pair into an error state, so don't try it.
493 495
 	 */
494
-	if ( ! ibdev->link_up )
496
+	if ( ! ib_link_ok ( ibdev ) )
495 497
 		return -ENETUNREACH;
496 498
 
497 499
 	/* Construct address vector */
@@ -691,13 +693,13 @@ ipoib_meta_complete_recv ( struct ib_device *ibdev __unused,
691 693
 	}
692 694
 	mad = iobuf->data;
693 695
 
694
-	if ( mad->mad_hdr.status != 0 ) {
696
+	if ( mad->hdr.status != 0 ) {
695 697
 		DBGC ( ipoib, "IPoIB %p metadata RX err status %04x\n",
696
-		       ipoib, ntohs ( mad->mad_hdr.status ) );
698
+		       ipoib, ntohs ( mad->hdr.status ) );
697 699
 		goto done;
698 700
 	}
699 701
 
700
-	switch ( mad->mad_hdr.tid[0] ) {
702
+	switch ( mad->hdr.tid[0] ) {
701 703
 	case IPOIB_TID_GET_PATH_REC:
702 704
 		ipoib_recv_path_record ( ipoib, &mad->path_record );
703 705
 		break;
@@ -928,7 +930,7 @@ static void ipoib_set_ib_params ( struct ipoib_device *ipoib ) {
928 930
 
929 931
 	/* Calculate GID portion of MAC address based on port GID */
930 932
 	mac = ( ( struct ipoib_mac * ) netdev->ll_addr );
931
-	memcpy ( &mac->gid, &ibdev->port_gid, sizeof ( mac->gid ) );
933
+	memcpy ( &mac->gid, &ibdev->gid, sizeof ( mac->gid ) );
932 934
 
933 935
 	/* Calculate broadcast GID based on partition key */
934 936
 	memcpy ( &ipoib->broadcast_gid, &ipv4_broadcast_gid,
@@ -936,7 +938,7 @@ static void ipoib_set_ib_params ( struct ipoib_device *ipoib ) {
936 938
 	ipoib->broadcast_gid.u.words[2] = htons ( ibdev->pkey );
937 939
 
938 940
 	/* Set net device link state to reflect Infiniband link state */
939
-	if ( ibdev->link_up ) {
941
+	if ( ib_link_ok ( ibdev ) ) {
940 942
 		netdev_link_up ( netdev );
941 943
 	} else {
942 944
 		netdev_link_down ( netdev );

+ 341
- 0
src/include/gpxe/ib_mad.h Ver fichero

@@ -0,0 +1,341 @@
1
+#ifndef _GPXE_IB_MAD_H
2
+#define _GPXE_IB_MAD_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband management datagrams
7
+ *
8
+ */
9
+
10
+#include <stdint.h>
11
+#include <gpxe/ib_packet.h>
12
+
13
+/** A management datagram common header
14
+ *
15
+ * Defined in section 13.4.2 of the IBA.
16
+ */
17
+struct ib_mad_hdr {
18
+	uint8_t base_version;
19
+	uint8_t mgmt_class;
20
+	uint8_t class_version;
21
+	uint8_t method;
22
+	uint16_t status;
23
+	uint16_t class_specific;
24
+	uint32_t tid[2];
25
+	uint16_t attr_id;
26
+	uint8_t reserved[2];
27
+	uint32_t attr_mod;
28
+} __attribute__ (( packed ));
29
+
30
+/* Management base version */
31
+#define IB_MGMT_BASE_VERSION			1
32
+
33
+/* Management classes */
34
+#define IB_MGMT_CLASS_SUBN_LID_ROUTED		0x01
35
+#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE	0x81
36
+#define IB_MGMT_CLASS_SUBN_ADM			0x03
37
+#define IB_MGMT_CLASS_PERF_MGMT			0x04
38
+#define IB_MGMT_CLASS_BM			0x05
39
+#define IB_MGMT_CLASS_DEVICE_MGMT		0x06
40
+#define IB_MGMT_CLASS_CM			0x07
41
+#define IB_MGMT_CLASS_SNMP			0x08
42
+#define IB_MGMT_CLASS_VENDOR_RANGE2_START	0x30
43
+#define IB_MGMT_CLASS_VENDOR_RANGE2_END		0x4F
44
+
45
+/* Management methods */
46
+#define IB_MGMT_METHOD_GET			0x01
47
+#define IB_MGMT_METHOD_SET			0x02
48
+#define IB_MGMT_METHOD_GET_RESP			0x81
49
+#define IB_MGMT_METHOD_SEND			0x03
50
+#define IB_MGMT_METHOD_TRAP			0x05
51
+#define IB_MGMT_METHOD_REPORT			0x06
52
+#define IB_MGMT_METHOD_REPORT_RESP		0x86
53
+#define IB_MGMT_METHOD_TRAP_REPRESS		0x07
54
+#define IB_MGMT_METHOD_DELETE			0x15
55
+
56
+/* Status codes */
57
+#define IB_MGMT_STATUS_OK			0x0000
58
+#define IB_MGMT_STATUS_BAD_VERSION		0x0001
59
+#define IB_MGMT_STATUS_UNSUPPORTED_METHOD	0x0002
60
+#define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR	0x0003
61
+#define IB_MGMT_STATUS_INVALID_VALUE		0x0004
62
+
63
+/** A LID routed SMP header
64
+ *
65
+ * Defined in section 14.2.1.1 of the IBA.
66
+ */
67
+struct ib_smp_lr_hdr {
68
+	uint64_t mkey;
69
+	uint8_t reserved[32];
70
+} __attribute__ (( packed ));
71
+
72
+/** A directed route SMP header
73
+ *
74
+ * Defined in section 14.2.1.2 of the IBA.
75
+ */
76
+struct ib_smp_dr_hdr {
77
+	uint64_t mkey;
78
+	uint16_t slid;
79
+	uint16_t dlid;
80
+	uint8_t reserved[28];
81
+} __attribute__ (( packed ));
82
+
83
+/** A subnet management header */
84
+union ib_smp_hdr {
85
+	uint64_t mkey;
86
+	struct ib_smp_lr_hdr lr;
87
+	struct ib_smp_dr_hdr dr;
88
+} __attribute__ (( packed ));
89
+
90
+/** Subnet management class version */
91
+#define IB_SMP_CLASS_VERSION			1
92
+
93
+/** Subnet management direction bit
94
+ *
95
+ * This bit resides in the "status" field in the MAD header.
96
+ */
97
+#define IB_SMP_STATUS_D_INBOUND			0x8000
98
+
99
+/* Subnet management attributes */
100
+#define IB_SMP_ATTR_NOTICE			0x0002
101
+#define IB_SMP_ATTR_NODE_DESC			0x0010
102
+#define IB_SMP_ATTR_NODE_INFO			0x0011
103
+#define IB_SMP_ATTR_SWITCH_INFO			0x0012
104
+#define IB_SMP_ATTR_GUID_INFO			0x0014
105
+#define IB_SMP_ATTR_PORT_INFO			0x0015
106
+#define IB_SMP_ATTR_PKEY_TABLE			0x0016
107
+#define IB_SMP_ATTR_SL_TO_VL_TABLE		0x0017
108
+#define IB_SMP_ATTR_VL_ARB_TABLE		0x0018
109
+#define IB_SMP_ATTR_LINEAR_FORWARD_TABLE	0x0019
110
+#define IB_SMP_ATTR_RANDOM_FORWARD_TABLE	0x001A
111
+#define IB_SMP_ATTR_MCAST_FORWARD_TABLE		0x001B
112
+#define IB_SMP_ATTR_SM_INFO			0x0020
113
+#define IB_SMP_ATTR_VENDOR_DIAG			0x0030
114
+#define IB_SMP_ATTR_LED_INFO			0x0031
115
+#define IB_SMP_ATTR_VENDOR_MASK			0xFF00
116
+
117
+/**
118
+ * A Node Description attribute
119
+ *
120
+ * Defined in section 14.2.5.2 of the IBA
121
+ */
122
+struct ib_node_desc {
123
+	char node_string[64];
124
+} __attribute__ (( packed ));
125
+
126
+/** A Node Information attribute
127
+ *
128
+ * Defined in section 14.2.5.3 of the IBA.
129
+ */
130
+struct ib_node_info {
131
+	uint8_t base_version;
132
+	uint8_t class_version;
133
+	uint8_t node_type;
134
+	uint8_t num_ports;
135
+	uint8_t sys_guid[8];
136
+	uint8_t node_guid[8];
137
+	uint8_t port_guid[8];
138
+	uint16_t partition_cap;
139
+	uint16_t device_id;
140
+	uint32_t revision;
141
+	uint8_t local_port_num;
142
+	uint8_t vendor_id[3];
143
+} __attribute__ ((packed));
144
+
145
+#define IB_NODE_TYPE_HCA		0x01
146
+#define IB_NODE_TYPE_SWITCH		0x02
147
+#define IB_NODE_TYPE_ROUTER		0x03
148
+
149
+/** A GUID Information attribute
150
+ *
151
+ * Defined in section 14.2.5.5 of the IBA.
152
+ */
153
+struct ib_guid_info {
154
+	uint8_t guid[8][8];
155
+} __attribute__ (( packed ));
156
+
157
+/** A Port Information attribute
158
+ *
159
+ * Defined in section 14.2.5.6 of the IBA.
160
+ */
161
+struct ib_port_info {
162
+	uint64_t mkey;
163
+	uint8_t gid_prefix[8];
164
+	uint16_t lid;
165
+	uint16_t mastersm_lid;
166
+	uint32_t cap_mask;
167
+	uint16_t diag_code;
168
+	uint16_t mkey_lease_period;
169
+	uint8_t local_port_num;
170
+	uint8_t link_width_enabled;
171
+	uint8_t link_width_supported;
172
+	uint8_t link_width_active;
173
+	uint8_t link_speed_supported__port_state;
174
+	uint8_t port_phys_state__link_down_def_state;
175
+	uint8_t mkey_prot_bits__lmc;
176
+	uint8_t link_speed_active__link_speed_enabled;
177
+	uint8_t neighbour_mtu__mastersm_sl;
178
+	uint8_t vl_cap__init_type;
179
+	uint8_t vl_high_limit;
180
+	uint8_t vl_arbitration_high_cap;
181
+	uint8_t vl_arbitration_low_cap;
182
+	uint8_t init_type_reply__mtu_cap;
183
+	uint8_t vl_stall_count__hoq_life;
184
+	uint8_t operational_vls__enforcement;
185
+	uint16_t mkey_violations;
186
+	uint16_t pkey_violations;
187
+	uint16_t qkey_violations;
188
+	uint8_t guid_cap;
189
+	uint8_t client_reregister__subnet_timeout;
190
+	uint8_t resp_time_value;
191
+	uint8_t local_phy_errors__overrun_errors;
192
+	uint16_t max_credit_hint;
193
+	uint32_t link_round_trip_latency;
194
+} __attribute__ (( packed ));
195
+
196
+#define IB_LINK_WIDTH_1X		0x01
197
+#define IB_LINK_WIDTH_4X		0x02
198
+#define IB_LINK_WIDTH_8X		0x04
199
+#define IB_LINK_WIDTH_12X		0x08
200
+
201
+#define IB_LINK_SPEED_SDR		0x01
202
+#define IB_LINK_SPEED_DDR		0x02
203
+#define IB_LINK_SPEED_QDR		0x04
204
+
205
+#define IB_PORT_STATE_DOWN		0x01
206
+#define IB_PORT_STATE_INIT		0x02
207
+#define IB_PORT_STATE_ARMED		0x03
208
+#define IB_PORT_STATE_ACTIVE		0x04
209
+
210
+#define IB_PORT_PHYS_STATE_SLEEP	0x01
211
+#define IB_PORT_PHYS_STATE_POLLING	0x02
212
+
213
+#define IB_MTU_256			0x01
214
+#define IB_MTU_512			0x02
215
+#define IB_MTU_1024			0x03
216
+#define IB_MTU_2048			0x04
217
+#define IB_MTU_4096			0x05
218
+
219
+#define IB_VL_0				0x01
220
+#define IB_VL_0_1			0x02
221
+#define IB_VL_0_3			0x03
222
+#define IB_VL_0_7			0x04
223
+#define IB_VL_0_14			0x05
224
+
225
+/** A Partition Key Table attribute
226
+ *
227
+ * Defined in section 14.2.5.7 of the IBA.
228
+ */
229
+struct ib_pkey_table {
230
+	uint16_t pkey[32];
231
+} __attribute__ (( packed ));
232
+
233
+/** A subnet management attribute */
234
+union ib_smp_data {
235
+	struct ib_node_desc node_desc;
236
+	struct ib_node_info node_info;
237
+	struct ib_guid_info guid_info;
238
+	struct ib_port_info port_info;
239
+	struct ib_pkey_table pkey_table;
240
+	uint8_t bytes[64];
241
+} __attribute__ (( packed ));
242
+
243
+/** A subnet management directed route path */
244
+struct ib_smp_dr_path {
245
+	uint8_t reserved;
246
+	uint8_t hops[63];
247
+} __attribute__ (( packed ));
248
+
249
+/** A subnet management MAD */
250
+struct ib_mad_smp {
251
+	struct ib_mad_hdr mad_hdr;
252
+	union ib_smp_hdr smp_hdr;
253
+	union ib_smp_data smp_data;
254
+	struct ib_smp_dr_path initial_path;
255
+	struct ib_smp_dr_path return_path;
256
+} __attribute__ (( packed ));
257
+
258
+struct ib_sa_hdr {
259
+	uint32_t sm_key[2];
260
+	uint16_t reserved;
261
+	uint16_t attrib_offset;
262
+	uint32_t comp_mask[2];
263
+} __attribute__ (( packed ));
264
+
265
+struct ib_rmpp_hdr {
266
+	uint32_t raw[3];
267
+} __attribute__ (( packed ));
268
+
269
+struct ib_mad_path_record {
270
+	struct ib_mad_hdr mad_hdr;
271
+	struct ib_rmpp_hdr rmpp_hdr;
272
+	struct ib_sa_hdr sa_hdr;
273
+	uint32_t reserved0[2];
274
+	struct ib_gid dgid;
275
+	struct ib_gid sgid;
276
+	uint16_t dlid;
277
+	uint16_t slid;
278
+	uint32_t hop_limit__flow_label__raw_traffic;
279
+	uint32_t pkey__numb_path__reversible__tclass;
280
+	uint8_t reserved1;
281
+	uint8_t reserved__sl;
282
+	uint8_t mtu_selector__mtu;
283
+	uint8_t rate_selector__rate;
284
+	uint32_t preference__packet_lifetime__packet_lifetime_selector;
285
+	uint32_t reserved2[35];
286
+} __attribute__ (( packed ));
287
+
288
+struct ib_mad_mc_member_record {
289
+	struct ib_mad_hdr mad_hdr;
290
+	struct ib_rmpp_hdr rmpp_hdr;
291
+	struct ib_sa_hdr sa_hdr;
292
+	struct ib_gid mgid;
293
+	struct ib_gid port_gid;
294
+	uint32_t qkey;
295
+	uint16_t mlid;
296
+	uint8_t mtu_selector__mtu;
297
+	uint8_t tclass;
298
+	uint16_t pkey;
299
+	uint8_t rate_selector__rate;
300
+	uint8_t packet_lifetime_selector__packet_lifetime;
301
+	uint32_t sl__flow_label__hop_limit;
302
+	uint8_t scope__join_state;
303
+	uint8_t proxy_join__reserved;
304
+	uint16_t reserved0;
305
+	uint32_t reserved1[37];
306
+} __attribute__ (( packed ));
307
+
308
+#define IB_SA_ATTR_MC_MEMBER_REC		0x38
309
+#define IB_SA_ATTR_PATH_REC			0x35
310
+
311
+#define IB_SA_MCMEMBER_REC_MGID			(1<<0)
312
+#define IB_SA_MCMEMBER_REC_PORT_GID		(1<<1)
313
+#define IB_SA_MCMEMBER_REC_QKEY			(1<<2)
314
+#define IB_SA_MCMEMBER_REC_MLID			(1<<3)
315
+#define IB_SA_MCMEMBER_REC_MTU_SELECTOR		(1<<4)
316
+#define IB_SA_MCMEMBER_REC_MTU			(1<<5)
317
+#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS	(1<<6)
318
+#define IB_SA_MCMEMBER_REC_PKEY			(1<<7)
319
+#define IB_SA_MCMEMBER_REC_RATE_SELECTOR	(1<<8)
320
+#define IB_SA_MCMEMBER_REC_RATE			(1<<9)
321
+#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR	(1<<10)
322
+#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME	(1<<11)
323
+#define IB_SA_MCMEMBER_REC_SL			(1<<12)
324
+#define IB_SA_MCMEMBER_REC_FLOW_LABEL		(1<<13)
325
+#define IB_SA_MCMEMBER_REC_HOP_LIMIT		(1<<14)
326
+#define IB_SA_MCMEMBER_REC_SCOPE		(1<<15)
327
+#define IB_SA_MCMEMBER_REC_JOIN_STATE		(1<<16)
328
+#define IB_SA_MCMEMBER_REC_PROXY_JOIN		(1<<17)
329
+
330
+#define IB_SA_PATH_REC_DGID			(1<<2)
331
+#define IB_SA_PATH_REC_SGID			(1<<3)
332
+
333
+union ib_mad {
334
+	struct ib_mad_hdr hdr;
335
+	struct ib_mad_smp smp;
336
+	struct ib_mad_path_record path_record;
337
+	struct ib_mad_mc_member_record mc_member_record;
338
+	uint8_t bytes[256];
339
+} __attribute__ (( packed ));
340
+
341
+#endif /* _GPXE_IB_MAD_H */

+ 114
- 0
src/include/gpxe/ib_packet.h Ver fichero

@@ -0,0 +1,114 @@
1
+#ifndef _GPXE_IB_PACKET_H
2
+#define _GPXE_IB_PACKET_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband packet format
7
+ *
8
+ */
9
+
10
+/** Half of an Infiniband Global Identifier */
11
+struct ib_gid_half {
12
+	uint8_t bytes[8];
13
+};
14
+
15
+/** An Infiniband Global Identifier */
16
+struct ib_gid {
17
+	union {
18
+		uint8_t bytes[16];
19
+		uint16_t words[8];
20
+		uint32_t dwords[4];
21
+		struct ib_gid_half half[2];
22
+	} u;
23
+};
24
+
25
+/** An Infiniband Local Route Header */
26
+struct ib_local_route_header {
27
+	/** Virtual lane and link version */
28
+	uint8_t vl__lver;
29
+	/** Service level and next link header */
30
+	uint8_t sl__lnh;
31
+	/** Destination LID */
32
+	uint16_t dlid;
33
+	/** Packet length */
34
+	uint16_t length;
35
+	/** Source LID */
36
+	uint16_t slid;
37
+} __attribute__ (( packed ));
38
+
39
+/** Infiniband virtual lanes */
40
+enum ib_vl {
41
+	IB_VL_DEFAULT = 0,
42
+	IB_VL_SMP = 15,
43
+};
44
+
45
+/** An Infiniband Link Next Header value */
46
+enum ib_lnh {
47
+	IB_LNH_RAW = 0,
48
+	IB_LNH_IPv6 = 1,
49
+	IB_LNH_BTH = 2,
50
+	IB_LNH_GRH = 3
51
+};
52
+
53
+/** Default Infiniband LID */
54
+#define IB_LID_NONE 0xffff
55
+
56
+/** An Infiniband Global Route Header */
57
+struct ib_global_route_header {
58
+	/** IP version, traffic class, and flow label
59
+	 *
60
+	 *  4 bits : Version of the GRH
61
+	 *  8 bits : Traffic class
62
+	 * 20 bits : Flow label
63
+	 */
64
+	uint32_t ipver__tclass__flowlabel;
65
+	/** Payload length */
66
+	uint16_t paylen;
67
+	/** Next header */
68
+	uint8_t nxthdr;
69
+	/** Hop limit */
70
+	uint8_t hoplmt;
71
+	/** Source GID */
72
+	struct ib_gid sgid;
73
+	/** Destiniation GID */
74
+	struct ib_gid dgid;
75
+} __attribute__ (( packed ));
76
+
77
+#define IB_GRH_IPVER_IPv6 0x06
78
+#define IB_GRH_NXTHDR_IBA 0x1b
79
+#define IB_GRH_HOPLMT_MAX 0xff
80
+
81
+/** An Infiniband Base Transport Header */
82
+struct ib_base_transport_header {
83
+	/** Opcode */
84
+	uint8_t opcode;
85
+	/** Transport header version, pad count, migration and solicitation */
86
+	uint8_t se__m__padcnt__tver;
87
+	/** Partition key */
88
+	uint16_t pkey;
89
+	/** Destination queue pair */
90
+	uint32_t dest_qp;
91
+	/** Packet sequence number and acknowledge request */
92
+	uint32_t ack__psn;
93
+} __attribute__ (( packed ));
94
+
95
+/** An Infiniband BTH opcode */
96
+enum ib_bth_opcode {
97
+	BTH_OPCODE_UD_SEND = 0x64,
98
+};
99
+
100
+/** Default Infiniband partition key */
101
+#define IB_PKEY_NONE 0xffff
102
+
103
+/** Subnet management queue pair number */
104
+#define IB_QPN_SMP 0
105
+
106
+/** An Infiniband Datagram Extended Transport Header */
107
+struct ib_datagram_extended_transport_header {
108
+	/** Queue key */
109
+	uint32_t qkey;
110
+	/** Source queue pair */
111
+	uint32_t src_qp;
112
+} __attribute__ (( packed ));
113
+
114
+#endif /* _GPXE_IB_PACKET_H */

+ 18
- 0
src/include/gpxe/ib_smc.h Ver fichero

@@ -0,0 +1,18 @@
1
+#ifndef _GPXE_IB_SMC_H
2
+#define _GPXE_IB_SMC_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband Subnet Management Client
7
+ *
8
+ */
9
+
10
+#include <gpxe/infiniband.h>
11
+
12
+typedef int ( * ib_local_mad_t ) ( struct ib_device *ibdev,
13
+				   union ib_mad *mad );
14
+
15
+extern int ib_smc_update ( struct ib_device *ibdev,
16
+			   ib_local_mad_t local_mad );
17
+
18
+#endif /* _GPXE_IB_SMC_H */

+ 52
- 271
src/include/gpxe/infiniband.h Ver fichero

@@ -10,6 +10,8 @@
10 10
 #include <stdint.h>
11 11
 #include <gpxe/refcnt.h>
12 12
 #include <gpxe/device.h>
13
+#include <gpxe/ib_packet.h>
14
+#include <gpxe/ib_mad.h>
13 15
 
14 16
 /** Subnet administrator QPN */
15 17
 #define IB_SA_QPN 1
@@ -20,36 +22,6 @@
20 22
 /** Subnet administrator queue key */
21 23
 #define IB_GLOBAL_QKEY 0x80010000UL
22 24
 
23
-/** An Infiniband Global Identifier */
24
-struct ib_gid {
25
-	union {
26
-		uint8_t bytes[16];
27
-		uint16_t words[8];
28
-		uint32_t dwords[4];
29
-	} u;
30
-};
31
-
32
-/** An Infiniband Global Route Header */
33
-struct ib_global_route_header {
34
-	/** IP version, traffic class, and flow label
35
-	 *
36
-	 *  4 bits : Version of the GRH
37
-	 *  8 bits : Traffic class
38
-	 * 20 bits : Flow label
39
-	 */
40
-	uint32_t ipver_tclass_flowlabel;
41
-	/** Payload length */
42
-	uint16_t paylen;
43
-	/** Next header */
44
-	uint8_t nxthdr;
45
-	/** Hop limit */
46
-	uint8_t hoplmt;
47
-	/** Source GID */
48
-	struct ib_gid sgid;
49
-	/** Destiniation GID */
50
-	struct ib_gid dgid;
51
-} __attribute__ (( packed ));
52
-
53 25
 struct ib_device;
54 26
 struct ib_queue_pair;
55 27
 struct ib_address_vector;
@@ -178,8 +150,6 @@ struct ib_completion_queue {
178 150
 	void *drv_priv;
179 151
 };
180 152
 
181
-struct ib_mad_hdr;
182
-
183 153
 /**
184 154
  * Infiniband device operations
185 155
  *
@@ -306,16 +276,6 @@ struct ib_device_operations {
306 276
 	void ( * mcast_detach ) ( struct ib_device *ibdev,
307 277
 				  struct ib_queue_pair *qp,
308 278
 				  struct ib_gid *gid );
309
-	/**
310
-	 * Issue management datagram
311
-	 *
312
-	 * @v ibdev		Infiniband device
313
-	 * @v mad		Management datagram
314
-	 * @v len		Length of management datagram
315
-	 * @ret rc		Return status code
316
-	 */
317
-	int ( * mad ) ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
318
-			size_t len );
319 279
 };
320 280
 
321 281
 /** An Infiniband device */
@@ -330,14 +290,24 @@ struct ib_device {
330 290
 	struct ib_device_operations *op;
331 291
 	/** Port number */
332 292
 	unsigned int port;
333
-	/** Link state */
334
-	int link_up;
293
+
294
+	/** Port state */
295
+	uint8_t port_state;
296
+	/** Link width */
297
+	uint8_t link_width;
298
+	/** Link speed */
299
+	uint8_t link_speed;
335 300
 	/** Port GID */
336
-	struct ib_gid port_gid;
301
+	struct ib_gid gid;
302
+	/** Port LID */
303
+	uint16_t lid;
337 304
 	/** Subnet manager LID */
338
-	unsigned long sm_lid;
305
+	uint16_t sm_lid;
306
+	/** Subnet manager SL */
307
+	uint8_t sm_sl;
339 308
 	/** Partition key */
340
-	unsigned int pkey;
309
+	uint16_t pkey;
310
+
341 311
 	/** Driver private data */
342 312
 	void *drv_priv;
343 313
 	/** Owner private data */
@@ -375,6 +345,11 @@ extern struct ib_device * alloc_ibdev ( size_t priv_size );
375 345
 extern int register_ibdev ( struct ib_device *ibdev );
376 346
 extern void unregister_ibdev ( struct ib_device *ibdev );
377 347
 extern void ib_link_state_changed ( struct ib_device *ibdev );
348
+extern struct list_head ib_devices;
349
+
350
+/** Iterate over all network devices */
351
+#define for_each_ibdev( ibdev ) \
352
+	list_for_each_entry ( (ibdev), &ib_devices, list )
378 353
 
379 354
 /**
380 355
  * Poll completion queue
@@ -382,7 +357,7 @@ extern void ib_link_state_changed ( struct ib_device *ibdev );
382 357
  * @v ibdev		Infiniband device
383 358
  * @v cq		Completion queue
384 359
  */
385
-static inline __attribute__ (( always_inline )) void
360
+static inline __always_inline void
386 361
 ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq ) {
387 362
 	ibdev->op->poll_cq ( ibdev, cq );
388 363
 }
@@ -393,7 +368,7 @@ ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq ) {
393 368
  * @v ibdev		Infiniband device
394 369
  * @ret rc		Return status code
395 370
  */
396
-static inline __attribute__ (( always_inline )) int
371
+static inline __always_inline int
397 372
 ib_open ( struct ib_device *ibdev ) {
398 373
 	return ibdev->op->open ( ibdev );
399 374
 }
@@ -403,11 +378,22 @@ ib_open ( struct ib_device *ibdev ) {
403 378
  *
404 379
  * @v ibdev		Infiniband device
405 380
  */
406
-static inline __attribute__ (( always_inline )) void
381
+static inline __always_inline void
407 382
 ib_close ( struct ib_device *ibdev ) {
408 383
 	ibdev->op->close ( ibdev );
409 384
 }
410 385
 
386
+/**
387
+ * Check link state
388
+ *
389
+ * @v ibdev		Infiniband device
390
+ * @ret link_up		Link is up
391
+ */
392
+static inline __always_inline int
393
+ib_link_ok ( struct ib_device *ibdev ) {
394
+	return ( ibdev->port_state == IB_PORT_STATE_ACTIVE );
395
+}
396
+
411 397
 /**
412 398
  * Attach to multicast group
413 399
  *
@@ -416,7 +402,7 @@ ib_close ( struct ib_device *ibdev ) {
416 402
  * @v gid		Multicast GID
417 403
  * @ret rc		Return status code
418 404
  */
419
-static inline __attribute__ (( always_inline )) int
405
+static inline __always_inline int
420 406
 ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
421 407
 		  struct ib_gid *gid ) {
422 408
 	return ibdev->op->mcast_attach ( ibdev, qp, gid );
@@ -429,32 +415,19 @@ ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
429 415
  * @v qp		Queue pair
430 416
  * @v gid		Multicast GID
431 417
  */
432
-static inline __attribute__ (( always_inline )) void
418
+static inline __always_inline void
433 419
 ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
434 420
 		  struct ib_gid *gid ) {
435 421
 	ibdev->op->mcast_detach ( ibdev, qp, gid );
436 422
 }
437 423
 
438
-/**
439
- * Issue management datagram
440
- *
441
- * @v ibdev		Infiniband device
442
- * @v mad		Management datagram
443
- * @v len		Length of management datagram
444
- * @ret rc		Return status code
445
- */
446
-static inline __attribute__ (( always_inline )) int
447
-ib_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad, size_t len ) {
448
-	return ibdev->op->mad ( ibdev, mad, len );
449
-}
450
-
451 424
 /**
452 425
  * Get reference to Infiniband device
453 426
  *
454 427
  * @v ibdev		Infiniband device
455 428
  * @ret ibdev		Infiniband device
456 429
  */
457
-static inline __attribute__ (( always_inline )) struct ib_device *
430
+static inline __always_inline struct ib_device *
458 431
 ibdev_get ( struct ib_device *ibdev ) {
459 432
 	ref_get ( &ibdev->refcnt );
460 433
 	return ibdev;
@@ -465,7 +438,7 @@ ibdev_get ( struct ib_device *ibdev ) {
465 438
  *
466 439
  * @v ibdev		Infiniband device
467 440
  */
468
-static inline __attribute__ (( always_inline )) void
441
+static inline __always_inline void
469 442
 ibdev_put ( struct ib_device *ibdev ) {
470 443
 	ref_put ( &ibdev->refcnt );
471 444
 }
@@ -476,7 +449,7 @@ ibdev_put ( struct ib_device *ibdev ) {
476 449
  * @v wq		Work queue
477 450
  * @v priv		Private data
478 451
  */
479
-static inline __attribute__ (( always_inline )) void
452
+static inline __always_inline void
480 453
 ib_wq_set_drvdata ( struct ib_work_queue *wq, void *priv ) {
481 454
 	wq->drv_priv = priv;
482 455
 }
@@ -487,7 +460,7 @@ ib_wq_set_drvdata ( struct ib_work_queue *wq, void *priv ) {
487 460
  * @v wq		Work queue
488 461
  * @ret priv		Private data
489 462
  */
490
-static inline __attribute__ (( always_inline )) void *
463
+static inline __always_inline void *
491 464
 ib_wq_get_drvdata ( struct ib_work_queue *wq ) {
492 465
 	return wq->drv_priv;
493 466
 }
@@ -498,7 +471,7 @@ ib_wq_get_drvdata ( struct ib_work_queue *wq ) {
498 471
  * @v qp		Queue pair
499 472
  * @v priv		Private data
500 473
  */
501
-static inline __attribute__ (( always_inline )) void
474
+static inline __always_inline void
502 475
 ib_qp_set_drvdata ( struct ib_queue_pair *qp, void *priv ) {
503 476
 	qp->drv_priv = priv;
504 477
 }
@@ -509,7 +482,7 @@ ib_qp_set_drvdata ( struct ib_queue_pair *qp, void *priv ) {
509 482
  * @v qp		Queue pair
510 483
  * @ret priv		Private data
511 484
  */
512
-static inline __attribute__ (( always_inline )) void *
485
+static inline __always_inline void *
513 486
 ib_qp_get_drvdata ( struct ib_queue_pair *qp ) {
514 487
 	return qp->drv_priv;
515 488
 }
@@ -520,7 +493,7 @@ ib_qp_get_drvdata ( struct ib_queue_pair *qp ) {
520 493
  * @v qp		Queue pair
521 494
  * @v priv		Private data
522 495
  */
523
-static inline __attribute__ (( always_inline )) void
496
+static inline __always_inline void
524 497
 ib_qp_set_ownerdata ( struct ib_queue_pair *qp, void *priv ) {
525 498
 	qp->owner_priv = priv;
526 499
 }
@@ -531,7 +504,7 @@ ib_qp_set_ownerdata ( struct ib_queue_pair *qp, void *priv ) {
531 504
  * @v qp		Queue pair
532 505
  * @ret priv		Private data
533 506
  */
534
-static inline __attribute__ (( always_inline )) void *
507
+static inline __always_inline void *
535 508
 ib_qp_get_ownerdata ( struct ib_queue_pair *qp ) {
536 509
 	return qp->owner_priv;
537 510
 }
@@ -542,7 +515,7 @@ ib_qp_get_ownerdata ( struct ib_queue_pair *qp ) {
542 515
  * @v cq		Completion queue
543 516
  * @v priv		Private data
544 517
  */
545
-static inline __attribute__ (( always_inline )) void
518
+static inline __always_inline void
546 519
 ib_cq_set_drvdata ( struct ib_completion_queue *cq, void *priv ) {
547 520
 	cq->drv_priv = priv;
548 521
 }
@@ -553,7 +526,7 @@ ib_cq_set_drvdata ( struct ib_completion_queue *cq, void *priv ) {
553 526
  * @v cq		Completion queue
554 527
  * @ret priv		Private data
555 528
  */
556
-static inline __attribute__ (( always_inline )) void *
529
+static inline __always_inline void *
557 530
 ib_cq_get_drvdata ( struct ib_completion_queue *cq ) {
558 531
 	return cq->drv_priv;
559 532
 }
@@ -564,7 +537,7 @@ ib_cq_get_drvdata ( struct ib_completion_queue *cq ) {
564 537
  * @v ibdev		Infiniband device
565 538
  * @v priv		Private data
566 539
  */
567
-static inline __attribute__ (( always_inline )) void
540
+static inline __always_inline void
568 541
 ib_set_drvdata ( struct ib_device *ibdev, void *priv ) {
569 542
 	ibdev->drv_priv = priv;
570 543
 }
@@ -575,7 +548,7 @@ ib_set_drvdata ( struct ib_device *ibdev, void *priv ) {
575 548
  * @v ibdev		Infiniband device
576 549
  * @ret priv		Private data
577 550
  */
578
-static inline __attribute__ (( always_inline )) void *
551
+static inline __always_inline void *
579 552
 ib_get_drvdata ( struct ib_device *ibdev ) {
580 553
 	return ibdev->drv_priv;
581 554
 }
@@ -586,7 +559,7 @@ ib_get_drvdata ( struct ib_device *ibdev ) {
586 559
  * @v ibdev		Infiniband device
587 560
  * @v priv		Private data
588 561
  */
589
-static inline __attribute__ (( always_inline )) void
562
+static inline __always_inline void
590 563
 ib_set_ownerdata ( struct ib_device *ibdev, void *priv ) {
591 564
 	ibdev->owner_priv = priv;
592 565
 }
@@ -597,201 +570,9 @@ ib_set_ownerdata ( struct ib_device *ibdev, void *priv ) {
597 570
  * @v ibdev		Infiniband device
598 571
  * @ret priv		Private data
599 572
  */
600
-static inline __attribute__ (( always_inline )) void *
573
+static inline __always_inline void *
601 574
 ib_get_ownerdata ( struct ib_device *ibdev ) {
602 575
 	return ibdev->owner_priv;
603 576
 }
604 577
 
605
-/*****************************************************************************
606
- *
607
- * Management datagrams
608
- *
609
- * Portions Copyright (c) 2004 Mellanox Technologies Ltd.  All rights
610
- * reserved.
611
- *
612
- */
613
-
614
-/* Management base version */
615
-#define IB_MGMT_BASE_VERSION			1
616
-
617
-/* Management classes */
618
-#define IB_MGMT_CLASS_SUBN_LID_ROUTED		0x01
619
-#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE	0x81
620
-#define IB_MGMT_CLASS_SUBN_ADM			0x03
621
-#define IB_MGMT_CLASS_PERF_MGMT			0x04
622
-#define IB_MGMT_CLASS_BM			0x05
623
-#define IB_MGMT_CLASS_DEVICE_MGMT		0x06
624
-#define IB_MGMT_CLASS_CM			0x07
625
-#define IB_MGMT_CLASS_SNMP			0x08
626
-#define IB_MGMT_CLASS_VENDOR_RANGE2_START	0x30
627
-#define IB_MGMT_CLASS_VENDOR_RANGE2_END		0x4F
628
-
629
-/* Management methods */
630
-#define IB_MGMT_METHOD_GET			0x01
631
-#define IB_MGMT_METHOD_SET			0x02
632
-#define IB_MGMT_METHOD_GET_RESP			0x81
633
-#define IB_MGMT_METHOD_SEND			0x03
634
-#define IB_MGMT_METHOD_TRAP			0x05
635
-#define IB_MGMT_METHOD_REPORT			0x06
636
-#define IB_MGMT_METHOD_REPORT_RESP		0x86
637
-#define IB_MGMT_METHOD_TRAP_REPRESS		0x07
638
-#define IB_MGMT_METHOD_DELETE			0x15
639
-#define IB_MGMT_METHOD_RESP			0x80
640
-
641
-/* Subnet management attributes */
642
-#define IB_SMP_ATTR_NOTICE			0x0002
643
-#define IB_SMP_ATTR_NODE_DESC			0x0010
644
-#define IB_SMP_ATTR_NODE_INFO			0x0011
645
-#define IB_SMP_ATTR_SWITCH_INFO			0x0012
646
-#define IB_SMP_ATTR_GUID_INFO			0x0014
647
-#define IB_SMP_ATTR_PORT_INFO			0x0015
648
-#define IB_SMP_ATTR_PKEY_TABLE			0x0016
649
-#define IB_SMP_ATTR_SL_TO_VL_TABLE		0x0017
650
-#define IB_SMP_ATTR_VL_ARB_TABLE		0x0018
651
-#define IB_SMP_ATTR_LINEAR_FORWARD_TABLE	0x0019
652
-#define IB_SMP_ATTR_RANDOM_FORWARD_TABLE	0x001A
653
-#define IB_SMP_ATTR_MCAST_FORWARD_TABLE		0x001B
654
-#define IB_SMP_ATTR_SM_INFO			0x0020
655
-#define IB_SMP_ATTR_VENDOR_DIAG			0x0030
656
-#define IB_SMP_ATTR_LED_INFO			0x0031
657
-#define IB_SMP_ATTR_VENDOR_MASK			0xFF00
658
-
659
-#define IB_SA_ATTR_MC_MEMBER_REC		0x38
660
-#define IB_SA_ATTR_PATH_REC			0x35
661
-
662
-#define IB_SA_MCMEMBER_REC_MGID			(1<<0)
663
-#define IB_SA_MCMEMBER_REC_PORT_GID		(1<<1)
664
-#define IB_SA_MCMEMBER_REC_QKEY			(1<<2)
665
-#define IB_SA_MCMEMBER_REC_MLID			(1<<3)
666
-#define IB_SA_MCMEMBER_REC_MTU_SELECTOR		(1<<4)
667
-#define IB_SA_MCMEMBER_REC_MTU			(1<<5)
668
-#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS	(1<<6)
669
-#define IB_SA_MCMEMBER_REC_PKEY			(1<<7)
670
-#define IB_SA_MCMEMBER_REC_RATE_SELECTOR	(1<<8)
671
-#define IB_SA_MCMEMBER_REC_RATE			(1<<9)
672
-#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR	(1<<10)
673
-#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME	(1<<11)
674
-#define IB_SA_MCMEMBER_REC_SL			(1<<12)
675
-#define IB_SA_MCMEMBER_REC_FLOW_LABEL		(1<<13)
676
-#define IB_SA_MCMEMBER_REC_HOP_LIMIT		(1<<14)
677
-#define IB_SA_MCMEMBER_REC_SCOPE		(1<<15)
678
-#define IB_SA_MCMEMBER_REC_JOIN_STATE		(1<<16)
679
-#define IB_SA_MCMEMBER_REC_PROXY_JOIN		(1<<17)
680
-
681
-#define IB_SA_PATH_REC_DGID			(1<<2)
682
-#define IB_SA_PATH_REC_SGID			(1<<3)
683
-
684
-struct ib_mad_hdr {
685
-	uint8_t base_version;
686
-	uint8_t mgmt_class;
687
-	uint8_t class_version;
688
-	uint8_t method;
689
-	uint16_t status;
690
-	uint16_t class_specific;
691
-	uint32_t tid[2];
692
-	uint16_t attr_id;
693
-	uint16_t resv;
694
-	uint32_t attr_mod;
695
-} __attribute__ (( packed ));
696
-
697
-struct ib_sa_hdr {
698
-	uint32_t sm_key[2];
699
-	uint16_t reserved;
700
-	uint16_t attrib_offset;
701
-	uint32_t comp_mask[2];
702
-} __attribute__ (( packed ));
703
-
704
-struct ib_rmpp_hdr {
705
-	uint32_t raw[3];
706
-} __attribute__ (( packed ));
707
-
708
-struct ib_mad_data {
709
-	struct ib_mad_hdr mad_hdr;
710
-	uint8_t data[232];
711
-} __attribute__ (( packed ));
712
-
713
-struct ib_mad_guid_info {
714
-	struct ib_mad_hdr mad_hdr;
715
-	uint32_t mkey[2];
716
-	uint32_t reserved[8];
717
-	uint8_t gid_local[8];
718
-} __attribute__ (( packed ));
719
-
720
-struct ib_mad_port_info {
721
-	struct ib_mad_hdr mad_hdr;
722
-	uint32_t mkey[2];
723
-	uint32_t reserved[8];
724
-	uint32_t mkey2[2];
725
-	uint8_t gid_prefix[8];
726
-	uint16_t lid;
727
-	uint16_t mastersm_lid;
728
-	uint32_t cap_mask;
729
-	uint16_t diag_code;
730
-	uint16_t mkey_lease_period;
731
-	uint8_t local_port_num;
732
-	uint8_t link_width_enabled;
733
-	uint8_t link_width_supported;
734
-	uint8_t link_width_active;
735
-	uint8_t port_state__link_speed_supported;
736
-	uint8_t link_down_def_state__port_phys_state;
737
-	uint8_t lmc__r1__mkey_prot_bits;
738
-	uint8_t link_speed_enabled__link_speed_active;
739
-} __attribute__ (( packed ));
740
-
741
-struct ib_mad_pkey_table {
742
-	struct ib_mad_hdr mad_hdr;
743
-	uint32_t mkey[2];
744
-	uint32_t reserved[8];
745
-	uint16_t pkey[16][2];
746
-} __attribute__ (( packed ));
747
-
748
-struct ib_mad_path_record {
749
-	struct ib_mad_hdr mad_hdr;
750
-	struct ib_rmpp_hdr rmpp_hdr;
751
-	struct ib_sa_hdr sa_hdr;
752
-	uint32_t reserved0[2];
753
-	struct ib_gid dgid;
754
-	struct ib_gid sgid;
755
-	uint16_t dlid;
756
-	uint16_t slid;
757
-	uint32_t hop_limit__flow_label__raw_traffic;
758
-	uint32_t pkey__numb_path__reversible__tclass;
759
-	uint8_t reserved1;
760
-	uint8_t reserved__sl;
761
-	uint8_t mtu_selector__mtu;
762
-	uint8_t rate_selector__rate;
763
-	uint32_t preference__packet_lifetime__packet_lifetime_selector;
764
-	uint32_t reserved2[35];
765
-} __attribute__ (( packed ));
766
-
767
-struct ib_mad_mc_member_record {
768
-	struct ib_mad_hdr mad_hdr;
769
-	struct ib_rmpp_hdr rmpp_hdr;
770
-	struct ib_sa_hdr sa_hdr;
771
-	struct ib_gid mgid;
772
-	struct ib_gid port_gid;
773
-	uint32_t qkey;
774
-	uint16_t mlid;
775
-	uint8_t mtu_selector__mtu;
776
-	uint8_t tclass;
777
-	uint16_t pkey;
778
-	uint8_t rate_selector__rate;
779
-	uint8_t packet_lifetime_selector__packet_lifetime;
780
-	uint32_t sl__flow_label__hop_limit;
781
-	uint8_t scope__join_state;
782
-	uint8_t proxy_join__reserved;
783
-	uint16_t reserved0;
784
-	uint32_t reserved1[37];
785
-} __attribute__ (( packed ));
786
-
787
-union ib_mad {
788
-	struct ib_mad_hdr mad_hdr;
789
-	struct ib_mad_data data;
790
-	struct ib_mad_guid_info guid_info;
791
-	struct ib_mad_port_info port_info;
792
-	struct ib_mad_pkey_table pkey_table;
793
-	struct ib_mad_path_record path_record;
794
-	struct ib_mad_mc_member_record mc_member_record;
795
-} __attribute__ (( packed ));
796
-
797 578
 #endif /* _GPXE_INFINIBAND_H */

+ 2
- 149
src/net/infiniband.c Ver fichero

@@ -333,142 +333,6 @@ void ib_complete_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
333 333
 	qp->recv.fill--;
334 334
 }
335 335
 
336
-/***************************************************************************
337
- *
338
- * Management datagram operations
339
- *
340
- ***************************************************************************
341
- */
342
-
343
-/**
344
- * Get port information
345
- *
346
- * @v ibdev		Infiniband device
347
- * @v port_info		Port information datagram to fill in
348
- * @ret rc		Return status code
349
- */
350
-static int ib_get_port_info ( struct ib_device *ibdev,
351
-			      struct ib_mad_port_info *port_info ) {
352
-	struct ib_mad_hdr *hdr = &port_info->mad_hdr;
353
-	int rc;
354
-
355
-	/* Construct MAD */
356
-	memset ( port_info, 0, sizeof ( *port_info ) );
357
-	hdr->base_version = IB_MGMT_BASE_VERSION;
358
-	hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
359
-	hdr->class_version = 1;
360
-	hdr->method = IB_MGMT_METHOD_GET;
361
-	hdr->attr_id = htons ( IB_SMP_ATTR_PORT_INFO );
362
-	hdr->attr_mod = htonl ( ibdev->port );
363
-
364
-	if ( ( rc = ib_mad ( ibdev, hdr, sizeof ( *port_info ) ) ) != 0 ) {
365
-		DBGC ( ibdev, "IBDEV %p could not get port info: %s\n",
366
-		       ibdev, strerror ( rc ) );
367
-		return rc;
368
-	}
369
-	return 0;
370
-}
371
-
372
-/**
373
- * Get GUID information
374
- *
375
- * @v ibdev		Infiniband device
376
- * @v guid_info		GUID information datagram to fill in
377
- * @ret rc		Return status code
378
- */
379
-static int ib_get_guid_info ( struct ib_device *ibdev,
380
-			      struct ib_mad_guid_info *guid_info ) {
381
-	struct ib_mad_hdr *hdr = &guid_info->mad_hdr;
382
-	int rc;
383
-
384
-	/* Construct MAD */
385
-	memset ( guid_info, 0, sizeof ( *guid_info ) );
386
-	hdr->base_version = IB_MGMT_BASE_VERSION;
387
-	hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
388
-	hdr->class_version = 1;
389
-	hdr->method = IB_MGMT_METHOD_GET;
390
-	hdr->attr_id = htons ( IB_SMP_ATTR_GUID_INFO );
391
-
392
-	if ( ( rc = ib_mad ( ibdev, hdr, sizeof ( *guid_info ) ) ) != 0 ) {
393
-		DBGC ( ibdev, "IBDEV %p could not get GUID info: %s\n",
394
-		       ibdev, strerror ( rc ) );
395
-		return rc;
396
-	}
397
-	return 0;
398
-}
399
-
400
-/**
401
- * Get partition key table
402
- *
403
- * @v ibdev		Infiniband device
404
- * @v guid_info		Partition key table datagram to fill in
405
- * @ret rc		Return status code
406
- */
407
-static int ib_get_pkey_table ( struct ib_device *ibdev,
408
-			       struct ib_mad_pkey_table *pkey_table ) {
409
-	struct ib_mad_hdr *hdr = &pkey_table->mad_hdr;
410
-	int rc;
411
-
412
-	/* Construct MAD */
413
-	memset ( pkey_table, 0, sizeof ( *pkey_table ) );
414
-	hdr->base_version = IB_MGMT_BASE_VERSION;
415
-	hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
416
-	hdr->class_version = 1;
417
-	hdr->method = IB_MGMT_METHOD_GET;
418
-	hdr->attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE );
419
-
420
-	if ( ( rc = ib_mad ( ibdev, hdr, sizeof ( *pkey_table ) ) ) != 0 ) {
421
-		DBGC ( ibdev, "IBDEV %p could not get pkey table: %s\n",
422
-		       ibdev, strerror ( rc ) );
423
-		return rc;
424
-	}
425
-	return 0;
426
-}
427
-
428
-/**
429
- * Get MAD parameters
430
- *
431
- * @v ibdev		Infiniband device
432
- * @ret rc		Return status code
433
- */
434
-static int ib_get_mad_params ( struct ib_device *ibdev ) {
435
-	union {
436
-		/* This union exists just to save stack space */
437
-		struct ib_mad_port_info port_info;
438
-		struct ib_mad_guid_info guid_info;
439
-		struct ib_mad_pkey_table pkey_table;
440
-	} u;
441
-	int rc;
442
-
443
-	/* Port info gives us the link state, the first half of the
444
-	 * port GID and the SM LID.
445
-	 */
446
-	if ( ( rc = ib_get_port_info ( ibdev, &u.port_info ) ) != 0 )
447
-		return rc;
448
-	ibdev->link_up = ( ( u.port_info.port_state__link_speed_supported
449
-			     & 0xf ) == 4 );
450
-	memcpy ( &ibdev->port_gid.u.bytes[0], u.port_info.gid_prefix, 8 );
451
-	ibdev->sm_lid = ntohs ( u.port_info.mastersm_lid );
452
-
453
-	/* GUID info gives us the second half of the port GID */
454
-	if ( ( rc = ib_get_guid_info ( ibdev, &u.guid_info ) ) != 0 )
455
-		return rc;
456
-	memcpy ( &ibdev->port_gid.u.bytes[8], u.guid_info.gid_local, 8 );
457
-
458
-	/* Get partition key */
459
-	if ( ( rc = ib_get_pkey_table ( ibdev, &u.pkey_table ) ) != 0 )
460
-		return rc;
461
-	ibdev->pkey = ntohs ( u.pkey_table.pkey[0][0] );
462
-
463
-	DBGC ( ibdev, "IBDEV %p port GID is %08lx:%08lx:%08lx:%08lx\n",
464
-	       ibdev, htonl ( ibdev->port_gid.u.dwords[0] ),
465
-	       htonl ( ibdev->port_gid.u.dwords[1] ),
466
-	       htonl ( ibdev->port_gid.u.dwords[2] ),
467
-	       htonl ( ibdev->port_gid.u.dwords[3] ) );
468
-
469
-	return 0;
470
-}
471
-
472 336
 /***************************************************************************
473 337
  *
474 338
  * Event queues
@@ -482,14 +346,6 @@ static int ib_get_mad_params ( struct ib_device *ibdev ) {
482 346
  * @v ibdev		Infiniband device
483 347
  */
484 348
 void ib_link_state_changed ( struct ib_device *ibdev ) {
485
-	int rc;
486
-
487
-	/* Update MAD parameters */
488
-	if ( ( rc = ib_get_mad_params ( ibdev ) ) != 0 ) {
489
-		DBGC ( ibdev, "IBDEV %p could not update MAD parameters: %s\n",
490
-		       ibdev, strerror ( rc ) );
491
-		return;
492
-	}
493 349
 
494 350
 	/* Notify IPoIB of link state change */
495 351
 	ipoib_link_state_changed ( ibdev );
@@ -536,6 +392,8 @@ struct ib_device * alloc_ibdev ( size_t priv_size ) {
536 392
 	if ( ibdev ) {
537 393
 		drv_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
538 394
 		ib_set_drvdata ( ibdev, drv_priv );
395
+		ibdev->lid = IB_LID_NONE;
396
+		ibdev->pkey = IB_PKEY_NONE;
539 397
 	}
540 398
 	return ibdev;
541 399
 }
@@ -557,10 +415,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
557 415
 	if ( ( rc = ib_open ( ibdev ) ) != 0 )
558 416
 		goto err_open;
559 417
 
560
-	/* Get MAD parameters */
561
-	if ( ( rc = ib_get_mad_params ( ibdev ) ) != 0 )
562
-		goto err_get_mad_params;
563
-
564 418
 	/* Add IPoIB device */
565 419
 	if ( ( rc = ipoib_probe ( ibdev ) ) != 0 ) {
566 420
 		DBGC ( ibdev, "IBDEV %p could not add IPoIB device: %s\n",
@@ -573,7 +427,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
573 427
 	return 0;
574 428
 
575 429
  err_ipoib_probe:
576
- err_get_mad_params:
577 430
 	ib_close ( ibdev );
578 431
  err_open:
579 432
 	list_del ( &ibdev->list );

Loading…
Cancelar
Guardar