[ofa-general] [PATCH RFC] - iw_cxgb3 debug - turn debug logging on/off at runtime

Steve Wise swise at opengridcomputing.com
Thu Jun 28 10:34:21 PDT 2007


This is an request for comments.

What do folks think about using a sysfs file to turn debug logging 
on/off at runtime for an rdma driver?

Is a /proc entry better?

Thanks,

Steve.


-------------------

> commit 5441877cbe5bb8bc56bbc5bd77e4551aa8a219b0
> Author: Steve Wise <swise at opengridcomputing.com>
> Date:   Wed May 9 10:09:03 2007 -0500
> 
>     Debug/Trace fixes.
>     
>     - Add sysfs entry to turn debug trace on/off.  You still need to compile
>     the driver to turn all the debug code on, but once compiled, you can turn
>     on the logging via:
>      echo 1 >  /sys/class/infiniband/cxgb3/debug
>     
>     Eventually I'll clean up the logging so that we can always leave this
>     code compiled in.  But for now, its way to verbose to always compile in.
>     
>     - Fixed bug in cxio_dump_rqt
>     
>     Signed-off-by: Steve Wise <swise at opengridcomputing.com>
> 
> diff --git a/drivers/infiniband/hw/cxgb3/core/cxio_dbg.c b/drivers/infiniband/hw/cxgb3/core/cxio_dbg.c
> index d6b6c97..76d2951 100644
> --- a/drivers/infiniband/hw/cxgb3/core/cxio_dbg.c
> +++ b/drivers/infiniband/hw/cxgb3/core/cxio_dbg.c
> @@ -133,7 +133,7 @@ void cxio_dump_wce(struct t3_cqe *wce)
>  	}
>  }
>  
> -void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents)
> +void cxio_dump_rqt(struct cxio_rdev *rdev, u32 rqt_addr, int nents)
>  {
>  	struct ch_mem_range *m;
>  	int size = nents * 64;
> @@ -146,7 +146,7 @@ void cxio_dump_rqt(struct cxio_rdev *rde
>  		return;
>  	}
>  	m->mem_id = MEM_PMRX;
> -	m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
> +	m->addr = rqt_addr;
>  	m->len = size;
>  	PDBG("%s RQT addr 0x%x len %d\n", __FUNCTION__, m->addr, m->len);
>  	rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
> diff --git a/drivers/infiniband/hw/cxgb3/core/cxio_hal.c b/drivers/infiniband/hw/cxgb3/core/cxio_hal.c
> index ce05db5..425536c 100644
> --- a/drivers/infiniband/hw/cxgb3/core/cxio_hal.c
> +++ b/drivers/infiniband/hw/cxgb3/core/cxio_hal.c
> @@ -45,6 +45,10 @@ #include "sge_defs.h"
>  static struct cxio_rdev *rdev_tbl[T3_MAX_NUM_RNIC];
>  static cxio_hal_ev_callback_func_t cxio_ev_cb = NULL;
>  
> +#ifdef DEBUG
> +unsigned int cxio_debug;
> +#endif
> +
>  static inline struct cxio_rdev *cxio_hal_find_rdev_by_name(char *dev_name)
>  {
>  	int i;
> diff --git a/drivers/infiniband/hw/cxgb3/core/cxio_hal.h b/drivers/infiniband/hw/cxgb3/core/cxio_hal.h
> index 1553bda..12ee689 100644
> --- a/drivers/infiniband/hw/cxgb3/core/cxio_hal.h
> +++ b/drivers/infiniband/hw/cxgb3/core/cxio_hal.h
> @@ -186,7 +186,6 @@ int cxio_poll_cq(struct t3_wq *wq, struc
>  		     u8 *cqe_flushed, u64 *cookie, u32 *credit);
>  
>  #define MOD "iw_cxgb3: "
> -#define PDBG(fmt, args...) pr_debug(MOD fmt, ## args)
>  
>  #ifdef DEBUG
>  void cxio_dump_tpt(struct cxio_rdev *rev, u32 stag);
> @@ -195,6 +194,15 @@ void cxio_dump_wqe(union t3_wr *wqe);
>  void cxio_dump_wce(struct t3_cqe *wce);
>  void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents);
>  void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid);
> +
> +extern unsigned int cxio_debug;
> +
> +#define PDBG(fmt, args...) { \
> +	if (cxio_debug) \
> +		printk(MOD fmt, ## args); \
> +}
> +#else
> +#define PDBG(fmt, arg...) do { ; } while (0)
>  #endif
>  
>  #endif
> diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
> index b0f7218..33c9e59 100644
> --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
> +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
> @@ -1057,16 +1057,42 @@ static ssize_t show_board(struct class_d
>  		                       dev->rdev.rnic_info.pdev->device);
>  }
>  
> +#ifdef DEBUG
> +static ssize_t show_debug(struct class_device *cdev, char *buf)
> +{
> +	return sprintf(buf, "cxio_debug=%d\n", cxio_debug);
> +}
> +
> +static ssize_t iwch_set_debug(struct class_device *cdev, const char *buf, size_t count)
> +{
> +	unsigned dbg;
> +
> +	sscanf(buf, "%u", &dbg);
> +	if (dbg > 1) 
> +		return -EINVAL;
> +	cxio_debug = dbg;
> +	printk(KERN_INFO MOD "cxio_debug=%d\n", cxio_debug);
> +	return count;
> +}
> +#endif
> +
>  static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
>  static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
>  static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
>  static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
>  
> +#ifdef DEBUG
> +static CLASS_DEVICE_ATTR(debug, S_IRUGO|S_IWUGO, show_debug, iwch_set_debug);
> +#endif
> +
>  static struct class_device_attribute *iwch_class_attributes[] = {
>  	&class_device_attr_hw_rev,
>  	&class_device_attr_fw_ver,
>  	&class_device_attr_hca_type,
> -	&class_device_attr_board_id
> +	&class_device_attr_board_id,
> +#ifdef DEBUG
> +	&class_device_attr_debug,
> +#endif
>  };
>  
>  int iwch_register_device(struct iwch_dev *dev)




More information about the general mailing list