Browse Source

[infiniband] Remove concept of whole-device owner data

Remove the implicit assumption that the IPoIB protocol owns the whole
Infiniband device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
60e205a551
2 changed files with 45 additions and 35 deletions
  1. 45
    11
      src/drivers/net/ipoib.c
  2. 0
    24
      src/include/ipxe/infiniband.h

+ 45
- 11
src/drivers/net/ipoib.c View File

79
 	struct net_device *netdev;
79
 	struct net_device *netdev;
80
 	/** Underlying Infiniband device */
80
 	/** Underlying Infiniband device */
81
 	struct ib_device *ibdev;
81
 	struct ib_device *ibdev;
82
+	/** List of IPoIB devices */
83
+	struct list_head list;
82
 	/** Completion queue */
84
 	/** Completion queue */
83
 	struct ib_completion_queue *cq;
85
 	struct ib_completion_queue *cq;
84
 	/** Queue pair */
86
 	/** Queue pair */
116
 	__einfo_errortab ( EINFO_EINPROGRESS_JOINING ),
118
 	__einfo_errortab ( EINFO_EINPROGRESS_JOINING ),
117
 };
119
 };
118
 
120
 
121
+/** List of all IPoIB devices */
122
+static LIST_HEAD ( ipoib_devices );
123
+
119
 static struct net_device_operations ipoib_operations;
124
 static struct net_device_operations ipoib_operations;
120
 
125
 
121
 /****************************************************************************
126
 /****************************************************************************
783
 /**
788
 /**
784
  * Handle link status change
789
  * Handle link status change
785
  *
790
  *
786
- * @v ibdev		Infiniband device
791
+ * @v ipoib		IPoIB device
787
  */
792
  */
788
-static void ipoib_link_state_changed ( struct ib_device *ibdev ) {
789
-	struct net_device *netdev = ib_get_ownerdata ( ibdev );
790
-	struct ipoib_device *ipoib = netdev->priv;
793
+static void ipoib_link_state_changed ( struct ipoib_device *ipoib ) {
794
+	struct ib_device *ibdev = ipoib->ibdev;
795
+	struct net_device *netdev = ipoib->netdev;
791
 	int rc;
796
 	int rc;
792
 
797
 
793
 	/* Leave existing broadcast group */
798
 	/* Leave existing broadcast group */
862
 	ib_refill_recv ( ibdev, ipoib->qp );
867
 	ib_refill_recv ( ibdev, ipoib->qp );
863
 
868
 
864
 	/* Fake a link status change to join the broadcast group */
869
 	/* Fake a link status change to join the broadcast group */
865
-	ipoib_link_state_changed ( ibdev );
870
+	ipoib_link_state_changed ( ipoib );
866
 
871
 
867
 	return 0;
872
 	return 0;
868
 
873
 
928
 		return -ENOMEM;
933
 		return -ENOMEM;
929
 	netdev_init ( netdev, &ipoib_operations );
934
 	netdev_init ( netdev, &ipoib_operations );
930
 	ipoib = netdev->priv;
935
 	ipoib = netdev->priv;
931
-	ib_set_ownerdata ( ibdev, netdev );
932
 	netdev->dev = ibdev->dev;
936
 	netdev->dev = ibdev->dev;
933
 	memset ( ipoib, 0, sizeof ( *ipoib ) );
937
 	memset ( ipoib, 0, sizeof ( *ipoib ) );
934
 	ipoib->netdev = netdev;
938
 	ipoib->netdev = netdev;
947
 	memcpy ( &ipoib->broadcast, &ipoib_broadcast,
951
 	memcpy ( &ipoib->broadcast, &ipoib_broadcast,
948
 		 sizeof ( ipoib->broadcast ) );
952
 		 sizeof ( ipoib->broadcast ) );
949
 
953
 
954
+	/* Add to list of IPoIB devices */
955
+	list_add_tail ( &ipoib->list, &ipoib_devices );
956
+
950
 	/* Register network device */
957
 	/* Register network device */
951
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
958
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
952
 		goto err_register_netdev;
959
 		goto err_register_netdev;
953
 
960
 
954
 	return 0;
961
 	return 0;
955
 
962
 
963
+	unregister_netdev ( netdev );
956
  err_register_netdev:
964
  err_register_netdev:
965
+	list_del ( &ipoib->list );
957
 	netdev_nullify ( netdev );
966
 	netdev_nullify ( netdev );
958
 	netdev_put ( netdev );
967
 	netdev_put ( netdev );
959
 	return rc;
968
 	return rc;
960
 }
969
 }
961
 
970
 
971
+/**
972
+ * Handle device or link status change
973
+ *
974
+ * @v ibdev		Infiniband device
975
+ */
976
+static void ipoib_notify ( struct ib_device *ibdev ) {
977
+	struct ipoib_device *ipoib;
978
+
979
+	/* Handle link status change for any attached IPoIB devices */
980
+	list_for_each_entry ( ipoib, &ipoib_devices, list ) {
981
+		if ( ipoib->ibdev != ibdev )
982
+			continue;
983
+		ipoib_link_state_changed ( ipoib );
984
+	}
985
+}
986
+
962
 /**
987
 /**
963
  * Remove IPoIB device
988
  * Remove IPoIB device
964
  *
989
  *
965
  * @v ibdev		Infiniband device
990
  * @v ibdev		Infiniband device
966
  */
991
  */
967
 static void ipoib_remove ( struct ib_device *ibdev ) {
992
 static void ipoib_remove ( struct ib_device *ibdev ) {
968
-	struct net_device *netdev = ib_get_ownerdata ( ibdev );
993
+	struct ipoib_device *ipoib;
994
+	struct ipoib_device *tmp;
995
+	struct net_device *netdev;
969
 
996
 
970
-	unregister_netdev ( netdev );
971
-	netdev_nullify ( netdev );
972
-	netdev_put ( netdev );
997
+	/* Remove any attached IPoIB devices */
998
+	list_for_each_entry_safe ( ipoib, tmp, &ipoib_devices, list ) {
999
+		if ( ipoib->ibdev != ibdev )
1000
+			continue;
1001
+		netdev = ipoib->netdev;
1002
+		unregister_netdev ( netdev );
1003
+		list_del ( &ipoib->list );
1004
+		netdev_nullify ( netdev );
1005
+		netdev_put ( netdev );
1006
+	}
973
 }
1007
 }
974
 
1008
 
975
 /** IPoIB driver */
1009
 /** IPoIB driver */
976
 struct ib_driver ipoib_driver __ib_driver = {
1010
 struct ib_driver ipoib_driver __ib_driver = {
977
 	.name = "IPoIB",
1011
 	.name = "IPoIB",
978
 	.probe = ipoib_probe,
1012
 	.probe = ipoib_probe,
979
-	.notify = ipoib_link_state_changed,
1013
+	.notify = ipoib_notify,
980
 	.remove = ipoib_remove,
1014
 	.remove = ipoib_remove,
981
 };
1015
 };

+ 0
- 24
src/include/ipxe/infiniband.h View File

450
 
450
 
451
 	/** Driver private data */
451
 	/** Driver private data */
452
 	void *drv_priv;
452
 	void *drv_priv;
453
-	/** Owner private data */
454
-	void *owner_priv;
455
 };
453
 };
456
 
454
 
457
 /** An Infiniband upper-layer driver */
455
 /** An Infiniband upper-layer driver */
695
 	return ibdev->drv_priv;
693
 	return ibdev->drv_priv;
696
 }
694
 }
697
 
695
 
698
-/**
699
- * Set Infiniband device owner-private data
700
- *
701
- * @v ibdev		Infiniband device
702
- * @v priv		Private data
703
- */
704
-static inline __always_inline void
705
-ib_set_ownerdata ( struct ib_device *ibdev, void *priv ) {
706
-	ibdev->owner_priv = priv;
707
-}
708
-
709
-/**
710
- * Get Infiniband device owner-private data
711
- *
712
- * @v ibdev		Infiniband device
713
- * @ret priv		Private data
714
- */
715
-static inline __always_inline void *
716
-ib_get_ownerdata ( struct ib_device *ibdev ) {
717
-	return ibdev->owner_priv;
718
-}
719
-
720
 #endif /* _IPXE_INFINIBAND_H */
696
 #endif /* _IPXE_INFINIBAND_H */

Loading…
Cancel
Save