From: Bang Nguyen Date: Wed, 8 Feb 2012 21:31:22 +0000 (-0800) Subject: RDS: cleanup checkpatch errors X-Git-Tag: v4.1.12-92~319^2^2~2^2~27 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d2abe298957f3de2193557cc205daca97f40e54c;p=users%2Fjedix%2Flinux-maple.git RDS: cleanup checkpatch errors Signed-off-by: Bang Nguyen --- diff --git a/include/linux/rds.h b/include/linux/rds.h index 4a649f4a0927d..feb55ed4595d0 100644 --- a/include/linux/rds.h +++ b/include/linux/rds.h @@ -50,7 +50,7 @@ /* * setsockopt/getsockopt for SOL_RDS */ -#define RDS_CANCEL_SENT_TO 1 +#define RDS_CANCEL_SENT_TO 1 #define RDS_GET_MR 2 #define RDS_FREE_MR 3 /* deprecated: RDS_BARRIER 4 */ @@ -126,7 +126,7 @@ struct rds_info_connection { __be32 faddr; u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */ u_int8_t flags; - u_int8_t tos; + u_int8_t tos; } __attribute__((packed)); struct rds_info_flow { @@ -148,7 +148,7 @@ struct rds_info_message { __be16 lport; __be16 fport; u_int8_t flags; - u_int8_t tos; + u_int8_t tos; } __attribute__((packed)); struct rds_info_socket { @@ -185,9 +185,9 @@ struct rds_info_rdma_connection { uint32_t max_send_sge; uint32_t rdma_mr_max; uint32_t rdma_mr_size; - uint8_t tos; - uint8_t sl; - uint32_t cache_allocs; + uint8_t tos; + uint8_t sl; + uint32_t cache_allocs; }; /* @@ -243,7 +243,7 @@ struct rds_get_mr_args { struct rds_get_mr_for_dest_args { struct sockaddr_storage dest_addr; - struct rds_iovec vec; + struct rds_iovec vec; u_int64_t cookie_addr; uint64_t flags; }; @@ -264,8 +264,8 @@ struct rds_rdma_args { struct rds_atomic_args { rds_rdma_cookie_t cookie; - uint64_t local_addr; - uint64_t remote_addr; + uint64_t local_addr; + uint64_t remote_addr; uint64_t swap_add; uint64_t compare; u_int64_t flags; @@ -273,9 +273,9 @@ struct rds_atomic_args { }; struct rds_reset { - u_int8_t tos; - struct in_addr src; - struct in_addr dst; + u_int8_t tos; + struct in_addr src; + struct in_addr dst; }; struct rds_rdma_notify { diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index b13b922fdcf16..c39181a0b4446 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c @@ -200,28 +200,28 @@ static unsigned int rds_poll(struct file *file, struct socket *sock, static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { - struct rds_sock *rs = rds_sk_to_rs(sock->sk); - rds_tos_t tos; - unsigned long flags; - - if (get_user(tos, (rds_tos_t __user *)arg)) - return -EFAULT; - - switch (cmd) { - case RDS_IOC_SET_TOS: - spin_lock_irqsave(&rds_sock_lock, flags); - if (rs->rs_tos || rs->rs_conn) { - spin_unlock_irqrestore(&rds_sock_lock, flags); - return -EINVAL; - } - rs->rs_tos = tos; - spin_unlock_irqrestore(&rds_sock_lock, flags); - break; - default: - return -ENOPROTOOPT; - } - - return 0; + struct rds_sock *rs = rds_sk_to_rs(sock->sk); + rds_tos_t tos; + unsigned long flags; + + if (get_user(tos, (rds_tos_t __user *)arg)) + return -EFAULT; + + switch (cmd) { + case RDS_IOC_SET_TOS: + spin_lock_irqsave(&rds_sock_lock, flags); + if (rs->rs_tos || rs->rs_conn) { + spin_unlock_irqrestore(&rds_sock_lock, flags); + return -EINVAL; + } + rs->rs_tos = tos; + spin_unlock_irqrestore(&rds_sock_lock, flags); + break; + default: + return -ENOPROTOOPT; + } + + return 0; } static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, @@ -284,28 +284,28 @@ static int rds_cong_monitor(struct rds_sock *rs, char __user *optval, static int rds_user_reset(struct rds_sock *rs, char __user *optval, int optlen) { - struct rds_reset reset; - struct rds_connection *conn; + struct rds_reset reset; + struct rds_connection *conn; - if (optlen != sizeof(struct rds_reset)) - return -EINVAL; + if (optlen != sizeof(struct rds_reset)) + return -EINVAL; - if (copy_from_user(&reset, (struct rds_reset __user *)optval, - sizeof(struct rds_reset))) - return -EFAULT; + if (copy_from_user(&reset, (struct rds_reset __user *)optval, + sizeof(struct rds_reset))) + return -EFAULT; - conn = rds_conn_find(reset.src.s_addr, reset.dst.s_addr, - rs->rs_transport, reset.tos); + conn = rds_conn_find(reset.src.s_addr, reset.dst.s_addr, + rs->rs_transport, reset.tos); - if (conn) { - printk(KERN_NOTICE "Resetting RDS/IB connection " - "<%u.%u.%u.%u,%u.%u.%u.%u,%d>\n", - NIPQUAD(reset.src.s_addr), - NIPQUAD(reset.dst.s_addr), conn->c_tos); - rds_conn_drop(conn); - } + if (conn) { + printk(KERN_NOTICE "Resetting RDS/IB connection " + "<%u.%u.%u.%u,%u.%u.%u.%u,%d>\n", + NIPQUAD(reset.src.s_addr), + NIPQUAD(reset.dst.s_addr), conn->c_tos); + rds_conn_drop(conn); + } - return 0; + return 0; } static int rds_setsockopt(struct socket *sock, int level, int optname, @@ -338,9 +338,9 @@ static int rds_setsockopt(struct socket *sock, int level, int optname, case RDS_CONG_MONITOR: ret = rds_cong_monitor(rs, optval, optlen); break; - case RDS_CONN_RESET: - ret = rds_user_reset(rs, optval, optlen); - break; + case RDS_CONN_RESET: + ret = rds_user_reset(rs, optval, optlen); + break; default: ret = -ENOPROTOOPT; } @@ -478,9 +478,8 @@ static int __rds_create(struct socket *sock, struct sock *sk, int protocol) rs->rs_tos = 0; rs->rs_conn = 0; - if (rs->rs_bound_addr) { -printk(KERN_CRIT "bound addr %x at create\n", rs->rs_bound_addr); - } + if (rs->rs_bound_addr) + printk(KERN_CRIT "bound addr %x at create\n", rs->rs_bound_addr); spin_lock_irqsave(&rds_sock_lock, flags); list_add_tail(&rs->rs_item, &rds_sock_list); diff --git a/net/rds/bind.c b/net/rds/bind.c index a9099cc5fcaa0..9f3a9df0dc1b9 100644 --- a/net/rds/bind.c +++ b/net/rds/bind.c @@ -130,14 +130,15 @@ static int rds_add_bound(struct rds_sock *rs, __be32 addr, __be16 *port) struct rds_sock *rrs; if (rover == 0) rover++; - if (!(rrs = rds_bind_lookup(addr, cpu_to_be16(rover), rs))) { + rrs = rds_bind_lookup(addr, cpu_to_be16(rover), rs); + + if (!rrs) { *port = rs->rs_bound_port; ret = 0; rdsdebug("rs %p binding to %pI4:%d\n", rs, &addr, (int)ntohs(*port)); break; - } - else + } else rds_sock_put(rrs); } while (rover++ != last); diff --git a/net/rds/connection.c b/net/rds/connection.c index d99b958aa3dcc..dc535e605ac85 100644 --- a/net/rds/connection.c +++ b/net/rds/connection.c @@ -64,8 +64,8 @@ static struct hlist_head *rds_conn_bucket(__be32 laddr, __be32 faddr) /* rcu read lock must be held or the connection spinlock */ static struct rds_connection *rds_conn_lookup(struct hlist_head *head, __be32 laddr, __be32 faddr, - struct rds_transport *trans, - u8 tos) + struct rds_transport *trans, + u8 tos) { struct rds_connection *conn, *ret = NULL; struct hlist_node *pos; @@ -256,32 +256,32 @@ out: } struct rds_connection *rds_conn_create(__be32 laddr, __be32 faddr, - struct rds_transport *trans, - u8 tos, gfp_t gfp) + struct rds_transport *trans, + u8 tos, gfp_t gfp) { return __rds_conn_create(laddr, faddr, trans, gfp, tos, 0); } EXPORT_SYMBOL_GPL(rds_conn_create); struct rds_connection *rds_conn_create_outgoing(__be32 laddr, __be32 faddr, - struct rds_transport *trans, - u8 tos, gfp_t gfp) + struct rds_transport *trans, + u8 tos, gfp_t gfp) { return __rds_conn_create(laddr, faddr, trans, gfp, tos, 1); } EXPORT_SYMBOL_GPL(rds_conn_create_outgoing); struct rds_connection *rds_conn_find(__be32 laddr, __be32 faddr, - struct rds_transport *trans, u8 tos) + struct rds_transport *trans, u8 tos) { - struct rds_connection *conn; - struct hlist_head *head = rds_conn_bucket(laddr, faddr); + struct rds_connection *conn; + struct hlist_head *head = rds_conn_bucket(laddr, faddr); - rcu_read_lock(); - conn = rds_conn_lookup(head, laddr, faddr, trans, tos); - rcu_read_unlock(); + rcu_read_lock(); + conn = rds_conn_lookup(head, laddr, faddr, trans, tos); + rcu_read_unlock(); - return conn; + return conn; } EXPORT_SYMBOL_GPL(rds_conn_find); diff --git a/net/rds/ib.c b/net/rds/ib.c index 89736d1a0b12b..68ab8d420a3be 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c @@ -101,8 +101,7 @@ static void rds_ib_dev_free(struct work_struct *work) ib_dereg_mr(rds_ibdev->mr); if (rds_ibdev->pd) ib_dealloc_pd(rds_ibdev->pd); - if (rds_ibdev->srq) - kfree(rds_ibdev->srq); + kfree(rds_ibdev->srq); list_for_each_entry_safe(i_ipaddr, i_next, &rds_ibdev->ipaddr_list, list) { list_del(&i_ipaddr->list); @@ -176,9 +175,9 @@ void rds_ib_add_one(struct ib_device *device) goto put_dev; } - rds_ibdev->srq = kmalloc(sizeof(struct rds_ib_srq), GFP_KERNEL); - if (!rds_ibdev->srq) - goto free_attr; + rds_ibdev->srq = kmalloc(sizeof(struct rds_ib_srq), GFP_KERNEL); + if (!rds_ibdev->srq) + goto free_attr; INIT_LIST_HEAD(&rds_ibdev->ipaddr_list); INIT_LIST_HEAD(&rds_ibdev->conn_list); @@ -297,9 +296,9 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn, iinfo->max_recv_wr = ic->i_recv_ring.w_nr; iinfo->max_send_sge = rds_ibdev->max_sge; rds_ib_get_mr_info(rds_ibdev, iinfo); - iinfo->tos = ic->conn->c_tos; - iinfo->sl = ic->i_sl; - iinfo->cache_allocs = atomic_read(&ic->i_cache_allocs); + iinfo->tos = ic->conn->c_tos; + iinfo->sl = ic->i_sl; + iinfo->cache_allocs = atomic_read(&ic->i_cache_allocs); } return 1; } @@ -425,11 +424,11 @@ int rds_ib_init(void) if (ret) goto out_sysctl; - ret = rds_ib_srqs_init(); - if (ret) { - printk(KERN_ERR "rds_ib_srqs_init failed.\n"); - goto out_recv; - } + ret = rds_ib_srqs_init(); + if (ret) { + printk(KERN_ERR "rds_ib_srqs_init failed.\n"); + goto out_recv; + } ret = rds_trans_register(&rds_ib_transport); if (ret) @@ -440,7 +439,7 @@ int rds_ib_init(void) goto out; out_srq: - rds_ib_srqs_exit(); + rds_ib_srqs_exit(); out_recv: rds_ib_recv_exit(); out_sysctl: diff --git a/net/rds/ib.h b/net/rds/ib.h index 234e078407fb5..543c432625781 100644 --- a/net/rds/ib.h +++ b/net/rds/ib.h @@ -12,13 +12,13 @@ #define RDS_FMR_POOL_SIZE 8192 #define RDS_IB_MAX_SGE 8 -#define RDS_IB_RECV_SGE 2 +#define RDS_IB_RECV_SGE 2 #define RDS_IB_DEFAULT_RECV_WR 1024 #define RDS_IB_DEFAULT_SEND_WR 256 #define RDS_IB_DEFAULT_SRQ_MAX_WR 4096 -#define RDS_IB_DEFAULT_SRQ_REFILL_WR RDS_IB_DEFAULT_SRQ_MAX_WR/2 -#define RDS_IB_DEFAULT_SRQ_LOW_WR RDS_IB_DEFAULT_SRQ_MAX_WR/10 +#define RDS_IB_DEFAULT_SRQ_REFILL_WR (RDS_IB_DEFAULT_SRQ_MAX_WR/2) +#define RDS_IB_DEFAULT_SRQ_LOW_WR (RDS_IB_DEFAULT_SRQ_MAX_WR/10) #define RDS_IB_DEFAULT_RETRY_COUNT 1 @@ -71,7 +71,7 @@ struct rds_ib_connect_private { __be32 dp_reserved1; __be64 dp_ack_seq; __be32 dp_credit; /* non-zero enables flow ctl */ - u8 dp_tos; + u8 dp_tos; }; struct rds_ib_send_work { @@ -82,12 +82,12 @@ struct rds_ib_send_work { }; struct rds_ib_recv_work { - struct rds_ib_incoming *r_ibinc; + struct rds_ib_incoming *r_ibinc; struct rds_page_frag *r_frag; struct ib_recv_wr r_wr; struct ib_sge r_sge[2]; - struct rds_ib_connection *r_ic; - int r_posted; + struct rds_ib_connection *r_ic; + int r_posted; }; struct rds_ib_work_ring { @@ -183,11 +183,11 @@ struct rds_ib_connection { /* Batched completions */ unsigned int i_unsignaled_wrs; - u8 i_sl; + u8 i_sl; - atomic_t i_cache_allocs; + atomic_t i_cache_allocs; - struct completion i_last_wqe_complete; + struct completion i_last_wqe_complete; }; /* This assumes that atomic_t is at least 32 bits */ @@ -203,17 +203,17 @@ struct rds_ib_ipaddr { }; struct rds_ib_srq { - struct rds_ib_device *rds_ibdev; - struct ib_srq *s_srq; - struct ib_event_handler s_event_handler; - struct rds_ib_recv_work *s_recvs; - u32 s_n_wr; - struct rds_header *s_recv_hdrs; - u64 s_recv_hdrs_dma; - atomic_t s_num_posted; - unsigned long s_refill_gate; - struct delayed_work s_refill_w; - struct delayed_work s_rearm_w; + struct rds_ib_device *rds_ibdev; + struct ib_srq *s_srq; + struct ib_event_handler s_event_handler; + struct rds_ib_recv_work *s_recvs; + u32 s_n_wr; + struct rds_header *s_recv_hdrs; + u64 s_recv_hdrs_dma; + atomic_t s_num_posted; + unsigned long s_refill_gate; + struct delayed_work s_refill_w; + struct delayed_work s_rearm_w; }; struct rds_ib_device { @@ -233,7 +233,7 @@ struct rds_ib_device { spinlock_t spinlock; /* protect the above */ atomic_t refcount; struct work_struct free_work; - struct rds_ib_srq *srq; + struct rds_ib_srq *srq; }; #define pcidev_to_node(pcidev) pcibus_to_node(pcidev->bus) @@ -263,9 +263,9 @@ struct rds_ib_statistics { uint64_t s_ib_rx_ring_empty; uint64_t s_ib_rx_refill_from_cq; uint64_t s_ib_rx_refill_from_thread; - uint64_t s_ib_rx_alloc_limit; - uint64_t s_ib_rx_total_frags; - uint64_t s_ib_rx_total_incs; + uint64_t s_ib_rx_alloc_limit; + uint64_t s_ib_rx_total_frags; + uint64_t s_ib_rx_total_incs; uint64_t s_ib_rx_credit_updates; uint64_t s_ib_ack_sent; uint64_t s_ib_ack_send_failure; @@ -280,9 +280,9 @@ struct rds_ib_statistics { uint64_t s_ib_rdma_mr_pool_depleted; uint64_t s_ib_atomic_cswp; uint64_t s_ib_atomic_fadd; - uint64_t s_ib_srq_lows; - uint64_t s_ib_srq_refills; - uint64_t s_ib_srq_empty_refills; + uint64_t s_ib_srq_lows; + uint64_t s_ib_srq_refills; + uint64_t s_ib_srq_empty_refills; }; extern struct workqueue_struct *rds_ib_wq; diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c index a936a5940891c..0ece35d042b19 100644 --- a/net/rds/ib_cm.c +++ b/net/rds/ib_cm.c @@ -38,7 +38,7 @@ #include "ib.h" static char *rds_ib_event_type_strings[] = { -#define RDS_IB_EVENT_STRING(foo) [IB_EVENT_##foo] = __stringify(foo) +#define RDS_IB_EVENT_STRING(foo)[IB_EVENT_##foo] = __stringify(foo) RDS_IB_EVENT_STRING(CQ_ERR), RDS_IB_EVENT_STRING(QP_FATAL), RDS_IB_EVENT_STRING(QP_REQ_ERR), @@ -141,44 +141,44 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even } } - if (conn->c_version < RDS_PROTOCOL(3,2)) { - if (conn->c_version == RDS_PROTOCOL(3,1)) { - if (conn->c_tos) { - printk(KERN_NOTICE "RDS: Connection to" - " %u.%u.%u.%u version %u.%u Tos %d" - " failed, not supporting QoS\n", - NIPQUAD(conn->c_faddr), - RDS_PROTOCOL_MAJOR(conn->c_version), - RDS_PROTOCOL_MINOR(conn->c_version), - conn->c_tos); - rds_conn_drop(conn); - return; - } - } else { - /* - * BUG: destroying connection here can deadlock with - * the CM event handler on the c_cm_lock. - */ - printk(KERN_NOTICE "RDS/IB: Connection to" - " %u.%u.%u.%u version %u.%u failed," - " no longer supported\n", - NIPQUAD(conn->c_faddr), - RDS_PROTOCOL_MAJOR(conn->c_version), - RDS_PROTOCOL_MINOR(conn->c_version)); - rds_conn_destroy(conn); - return; - } - } - - printk(KERN_NOTICE - "RDS/IB: connected to %u.%u.%u.%u version %u.%u%s Tos %d\n", - NIPQUAD(conn->c_faddr), - RDS_PROTOCOL_MAJOR(conn->c_version), - RDS_PROTOCOL_MINOR(conn->c_version), - ic->i_flowctl ? ", flow control" : "", - conn->c_tos); - - ic->i_sl = ic->i_cm_id->route.path_rec->sl; + if (conn->c_version < RDS_PROTOCOL(3, 2)) { + if (conn->c_version == RDS_PROTOCOL(3, 1)) { + if (conn->c_tos) { + printk(KERN_NOTICE "RDS: Connection to" + " %u.%u.%u.%u version %u.%u Tos %d" + " failed, not supporting QoS\n", + NIPQUAD(conn->c_faddr), + RDS_PROTOCOL_MAJOR(conn->c_version), + RDS_PROTOCOL_MINOR(conn->c_version), + conn->c_tos); + rds_conn_drop(conn); + return; + } + } else { + /* + * BUG: destroying connection here can deadlock with + * the CM event handler on the c_cm_lock. + */ + printk(KERN_NOTICE "RDS/IB: Connection to" + " %u.%u.%u.%u version %u.%u failed," + " no longer supported\n", + NIPQUAD(conn->c_faddr), + RDS_PROTOCOL_MAJOR(conn->c_version), + RDS_PROTOCOL_MINOR(conn->c_version)); + rds_conn_destroy(conn); + return; + } + } + + printk(KERN_NOTICE + "RDS/IB: connected to %u.%u.%u.%u version %u.%u%s Tos %d\n", + NIPQUAD(conn->c_faddr), + RDS_PROTOCOL_MAJOR(conn->c_version), + RDS_PROTOCOL_MINOR(conn->c_version), + ic->i_flowctl ? ", flow control" : "", + conn->c_tos); + + ic->i_sl = ic->i_cm_id->route.path_rec->sl; /* * Init rings and fill recv. this needs to wait until protocol negotiation @@ -186,14 +186,13 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even */ rds_ib_send_init_ring(ic); - if (!ic->conn->c_tos) - rds_ib_recv_init_ring(ic); + if (!ic->conn->c_tos) + rds_ib_recv_init_ring(ic); /* Post receive buffers - as a side effect, this will update * the posted credit count. */ - if (!ic->conn->c_tos) { - rds_ib_recv_refill(conn, 1, GFP_KERNEL); - } + if (!ic->conn->c_tos) + rds_ib_recv_refill(conn, 1, GFP_KERNEL); /* Tune RNR behavior */ rds_ib_tune_rnr(ic, &qp_attr); @@ -358,13 +357,11 @@ void rds_ib_tasklet_fn_recv(unsigned long data) if (rds_conn_up(conn)) rds_ib_attempt_ack(ic); - if (conn->c_tos) { - if ((atomic_read(&rds_ibdev->srq->s_num_posted) < - rds_ib_srq_refill_wr) && - !test_and_set_bit(0, &rds_ibdev->srq->s_refill_gate)) - queue_delayed_work(rds_wq, &rds_ibdev->srq->s_refill_w,0); - - } + if (conn->c_tos) + if ((atomic_read(&rds_ibdev->srq->s_num_posted) < + rds_ib_srq_refill_wr) && + !test_and_set_bit(0, &rds_ibdev->srq->s_refill_gate)) + queue_delayed_work(rds_wq, &rds_ibdev->srq->s_refill_w, 0); } static void rds_ib_qp_event_handler(struct ib_event *event, void *data) @@ -379,9 +376,9 @@ static void rds_ib_qp_event_handler(struct ib_event *event, void *data) case IB_EVENT_COMM_EST: rdma_notify(ic->i_cm_id, IB_EVENT_COMM_EST); break; - case IB_EVENT_QP_LAST_WQE_REACHED: - complete(&ic->i_last_wqe_complete); - break; + case IB_EVENT_QP_LAST_WQE_REACHED: + complete(&ic->i_last_wqe_complete); + break; default: rdsdebug("Fatal QP Event %u (%s) " "- connection %pI4->%pI4, reconnecting\n", @@ -435,16 +432,16 @@ static int rds_ib_setup_qp(struct rds_connection *conn) goto out; } - if (ic->conn->c_tos) - ic->i_rcq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv, - rds_ib_cq_event_handler, conn, - rds_ib_srq_max_wr - 1, - IB_CQ_VECTOR_LEAST_ATTACHED); - else - ic->i_rcq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv, - rds_ib_cq_event_handler, conn, - ic->i_recv_ring.w_nr, - IB_CQ_VECTOR_LEAST_ATTACHED); + if (ic->conn->c_tos) + ic->i_rcq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv, + rds_ib_cq_event_handler, conn, + rds_ib_srq_max_wr - 1, + IB_CQ_VECTOR_LEAST_ATTACHED); + else + ic->i_rcq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv, + rds_ib_cq_event_handler, conn, + rds_ib_srq_max_wr - 1, + IB_CQ_VECTOR_LEAST_ATTACHED); if (IS_ERR(ic->i_rcq)) { ret = PTR_ERR(ic->i_rcq); ic->i_rcq = NULL; @@ -478,10 +475,10 @@ static int rds_ib_setup_qp(struct rds_connection *conn) attr.send_cq = ic->i_scq; attr.recv_cq = ic->i_rcq; - if (ic->conn->c_tos) { - attr.cap.max_recv_wr = 0; - attr.srq = rds_ibdev->srq->s_srq; - } + if (ic->conn->c_tos) { + attr.cap.max_recv_wr = 0; + attr.srq = rds_ibdev->srq->s_srq; + } /* * XXX this can fail if max_*_wr is too large? Are we supposed @@ -503,17 +500,17 @@ static int rds_ib_setup_qp(struct rds_connection *conn) goto out; } - if (!ic->conn->c_tos) { - ic->i_recv_hdrs = ib_dma_alloc_coherent(dev, - ic->i_recv_ring.w_nr * - sizeof(struct rds_header), - &ic->i_recv_hdrs_dma, GFP_KERNEL); - if (!ic->i_recv_hdrs) { - ret = -ENOMEM; - rdsdebug("ib_dma_alloc_coherent recv failed\n"); - goto out; - } - } + if (!ic->conn->c_tos) { + ic->i_recv_hdrs = ib_dma_alloc_coherent(dev, + ic->i_recv_ring.w_nr * + sizeof(struct rds_header), + &ic->i_recv_hdrs_dma, GFP_KERNEL); + if (!ic->i_recv_hdrs) { + ret = -ENOMEM; + rdsdebug("ib_dma_alloc_coherent recv failed\n"); + goto out; + } + } ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header), &ic->i_ack_dma, GFP_KERNEL); @@ -532,16 +529,16 @@ static int rds_ib_setup_qp(struct rds_connection *conn) } memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work)); - if (!ic->conn->c_tos) { - ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * - sizeof(struct rds_ib_recv_work)); - if (!ic->i_recvs) { - ret = -ENOMEM; - rdsdebug("recv allocation failed\n"); - goto out; - } - memset(ic->i_recvs, 0, ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work)); - } + if (!ic->conn->c_tos) { + ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * + sizeof(struct rds_ib_recv_work)); + if (!ic->i_recvs) { + ret = -ENOMEM; + rdsdebug("recv allocation failed\n"); + goto out; + } + memset(ic->i_recvs, 0, ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work)); + } rds_ib_recv_init_ack(ic); @@ -577,7 +574,7 @@ static u32 rds_ib_protocol_compatible(struct rdma_cm_event *event) } /* Even if len is crap *now* I still want to check it. -ASG */ - if (event->param.conn.private_data_len < sizeof (*dp) + if (event->param.conn.private_data_len < sizeof(*dp) || dp->dp_protocol_major == 0) return RDS_PROTOCOL_3_0; @@ -660,8 +657,8 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id, if (now > conn->c_connection_start && now - conn->c_connection_start > 15) { printk(KERN_CRIT "rds connection racing for 15s, forcing reset " - "connection %u.%u.%u.%u->%u.%u.%u.%u\n", - NIPQUAD(conn->c_laddr), NIPQUAD(conn->c_faddr)); + "connection %u.%u.%u.%u->%u.%u.%u.%u\n", + NIPQUAD(conn->c_laddr), NIPQUAD(conn->c_faddr)); rds_conn_drop(conn); rds_ib_stats_inc(s_ib_listen_closed_stale); } else { @@ -823,13 +820,13 @@ void rds_ib_conn_shutdown(struct rds_connection *conn) */ rdsdebug("failed to disconnect, cm: %p err %d\n", ic->i_cm_id, err); - } else if (ic->conn->c_tos && ic->rds_ibdev) { - /* - * wait for the last wqe to complete, then schedule - * the recv tasklet to drain the RX CQ. - */ - wait_for_completion(&ic->i_last_wqe_complete); - tasklet_schedule(&ic->i_rtasklet); + } else if (ic->conn->c_tos && ic->rds_ibdev) { + /* + wait for the last wqe to complete, then schedule + the recv tasklet to drain the RX CQ. + */ + wait_for_completion(&ic->i_last_wqe_complete); + tasklet_schedule(&ic->i_rtasklet); } /* quiesce tx and rx completion before tearing down */ @@ -922,11 +919,11 @@ void rds_ib_conn_shutdown(struct rds_connection *conn) vfree(ic->i_sends); ic->i_sends = NULL; - if (!ic->conn->c_tos) - vfree(ic->i_recvs); + if (!ic->conn->c_tos) + vfree(ic->i_recvs); ic->i_recvs = NULL; - + INIT_COMPLETION(ic->i_last_wqe_complete); } @@ -965,7 +962,7 @@ int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp) ic->conn = conn; conn->c_transport_data = ic; - + init_completion(&ic->i_last_wqe_complete); spin_lock_irqsave(&ib_nodev_conns_lock, flags); @@ -992,6 +989,7 @@ void rds_ib_conn_free(void *arg) * A race with shutdown() or connect() would cause problems * (since rds_ibdev would change) but that should never happen. */ + lock_ptr = ic->rds_ibdev ? &ic->rds_ibdev->spinlock : &ib_nodev_conns_lock; spin_lock_irq(lock_ptr); diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c index 504fcb5011237..a62622c1b7d01 100644 --- a/net/rds/ib_rdma.c +++ b/net/rds/ib_rdma.c @@ -587,7 +587,7 @@ static void list_append_to_xlist(struct rds_ib_mr_pool *pool, * to free as many MRs as needed to get back to this limit. */ static int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool, - int free_all, struct rds_ib_mr **ibmr_ret) + int free_all, struct rds_ib_mr **ibmr_ret) { struct rds_ib_mr *ibmr, *next; struct xlist_head clean_xlist; @@ -602,7 +602,7 @@ static int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool, if (ibmr_ret) { DEFINE_WAIT(wait); - while(!mutex_trylock(&pool->flush_lock)) { + while (!mutex_trylock(&pool->flush_lock)) { ibmr = rds_ib_reuse_fmr(pool); if (ibmr) { *ibmr_ret = ibmr; diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index eb6c64623207c..56821fa573032 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -115,7 +115,7 @@ static int rds_ib_recv_alloc_cache(struct rds_ib_refill_cache *cache) cache->percpu = alloc_percpu(struct rds_ib_cache_head); if (!cache->percpu) - return -ENOMEM; + return -ENOMEM; for_each_possible_cpu(cpu) { head = per_cpu_ptr(cache->percpu, cpu); @@ -261,9 +261,8 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct rds_ib_connection *i ibinc = container_of(cache_item, struct rds_ib_incoming, ii_cache_entry); } else { ibinc = kmem_cache_alloc(rds_ib_incoming_slab, slab_mask); - if (!ibinc) { + if (!ibinc) return NULL; - } rds_ib_stats_inc(s_ib_rx_total_incs); } INIT_LIST_HEAD(&ibinc->ii_frags); @@ -272,7 +271,7 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct rds_ib_connection *i return ibinc; } -static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic, +static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic, gfp_t slab_mask, gfp_t page_mask) { struct rds_page_frag *frag; @@ -294,12 +293,12 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic if (!avail_allocs) { if (test_and_clear_bit(0, &rds_ib_allocation_warn)) { - printk(KERN_NOTICE "RDS/IB: WARNING - " - "recv memory exceeded max_recv_allocation %d\n", - atomic_read(&rds_ib_allocation)); - } - rds_ib_stats_inc(s_ib_rx_alloc_limit); - return NULL; + printk(KERN_NOTICE "RDS/IB: WARNING - " + "recv memory exceeded max_recv_allocation %d\n", + atomic_read(&rds_ib_allocation)); + } + rds_ib_stats_inc(s_ib_rx_alloc_limit); + return NULL; } sg_init_table(&frag->f_sg, 1); @@ -370,134 +369,135 @@ out: } static void rds_ib_srq_clear_one(struct rds_ib_srq *srq, - struct rds_ib_connection *ic, - struct rds_ib_recv_work *recv) + struct rds_ib_connection *ic, + struct rds_ib_recv_work *recv) { - if (recv->r_ibinc) { - rds_inc_put(&recv->r_ibinc->ii_inc); - recv->r_ibinc = NULL; - } - if (recv->r_frag) { - ib_dma_unmap_sg(srq->rds_ibdev->dev, &recv->r_frag->f_sg, - 1, DMA_FROM_DEVICE); - rds_ib_frag_free(ic, recv->r_frag); - recv->r_frag = NULL; - recv->r_ic = ic; - recv->r_posted = 0; - } + if (recv->r_ibinc) { + rds_inc_put(&recv->r_ibinc->ii_inc); + recv->r_ibinc = NULL; + } + if (recv->r_frag) { + ib_dma_unmap_sg(srq->rds_ibdev->dev, &recv->r_frag->f_sg, + 1, DMA_FROM_DEVICE); + rds_ib_frag_free(ic, recv->r_frag); + recv->r_frag = NULL; + recv->r_ic = ic; + recv->r_posted = 0; + } } static int rds_ib_srq_refill_one(struct rds_ib_srq *srq, - struct rds_ib_connection *ic, - struct rds_ib_recv_work *recv, gfp_t gfp) + struct rds_ib_connection *ic, + struct rds_ib_recv_work *recv, gfp_t gfp) { - struct ib_sge *sge; - int ret = -ENOMEM; - gfp_t slab_mask = GFP_NOWAIT; - gfp_t page_mask = GFP_NOWAIT; - - if (gfp & __GFP_WAIT) { - slab_mask = GFP_KERNEL; - page_mask = GFP_HIGHUSER; - } - - if (!ic->i_cache_incs.ready) - rds_ib_cache_xfer_to_ready(&ic->i_cache_incs); - if (!ic->i_cache_frags.ready) - rds_ib_cache_xfer_to_ready(&ic->i_cache_frags); - - /* - * ibinc was taken from recv if recv contained the start of a message. - * recvs that were continuations will still have this allocated. - */ - if (!recv->r_ibinc) { - recv->r_ibinc = rds_ib_refill_one_inc(ic, slab_mask); - if (!recv->r_ibinc) - goto out; - } - - WARN_ON_ONCE(recv->r_frag); /* leak! */ - recv->r_frag = rds_ib_refill_one_frag(ic, slab_mask, page_mask); - if (!recv->r_frag) - goto out; - - ret = ib_dma_map_sg(srq->rds_ibdev->dev, &recv->r_frag->f_sg, - 1, DMA_FROM_DEVICE); - - WARN_ON(ret != 1); - - sge = &recv->r_sge[0]; - - sge->addr = srq->s_recv_hdrs_dma + - (recv - srq->s_recvs) * - sizeof(struct rds_header); - - sge->length = sizeof(struct rds_header); - - sge = &recv->r_sge[1]; - sge->addr = sg_dma_address(&recv->r_frag->f_sg); - sge->length = sg_dma_len(&recv->r_frag->f_sg); - - ret = 0; + struct ib_sge *sge; + int ret = -ENOMEM; + gfp_t slab_mask = GFP_NOWAIT; + gfp_t page_mask = GFP_NOWAIT; + + if (gfp & __GFP_WAIT) { + slab_mask = GFP_KERNEL; + page_mask = GFP_HIGHUSER; + } + + if (!ic->i_cache_incs.ready) + rds_ib_cache_xfer_to_ready(&ic->i_cache_incs); + if (!ic->i_cache_frags.ready) + rds_ib_cache_xfer_to_ready(&ic->i_cache_frags); + + /* + * ibinc was taken from recv if recv contained the start of a message. + * recvs that were continuations will still have this allocated. + */ + + if (!recv->r_ibinc) { + recv->r_ibinc = rds_ib_refill_one_inc(ic, slab_mask); + if (!recv->r_ibinc) + goto out; + } + + WARN_ON_ONCE(recv->r_frag); /* leak! */ + recv->r_frag = rds_ib_refill_one_frag(ic, slab_mask, page_mask); + if (!recv->r_frag) + goto out; + + ret = ib_dma_map_sg(srq->rds_ibdev->dev, &recv->r_frag->f_sg, + 1, DMA_FROM_DEVICE); + + WARN_ON(ret != 1); + + sge = &recv->r_sge[0]; + + sge->addr = srq->s_recv_hdrs_dma + + (recv - srq->s_recvs) * + sizeof(struct rds_header); + + sge->length = sizeof(struct rds_header); + + sge = &recv->r_sge[1]; + sge->addr = sg_dma_address(&recv->r_frag->f_sg); + sge->length = sg_dma_len(&recv->r_frag->f_sg); + + ret = 0; out: - return ret; + return ret; } static int rds_ib_srq_prefill_one(struct rds_ib_device *rds_ibdev, - struct rds_ib_recv_work *recv, int prefill) + struct rds_ib_recv_work *recv, int prefill) { - struct ib_sge *sge; - int ret = -ENOMEM; - gfp_t slab_mask = GFP_NOWAIT; - gfp_t page_mask = GFP_NOWAIT; - - if (prefill) { - slab_mask = GFP_KERNEL; - page_mask = GFP_HIGHUSER; - } - - if (!recv->r_ibinc) { - recv->r_ibinc = kmem_cache_alloc(rds_ib_incoming_slab, slab_mask); - if (!recv->r_ibinc) - goto out; - rds_ib_stats_inc(s_ib_rx_total_incs); - INIT_LIST_HEAD(&recv->r_ibinc->ii_frags); - } - - WARN_ON_ONCE(recv->r_frag); /* leak! */ - recv->r_frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask); - if (!recv->r_frag) - goto out; - sg_init_table(&recv->r_frag->f_sg, 1); - ret = rds_page_remainder_alloc(&recv->r_frag->f_sg, - RDS_FRAG_SIZE, page_mask); - if (ret) { - kmem_cache_free(rds_ib_frag_slab, recv->r_frag); - goto out; - } - rds_ib_stats_inc(s_ib_rx_total_frags); - INIT_LIST_HEAD(&recv->r_frag->f_item); - - ret = ib_dma_map_sg(rds_ibdev->dev, &recv->r_frag->f_sg, - 1, DMA_FROM_DEVICE); - WARN_ON(ret != 1); - - sge = &recv->r_sge[0]; - sge->addr = rds_ibdev->srq->s_recv_hdrs_dma + - (recv - rds_ibdev->srq->s_recvs) * - sizeof(struct rds_header); - sge->length = sizeof(struct rds_header); - sge->lkey = rds_ibdev->mr->lkey; - - sge = &recv->r_sge[1]; - sge->addr = sg_dma_address(&recv->r_frag->f_sg); - sge->length = sg_dma_len(&recv->r_frag->f_sg); - sge->lkey = rds_ibdev->mr->lkey; - - ret = 0; + struct ib_sge *sge; + int ret = -ENOMEM; + gfp_t slab_mask = GFP_NOWAIT; + gfp_t page_mask = GFP_NOWAIT; + + if (prefill) { + slab_mask = GFP_KERNEL; + page_mask = GFP_HIGHUSER; + } + if (!recv->r_ibinc) { + recv->r_ibinc = kmem_cache_alloc(rds_ib_incoming_slab, slab_mask); + if (!recv->r_ibinc) + goto out; + rds_ib_stats_inc(s_ib_rx_total_incs); + INIT_LIST_HEAD(&recv->r_ibinc->ii_frags); + } + + WARN_ON_ONCE(recv->r_frag); /* leak! */ + recv->r_frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask); + if (!recv->r_frag) + goto out; + sg_init_table(&recv->r_frag->f_sg, 1); + ret = rds_page_remainder_alloc(&recv->r_frag->f_sg, + RDS_FRAG_SIZE, page_mask); + if (ret) { + kmem_cache_free(rds_ib_frag_slab, recv->r_frag); + goto out; + } + + rds_ib_stats_inc(s_ib_rx_total_frags); + INIT_LIST_HEAD(&recv->r_frag->f_item); + + ret = ib_dma_map_sg(rds_ibdev->dev, &recv->r_frag->f_sg, + 1, DMA_FROM_DEVICE); + WARN_ON(ret != 1); + + sge = &recv->r_sge[0]; + sge->addr = rds_ibdev->srq->s_recv_hdrs_dma + + (recv - rds_ibdev->srq->s_recvs) * + sizeof(struct rds_header); + sge->length = sizeof(struct rds_header); + sge->lkey = rds_ibdev->mr->lkey; + + sge = &recv->r_sge[1]; + sge->addr = sg_dma_address(&recv->r_frag->f_sg); + sge->length = sg_dma_len(&recv->r_frag->f_sg); + sge->lkey = rds_ibdev->mr->lkey; + + ret = 0; out: - return ret; + return ret; } @@ -537,7 +537,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp) unsigned int posted = 0; int ret = 0; int can_wait = gfp & __GFP_WAIT; - int must_wake = 0; + int must_wake = 0; int ring_low = 0; int ring_empty = 0; u32 pos; @@ -576,9 +576,8 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp) recv = &ic->i_recvs[pos]; ret = rds_ib_recv_refill_one(conn, recv, gfp); - if (ret) { + if (ret) break; - } /* XXX when can this fail? */ ret = ib_post_recv(ic->i_cm_id->qp, &recv->r_wr, &failed_wr); @@ -1156,96 +1155,97 @@ static void rds_ib_process_recv(struct rds_connection *conn, } void rds_ib_srq_process_recv(struct rds_connection *conn, - struct rds_ib_recv_work *recv, u32 data_len, - struct rds_ib_ack_state *state) + struct rds_ib_recv_work *recv, u32 data_len, + struct rds_ib_ack_state *state) { - struct rds_ib_connection *ic = conn->c_transport_data; - struct rds_ib_incoming *ibinc = ic->i_ibinc; - struct rds_header *ihdr, *hdr; - - if (data_len < sizeof(struct rds_header)) { - printk(KERN_WARNING "RDS: from %pI4 didn't inclue a " - "header, disconnecting and " - "reconnecting\n", - &conn->c_faddr); - rds_ib_frag_free(ic, recv->r_frag); - recv->r_frag = NULL; - return; - } - data_len -= sizeof(struct rds_header); - - ihdr = &ic->rds_ibdev->srq->s_recv_hdrs[recv->r_wr.wr_id]; - - /* Validate the checksum. */ - if (!rds_message_verify_checksum(ihdr)) { - printk(KERN_WARNING "RDS: from %pI4 has corrupted header - " - "forcing a reconnect\n", - &conn->c_faddr); - rds_stats_inc(s_recv_drop_bad_checksum); - rds_ib_frag_free(ic, recv->r_frag); - recv->r_frag = NULL; - return; - } - - /* Process the ACK sequence which comes with every packet */ - state->ack_recv = be64_to_cpu(ihdr->h_ack); - state->ack_recv_valid = 1; - - if (ihdr->h_sport == 0 && ihdr->h_dport == 0 && data_len == 0) { - rds_ib_stats_inc(s_ib_ack_received); - rds_ib_frag_free(ic, recv->r_frag); - recv->r_frag = NULL; - return; - } - - if (!ibinc) { - ibinc = recv->r_ibinc; - rds_inc_init(&ibinc->ii_inc, ic->conn, ic->conn->c_faddr); - recv->r_ibinc = NULL; - ic->i_ibinc = ibinc; - hdr = &ibinc->ii_inc.i_hdr; - memcpy(hdr, ihdr, sizeof(*hdr)); - ic->i_recv_data_rem = be32_to_cpu(hdr->h_len); - } else { - hdr = &ibinc->ii_inc.i_hdr; - if (hdr->h_sequence != ihdr->h_sequence - || hdr->h_len != ihdr->h_len - || hdr->h_sport != ihdr->h_sport - || hdr->h_dport != ihdr->h_dport) { - printk(KERN_WARNING "RDS: fragment header mismatch; " - "forcing reconnect\n"); - rds_ib_frag_free(ic, recv->r_frag); - recv->r_frag = NULL; - return; - } - } - - list_add_tail(&recv->r_frag->f_item, &ibinc->ii_frags); - - recv->r_frag = NULL; - - if (ic->i_recv_data_rem > RDS_FRAG_SIZE) - ic->i_recv_data_rem -= RDS_FRAG_SIZE; - else { - ic->i_recv_data_rem = 0; - ic->i_ibinc = NULL; - - if (ibinc->ii_inc.i_hdr.h_flags == RDS_FLAG_CONG_BITMAP) - rds_ib_cong_recv(conn, ibinc); - else { - rds_recv_incoming(conn, conn->c_faddr, conn->c_laddr, - &ibinc->ii_inc, GFP_ATOMIC, - KM_SOFTIRQ0); - - state->ack_next = be64_to_cpu(hdr->h_sequence); - state->ack_next_valid = 1; - } - if (hdr->h_flags & RDS_FLAG_ACK_REQUIRED) { - rds_stats_inc(s_recv_ack_required); - state->ack_required = 1; - } - rds_inc_put(&ibinc->ii_inc); - } + struct rds_ib_connection *ic = conn->c_transport_data; + struct rds_ib_incoming *ibinc = ic->i_ibinc; + struct rds_header *ihdr, *hdr; + + if (data_len < sizeof(struct rds_header)) { + printk(KERN_WARNING "RDS: from %pI4 didn't inclue a " + "header, disconnecting and " + "reconnecting\n", + &conn->c_faddr); + rds_ib_frag_free(ic, recv->r_frag); + recv->r_frag = NULL; + return; + } + data_len -= sizeof(struct rds_header); + + ihdr = &ic->rds_ibdev->srq->s_recv_hdrs[recv->r_wr.wr_id]; + + /* Validate the checksum. */ + if (!rds_message_verify_checksum(ihdr)) { + printk(KERN_WARNING "RDS: from %pI4 has corrupted header - " + "forcing a reconnect\n", + &conn->c_faddr); + rds_stats_inc(s_recv_drop_bad_checksum); + rds_ib_frag_free(ic, recv->r_frag); + recv->r_frag = NULL; + return; + } + + /* Process the ACK sequence which comes with every packet */ + state->ack_recv = be64_to_cpu(ihdr->h_ack); + state->ack_recv = be64_to_cpu(ihdr->h_ack); + state->ack_recv_valid = 1; + + if (ihdr->h_sport == 0 && ihdr->h_dport == 0 && data_len == 0) { + rds_ib_stats_inc(s_ib_ack_received); + rds_ib_frag_free(ic, recv->r_frag); + recv->r_frag = NULL; + return; + } + + if (!ibinc) { + ibinc = recv->r_ibinc; + rds_inc_init(&ibinc->ii_inc, ic->conn, ic->conn->c_faddr); + recv->r_ibinc = NULL; + ic->i_ibinc = ibinc; + hdr = &ibinc->ii_inc.i_hdr; + memcpy(hdr, ihdr, sizeof(*hdr)); + ic->i_recv_data_rem = be32_to_cpu(hdr->h_len); + } else { + hdr = &ibinc->ii_inc.i_hdr; + if (hdr->h_sequence != ihdr->h_sequence + || hdr->h_len != ihdr->h_len + || hdr->h_sport != ihdr->h_sport + || hdr->h_dport != ihdr->h_dport) { + printk(KERN_WARNING "RDS: fragment header mismatch; " + "forcing reconnect\n"); + rds_ib_frag_free(ic, recv->r_frag); + recv->r_frag = NULL; + return; + } + } + + list_add_tail(&recv->r_frag->f_item, &ibinc->ii_frags); + + recv->r_frag = NULL; + + if (ic->i_recv_data_rem > RDS_FRAG_SIZE) + ic->i_recv_data_rem -= RDS_FRAG_SIZE; + else { + ic->i_recv_data_rem = 0; + ic->i_ibinc = NULL; + + if (ibinc->ii_inc.i_hdr.h_flags == RDS_FLAG_CONG_BITMAP) + rds_ib_cong_recv(conn, ibinc); + else { + rds_recv_incoming(conn, conn->c_faddr, conn->c_laddr, + &ibinc->ii_inc, GFP_ATOMIC, + KM_SOFTIRQ0); + + state->ack_next = be64_to_cpu(hdr->h_sequence); + state->ack_next_valid = 1; + } + if (hdr->h_flags & RDS_FLAG_ACK_REQUIRED) { + rds_stats_inc(s_recv_ack_required); + state->ack_required = 1; + } + rds_inc_put(&ibinc->ii_inc); + } } void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, @@ -1261,10 +1261,10 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, be32_to_cpu(wc->ex.imm_data)); rds_ib_stats_inc(s_ib_rx_cq_event); - + if (conn->c_tos) { recv = &rds_ibdev->srq->s_recvs[wc->wr_id]; - atomic_dec(&rds_ibdev->srq->s_num_posted); + atomic_dec(&rds_ibdev->srq->s_num_posted); } else recv = &ic->i_recvs[rds_ib_ring_oldest(&ic->i_recv_ring)]; @@ -1308,117 +1308,116 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, void rds_ib_srq_refill(struct work_struct *work) { - struct rds_ib_srq *srq = container_of(work, struct rds_ib_srq, s_refill_w.work); - struct rds_ib_recv_work *prv=NULL, *cur=NULL, *tmp; - struct ib_recv_wr *bad_wr; - int i,refills=0,total_refills=0; - - if (!test_bit(0,&srq->s_refill_gate)) - return; - - rds_ib_stats_inc(s_ib_srq_refills); - - for (i=0; is_n_wr; i++) { - tmp = &srq->s_recvs[i]; - if (tmp->r_posted) - continue; - - if (rds_ib_srq_refill_one(srq, tmp->r_ic, tmp, GFP_NOWAIT)) { - printk(KERN_ERR "rds_ib_srq_refill_one failed\n"); - break; - } - cur = tmp; - - if (!prv) { - prv = cur; - prv->r_wr.next = NULL; - } else { - cur->r_wr.next = &prv->r_wr; - prv = cur; - } - cur->r_posted = 1; - - total_refills++; - if (++refills == RDS_IB_SRQ_POST_BATCH_COUNT) { - if (ib_post_srq_recv(srq->s_srq, &cur->r_wr, &bad_wr)) { - struct ib_recv_wr *wr; - struct rds_ib_recv_work *recv; - - for (wr = &cur->r_wr; wr; wr = wr->next) { - recv = container_of(wr, struct rds_ib_recv_work, r_wr); - rds_ib_srq_clear_one(srq, recv->r_ic, recv); - } - printk(KERN_ERR "ib_post_srq_recv failed\n"); - goto out; - } - - atomic_add(refills,&srq->s_num_posted); - prv = NULL; - refills = 0; - cur = NULL; - } - } - if (cur) { - if (ib_post_srq_recv(srq->s_srq, &cur->r_wr, &bad_wr)) { - struct ib_recv_wr *wr; - struct rds_ib_recv_work *recv; - - for (wr = &cur->r_wr; wr; wr = wr->next) { - recv = container_of(wr, struct rds_ib_recv_work, r_wr); - rds_ib_srq_clear_one(srq, recv->r_ic, recv); - } - printk(KERN_ERR "ib_post_srq_recv failed\n"); - goto out; - } - atomic_add(refills,&srq->s_num_posted); - } - - if (!total_refills) - rds_ib_stats_inc(s_ib_srq_empty_refills); + struct rds_ib_srq *srq = container_of(work, struct rds_ib_srq, s_refill_w.work); + struct rds_ib_recv_work *prv = NULL, *cur = NULL, *tmp; + struct ib_recv_wr *bad_wr; + int i, refills = 0, total_refills = 0; + + if (!test_bit(0, &srq->s_refill_gate)) + return; + + rds_ib_stats_inc(s_ib_srq_refills); + + for (i = 0; i < srq->s_n_wr; i++) { + tmp = &srq->s_recvs[i]; + if (tmp->r_posted) + continue; + + if (rds_ib_srq_refill_one(srq, tmp->r_ic, tmp, GFP_NOWAIT)) { + printk(KERN_ERR "rds_ib_srq_refill_one failed\n"); + break; + } + cur = tmp; + + if (!prv) { + prv = cur; + prv->r_wr.next = NULL; + } else { + cur->r_wr.next = &prv->r_wr; + prv = cur; + } + cur->r_posted = 1; + + total_refills++; + if (++refills == RDS_IB_SRQ_POST_BATCH_COUNT) { + if (ib_post_srq_recv(srq->s_srq, &cur->r_wr, &bad_wr)) { + struct ib_recv_wr *wr; + struct rds_ib_recv_work *recv; + + for (wr = &cur->r_wr; wr; wr = wr->next) { + recv = container_of(wr, struct rds_ib_recv_work, r_wr); + rds_ib_srq_clear_one(srq, recv->r_ic, recv); + } + printk(KERN_ERR "ib_post_srq_recv failed\n"); + goto out; + } + atomic_add(refills, &srq->s_num_posted); + prv = NULL; + refills = 0; + cur = NULL; + } + } + if (cur) { + if (ib_post_srq_recv(srq->s_srq, &cur->r_wr, &bad_wr)) { + struct ib_recv_wr *wr; + struct rds_ib_recv_work *recv; + + for (wr = &cur->r_wr; wr; wr = wr->next) { + recv = container_of(wr, struct rds_ib_recv_work, r_wr); + rds_ib_srq_clear_one(srq, recv->r_ic, recv); + } + printk(KERN_ERR "ib_post_srq_recv failed\n"); + goto out; + } + atomic_add(refills, &srq->s_num_posted); + } + + if (!total_refills) + rds_ib_stats_inc(s_ib_srq_empty_refills); out: - clear_bit(0,&srq->s_refill_gate); + clear_bit(0, &srq->s_refill_gate); } int rds_ib_srq_prefill_ring(struct rds_ib_device *rds_ibdev) { - struct rds_ib_recv_work *recv; - struct ib_recv_wr *bad_wr; - u32 i; - int ret; - - for (i = 0, recv = rds_ibdev->srq->s_recvs; - i < rds_ibdev->srq->s_n_wr; i++, recv++) { - recv->r_wr.next = NULL; - recv->r_wr.wr_id = i; - recv->r_wr.sg_list = recv->r_sge; - recv->r_wr.num_sge = RDS_IB_RECV_SGE; - recv->r_ibinc = NULL; - recv->r_frag = NULL; - recv->r_ic = NULL; - - if (rds_ib_srq_prefill_one(rds_ibdev, recv, 1)) - return 1; - - ret = ib_post_srq_recv(rds_ibdev->srq->s_srq, - &recv->r_wr, &bad_wr); - if (ret) { - printk(KERN_WARNING "RDS: ib_post_srq_recv failed %d\n", ret); - return 1; - } - atomic_inc(&rds_ibdev->srq->s_num_posted); - recv->r_posted = 1; - } - return 0; + struct rds_ib_recv_work *recv; + struct ib_recv_wr *bad_wr; + u32 i; + int ret; + + for (i = 0, recv = rds_ibdev->srq->s_recvs; + i < rds_ibdev->srq->s_n_wr; i++, recv++) { + recv->r_wr.next = NULL; + recv->r_wr.wr_id = i; + recv->r_wr.sg_list = recv->r_sge; + recv->r_wr.num_sge = RDS_IB_RECV_SGE; + recv->r_ibinc = NULL; + recv->r_frag = NULL; + recv->r_ic = NULL; + + if (rds_ib_srq_prefill_one(rds_ibdev, recv, 1)) + return 1; + + ret = ib_post_srq_recv(rds_ibdev->srq->s_srq, + &recv->r_wr, &bad_wr); + if (ret) { + printk(KERN_WARNING "RDS: ib_post_srq_recv failed %d\n", ret); + return 1; + } + atomic_inc(&rds_ibdev->srq->s_num_posted); + recv->r_posted = 1; + } + return 0; } static void rds_ib_srq_clear_ring(struct rds_ib_device *rds_ibdev) { - u32 i; - struct rds_ib_recv_work *recv; + u32 i; + struct rds_ib_recv_work *recv; - for (i = 0, recv = rds_ibdev->srq->s_recvs; - i < rds_ibdev->srq->s_n_wr; i++, recv++) - rds_ib_srq_clear_one(rds_ibdev->srq, recv->r_ic, recv); + for (i = 0, recv = rds_ibdev->srq->s_recvs; + i < rds_ibdev->srq->s_n_wr; i++, recv++) + rds_ib_srq_clear_one(rds_ibdev->srq, recv->r_ic, recv); } @@ -1469,138 +1468,138 @@ void rds_ib_recv_exit(void) void rds_ib_srq_rearm(struct work_struct *work) { - struct rds_ib_srq *srq = container_of(work, struct rds_ib_srq, s_rearm_w.work); - struct ib_srq_attr srq_attr; - - srq_attr.srq_limit = rds_ib_srq_low_wr; - if (ib_modify_srq(srq->s_srq, &srq_attr, IB_SRQ_LIMIT)) { - printk(KERN_ERR "RDS: ib_modify_srq failed\n"); - return; - } + struct rds_ib_srq *srq = container_of(work, struct rds_ib_srq, s_rearm_w.work); + struct ib_srq_attr srq_attr; + + srq_attr.srq_limit = rds_ib_srq_low_wr; + if (ib_modify_srq(srq->s_srq, &srq_attr, IB_SRQ_LIMIT)) { + printk(KERN_ERR "RDS: ib_modify_srq failed\n"); + return; + } } static void rds_ib_srq_event(struct ib_event *event, - void *ctx) + void *ctx) { - struct ib_srq_attr srq_attr; - struct rds_ib_device *rds_ibdev = ctx; - - switch (event->event) { - case IB_EVENT_SRQ_ERR: - printk(KERN_ERR "RDS: event IB_EVENT_SRQ_ERR unhandled\n", - event->event); - break; - case IB_EVENT_SRQ_LIMIT_REACHED: - rds_ib_stats_inc(s_ib_srq_lows); - queue_delayed_work(rds_wq, &rds_ibdev->srq->s_rearm_w,HZ); - - if (!test_and_set_bit(0, &rds_ibdev->srq->s_refill_gate)) - queue_delayed_work(rds_wq, &rds_ibdev->srq->s_refill_w, 0); - break; - default: - break; - } + struct ib_srq_attr srq_attr; + struct rds_ib_device *rds_ibdev = ctx; + + switch (event->event) { + case IB_EVENT_SRQ_ERR: + printk(KERN_ERR "RDS: event IB_EVENT_SRQ_ERR unhandled\n", + event->event); + break; + case IB_EVENT_SRQ_LIMIT_REACHED: + rds_ib_stats_inc(s_ib_srq_lows); + queue_delayed_work(rds_wq, &rds_ibdev->srq->s_rearm_w, HZ); + + if (!test_and_set_bit(0, &rds_ibdev->srq->s_refill_gate)) + queue_delayed_work(rds_wq, &rds_ibdev->srq->s_refill_w, 0); + break; + default: + break; + } } /* Setup SRQ for a device */ int rds_ib_srq_init(struct rds_ib_device *rds_ibdev) { - struct ib_srq_init_attr srq_init_attr = { - rds_ib_srq_event, - (void *)rds_ibdev, - .attr = { - .max_wr = rds_ib_srq_max_wr - 1, - .max_sge = rds_ibdev->max_sge - } - }; + struct ib_srq_init_attr srq_init_attr = { + rds_ib_srq_event, + (void *)rds_ibdev, + .attr = { + .max_wr = rds_ib_srq_max_wr - 1, + .max_sge = rds_ibdev->max_sge + } + }; - rds_ibdev->srq->rds_ibdev = rds_ibdev; + rds_ibdev->srq->rds_ibdev = rds_ibdev; - rds_ibdev->srq->s_n_wr = rds_ib_srq_max_wr - 1; - rds_ibdev->srq->s_srq = ib_create_srq(rds_ibdev->pd, - &srq_init_attr); + rds_ibdev->srq->s_n_wr = rds_ib_srq_max_wr - 1; + rds_ibdev->srq->s_srq = ib_create_srq(rds_ibdev->pd, + &srq_init_attr); - if (IS_ERR(rds_ibdev->srq->s_srq)) { - printk(KERN_WARNING "RDS: ib_create_srq failed %d\n", - ERR_PTR(rds_ibdev->srq->s_srq)); - return 1; - } + if (IS_ERR(rds_ibdev->srq->s_srq)) { + printk(KERN_WARNING "RDS: ib_create_srq failed %d\n", + ERR_PTR(rds_ibdev->srq->s_srq)); + return 1; + } - rds_ibdev->srq->s_recv_hdrs = ib_dma_alloc_coherent(rds_ibdev->dev, - rds_ibdev->srq->s_n_wr * - sizeof(struct rds_header), - &rds_ibdev->srq->s_recv_hdrs_dma, GFP_KERNEL); - if (!rds_ibdev->srq->s_recv_hdrs) { - printk(KERN_WARNING "ib_dma_alloc_coherent failed\n"); - return 1; - } + rds_ibdev->srq->s_recv_hdrs = ib_dma_alloc_coherent(rds_ibdev->dev, + rds_ibdev->srq->s_n_wr * + sizeof(struct rds_header), + &rds_ibdev->srq->s_recv_hdrs_dma, GFP_KERNEL); + if (!rds_ibdev->srq->s_recv_hdrs) { + printk(KERN_WARNING "ib_dma_alloc_coherent failed\n"); + return 1; + } - rds_ibdev->srq->s_recvs = vmalloc(rds_ibdev->srq->s_n_wr * - sizeof(struct rds_ib_recv_work)); + rds_ibdev->srq->s_recvs = vmalloc(rds_ibdev->srq->s_n_wr * + sizeof(struct rds_ib_recv_work)); - if (!rds_ibdev->srq->s_recvs) { - printk(KERN_WARNING "RDS: vmalloc failed\n"); - return 1; - } + if (!rds_ibdev->srq->s_recvs) { + printk(KERN_WARNING "RDS: vmalloc failed\n"); + return 1; + } - memset(rds_ibdev->srq->s_recvs, 0, rds_ibdev->srq->s_n_wr * - sizeof(struct rds_ib_recv_work)); + memset(rds_ibdev->srq->s_recvs, 0, rds_ibdev->srq->s_n_wr * + sizeof(struct rds_ib_recv_work)); - atomic_set(&rds_ibdev->srq->s_num_posted,0); - clear_bit(0,&rds_ibdev->srq->s_refill_gate); + atomic_set(&rds_ibdev->srq->s_num_posted, 0); + clear_bit(0, &rds_ibdev->srq->s_refill_gate); - if (rds_ib_srq_prefill_ring(rds_ibdev)) - return 1; + if (rds_ib_srq_prefill_ring(rds_ibdev)) + return 1; - INIT_DELAYED_WORK(&rds_ibdev->srq->s_refill_w, rds_ib_srq_refill); + INIT_DELAYED_WORK(&rds_ibdev->srq->s_refill_w, rds_ib_srq_refill); - INIT_DELAYED_WORK(&rds_ibdev->srq->s_rearm_w, rds_ib_srq_rearm); + INIT_DELAYED_WORK(&rds_ibdev->srq->s_rearm_w, rds_ib_srq_rearm); - queue_delayed_work(rds_wq, &rds_ibdev->srq->s_rearm_w, 0); + queue_delayed_work(rds_wq, &rds_ibdev->srq->s_rearm_w, 0); - return 0; + return 0; } int rds_ib_srqs_init(void) { - struct rds_ib_device *rds_ibdev; - int ret; + struct rds_ib_device *rds_ibdev; + int ret; - list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { - ret = rds_ib_srq_init(rds_ibdev); - if (ret) return ret; - } + list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { + ret = rds_ib_srq_init(rds_ibdev); + if (ret) + return ret; + } - return 0; + return 0; } void rds_ib_srq_exit(struct rds_ib_device *rds_ibdev) { - int ret; - - ret = ib_destroy_srq(rds_ibdev->srq->s_srq); - if (ret) { - printk(KERN_WARNING "RDS: ib_destroy_srq failed %d\n", ret); - } - rds_ibdev->srq->s_srq = NULL; - - if (rds_ibdev->srq->s_recv_hdrs) - ib_dma_free_coherent(rds_ibdev->dev, - rds_ibdev->srq->s_n_wr * - sizeof(struct rds_header), - rds_ibdev->srq->s_recv_hdrs, - rds_ibdev->srq->s_recv_hdrs_dma); - - rds_ib_srq_clear_ring(rds_ibdev); - vfree(rds_ibdev->srq->s_recvs); - rds_ibdev->srq->s_recvs = NULL; + int ret; + + ret = ib_destroy_srq(rds_ibdev->srq->s_srq); + if (ret) + printk(KERN_WARNING "RDS: ib_destroy_srq failed %d\n", ret); + rds_ibdev->srq->s_srq = NULL; + + if (rds_ibdev->srq->s_recv_hdrs) + ib_dma_free_coherent(rds_ibdev->dev, + rds_ibdev->srq->s_n_wr * + sizeof(struct rds_header), + rds_ibdev->srq->s_recv_hdrs, + rds_ibdev->srq->s_recv_hdrs_dma); + + rds_ib_srq_clear_ring(rds_ibdev); + vfree(rds_ibdev->srq->s_recvs); + rds_ibdev->srq->s_recvs = NULL; } void rds_ib_srqs_exit(void) { - struct rds_ib_device *rds_ibdev; + struct rds_ib_device *rds_ibdev; - list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { - rds_ib_srq_exit(rds_ibdev); - } + list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { + rds_ib_srq_exit(rds_ibdev); + } } diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c index 80ce6dcee2b6d..46d9d9840cae6 100644 --- a/net/rds/ib_stats.c +++ b/net/rds/ib_stats.c @@ -55,8 +55,8 @@ static char *rds_ib_stat_names[] = { "ib_rx_refill_from_cq", "ib_rx_refill_from_thread", "ib_rx_alloc_limit", - "ib_rx_total_frags", - "ib_rx_total_incs", + "ib_rx_total_frags", + "ib_rx_total_incs", "ib_rx_credit_updates", "ib_ack_sent", "ib_ack_send_failure", @@ -71,9 +71,9 @@ static char *rds_ib_stat_names[] = { "ib_rdma_mr_pool_depleted", "ib_atomic_cswp", "ib_atomic_fadd", - "ib_srq_lows", - "ib_srq_refills", - "ib_srq_empty_refills", + "ib_srq_lows", + "ib_srq_refills", + "ib_srq_empty_refills", }; unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter, diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c index 86a5c1d84b097..36f4b62369d0d 100644 --- a/net/rds/ib_sysctl.c +++ b/net/rds/ib_sysctl.c @@ -59,6 +59,7 @@ static unsigned long rds_ib_sysctl_max_unsig_wr_max = 64; * rings from ib_cm_connect_complete() back into ib_setup_qp() * will cause credits to be added before protocol negotiation. */ + unsigned int rds_ib_sysctl_flow_control = 0; ctl_table rds_ib_sysctl_table[] = { diff --git a/net/rds/message.c b/net/rds/message.c index 1da9fa6cffa1e..4ed85e11cca89 100644 --- a/net/rds/message.c +++ b/net/rds/message.c @@ -81,8 +81,8 @@ void rds_message_put(struct rds_message *rm) { rdsdebug("put rm %p ref %d\n", rm, atomic_read(&rm->m_refcount)); if (atomic_read(&rm->m_refcount) == 0) { -printk(KERN_CRIT "danger refcount zero on %p\n", rm); -WARN_ON(1); + printk(KERN_CRIT "danger refcount zero on %p\n", rm); + WARN_ON(1); } if (atomic_dec_and_test(&rm->m_refcount)) { BUG_ON(!list_empty(&rm->m_sock_item)); diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c index 646ba079288ad..b8a1b16289f09 100644 --- a/net/rds/rdma_transport.c +++ b/net/rds/rdma_transport.c @@ -93,7 +93,7 @@ int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, printk(KERN_CRIT "rds dropping connection after rdma_resolve_route failure" "connection %u.%u.%u.%u->%u.%u.%u.%u\n", NIPQUAD(conn->c_laddr), NIPQUAD(conn->c_faddr)); ibic = conn->c_transport_data; - if (ibic && ibic->i_cm_id == cm_id) + if (ibic && ibic->i_cm_id == cm_id) ibic->i_cm_id = NULL; rds_conn_drop(conn); } diff --git a/net/rds/rds.h b/net/rds/rds.h index a4179429a0e3f..5c54da324b938 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -139,8 +139,8 @@ struct rds_connection { int c_reconnect_warn; int c_reconnect_err; - /* Qos support */ - u8 c_tos; + /* Qos support */ + u8 c_tos; }; #define RDS_FLAG_CONG_BITMAP 0x01 @@ -621,13 +621,13 @@ struct rds_message *rds_cong_update_alloc(struct rds_connection *conn); int rds_conn_init(void); void rds_conn_exit(void); struct rds_connection *rds_conn_create(__be32 laddr, __be32 faddr, - struct rds_transport *trans, - u8 tos, gfp_t gfp); + struct rds_transport *trans, + u8 tos, gfp_t gfp); struct rds_connection *rds_conn_create_outgoing(__be32 laddr, __be32 faddr, - struct rds_transport *trans, - u8 tos, gfp_t gfp); + struct rds_transport *trans, + u8 tos, gfp_t gfp); struct rds_connection *rds_conn_find(__be32 laddr, __be32 faddr, - struct rds_transport *trans, u8 tos); + struct rds_transport *trans, u8 tos); void rds_conn_shutdown(struct rds_connection *conn); void rds_conn_destroy(struct rds_connection *conn); void rds_conn_reset(struct rds_connection *conn); diff --git a/net/rds/send.c b/net/rds/send.c index 4f8199e517d14..2faceb3a74356 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -117,9 +117,9 @@ static void release_in_xmit(struct rds_connection *conn) * down the connection at a time. * Pro: * - tx queueing is a simple fifo list - * - reassembly is optional and easily done by transports per conn + * - reassembly is optional and easily done by transports per conn * - no per flow rx lookup at all, straight to the socket - * - less per-frag memory and wire overhead + * - less per-frag memory and wire overhead * Con: * - queued acks can be delayed behind large messages * Depends: @@ -1048,8 +1048,8 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, /* rds_conn_create has a spinlock that runs with IRQ off. * Caching the conn in the socket helps a lot. */ - if (rs->rs_conn && rs->rs_conn->c_faddr == daddr && - rs->rs_tos == rs->rs_conn->c_tos) + if (rs->rs_conn && rs->rs_conn->c_faddr == daddr && + rs->rs_tos == rs->rs_conn->c_tos) conn = rs->rs_conn; else { conn = rds_conn_create_outgoing(rs->rs_bound_addr, daddr, diff --git a/net/rds/transport.c b/net/rds/transport.c index 7f2ac4fec3678..2dd3de3e57f3a 100644 --- a/net/rds/transport.c +++ b/net/rds/transport.c @@ -119,8 +119,7 @@ unsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter, rds_info_iter_unmap(iter); down_read(&rds_trans_sem); - for (i = 0; i < RDS_TRANS_COUNT; i++) - { + for (i = 0; i < RDS_TRANS_COUNT; i++) { trans = transports[i]; if (!trans || !trans->stats_info_copy) continue;