[openib-general] [PATCH] [TRIVIAL] ib_mad: change device to port routine names where appropriate (part 2)

Hal Rosenstock halr at voltaire.com
Fri Sep 10 13:42:00 PDT 2004


ib_mad: change device to port routine names where appropriate (part 2 of
this)

Index: ib_mad.c
===================================================================
--- ib_mad.c	(revision 767)
+++ ib_mad.c	(working copy)
@@ -66,7 +66,7 @@
 
 
 kmem_cache_t *ib_mad_cache;
-static struct list_head ib_mad_device_list;
+static struct list_head ib_mad_port_list;
 static struct list_head ib_mad_agent_list;
 static u32 ib_mad_client_id = 0;
 
@@ -75,10 +75,10 @@
  */
 
 /* Device list lock */
-static spinlock_t ib_mad_device_list_lock = SPIN_LOCK_UNLOCKED;
-#define IB_MAD_DEVICE_LIST_LOCK_VAR	unsigned long
ib_mad_device_list_sflags
-#define
IB_MAD_DEVICE_LIST_LOCK()	spin_lock_irqsave(&ib_mad_device_list_lock,
ib_mad_device_list_sflags)
-#define
IB_MAD_DEVICE_LIST_UNLOCK()	spin_unlock_irqrestore(&ib_mad_device_list_lock, ib_mad_device_list_sflags)
+static spinlock_t ib_mad_port_list_lock = SPIN_LOCK_UNLOCKED;
+#define IB_MAD_PORT_LIST_LOCK_VAR	unsigned long ib_mad_port_list_sflags
+#define
IB_MAD_PORT_LIST_LOCK()	spin_lock_irqsave(&ib_mad_port_list_lock,
ib_mad_port_list_sflags)
+#define
IB_MAD_PORT_LIST_UNLOCK()	spin_unlock_irqrestore(&ib_mad_port_list_lock,
ib_mad_port_list_sflags)
 
 /* Agent list lock */
 static spinlock_t ib_mad_agent_list_lock = SPIN_LOCK_UNLOCKED;
@@ -103,8 +103,8 @@
 static int add_mad_reg_req(struct ib_mad_reg_req *mad_reg_req,
 			   struct ib_mad_agent_private *priv);
 static void remove_mad_reg_req(struct ib_mad_agent_private *priv); 
-static int ib_mad_device_restart(struct ib_mad_device_private *priv);
-static int ib_mad_post_receive_mads(struct ib_mad_device_private
*priv);
+static int ib_mad_port_restart(struct ib_mad_port_private *priv);
+static int ib_mad_post_receive_mads(struct ib_mad_port_private *priv);
 
 
 /*
@@ -134,8 +134,8 @@
 				ib_mad_recv_handler recv_handler,
 				void *context)
 {
-	struct ib_mad_device_private *entry, *priv = NULL,
-				     *head = (struct ib_mad_device_private *) &ib_mad_device_list;
+	struct ib_mad_port_private *entry, *priv = NULL,
+				     *head = (struct ib_mad_port_private *) &ib_mad_port_list;
 	struct ib_mad_agent_private *entry2,
 				    *head2 =  (struct ib_mad_agent_private *)&ib_mad_agent_list;
 	struct ib_mad_agent *mad_agent, *ret;
@@ -144,7 +144,7 @@
 	struct ib_mad_mgmt_class_table *class;
 	struct ib_mad_mgmt_method_table *method;
 	int ret2;
-	IB_MAD_DEVICE_LIST_LOCK_VAR;
+	IB_MAD_PORT_LIST_LOCK_VAR;
 	IB_MAD_AGENT_LIST_LOCK_VAR;
 	u8 mgmt_class;
 
@@ -184,14 +184,14 @@
 	}
 
 	/* Validate device and port */
-	IB_MAD_DEVICE_LIST_LOCK();
+	IB_MAD_PORT_LIST_LOCK();
 	list_for_each(entry, head) {
 		if (entry->device == device && entry->port == port) {
 			priv = entry;
 			break;
 		}
 	}
-	IB_MAD_DEVICE_LIST_UNLOCK();
+	IB_MAD_PORT_LIST_UNLOCK();
 	if (!priv) {
 		ret = ERR_PTR(-ENODEV);
 		goto error1;
@@ -358,16 +358,16 @@
 		wr.send_flags = IB_SEND_SIGNALED; /* cur_send_wr->send_flags ? */
 
 		/* Link send WR into posted send MAD list */
-		IB_MAD_SEND_LIST_LOCK(((struct ib_mad_device_private
*)mad_agent->device->mad));
+		IB_MAD_SEND_LIST_LOCK(((struct ib_mad_port_private
*)mad_agent->device->mad));
 		list_add_tail((struct list_head *)mad_send_wr,
-			      &((struct ib_mad_device_private
*)mad_agent->device->mad)->send_posted_mad_list);
-		IB_MAD_SEND_LIST_UNLOCK(((struct ib_mad_device_private
*)mad_agent->device->mad));
+			      &((struct ib_mad_port_private
*)mad_agent->device->mad)->send_posted_mad_list);
+		IB_MAD_SEND_LIST_UNLOCK(((struct ib_mad_port_private
*)mad_agent->device->mad));
 
 		if (ib_post_send(mad_agent->qp, &wr, &bad_wr)) {
 			/* Unlink from posted send MAD list */
-			IB_MAD_SEND_LIST_LOCK(((struct ib_mad_device_private
*)mad_agent->device->mad));
+			IB_MAD_SEND_LIST_LOCK(((struct ib_mad_port_private
*)mad_agent->device->mad));
 			list_del((struct list_head *)send_wr);
-			IB_MAD_SEND_LIST_UNLOCK(((struct ib_mad_device_private
*)mad_agent->device->mad));
+			IB_MAD_SEND_LIST_UNLOCK(((struct ib_mad_port_private
*)mad_agent->device->mad));
 			*bad_send_wr = cur_send_wr;
 			printk(KERN_ERR "ib_mad_post_send failed\n");
 			return -EINVAL;		
@@ -466,7 +466,7 @@
 static int add_mad_reg_req(struct ib_mad_reg_req *mad_reg_req,
 			   struct ib_mad_agent_private *priv)
 {
-	struct ib_mad_device_private *private;
+	struct ib_mad_port_private *private;
 	struct ib_mad_mgmt_class_table **class;
 	struct ib_mad_mgmt_method_table **method;
 
@@ -540,7 +540,7 @@
 
 static void remove_mad_reg_req(struct ib_mad_agent_private *priv)
 {
-	struct ib_mad_device_private *private;
+	struct ib_mad_port_private *private;
 	struct ib_mad_mgmt_class_table *class;
 	struct ib_mad_mgmt_method_table *method;
 	u8 mgmt_class;
@@ -576,7 +576,7 @@
 	}
 }
 
-static void ib_mad_recv_done_handler(struct ib_mad_device_private
*priv,
+static void ib_mad_recv_done_handler(struct ib_mad_port_private *priv,
 				     struct ib_wc *wc)
 {
 	struct ib_mad_recv_wc recv_wc;
@@ -626,7 +626,7 @@
 	/* Receive reposting ?  !!! */
 }
 
-static void ib_mad_send_done_handler(struct ib_mad_device_private
*priv,
+static void ib_mad_send_done_handler(struct ib_mad_port_private *priv,
 				     struct ib_wc *wc)
 {
 	struct ib_mad_send_wr_private *entry, *send_wr = NULL,
@@ -660,7 +660,7 @@
 /*
  * IB MAD completion callback
  */
-static void ib_mad_completion_handler(struct ib_mad_device_private
*priv)
+static void ib_mad_completion_handler(struct ib_mad_port_private *priv)
 {
 
 	/*
@@ -707,7 +707,7 @@
 	}
 
 	if (err_status) {
-		ib_mad_device_restart(priv);
+		ib_mad_port_restart(priv);
 	} else {
 		ib_mad_post_receive_mads(priv);
 		ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP);
@@ -719,7 +719,7 @@
  */
 static int ib_mad_thread(void *param)
 {
-	struct ib_mad_device_private *priv = param;
+	struct ib_mad_port_private *priv = param;
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
 	lock_kernel();
@@ -745,7 +745,7 @@
 /*
  * Initialize the IB MAD thread
  */
-static void ib_mad_thread_init(struct ib_mad_device_private *priv)
+static void ib_mad_thread_init(struct ib_mad_port_private *priv)
 {
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
@@ -756,7 +756,7 @@
 /*
  * Wake up the IB MAD thread
  */
-static void ib_mad_thread_signal(struct ib_mad_device_private *priv)
+static void ib_mad_thread_signal(struct ib_mad_port_private *priv)
 {
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
@@ -766,7 +766,7 @@
 /*
  * Stop the IB MAD thread
  */
-static void ib_mad_thread_stop(struct ib_mad_device_private *priv)
+static void ib_mad_thread_stop(struct ib_mad_port_private *priv)
 {
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
@@ -780,7 +780,7 @@
 	ib_mad_thread_signal(cq->cq_context);
 }
 
-static int ib_mad_post_receive_mad(struct ib_mad_device_private *priv,
+static int ib_mad_post_receive_mad(struct ib_mad_port_private *priv,
 				   enum ib_qp_type qp_type)
 {
 	struct ib_mad_private *mad_priv;
@@ -842,7 +842,7 @@
 /*
  * Get receive MADs and post receive WRs for them 
  */
-static int ib_mad_post_receive_mads(struct ib_mad_device_private *priv)
+static int ib_mad_post_receive_mads(struct ib_mad_port_private *priv)
 {
 	int i;
 
@@ -864,7 +864,7 @@
 /*
  * Return all the posted receive MADs
  */
-static void ib_mad_return_posted_recv_mads(struct ib_mad_device_private
*priv)
+static void ib_mad_return_posted_recv_mads(struct ib_mad_port_private
*priv)
 {
 	IB_MAD_RECV_LIST_LOCK_VAR;
 
@@ -881,7 +881,7 @@
 /*
  * Return all the posted send MADs
  */
-static void ib_mad_return_posted_send_mads(struct ib_mad_device_private
*priv)
+static void ib_mad_return_posted_send_mads(struct ib_mad_port_private
*priv)
 {
 	IB_MAD_SEND_LIST_LOCK_VAR;
 
@@ -1012,22 +1012,22 @@
 	return ret;
 }
 
-#define IB_MAD_DEVICE_SET_UP(__device__) {\
-	IB_MAD_DEVICE_LIST_LOCK_VAR;\
-	IB_MAD_DEVICE_LIST_LOCK();\
-	(__device__)->up = 1;\
-	IB_MAD_DEVICE_LIST_UNLOCK();}
+#define IB_MAD_PORT_SET_UP(__port__) {\
+	IB_MAD_PORT_LIST_LOCK_VAR;\
+	IB_MAD_PORT_LIST_LOCK();\
+	(__port__)->up = 1;\
+	IB_MAD_PORT_LIST_UNLOCK();}
 
-#define IB_MAD_DEVICE_SET_DOWN(__device__) {\
-	IB_MAD_DEVICE_LIST_LOCK_VAR;\
-	IB_MAD_DEVICE_LIST_LOCK();\
-	(__device__)->up = 0;\
-	IB_MAD_DEVICE_LIST_UNLOCK();}
+#define IB_MAD_PORT_SET_DOWN(__port__) {\
+	IB_MAD_PORT_LIST_LOCK_VAR;\
+	IB_MAD_PORT_LIST_LOCK();\
+	(__port__)->up = 0;\
+	IB_MAD_PORT_LIST_UNLOCK();}
 
 /*
- * Start the device 
+ * Start the port
  */
-static int ib_mad_device_start(struct ib_mad_device_private *priv)
+static int ib_mad_port_start(struct ib_mad_port_private *priv)
 {
 	int ret, i;
 
@@ -1065,7 +1065,7 @@
 		}
 	}
 
-	IB_MAD_DEVICE_SET_UP(priv);
+	IB_MAD_PORT_SET_UP(priv);
 
 	return 0;
 error:
@@ -1078,13 +1078,13 @@
 }
 
 /*
- * Stop the device
+ * Stop the port
  */
-static void ib_mad_device_stop(struct ib_mad_device_private *priv)
+static void ib_mad_port_stop(struct ib_mad_port_private *priv)
 {
 	int i;
 
-	IB_MAD_DEVICE_SET_DOWN(priv);
+	IB_MAD_PORT_SET_DOWN(priv);
 
 	for (i = 0; i < 2; i++) {
 		ib_mad_change_qp_state_to_reset(priv->qp[i]);
@@ -1095,16 +1095,16 @@
 }
 
 /*
- * Restart the device
+ * Restart the port
  */
-static int ib_mad_device_restart(struct ib_mad_device_private *priv)
+static int ib_mad_port_restart(struct ib_mad_port_private *priv)
 {
 	int ret;
 
-	ib_mad_device_stop(priv);
-	ret = ib_mad_device_start(priv);
+	ib_mad_port_stop(priv);
+	ret = ib_mad_port_start(priv);
 	if (ret) {
-		printk(KERN_ERR "Could not start device %s/%d\n",
+		printk(KERN_ERR "Could not restart port%s/%d\n",
 			priv->device->name, priv->port);
 	}	
 
@@ -1126,19 +1126,19 @@
 	struct ib_device_attr device_attr;
 	struct ib_qp_init_attr qp_init_attr;
 	struct ib_qp_cap qp_cap;
-	struct ib_mad_device_private *entry, *priv = NULL,
-				     *head = (struct ib_mad_device_private *) &ib_mad_device_list;
-	IB_MAD_DEVICE_LIST_LOCK_VAR;
+	struct ib_mad_port_private *entry, *priv = NULL,
+				     *head = (struct ib_mad_port_private *) &ib_mad_port_list;
+	IB_MAD_PORT_LIST_LOCK_VAR;
 
 	/* First, check if port already open at MAD layer */
-	IB_MAD_DEVICE_LIST_LOCK();
+	IB_MAD_PORT_LIST_LOCK();
 	list_for_each(entry, head) {
 		if (entry->device == device && entry->port == port) {
 			priv = entry;
 			break;
 		}
 	}
-	IB_MAD_DEVICE_LIST_UNLOCK();
+	IB_MAD_PORT_LIST_UNLOCK();
 	if (priv) {
 		printk(KERN_DEBUG "Port already open\n");
 		return 0;
@@ -1147,7 +1147,7 @@
 	/* Create new device info */
 	priv = kmalloc(sizeof *priv, GFP_KERNEL);
 	if (!priv) {
-		printk(KERN_ERR "No memory for ib_mad_device_private\n");
+		printk(KERN_ERR "No memory for ib_mad_port_private\n");
 		return -ENOMEM;
 	}
 
@@ -1223,15 +1223,15 @@
 	INIT_LIST_HEAD(&priv->send_posted_mad_list);
 
 	ib_mad_thread_init(priv);
-	ret = ib_mad_device_start(priv);
+	ret = ib_mad_port_start(priv);
 	if (ret) {
-		printk(KERN_ERR "Could not start device\n");
+		printk(KERN_ERR "Could not start port\n");
 		goto error8;
 	}
 
-	IB_MAD_DEVICE_LIST_LOCK();
-	list_add_tail((struct list_head *)priv, &ib_mad_device_list);
-	IB_MAD_DEVICE_LIST_UNLOCK();
+	IB_MAD_PORT_LIST_LOCK();
+	list_add_tail((struct list_head *)priv, &ib_mad_port_list);
+	IB_MAD_PORT_LIST_UNLOCK();
 
 	return 0;
 
@@ -1258,11 +1258,11 @@
  */
 static int ib_mad_port_close(struct ib_device *device, int port)
 {
-	struct ib_mad_device_private *entry, *priv = NULL,
-				     *head = (struct ib_mad_device_private *)&ib_mad_device_list;
-	IB_MAD_DEVICE_LIST_LOCK_VAR;
+	struct ib_mad_port_private *entry, *priv = NULL,
+				     *head = (struct ib_mad_port_private *)&ib_mad_port_list;
+	IB_MAD_PORT_LIST_LOCK_VAR;
 
-	IB_MAD_DEVICE_LIST_LOCK();
+	IB_MAD_PORT_LIST_LOCK();
 	list_for_each(entry, head) {
 		if (entry->device == device && entry->port == port) {
 			priv = entry;
@@ -1272,14 +1272,14 @@
 
 	if (priv == NULL) {
 		printk(KERN_ERR "Port not found\n");
-		IB_MAD_DEVICE_LIST_UNLOCK();
+		IB_MAD_PORT_LIST_UNLOCK();
 		return -ENODEV;
 	}
 
 	list_del((struct list_head *)priv);
-	IB_MAD_DEVICE_LIST_UNLOCK();
+	IB_MAD_PORT_LIST_UNLOCK();
 
-	ib_mad_device_stop(priv);
+	ib_mad_port_stop(priv);
 	ib_mad_thread_stop(priv);
 	ib_destroy_qp(priv->qp[1]);
 	ib_destroy_qp(priv->qp[0]);
@@ -1312,7 +1312,7 @@
 	for (i = 0; i < num_ports; i++) {
 		ret = ib_mad_port_open(device, i);
 		if (ret) {
-			printk(KERN_ERR "Could not open device port %d\n", i);
+			printk(KERN_ERR "Could not open port %d\n", i);
 			goto error_device_open;
 		}
 	}
@@ -1323,7 +1323,7 @@
 	while (i > 0) {
 		ret2 = ib_mad_port_close(device, i);
 		if (ret2) {
-			printk(KERN_ERR "Could not close device port %d\n", i);
+			printk(KERN_ERR "Could not close port %d\n", i);
 		}
 		i--;
 	}
@@ -1348,7 +1348,7 @@
 	for (i = 0; i < num_ports; i++) {
 		ret2 = ib_mad_port_close(device, i);
 		if (ret2) {
-			printk(KERN_ERR "Could not close device port %d\n", i);
+			printk(KERN_ERR "Could not close port %d\n", i);
 			if (!ret)
 				ret = ret2;
 		}
@@ -1393,7 +1393,7 @@
 		return -ENOMEM;
 	}
 
-	INIT_LIST_HEAD(&ib_mad_device_list);
+	INIT_LIST_HEAD(&ib_mad_port_list);
 	INIT_LIST_HEAD(&ib_mad_agent_list);
 
 	ib_device_notifier_register(&mad_notifier);
Index: ib_mad_priv.h
===================================================================
--- ib_mad_priv.h	(revision 762)
+++ ib_mad_priv.h	(working copy)
@@ -119,8 +119,8 @@
 	int run;
 };
 
-struct ib_mad_device_private {
-	struct ib_mad_device_private *next;
+struct ib_mad_port_private {
+	struct ib_mad_port_private *next;
 	struct ib_device *device;
 	int port;
 	int up;





More information about the general mailing list