From patchwork Sun Oct 17 03:25:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Dillow X-Patchwork-Id: 259601 X-Patchwork-Delegate: dave@thedillows.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9H3pqZY015613 for ; Sun, 17 Oct 2010 03:51:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753232Ab0JQDvu (ORCPT ); Sat, 16 Oct 2010 23:51:50 -0400 Received: from amavis-smtp.knology.net ([75.76.199.6]:36447 "EHLO amavis-smtp.knology.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710Ab0JQDvu (ORCPT ); Sat, 16 Oct 2010 23:51:50 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 17 Oct 2010 03:51:52 +0000 (UTC) X-Greylist: delayed 1579 seconds by postgrey-1.27 at vger.kernel.org; Sat, 16 Oct 2010 23:51:50 EDT Received: from localhost (amavis-smtp [127.0.0.1]) by amavis-smtp.knology.net (Postfix) with ESMTP id C8F0888AC8; Sat, 16 Oct 2010 23:25:24 -0400 (EDT) Received: from smtp12.knology.net ([75.76.199.9]) by localhost (amavis-smtp.knology.net [75.76.199.6]) (amavisd-new, port 10024) with LMTP id OwWYImzMFMDa; Sat, 16 Oct 2010 23:25:24 -0400 (EDT) Received: from shed.thedillows.org (unknown [207.98.218.89]) by smtp12.knology.net (Postfix) with ESMTP id 3F2545200053; Sat, 16 Oct 2010 23:25:01 -0400 (EDT) Received: from shed.thedillows.org (localhost.localdomain [127.0.0.1]) by shed.thedillows.org (8.14.4/8.14.4) with ESMTP id o9H3PQhc011754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 16 Oct 2010 23:25:26 -0400 Received: (from dad@localhost) by shed.thedillows.org (8.14.4/8.14.4/Submit) id o9H3PQKa011753; Sat, 16 Oct 2010 23:25:26 -0400 X-Authentication-Warning: shed.thedillows.org: dad set sender to dave@thedillows.org using -f From: David Dillow To: rolandd@cisco.com Cc: linux-rdma@vger.kernel.org, bart.vanassche@gmail.com Subject: [PATCH 3/5] IB/srp: eliminate two forward declarations Date: Sat, 16 Oct 2010 23:25:23 -0400 Message-Id: <1287285925-11710-4-git-send-email-dillowda@ornl.gov> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1287285925-11710-1-git-send-email-dillowda@ornl.gov> References: <1287285925-11710-1-git-send-email-dillowda@ornl.gov> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index a54eee9..d4c08d6 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -83,10 +83,6 @@ static void srp_remove_one(struct ib_device *device); static void srp_recv_completion(struct ib_cq *cq, void *target_ptr); static void srp_send_completion(struct ib_cq *cq, void *target_ptr); static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); -static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target, - enum srp_iu_type iu_type); -static int __srp_post_send(struct srp_target_port *target, - struct srp_iu *iu, int len); static struct scsi_transport_template *ib_srp_transport_template; @@ -815,6 +811,75 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, return len; } +/* + * Must be called with target->scsi_host->host_lock held to protect + * req_lim and tx_head. Lock cannot be dropped between call here and + * call to __srp_post_send(). + * + * Note: + * An upper limit for the number of allocated information units for each + * request type is: + * - SRP_IU_CMD: SRP_CMD_SQ_SIZE, since the SCSI mid-layer never queues + * more than Scsi_Host.can_queue requests. + * - SRP_IU_TSK_MGMT: SRP_TSK_MGMT_SQ_SIZE. + * - SRP_IU_RSP: 1, since a conforming SRP target never sends more than + * one unanswered SRP request to an initiator. + */ +static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target, + enum srp_iu_type iu_type) +{ + s32 rsv = (iu_type == SRP_IU_TSK_MGMT) ? 0 : SRP_TSK_MGMT_SQ_SIZE; + struct srp_iu *iu; + + srp_send_completion(target->send_cq, target); + + if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE) + return NULL; + + /* Initiator responses to target requests do not consume credits */ + if (target->req_lim <= rsv && iu_type != SRP_IU_RSP) { + ++target->zero_req_lim; + return NULL; + } + + iu = target->tx_ring[target->tx_head & SRP_SQ_MASK]; + iu->type = iu_type; + return iu; +} + +/* + * Must be called with target->scsi_host->host_lock held to protect + * req_lim and tx_head. + */ +static int __srp_post_send(struct srp_target_port *target, + struct srp_iu *iu, int len) +{ + struct ib_sge list; + struct ib_send_wr wr, *bad_wr; + int ret = 0; + + list.addr = iu->dma; + list.length = len; + list.lkey = target->srp_host->srp_dev->mr->lkey; + + wr.next = NULL; + wr.wr_id = target->tx_head & SRP_SQ_MASK; + wr.sg_list = &list; + wr.num_sge = 1; + wr.opcode = IB_WR_SEND; + wr.send_flags = IB_SEND_SIGNALED; + + ret = ib_post_send(target->qp, &wr, &bad_wr); + + if (!ret) { + ++target->tx_head; + if (iu->type != SRP_IU_RSP) + --target->req_lim; + } + + return ret; +} + static int srp_post_recv(struct srp_target_port *target) { unsigned long flags; @@ -1058,75 +1123,6 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr) } } -/* - * Must be called with target->scsi_host->host_lock held to protect - * req_lim and tx_head. Lock cannot be dropped between call here and - * call to __srp_post_send(). - * - * Note: - * An upper limit for the number of allocated information units for each - * request type is: - * - SRP_IU_CMD: SRP_CMD_SQ_SIZE, since the SCSI mid-layer never queues - * more than Scsi_Host.can_queue requests. - * - SRP_IU_TSK_MGMT: SRP_TSK_MGMT_SQ_SIZE. - * - SRP_IU_RSP: 1, since a conforming SRP target never sends more than - * one unanswered SRP request to an initiator. - */ -static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target, - enum srp_iu_type iu_type) -{ - s32 rsv = (iu_type == SRP_IU_TSK_MGMT) ? 0 : SRP_TSK_MGMT_SQ_SIZE; - struct srp_iu *iu; - - srp_send_completion(target->send_cq, target); - - if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE) - return NULL; - - /* Initiator responses to target requests do not consume credits */ - if (target->req_lim <= rsv && iu_type != SRP_IU_RSP) { - ++target->zero_req_lim; - return NULL; - } - - iu = target->tx_ring[target->tx_head & SRP_SQ_MASK]; - iu->type = iu_type; - return iu; -} - -/* - * Must be called with target->scsi_host->host_lock held to protect - * req_lim and tx_head. - */ -static int __srp_post_send(struct srp_target_port *target, - struct srp_iu *iu, int len) -{ - struct ib_sge list; - struct ib_send_wr wr, *bad_wr; - int ret = 0; - - list.addr = iu->dma; - list.length = len; - list.lkey = target->srp_host->srp_dev->mr->lkey; - - wr.next = NULL; - wr.wr_id = target->tx_head & SRP_SQ_MASK; - wr.sg_list = &list; - wr.num_sge = 1; - wr.opcode = IB_WR_SEND; - wr.send_flags = IB_SEND_SIGNALED; - - ret = ib_post_send(target->qp, &wr, &bad_wr); - - if (!ret) { - ++target->tx_head; - if (iu->type != SRP_IU_RSP) - --target->req_lim; - } - - return ret; -} - static int srp_queuecommand(struct scsi_cmnd *scmnd, void (*done)(struct scsi_cmnd *)) {