Skip to content

Commit

Permalink
IB/rxe: improved debug prints & code cleanup
Browse files Browse the repository at this point in the history
1. Debugging qp state transitions and qp errors in loopback and
multiple QP tests is difficult without qp numbers in debug logs.
This patch adds qp number to important debug logs.

2. Instead of having rxe: prefix in few logs and not having in
few logs, using uniform module name prefix using pr_fmt macro.

3. Code cleanup for various warnings reported by checkpatch for
incomplete unsigned data type, line over 80 characters, return
statements.

Signed-off-by: Parav Pandit <pandit.parav@gmail.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Parav Pandit authored and Doug Ledford committed Oct 6, 2016
1 parent b9fe856 commit e404f94
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 88 deletions.
34 changes: 6 additions & 28 deletions drivers/infiniband/sw/rxe/rxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,38 +358,16 @@ static int __init rxe_module_init(void)
/* initialize slab caches for managed objects */
err = rxe_cache_init();
if (err) {
pr_err("rxe: unable to init object pools\n");
pr_err("unable to init object pools\n");
return err;
}

err = rxe_net_ipv4_init();
if (err) {
pr_err("rxe: unable to init ipv4 tunnel\n");
rxe_cache_exit();
goto exit;
}

err = rxe_net_ipv6_init();
if (err) {
pr_err("rxe: unable to init ipv6 tunnel\n");
rxe_cache_exit();
goto exit;
}

err = register_netdevice_notifier(&rxe_net_notifier);
if (err) {
pr_err("rxe: Failed to rigister netdev notifier\n");
goto exit;
}

pr_info("rxe: loaded\n");
err = rxe_net_init();
if (err)
return err;

pr_info("loaded\n");
return 0;

exit:
rxe_release_udp_tunnel(recv_sockets.sk4);
rxe_release_udp_tunnel(recv_sockets.sk6);
return err;
}

static void __exit rxe_module_exit(void)
Expand All @@ -398,7 +376,7 @@ static void __exit rxe_module_exit(void)
rxe_net_exit();
rxe_cache_exit();

pr_info("rxe: unloaded\n");
pr_info("unloaded\n");
}

late_initcall(rxe_module_init);
Expand Down
5 changes: 5 additions & 0 deletions drivers/infiniband/sw/rxe/rxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#ifndef RXE_H
#define RXE_H

#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/crc32.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ int rxe_av_chk_attr(struct rxe_dev *rxe, struct ib_ah_attr *attr)
struct rxe_port *port;

if (attr->port_num != 1) {
pr_info("rxe: invalid port_num = %d\n", attr->port_num);
pr_info("invalid port_num = %d\n", attr->port_num);
return -EINVAL;
}

port = &rxe->port;

if (attr->ah_flags & IB_AH_GRH) {
if (attr->grh.sgid_index > port->attr.gid_tbl_len) {
pr_info("rxe: invalid sgid index = %d\n",
pr_info("invalid sgid index = %d\n",
attr->grh.sgid_index);
return -EINVAL;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ int rxe_completer(void *arg)
state = COMPST_GET_ACK;

while (1) {
pr_debug("state = %s\n", comp_state_name[state]);
pr_debug("qp#%d state = %s\n", qp_num(qp),
comp_state_name[state]);
switch (state) {
case COMPST_GET_ACK:
skb = skb_dequeue(&qp->resp_pkts);
Expand Down Expand Up @@ -709,7 +710,8 @@ int rxe_completer(void *arg)
qp->comp.rnr_retry--;

qp->req.need_retry = 1;
pr_debug("set rnr nak timer\n");
pr_debug("qp#%d set rnr nak timer\n",
qp_num(qp));
mod_timer(&qp->rnr_nak_timer,
jiffies + rnrnak_jiffies(aeth_syn(pkt)
& ~AETH_TYPE_MASK));
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)

ret = remap_vmalloc_range(vma, ip->obj, 0);
if (ret) {
pr_err("rxe: err %d from remap_vmalloc_range\n", ret);
pr_err("err %d from remap_vmalloc_range\n", ret);
goto done;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
static u8 rxe_get_key(void)
{
static unsigned key = 1;
static u32 key = 1;

key = key << 1;

Expand Down
39 changes: 30 additions & 9 deletions drivers/infiniband/sw/rxe/rxe_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct rxe_dev *net_to_rxe(struct net_device *ndev)
return found;
}

struct rxe_dev *get_rxe_by_name(const char* name)
struct rxe_dev *get_rxe_by_name(const char *name)
{
struct rxe_dev *rxe;
struct rxe_dev *found = NULL;
Expand Down Expand Up @@ -601,8 +601,7 @@ void rxe_port_up(struct rxe_dev *rxe)
port->attr.phys_state = IB_PHYS_STATE_LINK_UP;

rxe_port_event(rxe, IB_EVENT_PORT_ACTIVE);
pr_info("rxe: set %s active\n", rxe->ib_dev.name);
return;
pr_info("set %s active\n", rxe->ib_dev.name);
}

/* Caller must hold net_info_lock */
Expand All @@ -615,8 +614,7 @@ void rxe_port_down(struct rxe_dev *rxe)
port->attr.phys_state = IB_PHYS_STATE_LINK_DOWN;

rxe_port_event(rxe, IB_EVENT_PORT_ERR);
pr_info("rxe: set %s down\n", rxe->ib_dev.name);
return;
pr_info("set %s down\n", rxe->ib_dev.name);
}

static int rxe_notify(struct notifier_block *not_blk,
Expand All @@ -641,7 +639,7 @@ static int rxe_notify(struct notifier_block *not_blk,
rxe_port_down(rxe);
break;
case NETDEV_CHANGEMTU:
pr_info("rxe: %s changed mtu to %d\n", ndev->name, ndev->mtu);
pr_info("%s changed mtu to %d\n", ndev->name, ndev->mtu);
rxe_set_mtu(rxe, ndev->mtu);
break;
case NETDEV_REBOOT:
Expand All @@ -651,7 +649,7 @@ static int rxe_notify(struct notifier_block *not_blk,
case NETDEV_CHANGENAME:
case NETDEV_FEAT_CHANGE:
default:
pr_info("rxe: ignoring netdev event = %ld for %s\n",
pr_info("ignoring netdev event = %ld for %s\n",
event, ndev->name);
break;
}
Expand All @@ -671,7 +669,7 @@ int rxe_net_ipv4_init(void)
htons(ROCE_V2_UDP_DPORT), false);
if (IS_ERR(recv_sockets.sk4)) {
recv_sockets.sk4 = NULL;
pr_err("rxe: Failed to create IPv4 UDP tunnel\n");
pr_err("Failed to create IPv4 UDP tunnel\n");
return -1;
}

Expand All @@ -688,7 +686,7 @@ int rxe_net_ipv6_init(void)
htons(ROCE_V2_UDP_DPORT), true);
if (IS_ERR(recv_sockets.sk6)) {
recv_sockets.sk6 = NULL;
pr_err("rxe: Failed to create IPv6 UDP tunnel\n");
pr_err("Failed to create IPv6 UDP tunnel\n");
return -1;
}
#endif
Expand All @@ -701,3 +699,26 @@ void rxe_net_exit(void)
rxe_release_udp_tunnel(recv_sockets.sk4);
unregister_netdevice_notifier(&rxe_net_notifier);
}

int rxe_net_init(void)
{
int err;

recv_sockets.sk6 = NULL;

err = rxe_net_ipv4_init();
if (err)
return err;
err = rxe_net_ipv6_init();
if (err)
goto err_out;
err = register_netdevice_notifier(&rxe_net_notifier);
if (err) {
pr_err("Failed to register netdev notifier\n");
goto err_out;
}
return 0;
err_out:
rxe_net_exit();
return err;
}
3 changes: 1 addition & 2 deletions drivers/infiniband/sw/rxe/rxe_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void rxe_release_udp_tunnel(struct socket *sk);

struct rxe_dev *rxe_net_add(struct net_device *ndev);

int rxe_net_ipv4_init(void);
int rxe_net_ipv6_init(void);
int rxe_net_init(void);
void rxe_net_exit(void);

#endif /* RXE_NET_H */
31 changes: 17 additions & 14 deletions drivers/infiniband/sw/rxe/rxe_qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,

wqe_size = rcv_wqe_size(qp->rq.max_sge);

pr_debug("max_wr = %d, max_sge = %d, wqe_size = %d\n",
qp->rq.max_wr, qp->rq.max_sge, wqe_size);
pr_debug("qp#%d max_wr = %d, max_sge = %d, wqe_size = %d\n",
qp_num(qp), qp->rq.max_wr, qp->rq.max_sge, wqe_size);

qp->rq.queue = rxe_queue_init(rxe,
&qp->rq.max_wr,
Expand Down Expand Up @@ -680,32 +680,35 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask,
if (mask & IB_QP_RETRY_CNT) {
qp->attr.retry_cnt = attr->retry_cnt;
qp->comp.retry_cnt = attr->retry_cnt;
pr_debug("set retry count = %d\n", attr->retry_cnt);
pr_debug("qp#%d set retry count = %d\n", qp_num(qp),
attr->retry_cnt);
}

if (mask & IB_QP_RNR_RETRY) {
qp->attr.rnr_retry = attr->rnr_retry;
qp->comp.rnr_retry = attr->rnr_retry;
pr_debug("set rnr retry count = %d\n", attr->rnr_retry);
pr_debug("qp#%d set rnr retry count = %d\n", qp_num(qp),
attr->rnr_retry);
}

if (mask & IB_QP_RQ_PSN) {
qp->attr.rq_psn = (attr->rq_psn & BTH_PSN_MASK);
qp->resp.psn = qp->attr.rq_psn;
pr_debug("set resp psn = 0x%x\n", qp->resp.psn);
pr_debug("qp#%d set resp psn = 0x%x\n", qp_num(qp),
qp->resp.psn);
}

if (mask & IB_QP_MIN_RNR_TIMER) {
qp->attr.min_rnr_timer = attr->min_rnr_timer;
pr_debug("set min rnr timer = 0x%x\n",
pr_debug("qp#%d set min rnr timer = 0x%x\n", qp_num(qp),
attr->min_rnr_timer);
}

if (mask & IB_QP_SQ_PSN) {
qp->attr.sq_psn = (attr->sq_psn & BTH_PSN_MASK);
qp->req.psn = qp->attr.sq_psn;
qp->comp.psn = qp->attr.sq_psn;
pr_debug("set req psn = 0x%x\n", qp->req.psn);
pr_debug("qp#%d set req psn = 0x%x\n", qp_num(qp), qp->req.psn);
}

if (mask & IB_QP_PATH_MIG_STATE)
Expand All @@ -719,38 +722,38 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask,

switch (attr->qp_state) {
case IB_QPS_RESET:
pr_debug("qp state -> RESET\n");
pr_debug("qp#%d state -> RESET\n", qp_num(qp));
rxe_qp_reset(qp);
break;

case IB_QPS_INIT:
pr_debug("qp state -> INIT\n");
pr_debug("qp#%d state -> INIT\n", qp_num(qp));
qp->req.state = QP_STATE_INIT;
qp->resp.state = QP_STATE_INIT;
break;

case IB_QPS_RTR:
pr_debug("qp state -> RTR\n");
pr_debug("qp#%d state -> RTR\n", qp_num(qp));
qp->resp.state = QP_STATE_READY;
break;

case IB_QPS_RTS:
pr_debug("qp state -> RTS\n");
pr_debug("qp#%d state -> RTS\n", qp_num(qp));
qp->req.state = QP_STATE_READY;
break;

case IB_QPS_SQD:
pr_debug("qp state -> SQD\n");
pr_debug("qp#%d state -> SQD\n", qp_num(qp));
rxe_qp_drain(qp);
break;

case IB_QPS_SQE:
pr_warn("qp state -> SQE !!?\n");
pr_warn("qp#%d state -> SQE !!?\n", qp_num(qp));
/* Not possible from modify_qp. */
break;

case IB_QPS_ERR:
pr_debug("qp state -> ERR\n");
pr_debug("qp#%d state -> ERR\n", qp_num(qp));
rxe_qp_error(qp);
break;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/infiniband/sw/rxe/rxe_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ int rxe_rcv(struct sk_buff *skb)
pack_icrc = be32_to_cpu(*icrcp);

calc_icrc = rxe_icrc_hdr(pkt, skb);
calc_icrc = crc32_le(calc_icrc, (u8 *)payload_addr(pkt), payload_size(pkt));
calc_icrc = crc32_le(calc_icrc, (u8 *)payload_addr(pkt),
payload_size(pkt));
calc_icrc = cpu_to_be32(~calc_icrc);
if (unlikely(calc_icrc != pack_icrc)) {
char saddr[sizeof(struct in6_addr)];
Expand Down
Loading

0 comments on commit e404f94

Please sign in to comment.