ib/umad: update module to [pr|dev]_* style print messages
PATCH v2 1/5 ib/umad: update module to [pr|dev]_* style print messages
From: Ira Weiny <[email protected]>
Use dev_* style print when struct device is available.
Also combine previously line broken user-visible strings as per Documentation/CodingStyle
"However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them."
--- drivers/infiniband/core/user_mad.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/infiniband/core/user_mad.c +15 -11
@@ -33,6 +33,8 @@* SOFTWARE. */ +#define pr_fmt (fmt) "user_mad: " fmt +#include <linux/module.h> #include <linux/init.h> #include <linux/device.h>
@@ -669,10 +671,11 @@ found:if (!file->already_used) { file->already_used =1 ;if (!file->use_pkey_index) { -printk (KERN_WARNING "user_mad: process %s did not enable " -"P_Key index support.\n" , current->comm); -printk (KERN_WARNING "user_mad: Documentation/infiniband/user_mad.txt " -"has info on the new ABI.\n" ); +dev_warn (file->port->dev, +"process %s did not enable P_Key index support.\n" , + current->comm); +dev_warn (file->port->dev, +" Documentation/infiniband/user_mad.txt has info on the new ABI.\n" ); } }
@@ -974,7 +977,7 @@ static CLASS_ATTR_STRING(abi_version, S_IRUGO,static dev_t overflow_maj; static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); -static int find_overflow_devnum (void ) +static int find_overflow_devnum (struct ib_device *device) {int ret;
@@ -982,7 +985,8 @@ static int find_overflow_devnum(void) ret =alloc_chrdev_region (&overflow_maj,0 ,IB_UMAD_MAX_PORTS *2 ,"infiniband_mad" );if (ret) { -printk (KERN_ERR "user_mad: couldn't register dynamic device number\n" ); +dev_err (&device->dev, +"couldn't register dynamic device number\n" );return ret; } }
@@ -1004,7 +1008,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, devnum =find_first_zero_bit (dev_map,IB_UMAD_MAX_PORTS );if (devnum >=IB_UMAD_MAX_PORTS ) {spin_unlock (&port_lock); - devnum =find_overflow_devnum (); + devnum =find_overflow_devnum (device);if (devnum <0 )return -1 ;
@@ -1187,14 +1191,14 @@ static int __init ib_umad_init(void) ret =register_chrdev_region (base_dev,IB_UMAD_MAX_PORTS *2 ,"infiniband_mad" );if (ret) { -printk (KERN_ERR "user_mad: couldn't register device number\n" ); +pr_err ("couldn't register device number\n" ); goto out; } umad_class =class_create (THIS_MODULE ,"infiniband_mad" );if (IS_ERR (umad_class)) { ret =PTR_ERR (umad_class); -printk (KERN_ERR "user_mad: couldn't create class infiniband_mad\n" ); +pr_err ("couldn't create class infiniband_mad\n" ); goto out_chrdev; }
@@ -1202,13 +1206,13 @@ static int __init ib_umad_init(void) ret =class_create_file (umad_class, &class_attr_abi_version.attr);if (ret) { -printk (KERN_ERR "user_mad: couldn't create abi_version attribute\n" ); +pr_err ("couldn't create abi_version attribute\n" ); goto out_class; } ret =ib_register_client (&umad_client);if (ret) { -printk (KERN_ERR "user_mad: couldn't register ib_umad client\n" ); +pr_err ("couldn't register ib_umad client\n" ); goto out_class; }
Signature · 6 lines
1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/5 ib/mad: update module to [pr|dev]_* style print messages
In reply to a message not in the archiveFrom: Ira Weiny <[email protected]>
Use dev_* style print when struct device is available.
Also combine previously line broken user-visible strings as per Documentation/CodingStyle
"However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them."
--- drivers/infiniband/core/agent.c | 12 ++-- drivers/infiniband/core/mad.c | 147 +++++++++++++++++++++------------------- 2 files changed, 85 insertions(+), 74 deletions(-)
drivers/infiniband/core/agent.c +6 -6
@@ -94,14 +94,14 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh, port_priv =ib_get_agent_port (device, port_num);if (!port_priv) { - printk(KERN_ERR SPFX "Unable to find port agent\n"); +dev_err (&device->dev,"Unable to find port agent\n" );return ; } agent = port_priv->agent[qpn]; ah =ib_create_ah_from_wc (agent->qp->pd, wc, grh, port_num);if (IS_ERR (ah)) { - printk(KERN_ERR SPFX "ib_create_ah_from_wc error %ld\n", +dev_err (&device->dev,"ib_create_ah_from_wc error %ld\n" ,PTR_ERR (ah));return ; }
@@ -110,7 +110,7 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,IB_MGMT_MAD_HDR ,IB_MGMT_MAD_DATA , GFP_KERNEL);if (IS_ERR (send_buf)) { - printk(KERN_ERR SPFX "ib_create_send_mad error\n"); +dev_err (&device->dev,"ib_create_send_mad error\n" ); goto err1; }
@@ -125,7 +125,7 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh, }if (ib_post_send_mad (send_buf,NULL )) { - printk(KERN_ERR SPFX "ib_post_send_mad error\n"); +dev_err (&device->dev,"ib_post_send_mad error\n" ); goto err2; }return ;
@@ -151,7 +151,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)/* Create new device info */ port_priv =kzalloc (sizeof *port_priv,GFP_KERNEL );if (!port_priv) { - printk(KERN_ERR SPFX "No memory for ib_agent_port_private\n"); +dev_err (&device->dev,"No memory for ib_agent_port_private\n" ); ret = -ENOMEM ; goto error1; }
@@ -202,7 +202,7 @@ int ib_agent_port_close(struct ib_device *device, int port_num) port_priv =__ib_get_agent_port (device, port_num);if (port_priv ==NULL ) {spin_unlock_irqrestore (&ib_agent_port_list_lock, flags); - printk(KERN_ERR SPFX "Port %d not found\n", port_num); +dev_err (&device->dev,"Port %d not found\n" , port_num);return -ENODEV ; }list_del (&port_priv->port_list);
drivers/infiniband/core/mad.c +79 -68
392 lines not on this page · raw message
Signature · 6 lines
1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/5 ib/mad: Add dev_notice messages for various umad/mad registration failures
In reply to a message not in the archiveFrom: Ira Weiny <[email protected]>
Registration failures can be difficult to debug from userspace. This gives more visibility.
--- drivers/infiniband/core/mad.c | 58 ++++++++++++++++++++++++++++++++------ drivers/infiniband/core/user_mad.c | 8 ++++++ 2 files changed, 57 insertions(+), 9 deletions(-)
drivers/infiniband/core/mad.c +49 -9
@@ -214,58 +214,95 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,/* Validate parameters */ qpn =get_spl_qp_index (qp_type); -if (qpn ==-1 ) +if (qpn ==-1 ) { +dev_notice (&device->dev, +"ib_register_mad_agent: invalid QP Type %d\n" , + qp_type); goto error1; + } -if (rmpp_version && rmpp_version !=IB_MGMT_RMPP_VERSION ) +if (rmpp_version && rmpp_version !=IB_MGMT_RMPP_VERSION ) { +dev_notice (&device->dev, +"ib_register_mad_agent: invalid RMPP Version %u\n" , + rmpp_version); goto error1; + }/* Validate MAD registration request if supplied */ if (mad_reg_req) { -if (mad_reg_req->mgmt_class_version >=MAX_MGMT_VERSION ) +if (mad_reg_req->mgmt_class_version >=MAX_MGMT_VERSION ) { +dev_notice (&device->dev, +"ib_register_mad_agent: invalid Class Version %u\n" , + mad_reg_req->mgmt_class_version); goto error1; -if (!recv_handler) + } +if (!recv_handler) { +dev_notice (&device->dev, +"ib_register_mad_agent: no recv_handler\n" ); goto error1; + }if (mad_reg_req->mgmt_class >=MAX_MGMT_CLASS ) {/* * IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE is the only * one in this range currently allowed */ if (mad_reg_req->mgmt_class != -IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) +IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) { +dev_notice (&device->dev, +"ib_register_mad_agent: Invalid Mgmt Class 0x%x\n" , + mad_reg_req->mgmt_class); goto error1; + } }else if (mad_reg_req->mgmt_class ==0 ) {/* * Class 0 is reserved in IBA and is used for * aliasing of IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE */ +dev_notice (&device->dev, +"ib_register_mad_agent: Invalid Mgmt Class 0\n" ); goto error1; }else if (is_vendor_class (mad_reg_req->mgmt_class)) {/* * If class is in "new" vendor range, * ensure supplied OUI is not zero */ -if (!is_vendor_oui (mad_reg_req->oui)) +if (!is_vendor_oui (mad_reg_req->oui)) { +dev_notice (&device->dev, +"ib_register_mad_agent: No OUI specified for class 0x%x\n" , + mad_reg_req->mgmt_class); goto error1; + } }/* Make sure class supplied is consistent with RMPP */ if (!ib_is_mad_class_rmpp (mad_reg_req->mgmt_class)) { -if (rmpp_version) +if (rmpp_version) { +dev_notice (&device->dev, +"ib_register_mad_agent: RMPP version for non-RMPP class 0x%x\n" , + mad_reg_req->mgmt_class); goto error1; + } }/* Make sure class supplied is consistent with QP type */ if (qp_type ==IB_QPT_SMI ) {if ((mad_reg_req->mgmt_class !=IB_MGMT_CLASS_SUBN_LID_ROUTED ) && (mad_reg_req->mgmt_class != -IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE )) +IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE )) { +dev_notice (&device->dev, +"ib_register_mad_agent: Invalid SM QP type: class 0x%x\n" , + mad_reg_req->mgmt_class); goto error1; + } }else {if ((mad_reg_req->mgmt_class ==IB_MGMT_CLASS_SUBN_LID_ROUTED ) || (mad_reg_req->mgmt_class == -IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE )) +IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE )) { +dev_notice (&device->dev, +"ib_register_mad_agent: Invalid GS QP type: class 0x%x\n" , + mad_reg_req->mgmt_class); goto error1; + } } }else {/* No registration request supplied */
@@ -276,6 +313,7 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,/* Validate device and port */ port_priv =ib_get_mad_port (device, port_num);if (!port_priv) { +dev_notice (&device->dev,"ib_register_mad_agent: Invalid port\n" ); ret =ERR_PTR (-ENODEV ); goto error1; }
@@ -283,6 +321,8 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,/* Verify the QP requested is supported. For example, Ethernet devices * will not have QP0 */ if (!port_priv->qp_info[qpn].qp) { +dev_notice (&device->dev, +"ib_register_mad_agent: QP %d not supported\n" , qpn); ret =ERR_PTR (-EPROTONOSUPPORT ); goto error1; }
drivers/infiniband/core/user_mad.c +8 -0
@@ -612,6 +612,8 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,mutex_lock (&file->mutex);if (!file->port->ib_dev) { +dev_notice (file->port->dev, +"ib_umad_reg_agent: invalid device\n" ); ret = -EPIPE ; goto out; }
@@ -622,6 +624,9 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg, }if (ureq.qpn !=0 && ureq.qpn !=1 ) { +dev_notice (file->port->dev, +"ib_umad_reg_agent: invalid QPN %d specified\n" , + ureq.qpn); ret = -EINVAL ; goto out; }
@@ -630,6 +635,9 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,if (!__get_agent (file, agent_id)) goto found; +dev_notice (file->port->dev, +"ib_umad_reg_agent: Max Agents (%u) reached\n" , +IB_UMAD_MAX_AGENTS ); ret = -ENOMEM ; goto out;
Signature · 6 lines
1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html