Browse Source

[Infiniband] Add preliminary support for multi-port devices.

Arbel and Hermon cards both have multiple ports.  Add the
infrastructure required to register each port as a separate IB
device.  Don't yet register more than one port, since registration
will currently fail unless a valid link is detected.

Use ib_*_{set,get}_{drv,owner}data wrappers to access driver- and
owner-private data on Infiniband structures.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
bc3f0a25c6

+ 67
- 48
src/drivers/infiniband/arbel.c View File

43
  *
43
  *
44
  */
44
  */
45
 
45
 
46
-/* Port to use */
47
-#define PXE_IB_PORT 1
48
-
49
 /***************************************************************************
46
 /***************************************************************************
50
  *
47
  *
51
  * Queue number allocation
48
  * Queue number allocation
482
  */
479
  */
483
 static int arbel_create_cq ( struct ib_device *ibdev,
480
 static int arbel_create_cq ( struct ib_device *ibdev,
484
 			     struct ib_completion_queue *cq ) {
481
 			     struct ib_completion_queue *cq ) {
485
-	struct arbel *arbel = ibdev->dev_priv;
482
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
486
 	struct arbel_completion_queue *arbel_cq;
483
 	struct arbel_completion_queue *arbel_cq;
487
 	struct arbelprm_completion_queue_context cqctx;
484
 	struct arbelprm_completion_queue_context cqctx;
488
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
485
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
560
 	DBGC ( arbel, "Arbel %p CQN %#lx ring at [%p,%p)\n",
557
 	DBGC ( arbel, "Arbel %p CQN %#lx ring at [%p,%p)\n",
561
 	       arbel, cq->cqn, arbel_cq->cqe,
558
 	       arbel, cq->cqn, arbel_cq->cqe,
562
 	       ( ( ( void * ) arbel_cq->cqe ) + arbel_cq->cqe_size ) );
559
 	       ( ( ( void * ) arbel_cq->cqe ) + arbel_cq->cqe_size ) );
563
-	cq->dev_priv = arbel_cq;
560
+	ib_cq_set_drvdata ( cq, arbel_cq );
564
 	return 0;
561
 	return 0;
565
 
562
 
566
  err_sw2hw_cq:
563
  err_sw2hw_cq:
583
  */
580
  */
584
 static void arbel_destroy_cq ( struct ib_device *ibdev,
581
 static void arbel_destroy_cq ( struct ib_device *ibdev,
585
 			       struct ib_completion_queue *cq ) {
582
 			       struct ib_completion_queue *cq ) {
586
-	struct arbel *arbel = ibdev->dev_priv;
587
-	struct arbel_completion_queue *arbel_cq = cq->dev_priv;
583
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
584
+	struct arbel_completion_queue *arbel_cq = ib_cq_get_drvdata ( cq );
588
 	struct arbelprm_completion_queue_context cqctx;
585
 	struct arbelprm_completion_queue_context cqctx;
589
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
586
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
590
 	struct arbelprm_cq_arm_db_record *arm_db_rec;
587
 	struct arbelprm_cq_arm_db_record *arm_db_rec;
613
 	cqn_offset = ( cq->cqn - arbel->limits.reserved_cqs );
610
 	cqn_offset = ( cq->cqn - arbel->limits.reserved_cqs );
614
 	arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
611
 	arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
615
 
612
 
616
-	cq->dev_priv = NULL;
613
+	ib_cq_set_drvdata ( cq, NULL );
617
 }
614
 }
618
 
615
 
619
 /***************************************************************************
616
 /***************************************************************************
712
  */
709
  */
713
 static int arbel_create_qp ( struct ib_device *ibdev,
710
 static int arbel_create_qp ( struct ib_device *ibdev,
714
 			     struct ib_queue_pair *qp ) {
711
 			     struct ib_queue_pair *qp ) {
715
-	struct arbel *arbel = ibdev->dev_priv;
712
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
716
 	struct arbel_queue_pair *arbel_qp;
713
 	struct arbel_queue_pair *arbel_qp;
717
 	struct arbelprm_qp_ee_state_transitions qpctx;
714
 	struct arbelprm_qp_ee_state_transitions qpctx;
718
 	struct arbelprm_qp_db_record *send_db_rec;
715
 	struct arbelprm_qp_db_record *send_db_rec;
819
 	DBGC ( arbel, "Arbel %p QPN %#lx receive ring at [%p,%p)\n",
816
 	DBGC ( arbel, "Arbel %p QPN %#lx receive ring at [%p,%p)\n",
820
 	       arbel, qp->qpn, arbel_qp->recv.wqe,
817
 	       arbel, qp->qpn, arbel_qp->recv.wqe,
821
 	       ( ( (void *) arbel_qp->recv.wqe ) + arbel_qp->recv.wqe_size ) );
818
 	       ( ( (void *) arbel_qp->recv.wqe ) + arbel_qp->recv.wqe_size ) );
822
-	qp->dev_priv = arbel_qp;
819
+	ib_qp_set_drvdata ( qp, arbel_qp );
823
 	return 0;
820
 	return 0;
824
 
821
 
825
  err_rtr2rts_qpee:
822
  err_rtr2rts_qpee:
847
  */
844
  */
848
 static void arbel_destroy_qp ( struct ib_device *ibdev,
845
 static void arbel_destroy_qp ( struct ib_device *ibdev,
849
 			       struct ib_queue_pair *qp ) {
846
 			       struct ib_queue_pair *qp ) {
850
-	struct arbel *arbel = ibdev->dev_priv;
851
-	struct arbel_queue_pair *arbel_qp = qp->dev_priv;
847
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
848
+	struct arbel_queue_pair *arbel_qp = ib_qp_get_drvdata ( qp );
852
 	struct arbelprm_qp_db_record *send_db_rec;
849
 	struct arbelprm_qp_db_record *send_db_rec;
853
 	struct arbelprm_qp_db_record *recv_db_rec;
850
 	struct arbelprm_qp_db_record *recv_db_rec;
854
 	int qpn_offset;
851
 	int qpn_offset;
877
 	qpn_offset = ( qp->qpn - ARBEL_QPN_BASE - arbel->limits.reserved_qps );
874
 	qpn_offset = ( qp->qpn - ARBEL_QPN_BASE - arbel->limits.reserved_qps );
878
 	arbel_free_qn_offset ( arbel->qp_inuse, qpn_offset );
875
 	arbel_free_qn_offset ( arbel->qp_inuse, qpn_offset );
879
 
876
 
880
-	qp->dev_priv = NULL;
877
+	ib_qp_set_drvdata ( qp, NULL );
881
 }
878
 }
882
 
879
 
883
 /***************************************************************************
880
 /***************************************************************************
926
 			     struct ib_queue_pair *qp,
923
 			     struct ib_queue_pair *qp,
927
 			     struct ib_address_vector *av,
924
 			     struct ib_address_vector *av,
928
 			     struct io_buffer *iobuf ) {
925
 			     struct io_buffer *iobuf ) {
929
-	struct arbel *arbel = ibdev->dev_priv;
930
-	struct arbel_queue_pair *arbel_qp = qp->dev_priv;
926
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
927
+	struct arbel_queue_pair *arbel_qp = ib_qp_get_drvdata ( qp );
931
 	struct ib_work_queue *wq = &qp->send;
928
 	struct ib_work_queue *wq = &qp->send;
932
 	struct arbel_send_work_queue *arbel_send_wq = &arbel_qp->send;
929
 	struct arbel_send_work_queue *arbel_send_wq = &arbel_qp->send;
933
 	struct arbelprm_ud_send_wqe *prev_wqe;
930
 	struct arbelprm_ud_send_wqe *prev_wqe;
1016
 static int arbel_post_recv ( struct ib_device *ibdev,
1013
 static int arbel_post_recv ( struct ib_device *ibdev,
1017
 			     struct ib_queue_pair *qp,
1014
 			     struct ib_queue_pair *qp,
1018
 			     struct io_buffer *iobuf ) {
1015
 			     struct io_buffer *iobuf ) {
1019
-	struct arbel *arbel = ibdev->dev_priv;
1020
-	struct arbel_queue_pair *arbel_qp = qp->dev_priv;
1016
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1017
+	struct arbel_queue_pair *arbel_qp = ib_qp_get_drvdata ( qp );
1021
 	struct ib_work_queue *wq = &qp->recv;
1018
 	struct ib_work_queue *wq = &qp->recv;
1022
 	struct arbel_recv_work_queue *arbel_recv_wq = &arbel_qp->recv;
1019
 	struct arbel_recv_work_queue *arbel_recv_wq = &arbel_qp->recv;
1023
 	struct arbelprm_recv_wqe *wqe;
1020
 	struct arbelprm_recv_wqe *wqe;
1066
 			    union arbelprm_completion_entry *cqe,
1063
 			    union arbelprm_completion_entry *cqe,
1067
 			    ib_completer_t complete_send,
1064
 			    ib_completer_t complete_send,
1068
 			    ib_completer_t complete_recv ) {
1065
 			    ib_completer_t complete_recv ) {
1069
-	struct arbel *arbel = ibdev->dev_priv;
1066
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1070
 	struct ib_completion completion;
1067
 	struct ib_completion completion;
1071
 	struct ib_work_queue *wq;
1068
 	struct ib_work_queue *wq;
1072
 	struct ib_queue_pair *qp;
1069
 	struct ib_queue_pair *qp;
1108
 		return -EIO;
1105
 		return -EIO;
1109
 	}
1106
 	}
1110
 	qp = wq->qp;
1107
 	qp = wq->qp;
1111
-	arbel_qp = qp->dev_priv;
1108
+	arbel_qp = ib_qp_get_drvdata ( qp );
1112
 	arbel_send_wq = &arbel_qp->send;
1109
 	arbel_send_wq = &arbel_qp->send;
1113
 	arbel_recv_wq = &arbel_qp->recv;
1110
 	arbel_recv_wq = &arbel_qp->recv;
1114
 
1111
 
1170
 			    struct ib_completion_queue *cq,
1167
 			    struct ib_completion_queue *cq,
1171
 			    ib_completer_t complete_send,
1168
 			    ib_completer_t complete_send,
1172
 			    ib_completer_t complete_recv ) {
1169
 			    ib_completer_t complete_recv ) {
1173
-	struct arbel *arbel = ibdev->dev_priv;
1174
-	struct arbel_completion_queue *arbel_cq = cq->dev_priv;
1170
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1171
+	struct arbel_completion_queue *arbel_cq = ib_cq_get_drvdata ( cq );
1175
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
1172
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
1176
 	union arbelprm_completion_entry *cqe;
1173
 	union arbelprm_completion_entry *cqe;
1177
 	unsigned int cqe_idx_mask;
1174
 	unsigned int cqe_idx_mask;
1220
  * @ret rc		Return status code
1217
  * @ret rc		Return status code
1221
  */
1218
  */
1222
 static int arbel_open ( struct ib_device *ibdev ) {
1219
 static int arbel_open ( struct ib_device *ibdev ) {
1223
-	struct arbel *arbel = ibdev->dev_priv;
1220
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1224
 	struct arbelprm_init_ib init_ib;
1221
 	struct arbelprm_init_ib init_ib;
1225
 	int rc;
1222
 	int rc;
1226
 
1223
 
1247
  * @v ibdev		Infiniband device
1244
  * @v ibdev		Infiniband device
1248
  */
1245
  */
1249
 static void arbel_close ( struct ib_device *ibdev ) {
1246
 static void arbel_close ( struct ib_device *ibdev ) {
1250
-	struct arbel *arbel = ibdev->dev_priv;
1247
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1251
 	int rc;
1248
 	int rc;
1252
 
1249
 
1253
 	if ( ( rc = arbel_cmd_close_ib ( arbel, ibdev->port ) ) != 0 ) {
1250
 	if ( ( rc = arbel_cmd_close_ib ( arbel, ibdev->port ) ) != 0 ) {
1275
 static int arbel_mcast_attach ( struct ib_device *ibdev,
1272
 static int arbel_mcast_attach ( struct ib_device *ibdev,
1276
 				struct ib_queue_pair *qp,
1273
 				struct ib_queue_pair *qp,
1277
 				struct ib_gid *gid ) {
1274
 				struct ib_gid *gid ) {
1278
-	struct arbel *arbel = ibdev->dev_priv;
1275
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1279
 	struct arbelprm_mgm_hash hash;
1276
 	struct arbelprm_mgm_hash hash;
1280
 	struct arbelprm_mgm_entry mgm;
1277
 	struct arbelprm_mgm_entry mgm;
1281
 	unsigned int index;
1278
 	unsigned int index;
1330
 static void arbel_mcast_detach ( struct ib_device *ibdev,
1327
 static void arbel_mcast_detach ( struct ib_device *ibdev,
1331
 				 struct ib_queue_pair *qp __unused,
1328
 				 struct ib_queue_pair *qp __unused,
1332
 				 struct ib_gid *gid ) {
1329
 				 struct ib_gid *gid ) {
1333
-	struct arbel *arbel = ibdev->dev_priv;
1330
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1334
 	struct arbelprm_mgm_hash hash;
1331
 	struct arbelprm_mgm_hash hash;
1335
 	struct arbelprm_mgm_entry mgm;
1332
 	struct arbelprm_mgm_entry mgm;
1336
 	unsigned int index;
1333
 	unsigned int index;
1370
  */
1367
  */
1371
 static int arbel_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1368
 static int arbel_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1372
 		       size_t len ) {
1369
 		       size_t len ) {
1373
-	struct arbel *arbel = ibdev->dev_priv;
1370
+	struct arbel *arbel = ib_get_drvdata ( ibdev );
1374
 	union arbelprm_mad mad_ifc;
1371
 	union arbelprm_mad mad_ifc;
1375
 	int rc;
1372
 	int rc;
1376
 
1373
 
1837
  */
1834
  */
1838
 static int arbel_probe ( struct pci_device *pci,
1835
 static int arbel_probe ( struct pci_device *pci,
1839
 			 const struct pci_device_id *id __unused ) {
1836
 			 const struct pci_device_id *id __unused ) {
1840
-	struct ib_device *ibdev;
1841
 	struct arbel *arbel;
1837
 	struct arbel *arbel;
1838
+	struct ib_device *ibdev;
1842
 	struct arbelprm_init_hca init_hca;
1839
 	struct arbelprm_init_hca init_hca;
1840
+	int i;
1843
 	int rc;
1841
 	int rc;
1844
 
1842
 
1845
-	/* Allocate Infiniband device */
1846
-	ibdev = alloc_ibdev ( sizeof ( *arbel ) );
1847
-	if ( ! ibdev ) {
1843
+	/* Allocate Arbel device */
1844
+	arbel = zalloc ( sizeof ( *arbel ) );
1845
+	if ( ! arbel ) {
1848
 		rc = -ENOMEM;
1846
 		rc = -ENOMEM;
1849
-		goto err_ibdev;
1847
+		goto err_alloc_arbel;
1848
+	}
1849
+	pci_set_drvdata ( pci, arbel );
1850
+
1851
+	/* Allocate Infiniband devices */
1852
+	for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ ) {
1853
+		ibdev = alloc_ibdev ( 0 );
1854
+		if ( ! ibdev ) {
1855
+			rc = -ENOMEM;
1856
+			goto err_alloc_ibdev;
1857
+		}
1858
+		arbel->ibdev[i] = ibdev;
1859
+		ibdev->op = &arbel_ib_operations;
1860
+		ibdev->dev = &pci->dev;
1861
+		ibdev->port = ( ARBEL_PORT_BASE + i );
1862
+		ib_set_drvdata ( ibdev, arbel );
1850
 	}
1863
 	}
1851
-	ibdev->op = &arbel_ib_operations;
1852
-	pci_set_drvdata ( pci, ibdev );
1853
-	ibdev->dev = &pci->dev;
1854
-	ibdev->port = PXE_IB_PORT;
1855
-	arbel = ibdev->dev_priv;
1856
-	memset ( arbel, 0, sizeof ( *arbel ) );
1857
 
1864
 
1858
 	/* Fix up PCI device */
1865
 	/* Fix up PCI device */
1859
 	adjust_pci_device ( pci );
1866
 	adjust_pci_device ( pci );
1902
 	if ( ( rc = arbel_setup_mpt ( arbel ) ) != 0 )
1909
 	if ( ( rc = arbel_setup_mpt ( arbel ) ) != 0 )
1903
 		goto err_setup_mpt;
1910
 		goto err_setup_mpt;
1904
 
1911
 
1905
-	/* Register Infiniband device */
1906
-	if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
1907
-		DBGC ( arbel, "Arbel %p could not register IB device: %s\n",
1908
-		       arbel, strerror ( rc ) );
1909
-		goto err_register_ibdev;
1912
+	/* Register Infiniband devices */
1913
+	for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ ) {
1914
+		if ( ( rc = register_ibdev ( arbel->ibdev[i] ) ) != 0 ) {
1915
+			DBGC ( arbel, "Arbel %p could not register IB "
1916
+			       "device: %s\n", arbel, strerror ( rc ) );
1917
+			goto err_register_ibdev;
1918
+		}
1910
 	}
1919
 	}
1911
 
1920
 
1912
 	return 0;
1921
 	return 0;
1913
 
1922
 
1923
+	i = ( ARBEL_NUM_PORTS - 1 );
1914
  err_register_ibdev:
1924
  err_register_ibdev:
1925
+	for ( ; i >= 0 ; i-- )
1926
+		unregister_ibdev ( arbel->ibdev[i] );
1915
  err_setup_mpt:
1927
  err_setup_mpt:
1916
 	arbel_cmd_close_hca ( arbel );
1928
 	arbel_cmd_close_hca ( arbel );
1917
  err_init_hca:
1929
  err_init_hca:
1924
  err_mailbox_out:
1936
  err_mailbox_out:
1925
 	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
1937
 	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
1926
  err_mailbox_in:
1938
  err_mailbox_in:
1927
-	free_ibdev ( ibdev );
1928
- err_ibdev:
1939
+	i = ( ARBEL_NUM_PORTS - 1 );
1940
+ err_alloc_ibdev:
1941
+	for ( ; i >= 0 ; i-- )
1942
+		free_ibdev ( arbel->ibdev[i] );
1943
+	free ( arbel );
1944
+ err_alloc_arbel:
1929
 	return rc;
1945
 	return rc;
1930
 }
1946
 }
1931
 
1947
 
1935
  * @v pci		PCI device
1951
  * @v pci		PCI device
1936
  */
1952
  */
1937
 static void arbel_remove ( struct pci_device *pci ) {
1953
 static void arbel_remove ( struct pci_device *pci ) {
1938
-	struct ib_device *ibdev = pci_get_drvdata ( pci );
1939
-	struct arbel *arbel = ibdev->dev_priv;
1954
+	struct arbel *arbel = pci_get_drvdata ( pci );
1955
+	int i;
1940
 
1956
 
1941
-	unregister_ibdev ( ibdev );
1957
+	for ( i = ( ARBEL_NUM_PORTS - 1 ) ; i >= 0 ; i-- )
1958
+		unregister_ibdev ( arbel->ibdev[i] );
1942
 	arbel_cmd_close_hca ( arbel );
1959
 	arbel_cmd_close_hca ( arbel );
1943
 	arbel_free_icm ( arbel );
1960
 	arbel_free_icm ( arbel );
1944
 	arbel_stop_firmware ( arbel );
1961
 	arbel_stop_firmware ( arbel );
1945
 	arbel_stop_firmware ( arbel );
1962
 	arbel_stop_firmware ( arbel );
1946
 	free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
1963
 	free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
1947
 	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
1964
 	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
1948
-	free_ibdev ( ibdev );
1965
+	for ( i = ( ARBEL_NUM_PORTS - 1 ) ; i >= 0 ; i-- )
1966
+		free_ibdev ( arbel->ibdev[i] );
1967
+	free ( arbel );
1949
 }
1968
 }
1950
 
1969
 
1951
 static struct pci_device_id arbel_nics[] = {
1970
 static struct pci_device_id arbel_nics[] = {

+ 7
- 0
src/drivers/infiniband/arbel.h View File

17
  *
17
  *
18
  */
18
  */
19
 
19
 
20
+/* Ports in existence */
21
+#define ARBEL_NUM_PORTS			1
22
+#define ARBEL_PORT_BASE			1
23
+
20
 /* PCI BARs */
24
 /* PCI BARs */
21
 #define ARBEL_PCI_CONFIG_BAR		PCI_BASE_ADDRESS_0
25
 #define ARBEL_PCI_CONFIG_BAR		PCI_BASE_ADDRESS_0
22
 #define ARBEL_PCI_CONFIG_BAR_SIZE	0x100000
26
 #define ARBEL_PCI_CONFIG_BAR_SIZE	0x100000
344
 	
348
 	
345
 	/** Device limits */
349
 	/** Device limits */
346
 	struct arbel_dev_limits limits;
350
 	struct arbel_dev_limits limits;
351
+
352
+	/** Infiniband devices */
353
+	struct ib_device *ibdev[ARBEL_NUM_PORTS];
347
 };
354
 };
348
 
355
 
349
 /** Global protection domain */
356
 /** Global protection domain */

+ 67
- 48
src/drivers/infiniband/hermon.c View File

41
  *
41
  *
42
  */
42
  */
43
 
43
 
44
-/* Port to use */
45
-#define PXE_IB_PORT 1
46
-
47
 /***************************************************************************
44
 /***************************************************************************
48
  *
45
  *
49
  * Queue number allocation
46
  * Queue number allocation
599
  */
596
  */
600
 static int hermon_create_cq ( struct ib_device *ibdev,
597
 static int hermon_create_cq ( struct ib_device *ibdev,
601
 			      struct ib_completion_queue *cq ) {
598
 			      struct ib_completion_queue *cq ) {
602
-	struct hermon *hermon = ibdev->dev_priv;
599
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
603
 	struct hermon_completion_queue *hermon_cq;
600
 	struct hermon_completion_queue *hermon_cq;
604
 	struct hermonprm_completion_queue_context cqctx;
601
 	struct hermonprm_completion_queue_context cqctx;
605
 	int cqn_offset;
602
 	int cqn_offset;
665
 	DBGC ( hermon, "Hermon %p CQN %#lx ring at [%p,%p)\n",
662
 	DBGC ( hermon, "Hermon %p CQN %#lx ring at [%p,%p)\n",
666
 	       hermon, cq->cqn, hermon_cq->cqe,
663
 	       hermon, cq->cqn, hermon_cq->cqe,
667
 	       ( ( ( void * ) hermon_cq->cqe ) + hermon_cq->cqe_size ) );
664
 	       ( ( ( void * ) hermon_cq->cqe ) + hermon_cq->cqe_size ) );
668
-	cq->dev_priv = hermon_cq;
665
+	ib_cq_set_drvdata ( cq, hermon_cq );
669
 	return 0;
666
 	return 0;
670
 
667
 
671
  err_sw2hw_cq:
668
  err_sw2hw_cq:
688
  */
685
  */
689
 static void hermon_destroy_cq ( struct ib_device *ibdev,
686
 static void hermon_destroy_cq ( struct ib_device *ibdev,
690
 				struct ib_completion_queue *cq ) {
687
 				struct ib_completion_queue *cq ) {
691
-	struct hermon *hermon = ibdev->dev_priv;
692
-	struct hermon_completion_queue *hermon_cq = cq->dev_priv;
688
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
689
+	struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
693
 	struct hermonprm_completion_queue_context cqctx;
690
 	struct hermonprm_completion_queue_context cqctx;
694
 	int cqn_offset;
691
 	int cqn_offset;
695
 	int rc;
692
 	int rc;
713
 	cqn_offset = ( cq->cqn - hermon->cap.reserved_cqs );
710
 	cqn_offset = ( cq->cqn - hermon->cap.reserved_cqs );
714
 	hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
711
 	hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
715
 
712
 
716
-	cq->dev_priv = NULL;
713
+	ib_cq_set_drvdata ( cq, NULL );
717
 }
714
 }
718
 
715
 
719
 /***************************************************************************
716
 /***************************************************************************
732
  */
729
  */
733
 static int hermon_create_qp ( struct ib_device *ibdev,
730
 static int hermon_create_qp ( struct ib_device *ibdev,
734
 			      struct ib_queue_pair *qp ) {
731
 			      struct ib_queue_pair *qp ) {
735
-	struct hermon *hermon = ibdev->dev_priv;
732
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
736
 	struct hermon_queue_pair *hermon_qp;
733
 	struct hermon_queue_pair *hermon_qp;
737
 	struct hermonprm_qp_ee_state_transitions qpctx;
734
 	struct hermonprm_qp_ee_state_transitions qpctx;
738
 	int qpn_offset;
735
 	int qpn_offset;
845
 	DBGC ( hermon, "Hermon %p QPN %#lx receive ring at [%p,%p)\n",
842
 	DBGC ( hermon, "Hermon %p QPN %#lx receive ring at [%p,%p)\n",
846
 	       hermon, qp->qpn, hermon_qp->recv.wqe,
843
 	       hermon, qp->qpn, hermon_qp->recv.wqe,
847
 	       ( ((void *)hermon_qp->recv.wqe ) + hermon_qp->recv.wqe_size ) );
844
 	       ( ((void *)hermon_qp->recv.wqe ) + hermon_qp->recv.wqe_size ) );
848
-	qp->dev_priv = hermon_qp;
845
+	ib_qp_set_drvdata ( qp, hermon_qp );
849
 	return 0;
846
 	return 0;
850
 
847
 
851
  err_rtr2rts_qp:
848
  err_rtr2rts_qp:
871
  */
868
  */
872
 static void hermon_destroy_qp ( struct ib_device *ibdev,
869
 static void hermon_destroy_qp ( struct ib_device *ibdev,
873
 				struct ib_queue_pair *qp ) {
870
 				struct ib_queue_pair *qp ) {
874
-	struct hermon *hermon = ibdev->dev_priv;
875
-	struct hermon_queue_pair *hermon_qp = qp->dev_priv;
871
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
872
+	struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
876
 	int qpn_offset;
873
 	int qpn_offset;
877
 	int rc;
874
 	int rc;
878
 
875
 
896
 		       hermon->cap.reserved_qps );
893
 		       hermon->cap.reserved_qps );
897
 	hermon_bitmask_free ( hermon->qp_inuse, qpn_offset, 1 );
894
 	hermon_bitmask_free ( hermon->qp_inuse, qpn_offset, 1 );
898
 
895
 
899
-	qp->dev_priv = NULL;
896
+	ib_qp_set_drvdata ( qp, NULL );
900
 }
897
 }
901
 
898
 
902
 /***************************************************************************
899
 /***************************************************************************
924
 			      struct ib_queue_pair *qp,
921
 			      struct ib_queue_pair *qp,
925
 			      struct ib_address_vector *av,
922
 			      struct ib_address_vector *av,
926
 			      struct io_buffer *iobuf ) {
923
 			      struct io_buffer *iobuf ) {
927
-	struct hermon *hermon = ibdev->dev_priv;
928
-	struct hermon_queue_pair *hermon_qp = qp->dev_priv;
924
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
925
+	struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
929
 	struct ib_work_queue *wq = &qp->send;
926
 	struct ib_work_queue *wq = &qp->send;
930
 	struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
927
 	struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
931
 	struct hermonprm_ud_send_wqe *wqe;
928
 	struct hermonprm_ud_send_wqe *wqe;
1000
 static int hermon_post_recv ( struct ib_device *ibdev,
997
 static int hermon_post_recv ( struct ib_device *ibdev,
1001
 			      struct ib_queue_pair *qp,
998
 			      struct ib_queue_pair *qp,
1002
 			      struct io_buffer *iobuf ) {
999
 			      struct io_buffer *iobuf ) {
1003
-	struct hermon *hermon = ibdev->dev_priv;
1004
-	struct hermon_queue_pair *hermon_qp = qp->dev_priv;
1000
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1001
+	struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1005
 	struct ib_work_queue *wq = &qp->recv;
1002
 	struct ib_work_queue *wq = &qp->recv;
1006
 	struct hermon_recv_work_queue *hermon_recv_wq = &hermon_qp->recv;
1003
 	struct hermon_recv_work_queue *hermon_recv_wq = &hermon_qp->recv;
1007
 	struct hermonprm_recv_wqe *wqe;
1004
 	struct hermonprm_recv_wqe *wqe;
1048
 			     union hermonprm_completion_entry *cqe,
1045
 			     union hermonprm_completion_entry *cqe,
1049
 			     ib_completer_t complete_send,
1046
 			     ib_completer_t complete_send,
1050
 			     ib_completer_t complete_recv ) {
1047
 			     ib_completer_t complete_recv ) {
1051
-	struct hermon *hermon = ibdev->dev_priv;
1048
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1052
 	struct ib_completion completion;
1049
 	struct ib_completion completion;
1053
 	struct ib_work_queue *wq;
1050
 	struct ib_work_queue *wq;
1054
 	struct ib_queue_pair *qp;
1051
 	struct ib_queue_pair *qp;
1085
 		return -EIO;
1082
 		return -EIO;
1086
 	}
1083
 	}
1087
 	qp = wq->qp;
1084
 	qp = wq->qp;
1088
-	hermon_qp = qp->dev_priv;
1085
+	hermon_qp = ib_qp_get_drvdata ( qp );
1089
 
1086
 
1090
 	/* Identify I/O buffer */
1087
 	/* Identify I/O buffer */
1091
 	wqe_idx = ( MLX_GET ( &cqe->normal, wqe_counter ) &
1088
 	wqe_idx = ( MLX_GET ( &cqe->normal, wqe_counter ) &
1128
 			     struct ib_completion_queue *cq,
1125
 			     struct ib_completion_queue *cq,
1129
 			     ib_completer_t complete_send,
1126
 			     ib_completer_t complete_send,
1130
 			     ib_completer_t complete_recv ) {
1127
 			     ib_completer_t complete_recv ) {
1131
-	struct hermon *hermon = ibdev->dev_priv;
1132
-	struct hermon_completion_queue *hermon_cq = cq->dev_priv;
1128
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1129
+	struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
1133
 	union hermonprm_completion_entry *cqe;
1130
 	union hermonprm_completion_entry *cqe;
1134
 	unsigned int cqe_idx_mask;
1131
 	unsigned int cqe_idx_mask;
1135
 	int rc;
1132
 	int rc;
1177
  * @ret rc		Return status code
1174
  * @ret rc		Return status code
1178
  */
1175
  */
1179
 static int hermon_open ( struct ib_device *ibdev ) {
1176
 static int hermon_open ( struct ib_device *ibdev ) {
1180
-	struct hermon *hermon = ibdev->dev_priv;
1177
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1181
 	struct hermonprm_init_port init_port;
1178
 	struct hermonprm_init_port init_port;
1182
 	int rc;
1179
 	int rc;
1183
 
1180
 
1205
  * @v ibdev		Infiniband device
1202
  * @v ibdev		Infiniband device
1206
  */
1203
  */
1207
 static void hermon_close ( struct ib_device *ibdev ) {
1204
 static void hermon_close ( struct ib_device *ibdev ) {
1208
-	struct hermon *hermon = ibdev->dev_priv;
1205
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1209
 	int rc;
1206
 	int rc;
1210
 
1207
 
1211
 	if ( ( rc = hermon_cmd_close_port ( hermon, ibdev->port ) ) != 0 ) {
1208
 	if ( ( rc = hermon_cmd_close_port ( hermon, ibdev->port ) ) != 0 ) {
1233
 static int hermon_mcast_attach ( struct ib_device *ibdev,
1230
 static int hermon_mcast_attach ( struct ib_device *ibdev,
1234
 				 struct ib_queue_pair *qp,
1231
 				 struct ib_queue_pair *qp,
1235
 				 struct ib_gid *gid ) {
1232
 				 struct ib_gid *gid ) {
1236
-	struct hermon *hermon = ibdev->dev_priv;
1233
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1237
 	struct hermonprm_mgm_hash hash;
1234
 	struct hermonprm_mgm_hash hash;
1238
 	struct hermonprm_mcg_entry mcg;
1235
 	struct hermonprm_mcg_entry mcg;
1239
 	unsigned int index;
1236
 	unsigned int index;
1287
 static void hermon_mcast_detach ( struct ib_device *ibdev,
1284
 static void hermon_mcast_detach ( struct ib_device *ibdev,
1288
 				  struct ib_queue_pair *qp __unused,
1285
 				  struct ib_queue_pair *qp __unused,
1289
 				  struct ib_gid *gid ) {
1286
 				  struct ib_gid *gid ) {
1290
-	struct hermon *hermon = ibdev->dev_priv;
1287
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1291
 	struct hermonprm_mgm_hash hash;
1288
 	struct hermonprm_mgm_hash hash;
1292
 	struct hermonprm_mcg_entry mcg;
1289
 	struct hermonprm_mcg_entry mcg;
1293
 	unsigned int index;
1290
 	unsigned int index;
1327
  */
1324
  */
1328
 static int hermon_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1325
 static int hermon_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
1329
 			size_t len ) {
1326
 			size_t len ) {
1330
-	struct hermon *hermon = ibdev->dev_priv;
1327
+	struct hermon *hermon = ib_get_drvdata ( ibdev );
1331
 	union hermonprm_mad mad_ifc;
1328
 	union hermonprm_mad mad_ifc;
1332
 	int rc;
1329
 	int rc;
1333
 
1330
 
1870
  */
1867
  */
1871
 static int hermon_probe ( struct pci_device *pci,
1868
 static int hermon_probe ( struct pci_device *pci,
1872
 			  const struct pci_device_id *id __unused ) {
1869
 			  const struct pci_device_id *id __unused ) {
1873
-	struct ib_device *ibdev;
1874
 	struct hermon *hermon;
1870
 	struct hermon *hermon;
1871
+	struct ib_device *ibdev;
1875
 	struct hermonprm_init_hca init_hca;
1872
 	struct hermonprm_init_hca init_hca;
1873
+	int i;
1876
 	int rc;
1874
 	int rc;
1877
 
1875
 
1878
-	/* Allocate Infiniband device */
1879
-	ibdev = alloc_ibdev ( sizeof ( *hermon ) );
1880
-	if ( ! ibdev ) {
1876
+	/* Allocate Hermon device */
1877
+	hermon = zalloc ( sizeof ( *hermon ) );
1878
+	if ( ! hermon ) {
1881
 		rc = -ENOMEM;
1879
 		rc = -ENOMEM;
1882
-		goto err_ibdev;
1880
+		goto err_alloc_hermon;
1881
+	}
1882
+	pci_set_drvdata ( pci, hermon );
1883
+
1884
+	/* Allocate Infiniband devices */
1885
+	for ( i = 0 ; i < HERMON_NUM_PORTS ; i++ ) {
1886
+	        ibdev = alloc_ibdev ( 0 );
1887
+		if ( ! ibdev ) {
1888
+			rc = -ENOMEM;
1889
+			goto err_alloc_ibdev;
1890
+		}
1891
+		hermon->ibdev[i] = ibdev;
1892
+		ibdev->op = &hermon_ib_operations;
1893
+		ibdev->dev = &pci->dev;
1894
+		ibdev->port = ( HERMON_PORT_BASE + i );
1895
+		ib_set_drvdata ( ibdev, hermon );
1883
 	}
1896
 	}
1884
-	ibdev->op = &hermon_ib_operations;
1885
-	pci_set_drvdata ( pci, ibdev );
1886
-	ibdev->dev = &pci->dev;
1887
-	ibdev->port = PXE_IB_PORT;
1888
-	hermon = ibdev->dev_priv;
1889
-	memset ( hermon, 0, sizeof ( *hermon ) );
1890
 
1897
 
1891
 	/* Fix up PCI device */
1898
 	/* Fix up PCI device */
1892
 	adjust_pci_device ( pci );
1899
 	adjust_pci_device ( pci );
1939
 	if ( ( rc = hermon_setup_mpt ( hermon ) ) != 0 )
1946
 	if ( ( rc = hermon_setup_mpt ( hermon ) ) != 0 )
1940
 		goto err_setup_mpt;
1947
 		goto err_setup_mpt;
1941
 
1948
 
1942
-	/* Register Infiniband device */
1943
-	if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
1944
-		DBGC ( hermon, "Hermon %p could not register IB device: %s\n",
1945
-		       hermon, strerror ( rc ) );
1946
-		goto err_register_ibdev;
1949
+	/* Register Infiniband devices */
1950
+	for ( i = 0 ; i < HERMON_NUM_PORTS ; i++ ) {
1951
+		if ( ( rc = register_ibdev ( hermon->ibdev[i] ) ) != 0 ) {
1952
+			DBGC ( hermon, "Hermon %p could not register IB "
1953
+			       "device: %s\n", hermon, strerror ( rc ) );
1954
+			goto err_register_ibdev;
1955
+		}
1947
 	}
1956
 	}
1948
 
1957
 
1949
 	return 0;
1958
 	return 0;
1950
 
1959
 
1960
+	i = ( HERMON_NUM_PORTS - 1 );
1951
  err_register_ibdev:
1961
  err_register_ibdev:
1962
+	for ( ; i >= 0 ; i-- )
1963
+		unregister_ibdev ( hermon->ibdev[i] );
1952
  err_setup_mpt:
1964
  err_setup_mpt:
1953
 	hermon_cmd_close_hca ( hermon );
1965
 	hermon_cmd_close_hca ( hermon );
1954
  err_init_hca:
1966
  err_init_hca:
1961
  err_mailbox_out:
1973
  err_mailbox_out:
1962
 	free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
1974
 	free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
1963
  err_mailbox_in:
1975
  err_mailbox_in:
1964
-	free_ibdev ( ibdev );
1965
- err_ibdev:
1976
+	i = ( HERMON_NUM_PORTS - 1 );
1977
+ err_alloc_ibdev:
1978
+	for ( ; i >= 0 ; i-- )
1979
+		free_ibdev ( hermon->ibdev[i] );
1980
+	free ( hermon );
1981
+ err_alloc_hermon:
1966
 	return rc;
1982
 	return rc;
1967
 }
1983
 }
1968
 
1984
 
1972
  * @v pci		PCI device
1988
  * @v pci		PCI device
1973
  */
1989
  */
1974
 static void hermon_remove ( struct pci_device *pci ) {
1990
 static void hermon_remove ( struct pci_device *pci ) {
1975
-	struct ib_device *ibdev = pci_get_drvdata ( pci );
1976
-	struct hermon *hermon = ibdev->dev_priv;
1991
+	struct hermon *hermon = pci_get_drvdata ( pci );
1992
+	int i;
1977
 
1993
 
1978
-	unregister_ibdev ( ibdev );
1994
+	for ( i = ( HERMON_NUM_PORTS - 1 ) ; i >= 0 ; i-- )
1995
+		unregister_ibdev ( hermon->ibdev[i] );
1979
 	hermon_cmd_close_hca ( hermon );
1996
 	hermon_cmd_close_hca ( hermon );
1980
 	hermon_free_icm ( hermon );
1997
 	hermon_free_icm ( hermon );
1981
 	hermon_stop_firmware ( hermon );
1998
 	hermon_stop_firmware ( hermon );
1982
 	hermon_stop_firmware ( hermon );
1999
 	hermon_stop_firmware ( hermon );
1983
 	free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE );
2000
 	free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE );
1984
 	free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
2001
 	free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
1985
-	free_ibdev ( ibdev );
2002
+	for ( i = ( HERMON_NUM_PORTS - 1 ) ; i >= 0 ; i-- )
2003
+		free_ibdev ( hermon->ibdev[i] );
2004
+	free ( hermon );
1986
 }
2005
 }
1987
 
2006
 
1988
 static struct pci_device_id hermon_nics[] = {
2007
 static struct pci_device_id hermon_nics[] = {

+ 7
- 0
src/drivers/infiniband/hermon.h View File

17
  *
17
  *
18
  */
18
  */
19
 
19
 
20
+/* Ports in existence */
21
+#define HERMON_NUM_PORTS		1
22
+#define HERMON_PORT_BASE		1
23
+
20
 /* PCI BARs */
24
 /* PCI BARs */
21
 #define HERMON_PCI_CONFIG_BAR		PCI_BASE_ADDRESS_0
25
 #define HERMON_PCI_CONFIG_BAR		PCI_BASE_ADDRESS_0
22
 #define HERMON_PCI_CONFIG_BAR_SIZE	0x100000
26
 #define HERMON_PCI_CONFIG_BAR_SIZE	0x100000
402
 
406
 
403
 	/** Device capabilities */
407
 	/** Device capabilities */
404
 	struct hermon_dev_cap cap;
408
 	struct hermon_dev_cap cap;
409
+
410
+	/** Infiniband devices */
411
+	struct ib_device *ibdev[HERMON_NUM_PORTS];
405
 };
412
 };
406
 
413
 
407
 /** Global protection domain */
414
 /** Global protection domain */

+ 5
- 5
src/drivers/net/ipoib.c View File

294
 		rc = -ENOMEM;
294
 		rc = -ENOMEM;
295
 		goto err;
295
 		goto err;
296
 	}
296
 	}
297
-	qset->qp->owner_priv = ipoib->netdev;
297
+	ib_qp_set_ownerdata ( qset->qp, ipoib->netdev );
298
 
298
 
299
 	return 0;
299
 	return 0;
300
 
300
 
506
 				       struct ib_queue_pair *qp,
506
 				       struct ib_queue_pair *qp,
507
 				       struct ib_completion *completion,
507
 				       struct ib_completion *completion,
508
 				       struct io_buffer *iobuf ) {
508
 				       struct io_buffer *iobuf ) {
509
-	struct net_device *netdev = qp->owner_priv;
509
+	struct net_device *netdev = ib_qp_get_ownerdata ( qp );
510
 
510
 
511
 	netdev_tx_complete_err ( netdev, iobuf,
511
 	netdev_tx_complete_err ( netdev, iobuf,
512
 				 ( completion->syndrome ? -EIO : 0 ) );
512
 				 ( completion->syndrome ? -EIO : 0 ) );
524
 				       struct ib_queue_pair *qp,
524
 				       struct ib_queue_pair *qp,
525
 				       struct ib_completion *completion,
525
 				       struct ib_completion *completion,
526
 				       struct io_buffer *iobuf ) {
526
 				       struct io_buffer *iobuf ) {
527
-	struct net_device *netdev = qp->owner_priv;
527
+	struct net_device *netdev = ib_qp_get_ownerdata ( qp );
528
 	struct ipoib_device *ipoib = netdev->priv;
528
 	struct ipoib_device *ipoib = netdev->priv;
529
 	struct ipoib_pseudo_hdr *ipoib_pshdr;
529
 	struct ipoib_pseudo_hdr *ipoib_pshdr;
530
 
530
 
572
 				       struct ib_queue_pair *qp,
572
 				       struct ib_queue_pair *qp,
573
 				       struct ib_completion *completion,
573
 				       struct ib_completion *completion,
574
 				       struct io_buffer *iobuf ) {
574
 				       struct io_buffer *iobuf ) {
575
-	struct net_device *netdev = qp->owner_priv;
575
+	struct net_device *netdev = ib_qp_get_ownerdata ( qp );
576
 	struct ipoib_device *ipoib = netdev->priv;
576
 	struct ipoib_device *ipoib = netdev->priv;
577
 
577
 
578
 	if ( completion->syndrome ) {
578
 	if ( completion->syndrome ) {
640
 				       struct ib_queue_pair *qp,
640
 				       struct ib_queue_pair *qp,
641
 				       struct ib_completion *completion,
641
 				       struct ib_completion *completion,
642
 				       struct io_buffer *iobuf ) {
642
 				       struct io_buffer *iobuf ) {
643
-	struct net_device *netdev = qp->owner_priv;
643
+	struct net_device *netdev = ib_qp_get_ownerdata ( qp );
644
 	struct ipoib_device *ipoib = netdev->priv;
644
 	struct ipoib_device *ipoib = netdev->priv;
645
 	union ib_mad *mad;
645
 	union ib_mad *mad;
646
 
646
 

+ 124
- 14
src/include/gpxe/infiniband.h View File

75
 	unsigned long next_idx;
75
 	unsigned long next_idx;
76
 	/** I/O buffers assigned to work queue */
76
 	/** I/O buffers assigned to work queue */
77
 	struct io_buffer **iobufs;
77
 	struct io_buffer **iobufs;
78
-	/** Device private data */
79
-	void *dev_priv;
78
+	/** Driver private data */
79
+	void *drv_priv;
80
 };
80
 };
81
 
81
 
82
 /** An Infiniband Queue Pair */
82
 /** An Infiniband Queue Pair */
89
 	struct ib_work_queue send;
89
 	struct ib_work_queue send;
90
 	/** Receive queue */
90
 	/** Receive queue */
91
 	struct ib_work_queue recv;
91
 	struct ib_work_queue recv;
92
-	/** Device private data */
93
-	void *dev_priv;
92
+	/** Driver private data */
93
+	void *drv_priv;
94
 	/** Queue owner private data */
94
 	/** Queue owner private data */
95
 	void *owner_priv;
95
 	void *owner_priv;
96
 };
96
 };
111
 	unsigned long next_idx;
111
 	unsigned long next_idx;
112
 	/** List of work queues completing to this queue */
112
 	/** List of work queues completing to this queue */
113
 	struct list_head work_queues;
113
 	struct list_head work_queues;
114
-	/** Device private data */
115
-	void *dev_priv;
114
+	/** Driver private data */
115
+	void *drv_priv;
116
 };
116
 };
117
 
117
 
118
 /** An Infiniband completion */
118
 /** An Infiniband completion */
297
 	unsigned long sm_lid;
297
 	unsigned long sm_lid;
298
 	/** Partition key */
298
 	/** Partition key */
299
 	unsigned int pkey;
299
 	unsigned int pkey;
300
-	/** Device private data */
301
-	void *dev_priv;
300
+	/** Driver private data */
301
+	void *drv_priv;
302
 	/** Owner private data */
302
 	/** Owner private data */
303
 	void *owner_priv;
303
 	void *owner_priv;
304
 };
304
 };
425
 }
425
 }
426
 
426
 
427
 /**
427
 /**
428
- * Set Infiniband owner-private data
428
+ * Set Infiniband work queue driver-private data
429
  *
429
  *
430
- * @v pci		Infiniband device
430
+ * @v wq		Work queue
431
  * @v priv		Private data
431
  * @v priv		Private data
432
  */
432
  */
433
 static inline __attribute__ (( always_inline )) void
433
 static inline __attribute__ (( always_inline )) void
434
-ib_set_ownerdata ( struct ib_device *ibdev, void *owner_priv ) {
435
-	ibdev->owner_priv = owner_priv;
434
+ib_wq_set_drvdata ( struct ib_work_queue *wq, void *priv ) {
435
+	wq->drv_priv = priv;
436
 }
436
 }
437
 
437
 
438
 /**
438
 /**
439
- * Get Infiniband owner-private data
439
+ * Get Infiniband work queue driver-private data
440
  *
440
  *
441
- * @v pci		Infiniband device
441
+ * @v wq		Work queue
442
+ * @ret priv		Private data
443
+ */
444
+static inline __attribute__ (( always_inline )) void *
445
+ib_wq_get_drvdata ( struct ib_work_queue *wq ) {
446
+	return wq->drv_priv;
447
+}
448
+
449
+/**
450
+ * Set Infiniband queue pair driver-private data
451
+ *
452
+ * @v qp		Queue pair
453
+ * @v priv		Private data
454
+ */
455
+static inline __attribute__ (( always_inline )) void
456
+ib_qp_set_drvdata ( struct ib_queue_pair *qp, void *priv ) {
457
+	qp->drv_priv = priv;
458
+}
459
+
460
+/**
461
+ * Get Infiniband queue pair driver-private data
462
+ *
463
+ * @v qp		Queue pair
464
+ * @ret priv		Private data
465
+ */
466
+static inline __attribute__ (( always_inline )) void *
467
+ib_qp_get_drvdata ( struct ib_queue_pair *qp ) {
468
+	return qp->drv_priv;
469
+}
470
+
471
+/**
472
+ * Set Infiniband queue pair owner-private data
473
+ *
474
+ * @v qp		Queue pair
475
+ * @v priv		Private data
476
+ */
477
+static inline __attribute__ (( always_inline )) void
478
+ib_qp_set_ownerdata ( struct ib_queue_pair *qp, void *priv ) {
479
+	qp->owner_priv = priv;
480
+}
481
+
482
+/**
483
+ * Get Infiniband queue pair owner-private data
484
+ *
485
+ * @v qp		Queue pair
486
+ * @ret priv		Private data
487
+ */
488
+static inline __attribute__ (( always_inline )) void *
489
+ib_qp_get_ownerdata ( struct ib_queue_pair *qp ) {
490
+	return qp->owner_priv;
491
+}
492
+
493
+/**
494
+ * Set Infiniband completion queue driver-private data
495
+ *
496
+ * @v cq		Completion queue
497
+ * @v priv		Private data
498
+ */
499
+static inline __attribute__ (( always_inline )) void
500
+ib_cq_set_drvdata ( struct ib_completion_queue *cq, void *priv ) {
501
+	cq->drv_priv = priv;
502
+}
503
+
504
+/**
505
+ * Get Infiniband completion queue driver-private data
506
+ *
507
+ * @v cq		Completion queue
508
+ * @ret priv		Private data
509
+ */
510
+static inline __attribute__ (( always_inline )) void *
511
+ib_cq_get_drvdata ( struct ib_completion_queue *cq ) {
512
+	return cq->drv_priv;
513
+}
514
+
515
+/**
516
+ * Set Infiniband device driver-private data
517
+ *
518
+ * @v ibdev		Infiniband device
519
+ * @v priv		Private data
520
+ */
521
+static inline __attribute__ (( always_inline )) void
522
+ib_set_drvdata ( struct ib_device *ibdev, void *priv ) {
523
+	ibdev->drv_priv = priv;
524
+}
525
+
526
+/**
527
+ * Get Infiniband device driver-private data
528
+ *
529
+ * @v ibdev		Infiniband device
530
+ * @ret priv		Private data
531
+ */
532
+static inline __attribute__ (( always_inline )) void *
533
+ib_get_drvdata ( struct ib_device *ibdev ) {
534
+	return ibdev->drv_priv;
535
+}
536
+
537
+/**
538
+ * Set Infiniband device owner-private data
539
+ *
540
+ * @v ibdev		Infiniband device
541
+ * @v priv		Private data
542
+ */
543
+static inline __attribute__ (( always_inline )) void
544
+ib_set_ownerdata ( struct ib_device *ibdev, void *priv ) {
545
+	ibdev->owner_priv = priv;
546
+}
547
+
548
+/**
549
+ * Get Infiniband device owner-private data
550
+ *
551
+ * @v ibdev		Infiniband device
442
  * @ret priv		Private data
552
  * @ret priv		Private data
443
  */
553
  */
444
 static inline __attribute__ (( always_inline )) void *
554
 static inline __attribute__ (( always_inline )) void *

+ 7
- 4
src/net/infiniband.c View File

67
 	}
67
 	}
68
 
68
 
69
 	DBGC ( ibdev, "IBDEV %p created %d-entry completion queue %p (%p) "
69
 	DBGC ( ibdev, "IBDEV %p created %d-entry completion queue %p (%p) "
70
-	       "with CQN %#lx\n", ibdev, num_cqes, cq, cq->dev_priv, cq->cqn );
70
+	       "with CQN %#lx\n", ibdev, num_cqes, cq,
71
+	       ib_cq_get_drvdata ( cq ), cq->cqn );
71
 	return cq;
72
 	return cq;
72
 }
73
 }
73
 
74
 
141
 	}
142
 	}
142
 
143
 
143
 	DBGC ( ibdev, "IBDEV %p created queue pair %p (%p) with QPN %#lx\n",
144
 	DBGC ( ibdev, "IBDEV %p created queue pair %p (%p) with QPN %#lx\n",
144
-	       ibdev, qp, qp->dev_priv, qp->qpn );
145
+	       ibdev, qp, ib_qp_get_drvdata ( qp ), qp->qpn );
145
 	DBGC ( ibdev, "IBDEV %p QPN %#lx has %d send entries at [%p,%p)\n",
146
 	DBGC ( ibdev, "IBDEV %p QPN %#lx has %d send entries at [%p,%p)\n",
146
 	       ibdev, qp->qpn, num_send_wqes, qp->send.iobufs,
147
 	       ibdev, qp->qpn, num_send_wqes, qp->send.iobufs,
147
 	       qp->recv.iobufs );
148
 	       qp->recv.iobufs );
360
 /**
361
 /**
361
  * Allocate Infiniband device
362
  * Allocate Infiniband device
362
  *
363
  *
363
- * @v priv_size		Size of private data area
364
+ * @v priv_size		Size of driver private data area
364
  * @ret ibdev		Infiniband device, or NULL
365
  * @ret ibdev		Infiniband device, or NULL
365
  */
366
  */
366
 struct ib_device * alloc_ibdev ( size_t priv_size ) {
367
 struct ib_device * alloc_ibdev ( size_t priv_size ) {
367
 	struct ib_device *ibdev;
368
 	struct ib_device *ibdev;
369
+	void *drv_priv;
368
 	size_t total_len;
370
 	size_t total_len;
369
 
371
 
370
 	total_len = ( sizeof ( *ibdev ) + priv_size );
372
 	total_len = ( sizeof ( *ibdev ) + priv_size );
371
 	ibdev = zalloc ( total_len );
373
 	ibdev = zalloc ( total_len );
372
 	if ( ibdev ) {
374
 	if ( ibdev ) {
373
-		ibdev->dev_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
375
+		drv_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
376
+		ib_set_drvdata ( ibdev, drv_priv );
374
 	}
377
 	}
375
 	return ibdev;
378
 	return ibdev;
376
 }
379
 }

Loading…
Cancel
Save