[openib-general] [PATCH] mad: Eliminate line wraps in mad.c and agent.c

Hal Rosenstock halr at voltaire.com
Mon Nov 8 11:19:53 PST 2004


mad: Eliminate line wraps (lines over 80 columns) in mad.c and agent.c

Index: mad.c
===================================================================
--- mad.c	(revision 1168)
+++ mad.c	(working copy)
@@ -244,7 +244,6 @@
 	mad_agent_priv->qp_info = &port_priv->qp_info[qpn];
 	mad_agent_priv->reg_req = reg_req;
 	mad_agent_priv->rmpp_version = rmpp_version;
-	mad_agent_priv->phys_port_cnt = port_priv->phys_port_cnt;
 	mad_agent_priv->agent.device = device;
 	mad_agent_priv->agent.recv_handler = recv_handler;
 	mad_agent_priv->agent.send_handler = send_handler;
@@ -400,25 +399,28 @@
 					    GFP_ATOMIC : GFP_KERNEL);
 		if (!mad_priv) {
 			ret = -ENOMEM;
-			printk(KERN_ERR PFX "No memory for local response MAD\n");
+			printk(KERN_ERR PFX "No memory for local "
+			       "response MAD\n");
 			goto error1;
 		}
 
 		mad_agent_priv = container_of(mad_agent,
 					      struct ib_mad_agent_private,
 					      agent);
-		ret = mad_agent->device->process_mad(mad_agent->device,
-						     0,
-						     mad_agent->port_num,
-						     smp->dr_slid, /* ? */
-						     (struct ib_mad *)smp,
-						     (struct ib_mad *)&mad_priv->mad);
+		ret = mad_agent->device->process_mad(
+					mad_agent->device,
+					0,
+					mad_agent->port_num,
+					smp->dr_slid, /* ? */
+					(struct ib_mad *)smp,
+					(struct ib_mad *)&mad_priv->mad);
 		if ((ret & IB_MAD_RESULT_SUCCESS) &&
 		    (ret & IB_MAD_RESULT_REPLY)) {
-			if (!smi_handle_dr_smp_recv((struct ib_smp *)&mad_priv->mad,
-						    mad_agent->device->node_type,
-						    mad_agent->port_num,
-						    mad_agent_priv->phys_port_cnt)) {
+			if (!smi_handle_dr_smp_recv(
+					(struct ib_smp *)&mad_priv->mad,
+					mad_agent->device->node_type,
+					mad_agent->port_num,
+					mad_agent->device->phys_port_cnt)) {
 				ret = -EINVAL;
 				kmem_cache_free(ib_mad_cache, mad_priv);
 				goto error1;
@@ -430,7 +432,10 @@
 		    mad_agent_priv->agent.recv_handler) {
 			struct ib_wc wc;
 
-			/* Defined behavior is to complete response before request */
+			/*
+			 * Defined behavior is to complete response
+			 * before request
+			 */
 			wc.wr_id = send_wr->wr_id;
 			wc.status = IB_WC_SUCCESS;
 			wc.opcode = IB_WC_RECV;
@@ -443,13 +448,16 @@
 			wc.sl = 0;
 			wc.dlid_path_bits = 0;
 			mad_priv->header.recv_wc.wc = &wc;
-			mad_priv->header.recv_wc.mad_len = sizeof(struct ib_mad);
+			mad_priv->header.recv_wc.mad_len =
+							sizeof(struct ib_mad);
 			INIT_LIST_HEAD(&mad_priv->header.recv_buf.list);
 			mad_priv->header.recv_buf.grh = NULL;
 			mad_priv->header.recv_buf.mad = &mad_priv->mad.mad;
-			mad_priv->header.recv_wc.recv_buf = &mad_priv->header.recv_buf;
-			mad_agent_priv->agent.recv_handler(mad_agent,
-							   &mad_priv->header.recv_wc);
+			mad_priv->header.recv_wc.recv_buf =
+						&mad_priv->header.recv_buf;
+			mad_agent_priv->agent.recv_handler(
+						mad_agent,
+						&mad_priv->header.recv_wc);
 		} else
 			kmem_cache_free(ib_mad_cache, mad_priv);
 
@@ -458,7 +466,9 @@
 			mad_send_wc.status = IB_WC_SUCCESS;
 			mad_send_wc.vendor_err = 0;
 			mad_send_wc.wr_id = send_wr->wr_id;
-			mad_agent_priv->agent.send_handler(mad_agent, &mad_send_wc);
+			mad_agent_priv->agent.send_handler(
+						mad_agent,
+						&mad_send_wc);
 			ret = 1;
 		} else
 			ret = -EINVAL;
@@ -515,7 +525,8 @@
 	    (send_wr->wr.ud.timeout_ms && !mad_agent->recv_handler))
 		goto error2;
 
-	mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
+	mad_agent_priv = container_of(mad_agent,
+				      struct ib_mad_agent_private,
 				      agent);
 
 	/* Walk list of send WRs and post each on send list */
@@ -527,7 +538,8 @@
 
 		if (!cur_send_wr->wr.ud.mad_hdr) {
 			*bad_send_wr = cur_send_wr;
-			printk(KERN_ERR PFX "MAD header must be supplied in WR %p\n", cur_send_wr);
+			printk(KERN_ERR PFX "MAD header must be supplied "
+			       "in WR %p\n", cur_send_wr);
 			goto error1;
 		}
 
@@ -609,7 +621,8 @@
 	struct ib_mad_private_header *mad_priv_hdr;
 	struct ib_mad_private *priv;
 
-	mad_priv_hdr = container_of(mad_recv_wc, struct ib_mad_private_header,
+	mad_priv_hdr = container_of(mad_recv_wc,
+				    struct ib_mad_private_header,
 				    recv_wc);
 	priv = container_of(mad_priv_hdr, struct ib_mad_private, header);
 
@@ -678,7 +691,8 @@
 	/* Allocate management method table */
 	*method = kmalloc(sizeof **method, GFP_ATOMIC);
 	if (!*method) {
-		printk(KERN_ERR PFX "No memory for ib_mad_mgmt_method_table\n");
+		printk(KERN_ERR PFX "No memory for "
+		       "ib_mad_mgmt_method_table\n");
 		return -ENOMEM;
 	}
 	/* Clear management method table */
@@ -773,7 +787,8 @@
 		goto error3;
 
 	/* Finally, add in methods being registered */
-	for (i = find_first_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS); 
+	for (i = find_first_bit(mad_reg_req->method_mask,
+				IB_MGMT_MAX_METHODS); 
 	     i < IB_MGMT_MAX_METHODS;
 	     i = find_next_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS,
 			       1+i)) {
@@ -806,7 +821,10 @@
 	struct ib_mad_mgmt_method_table *method;
 	u8 mgmt_class;
 
-	/* Was MAD registration request supplied with original registration ? */
+	/*
+	 * Was MAD registration request supplied
+	 * with original registration ?
+	 */
 	if (!agent_priv->reg_req) {
 		goto out;
 	}
@@ -1085,7 +1103,7 @@
 		if (!smi_handle_dr_smp_recv(smp,
 					    port_priv->device->node_type,
 					    port_priv->port_num,
-					    port_priv->phys_port_cnt))
+					    port_priv->device->phys_port_cnt))
 			goto out;
 		if (!smi_check_forward_dr_smp(smp))
 			goto out;
@@ -1108,7 +1126,10 @@
 		response = kmalloc(sizeof(struct ib_mad), GFP_KERNEL);
 		if (!response) {
 			printk(KERN_ERR PFX "No memory for response MAD\n");
-			/* Is it better to assume that it wouldn't be processed ? */
+			/*
+			 * Is it better to assume that
+			 * it wouldn't be processed ?
+			 */
 			goto out;
 		}
 
@@ -1122,16 +1143,17 @@
 			if (response->mad_hdr.mgmt_class ==
 			    IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
 				if (!smi_handle_dr_smp_recv(
-						(struct ib_smp *)response,
-						port_priv->device->node_type,
-						port_priv->port_num,
-						port_priv->phys_port_cnt)) {
+					(struct ib_smp *)response,
+					port_priv->device->node_type,
+					port_priv->port_num,
+					port_priv->device->phys_port_cnt)) {
 					kfree(response);
 					goto out;
 				}
 			}
 			/* Send response */
-			grh = (void *)recv->header.recv_buf.mad - sizeof(struct ib_grh);
+			grh = (void *)recv->header.recv_buf.mad -
+			      sizeof(struct ib_grh);
 			if (agent_send(response, grh, wc,
 				       port_priv->device,
 				       port_priv->port_num)) {
@@ -1175,7 +1197,8 @@
 					 struct ib_mad_send_wr_private,
 					 agent_list);
 
-		if (time_after(mad_agent_priv->timeout, mad_send_wr->timeout)) {
+		if (time_after(mad_agent_priv->timeout,
+			       mad_send_wr->timeout)) {
 			mad_agent_priv->timeout = mad_send_wr->timeout;
 			cancel_delayed_work(&mad_agent_priv->work);
 			delay = mad_send_wr->timeout - jiffies;
@@ -1204,7 +1227,8 @@
 		temp_mad_send_wr = list_entry(list_item,
 					      struct ib_mad_send_wr_private,
 					      agent_list);
-		if (time_after(mad_send_wr->timeout, temp_mad_send_wr->timeout))
+		if (time_after(mad_send_wr->timeout,
+			       temp_mad_send_wr->timeout))
 			break;
 	}
 	list_add(&mad_send_wr->agent_list, list_item);
@@ -1517,7 +1541,8 @@
 				 PCI_DMA_FROMDEVICE);
 
 		kmem_cache_free(ib_mad_cache, mad_priv);
-		printk(KERN_NOTICE PFX "ib_post_recv WRID 0x%Lx failed ret = %d\n",
+		printk(KERN_NOTICE PFX "ib_post_recv WRID 0x%Lx "
+		       "failed ret = %d\n",
 		       (unsigned long long) recv_wr.wr_id, ret);
 		return -EINVAL;
 	}
@@ -1607,7 +1632,8 @@
 
 	attr =  kmalloc(sizeof *attr, GFP_KERNEL);
 	if (!attr) {
-		printk(KERN_ERR PFX "Couldn't allocate memory for ib_qp_attr\n");
+		printk(KERN_ERR PFX "Couldn't allocate memory for "
+		       "ib_qp_attr\n");
 		return -ENOMEM;
 	}
 
@@ -1628,7 +1654,8 @@
 	kfree(attr);
 
 	if (ret)
-		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_init ret = %d\n", ret);
+		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_init "
+		       "ret = %d\n", ret);
 	return ret;
 }
 
@@ -1643,7 +1670,8 @@
 
 	attr =  kmalloc(sizeof *attr, GFP_KERNEL);
 	if (!attr) {
-		printk(KERN_ERR PFX "Couldn't allocate memory for ib_qp_attr\n");
+		printk(KERN_ERR PFX "Couldn't allocate memory for "
+		       "ib_qp_attr\n");
 		return -ENOMEM;
 	}
 
@@ -1654,7 +1682,8 @@
 	kfree(attr);
 
 	if (ret)
-		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_rtr ret = %d\n", ret);
+		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_rtr "
+		       "ret = %d\n", ret);
 	return ret;
 }
 
@@ -1669,7 +1698,8 @@
 
 	attr = kmalloc(sizeof *attr, GFP_KERNEL);
 	if (!attr) {
-		printk(KERN_ERR PFX "Couldn't allocate memory for ib_qp_attr\n");
+		printk(KERN_ERR PFX "Couldn't allocate memory for "
+		       "ib_qp_attr\n");
 		return -ENOMEM;
 	}
 
@@ -1681,7 +1711,8 @@
 	kfree(attr);
 
 	if (ret)
-		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_rts ret = %d\n", ret);
+		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_rts "
+		       "ret = %d\n", ret);
 	return ret;
 }
 
@@ -1696,7 +1727,8 @@
 
 	attr = kmalloc(sizeof *attr, GFP_KERNEL);
  	if (!attr) {
-		printk(KERN_ERR PFX "Couldn't allocate memory for ib_qp_attr\n");
+		printk(KERN_ERR PFX "Couldn't allocate memory for "
+		       "ib_qp_attr\n");
 		return -ENOMEM;
 	}
 
@@ -1707,7 +1739,8 @@
 	kfree(attr);
 
 	if (ret)
-		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_reset ret = %d\n", ret);
+		printk(KERN_WARNING PFX "ib_mad_change_qp_state_to_reset "
+		       "ret = %d\n", ret);
 	return ret;
 }
 
@@ -1743,14 +1776,16 @@
 
 	ret = ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
 	if (ret) {
-		printk(KERN_ERR PFX "Failed to request completion notification\n");
+		printk(KERN_ERR PFX "Failed to request completion "
+		       "notification\n");
 		goto error;
 	}
 
 	for (i = 0; i < IB_MAD_QPS_CORE; i++) {
 		ret = ib_mad_post_receive_mads(&port_priv->qp_info[i]);
 		if (ret) {
-			printk(KERN_ERR PFX "Couldn't post receive requests\n");
+			printk(KERN_ERR PFX "Couldn't post receive "
+			       "requests\n");
 			goto error;
 		}
 	}
@@ -1777,11 +1812,13 @@
 	int i, ret;
 
 	for (i = 0; i < IB_MAD_QPS_CORE; i++) {
-		ret = ib_mad_change_qp_state_to_reset(port_priv->qp_info[i].qp);
+		ret = ib_mad_change_qp_state_to_reset(
+						port_priv->qp_info[i].qp);
 		if (ret) {
-			printk(KERN_ERR PFX "ib_mad_port_stop: Couldn't change "
-			       "%s port %d QP%d state to RESET\n",
-			       port_priv->device->name, port_priv->port_num, i);
+			printk(KERN_ERR PFX "ib_mad_port_stop: Couldn't change"
+			       " %s port %d QP%d state to RESET\n",
+			       port_priv->device->name, port_priv->port_num,
+			       i);
 		}
 		ib_mad_return_posted_recv_mads(&port_priv->qp_info[i]);
 		ib_mad_return_posted_send_mads(&port_priv->qp_info[i]);
@@ -1842,8 +1879,7 @@
  * Create the QP, PD, MR, and CQ if needed
  */
 static int ib_mad_port_open(struct ib_device *device,
-			    int port_num,
-			    int num_ports)
+			    int port_num)
 {
 	int ret, cq_size;
 	u64 iova = 0;
@@ -1872,7 +1908,6 @@
 	memset(port_priv, 0, sizeof *port_priv);
 	port_priv->device = device;
 	port_priv->port_num = port_num;
-	port_priv->phys_port_cnt = num_ports;
 	spin_lock_init(&port_priv->reg_lock);
 
 	cq_size = (IB_MAD_QP_SEND_SIZE + IB_MAD_QP_RECV_SIZE) * 2;
@@ -1985,31 +2020,25 @@
 static void ib_mad_init_device(struct ib_device *device)
 {
 	int ret, num_ports, cur_port, i, ret2;
-	struct ib_device_attr device_attr;
 
-	ret = ib_query_device(device, &device_attr);
-	if (ret) {
-		printk(KERN_ERR PFX "Couldn't query device %s\n", device->name);
-		goto error_device_query;
-	}
-
 	if (device->node_type == IB_NODE_SWITCH) {
 		num_ports = 1;
 		cur_port = 0;
 	} else {
-		num_ports = device_attr.phys_port_cnt;
+		num_ports = device->phys_port_cnt;
 		cur_port = 1;
 	}
 	for (i = 0; i < num_ports; i++, cur_port++) {
-		ret = ib_mad_port_open(device, cur_port, num_ports);
+		ret = ib_mad_port_open(device, cur_port);
 		if (ret) {
 			printk(KERN_ERR PFX "Couldn't open %s port %d\n",
 			       device->name, cur_port);
 			goto error_device_open;
 		}
-		ret = ib_agent_port_open(device, cur_port, num_ports);
+		ret = ib_agent_port_open(device, cur_port);
 		if (ret) {
-			printk(KERN_ERR PFX "Couldn't open %s port %d for agents\n",
+			printk(KERN_ERR PFX "Couldn't open %s port %d "
+			       "for agents\n",
 			       device->name, cur_port);
 			goto error_device_open;
 		}
@@ -2022,7 +2051,8 @@
 		cur_port--;
 		ret2 = ib_agent_port_close(device, cur_port);
 		if (ret2) {
-			printk(KERN_ERR PFX "Couldn't close %s port %d for agent\n",
+			printk(KERN_ERR PFX "Couldn't close %s port %d "
+			       "for agents\n",
 			       device->name, cur_port);
 		}
 		ret2 = ib_mad_port_close(device, cur_port);
@@ -2039,26 +2069,20 @@
 
 static void ib_mad_remove_device(struct ib_device *device)
 {
-	int ret, i, num_ports, cur_port, ret2;
-	struct ib_device_attr device_attr;
+	int ret = 0, i, num_ports, cur_port, ret2;
 
-	ret = ib_query_device(device, &device_attr);
-	if (ret) {
-		printk(KERN_ERR PFX "Couldn't query device %s\n", device->name);
-		goto error_device_query;
-	}
-
 	if (device->node_type == IB_NODE_SWITCH) {
 		num_ports = 1;
 		cur_port = 0;
 	} else {
-		num_ports = device_attr.phys_port_cnt;
+		num_ports = device->phys_port_cnt;
 		cur_port = 1;
 	}
 	for (i = 0; i < num_ports; i++, cur_port++) {
 		ret2 = ib_agent_port_close(device, cur_port);
 		if (ret2) {
-			printk(KERN_ERR PFX "Couldn't close %s port %d for agent\n",
+			printk(KERN_ERR PFX "Couldn't close %s port %d "
+			       "for agents\n",
 			       device->name, cur_port);
 			if (!ret)
 				ret = ret2;
@@ -2071,9 +2095,6 @@
 				ret = ret2;
 		}
 	}
-
-error_device_query:
-	return;
 }
 
 static struct ib_client mad_client = {
Index: agent.c
===================================================================
--- agent.c	(revision 1168)
+++ agent.c	(working copy)
@@ -84,7 +84,8 @@
 		return 1;
 	port_priv = ib_get_agent_mad(device, port_num, NULL);
 	if (!port_priv) {
-		printk(KERN_DEBUG SPFX "smi_check_local_dr_smp %s port %d not open\n",
+		printk(KERN_DEBUG SPFX "smi_check_local_dr_smp %s port %d "
+		       "not open\n",
 		       device->name, port_num);
 		return 1;
 	}
@@ -109,7 +110,8 @@
 	/* Find matching MAD agent */
 	port_priv = ib_get_agent_mad(NULL, 0, mad_agent);
 	if (!port_priv) {
-		printk(KERN_ERR SPFX "agent_mad_send: no matching MAD agent %p\n",
+		printk(KERN_ERR SPFX "agent_mad_send: no matching MAD agent "
+		       "%p\n",
 		       mad_agent);
 		goto out;
 	}
@@ -143,12 +145,16 @@
 	if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
 		if (wc->wc_flags & IB_WC_GRH) {
 			ah_attr.ah_flags = IB_AH_GRH;
-			ah_attr.grh.sgid_index = 0; /* Should sgid be looked up
-? */
+			/* Should sgid be looked up ? */
+			ah_attr.grh.sgid_index = 0;
 			ah_attr.grh.hop_limit = grh->hop_limit;
-			ah_attr.grh.flow_label = be32_to_cpup(&grh->version_tclass_flow) & 0xfffff; 
-			ah_attr.grh.traffic_class = (be32_to_cpup(&grh->version_tclass_flow) >> 20) & 0xff;
-			memcpy(ah_attr.grh.dgid.raw, grh->sgid.raw, sizeof(struct ib_grh));
+			ah_attr.grh.flow_label = be32_to_cpup(
+				&grh->version_tclass_flow)  & 0xffff;
+			ah_attr.grh.traffic_class = (be32_to_cpup(
+				&grh->version_tclass_flow) >> 20) & 0xff;
+			memcpy(ah_attr.grh.dgid.raw,
+			       grh->sgid.raw,
+			       sizeof(struct ib_grh));
 		} else {
 			ah_attr.ah_flags = 0; /* No GRH for SM class */
 		}
@@ -243,8 +249,8 @@
 	/* Find matching MAD agent */
 	port_priv = ib_get_agent_mad(NULL, 0, mad_agent);
 	if (!port_priv) {
-		printk(KERN_ERR SPFX "agent_send_handler: no matching MAD agent "
-		       "%p\n", mad_agent);
+		printk(KERN_ERR SPFX "agent_send_handler: no matching MAD "
+		       "agent %p\n", mad_agent);
 		return;
 	}
 
@@ -252,8 +258,9 @@
 	spin_lock_irqsave(&port_priv->send_list_lock, flags);
 	if (list_empty(&port_priv->send_posted_list)) {
 		spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
-		printk(KERN_ERR SPFX "Send completion WR ID 0x%Lx but send list "
-		       "is empty\n", (unsigned long long) mad_send_wc->wr_id);
+		printk(KERN_ERR SPFX "Send completion WR ID 0x%Lx but send "
+		       "list is empty\n",
+		       (unsigned long long) mad_send_wc->wr_id);
 		return;
 	}
 






More information about the general mailing list