Sfoglia il codice sorgente

[ipoib] Remove the queue set abstraction

Now that IPoIB has to deal with only one set of queues, the queue set
abstraction becomes merely an inconvenient wrapper.
tags/v0.9.8
Michael Brown 15 anni fa
parent
commit
cb9ef4dee2
3 ha cambiato i file con 36 aggiunte e 148 eliminazioni
  1. 36
    20
      src/drivers/net/ipoib.c
  2. 0
    31
      src/include/gpxe/ib_qset.h
  3. 0
    97
      src/net/infiniband/ib_qset.c

+ 36
- 20
src/drivers/net/ipoib.c Vedi File

@@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
28 28
 #include <gpxe/iobuf.h>
29 29
 #include <gpxe/netdevice.h>
30 30
 #include <gpxe/infiniband.h>
31
-#include <gpxe/ib_qset.h>
32 31
 #include <gpxe/ib_pathrec.h>
33 32
 #include <gpxe/ib_mcast.h>
34 33
 #include <gpxe/ipoib.h>
@@ -53,8 +52,10 @@ struct ipoib_device {
53 52
 	struct net_device *netdev;
54 53
 	/** Underlying Infiniband device */
55 54
 	struct ib_device *ibdev;
56
-	/** Queue set */
57
-	struct ib_queue_set qset;
55
+	/** Completion queue */
56
+	struct ib_completion_queue *cq;
57
+	/** Queue pair */
58
+	struct ib_queue_pair *qp;
58 59
 	/** Broadcast MAC */
59 60
 	struct ipoib_mac broadcast;
60 61
 	/** Joined to multicast group
@@ -361,7 +362,7 @@ static int ipoib_transmit ( struct net_device *netdev,
361 362
 		return rc;
362 363
 	}
363 364
 
364
-	return ib_post_send ( ibdev, ipoib->qset.qp, &av, iobuf );
365
+	return ib_post_send ( ibdev, ipoib->qp, &av, iobuf );
365 366
 }
366 367
 
367 368
 /**
@@ -464,7 +465,7 @@ static void ipoib_irq ( struct net_device *netdev __unused,
464 465
 static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
465 466
 	int rc;
466 467
 
467
-	if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qset.qp,
468
+	if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qp,
468 469
 				    &ipoib->broadcast.gid ) ) != 0 ) {
469 470
 		DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
470 471
 		       ipoib, strerror ( rc ) );
@@ -483,7 +484,7 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
483 484
 static void ipoib_leave_broadcast_group ( struct ipoib_device *ipoib ) {
484 485
 
485 486
 	if ( ipoib->broadcast_joined ) {
486
-		ib_mcast_leave ( ipoib->ibdev, ipoib->qset.qp,
487
+		ib_mcast_leave ( ipoib->ibdev, ipoib->qp,
487 488
 				 &ipoib->broadcast.gid );
488 489
 		ipoib->broadcast_joined = 0;
489 490
 	}
@@ -508,21 +509,31 @@ static int ipoib_open ( struct net_device *netdev ) {
508 509
 		goto err_ib_open;
509 510
 	}
510 511
 
511
-	/* Allocate queue set */
512
-	if ( ( rc = ib_create_qset ( ibdev, &ipoib->qset, IPOIB_NUM_CQES,
513
-				     &ipoib_cq_op, IPOIB_NUM_SEND_WQES,
514
-				     IPOIB_NUM_RECV_WQES, 0 ) ) != 0 ) {
515
-		DBGC ( ipoib, "IPoIB %p could not allocate queue set: %s\n",
516
-		       ipoib, strerror ( rc ) );
517
-		goto err_create_qset;
512
+	/* Allocate completion queue */
513
+	ipoib->cq = ib_create_cq ( ibdev, IPOIB_NUM_CQES, &ipoib_cq_op );
514
+	if ( ! ipoib->cq ) {
515
+		DBGC ( ipoib, "IPoIB %p could not allocate completion queue\n",
516
+		       ipoib );
517
+		rc = -ENOMEM;
518
+		goto err_create_cq;
519
+	}
520
+
521
+	/* Allocate queue pair */
522
+	ipoib->qp = ib_create_qp ( ibdev, IPOIB_NUM_SEND_WQES, ipoib->cq,
523
+				   IPOIB_NUM_RECV_WQES, ipoib->cq, 0 );
524
+	if ( ! ipoib->qp ) {
525
+		DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n",
526
+		       ipoib );
527
+		rc = -ENOMEM;
528
+		goto err_create_qp;
518 529
 	}
519
-	ib_qp_set_ownerdata ( ipoib->qset.qp, ipoib );
530
+	ib_qp_set_ownerdata ( ipoib->qp, ipoib );
520 531
 
521 532
 	/* Update MAC address with QPN */
522
-	mac->qpn = htonl ( ipoib->qset.qp->qpn );
533
+	mac->qpn = htonl ( ipoib->qp->qpn );
523 534
 
524 535
 	/* Fill receive rings */
525
-	ib_refill_recv ( ibdev, ipoib->qset.qp );
536
+	ib_refill_recv ( ibdev, ipoib->qp );
526 537
 
527 538
 	/* Join broadcast group */
528 539
 	if ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) {
@@ -533,9 +544,12 @@ static int ipoib_open ( struct net_device *netdev ) {
533 544
 
534 545
 	return 0;
535 546
 
547
+	ipoib_leave_broadcast_group ( ipoib );
536 548
  err_join_broadcast:
537
-	ib_destroy_qset ( ibdev, &ipoib->qset );
538
- err_create_qset:
549
+	ib_destroy_qp ( ibdev, ipoib->qp );
550
+ err_create_qp:
551
+	ib_destroy_cq ( ibdev, ipoib->cq );
552
+ err_create_cq:
539 553
 	ib_close ( ibdev );
540 554
  err_ib_open:
541 555
 	return rc;
@@ -548,6 +562,7 @@ static int ipoib_open ( struct net_device *netdev ) {
548 562
  */
549 563
 static void ipoib_close ( struct net_device *netdev ) {
550 564
 	struct ipoib_device *ipoib = netdev->priv;
565
+	struct ib_device *ibdev = ipoib->ibdev;
551 566
 	struct ipoib_mac *mac = ( ( struct ipoib_mac * ) netdev->ll_addr );
552 567
 
553 568
 	/* Leave broadcast group */
@@ -557,10 +572,11 @@ static void ipoib_close ( struct net_device *netdev ) {
557 572
 	mac->qpn = 0;
558 573
 
559 574
 	/* Tear down the queues */
560
-	ib_destroy_qset ( ipoib->ibdev, &ipoib->qset );
575
+	ib_destroy_qp ( ibdev, ipoib->qp );
576
+	ib_destroy_cq ( ibdev, ipoib->cq );
561 577
 
562 578
 	/* Close IB device */
563
-	ib_close ( ipoib->ibdev );
579
+	ib_close ( ibdev );
564 580
 }
565 581
 
566 582
 /** IPoIB network device operations */

+ 0
- 31
src/include/gpxe/ib_qset.h Vedi File

@@ -1,31 +0,0 @@
1
-#ifndef _GPXE_IB_QSET_H
2
-#define _GPXE_IB_QSET_H
3
-
4
-/** @file
5
- *
6
- * Infiniband queue sets
7
- *
8
- */
9
-
10
-FILE_LICENCE ( GPL2_OR_LATER );
11
-
12
-#include <stdint.h>
13
-#include <gpxe/infiniband.h>
14
-
15
-/** An Infiniband queue set */
16
-struct ib_queue_set {
17
-	/** Completion queue */
18
-	struct ib_completion_queue *cq;
19
-	/** Queue pair */
20
-	struct ib_queue_pair *qp;
21
-};
22
-
23
-extern int ib_create_qset ( struct ib_device *ibdev,
24
-			    struct ib_queue_set *qset, unsigned int num_cqes,
25
-			    struct ib_completion_queue_operations *cq_op,
26
-			    unsigned int num_send_wqes,
27
-			    unsigned int num_recv_wqes, unsigned long qkey );
28
-extern void ib_destroy_qset ( struct ib_device *ibdev,
29
-			      struct ib_queue_set *qset );
30
-
31
-#endif /* _GPXE_IB_QSET_H */

+ 0
- 97
src/net/infiniband/ib_qset.c Vedi File

@@ -1,97 +0,0 @@
1
-/*
2
- * Copyright (C) 2009 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
-FILE_LICENCE ( GPL2_OR_LATER );
20
-
21
-#include <errno.h>
22
-#include <string.h>
23
-#include <gpxe/iobuf.h>
24
-#include <gpxe/infiniband.h>
25
-#include <gpxe/ib_qset.h>
26
-
27
-/**
28
- * @file
29
- *
30
- * Infiniband queue sets
31
- *
32
- */
33
-
34
-/**
35
- * Create queue set
36
- *
37
- * @v ibdev		Infiniband device
38
- * @v qset		Queue set
39
- * @v num_cqes		Number of completion queue entries
40
- * @v cq_op		Completion queue operations
41
- * @v num_send_wqes	Number of send work queue entries
42
- * @v num_recv_wqes	Number of receive work queue entries
43
- * @v qkey		Queue key
44
- * @ret rc		Return status code
45
- */
46
-int ib_create_qset ( struct ib_device *ibdev, struct ib_queue_set *qset,
47
-		     unsigned int num_cqes,
48
-		     struct ib_completion_queue_operations *cq_op,
49
-		     unsigned int num_send_wqes, unsigned int num_recv_wqes,
50
-		     unsigned long qkey ) {
51
-	int rc;
52
-
53
-	/* Sanity check */
54
-	assert ( qset->cq == NULL );
55
-	assert ( qset->qp == NULL );
56
-
57
-	/* Allocate completion queue */
58
-	qset->cq = ib_create_cq ( ibdev, num_cqes, cq_op );
59
-	if ( ! qset->cq ) {
60
-		DBGC ( ibdev, "IBDEV %p could not allocate completion queue\n",
61
-		       ibdev );
62
-		rc = -ENOMEM;
63
-		goto err;
64
-	}
65
-
66
-	/* Allocate queue pair */
67
-	qset->qp = ib_create_qp ( ibdev, num_send_wqes, qset->cq,
68
-				  num_recv_wqes, qset->cq, qkey );
69
-	if ( ! qset->qp ) {
70
-		DBGC ( ibdev, "IBDEV %p could not allocate queue pair\n",
71
-		       ibdev );
72
-		rc = -ENOMEM;
73
-		goto err;
74
-	}
75
-
76
-	return 0;
77
-
78
- err:
79
-	ib_destroy_qset ( ibdev, qset );
80
-	return rc;
81
-}
82
-
83
-/**
84
- * Destroy queue set
85
- *
86
- * @v ibdev		Infiniband device
87
- * @v qset		Queue set
88
- */
89
-void ib_destroy_qset ( struct ib_device *ibdev,
90
-		       struct ib_queue_set *qset ) {
91
-
92
-	if ( qset->qp )
93
-		ib_destroy_qp ( ibdev, qset->qp );
94
-	if ( qset->cq )
95
-		ib_destroy_cq ( ibdev, qset->cq );
96
-	memset ( qset, 0, sizeof ( *qset ) );
97
-}

Loading…
Annulla
Salva