From: Mike Christie <michael.christie@oracle.com>
To: subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com,
jitendra.bhivare@broadcom.com, lduncan@suse.com,
cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com,
GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
james.bottomley@hansenpartnership.com
Subject: [PATCH 09/15] bnx2i: set scsi_host_template cmd_size
Date: Tue, 1 Dec 2020 15:29:50 -0600 [thread overview]
Message-ID: <1606858196-5421-10-git-send-email-michael.christie@oracle.com> (raw)
In-Reply-To: <1606858196-5421-1-git-send-email-michael.christie@oracle.com>
Use scsi_host_template cmd_size so the block/scsi-ml layers allocate the
iscsi structs for the driver.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/scsi/bnx2i/bnx2i_iscsi.c | 112 +++++++++++----------------------------
1 file changed, 30 insertions(+), 82 deletions(-)
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fdd4467..d523382 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -438,11 +438,9 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep)
/**
* bnx2i_alloc_bdt - allocates buffer descriptor (BD) table for the command
* @hba: adapter instance pointer
- * @session: iscsi session pointer
* @cmd: iscsi command structure
*/
-static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct iscsi_session *session,
- struct bnx2i_cmd *cmd)
+static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd)
{
struct io_bdt *io = &cmd->io_tbl;
struct iscsi_bd *bd;
@@ -451,68 +449,44 @@ static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct iscsi_session *session,
ISCSI_MAX_BDS_PER_CMD * sizeof(*bd),
&io->bd_tbl_dma, GFP_KERNEL);
if (!io->bd_tbl) {
- iscsi_session_printk(KERN_ERR, session, "Could not "
- "allocate bdt.\n");
+ shost_printk(KERN_ERR, hba->shost, "Could not allocate bdt.\n");
return -ENOMEM;
}
io->bd_valid = 0;
return 0;
}
-/**
- * bnx2i_destroy_cmd_pool - destroys iscsi command pool and release BD table
- * @hba: adapter instance pointer
- * @session: iscsi session pointer
- */
-static void bnx2i_destroy_cmd_pool(struct bnx2i_hba *hba,
- struct iscsi_session *session)
+static int bnx2i_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc)
{
- int i;
-
- for (i = 0; i < session->cmds_max; i++) {
- struct iscsi_task *task = session->cmds[i];
- struct bnx2i_cmd *cmd = task->dd_data;
+ struct bnx2i_hba *hba = iscsi_host_priv(shost);
+ struct iscsi_task *task = scsi_cmd_priv(sc);
+ struct bnx2i_cmd *cmd = task->dd_data;
- if (cmd->io_tbl.bd_tbl)
- dma_free_coherent(&hba->pcidev->dev,
- ISCSI_MAX_BDS_PER_CMD *
- sizeof(struct iscsi_bd),
- cmd->io_tbl.bd_tbl,
- cmd->io_tbl.bd_tbl_dma);
- }
+ if (!cmd->io_tbl.bd_tbl)
+ return 0;
+ dma_free_coherent(&hba->pcidev->dev,
+ ISCSI_MAX_BDS_PER_CMD * sizeof(struct iscsi_bd),
+ cmd->io_tbl.bd_tbl, cmd->io_tbl.bd_tbl_dma);
+ return 0;
}
-
-/**
- * bnx2i_setup_cmd_pool - sets up iscsi command pool for the session
- * @hba: adapter instance pointer
- * @session: iscsi session pointer
- */
-static int bnx2i_setup_cmd_pool(struct bnx2i_hba *hba,
- struct iscsi_session *session)
+static int bnx2i_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc)
{
- int i;
-
- for (i = 0; i < session->cmds_max; i++) {
- struct iscsi_task *task = session->cmds[i];
- struct bnx2i_cmd *cmd = task->dd_data;
-
- task->hdr = &cmd->hdr;
- task->hdr_max = sizeof(struct iscsi_hdr);
+ struct bnx2i_hba *hba = iscsi_host_priv(shost);
+ struct iscsi_task *task;
+ struct bnx2i_cmd *cmd;
- if (bnx2i_alloc_bdt(hba, session, cmd))
- goto free_bdts;
- }
+ iscsi_init_cmd_priv(shost, sc);
- return 0;
+ task = scsi_cmd_priv(sc);
+ cmd = task->dd_data;
+ task->hdr = &cmd->hdr;
+ task->hdr_max = sizeof(struct iscsi_hdr);
-free_bdts:
- bnx2i_destroy_cmd_pool(hba, session);
- return -ENOMEM;
+ return bnx2i_alloc_bdt(hba, cmd);
}
-
/**
* bnx2i_setup_mp_bdt - allocate BD table resources
* @hba: pointer to adapter structure
@@ -1288,7 +1262,6 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
uint32_t initial_cmdsn)
{
struct Scsi_Host *shost;
- struct iscsi_cls_session *cls_session;
struct bnx2i_hba *hba;
struct bnx2i_endpoint *bnx2i_ep;
@@ -1312,40 +1285,11 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
else if (cmds_max < BNX2I_SQ_WQES_MIN)
cmds_max = BNX2I_SQ_WQES_MIN;
- cls_session = iscsi_session_setup(&bnx2i_iscsi_transport, shost,
- cmds_max, 0, sizeof(struct bnx2i_cmd),
- initial_cmdsn, ISCSI_MAX_TARGET);
- if (!cls_session)
- return NULL;
-
- if (bnx2i_setup_cmd_pool(hba, cls_session->dd_data))
- goto session_teardown;
- return cls_session;
-
-session_teardown:
- iscsi_session_teardown(cls_session);
- return NULL;
+ return iscsi_session_setup(&bnx2i_iscsi_transport, shost,
+ cmds_max, 0, sizeof(struct bnx2i_cmd),
+ initial_cmdsn, ISCSI_MAX_TARGET);
}
-
-/**
- * bnx2i_session_destroy - destroys iscsi session
- * @cls_session: pointer to iscsi cls session
- *
- * Destroys previously created iSCSI session instance and releases
- * all resources held by it
- */
-static void bnx2i_session_destroy(struct iscsi_cls_session *cls_session)
-{
- struct iscsi_session *session = cls_session->dd_data;
- struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
- struct bnx2i_hba *hba = iscsi_host_priv(shost);
-
- bnx2i_destroy_cmd_pool(hba, session);
- iscsi_session_teardown(cls_session);
-}
-
-
/**
* bnx2i_conn_create - create iscsi connection instance
* @cls_session: pointer to iscsi cls session
@@ -2265,6 +2209,10 @@ static umode_t bnx2i_attr_is_visible(int param_type, int param)
.sg_tablesize = ISCSI_MAX_BDS_PER_CMD,
.shost_attrs = bnx2i_dev_attributes,
.track_queue_depth = 1,
+ .cmd_size = sizeof(struct bnx2i_cmd) +
+ sizeof(struct iscsi_task),
+ .init_cmd_priv = bnx2i_init_cmd_priv,
+ .exit_cmd_priv = bnx2i_exit_cmd_priv,
};
struct iscsi_transport bnx2i_iscsi_transport = {
@@ -2275,7 +2223,7 @@ struct iscsi_transport bnx2i_iscsi_transport = {
CAP_DATA_PATH_OFFLOAD |
CAP_TEXT_NEGO,
.create_session = bnx2i_session_create,
- .destroy_session = bnx2i_session_destroy,
+ .destroy_session = iscsi_session_teardown,
.create_conn = bnx2i_conn_create,
.bind_conn = bnx2i_conn_bind,
.destroy_conn = bnx2i_conn_destroy,
--
1.8.3.1
next prev parent reply other threads:[~2020-12-01 21:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 21:29 [RFC PATCH 00/15] libiscsi: lock clean ups Mike Christie
2020-12-01 21:29 ` [PATCH 01/15] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Mike Christie
2020-12-02 17:04 ` Lee Duncan
2020-12-01 21:29 ` [PATCH 02/15] libiscsi: drop taskqueuelock Mike Christie
2020-12-01 21:29 ` [PATCH 03/15] qla4xxx: use iscsi_is_session_online Mike Christie
2020-12-03 21:07 ` Lee Duncan
2020-12-01 21:29 ` [PATCH 04/15] iscsi class: drop session lock in iscsi_session_chkready Mike Christie
2020-12-03 21:08 ` Lee Duncan
2020-12-01 21:29 ` [PATCH 05/15] libiscsi: remove queued_cmdsn Mike Christie
2020-12-01 21:29 ` [PATCH 06/15] libiscsi: drop frwd lock for session state Mike Christie
2020-12-01 21:29 ` [PATCH 07/15] libiscsi: separate itt from task allocation Mike Christie
2020-12-01 21:29 ` [PATCH 08/15] iser, be2iscsi, qla4xxx: set scsi_host_template cmd_size Mike Christie
2020-12-01 21:29 ` Mike Christie [this message]
2020-12-01 21:29 ` [PATCH 10/15] qedi: " Mike Christie
2020-12-01 21:29 ` [PATCH 11/15] iscsi_tcp, libcxgbi: " Mike Christie
2020-12-01 21:29 ` [PATCH 12/15] libiscsi: use blk/scsi-ml mq cmd pre-allocator Mike Christie
2020-12-01 21:29 ` [PATCH 13/15] libiscsi: drop back_lock requirement for iscsi_put_task Mike Christie
2020-12-01 21:29 ` [PATCH 14/15] libiscsi: drop back_lock from xmit path Mike Christie
2020-12-01 21:29 ` [PATCH 15/15] libiscsi: convert ping_task to refcount handler Mike Christie
2020-12-02 1:27 ` Mike Christie
2020-12-04 12:10 ` [EXT] [RFC PATCH 00/15] libiscsi: lock clean ups Manish Rangankar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1606858196-5421-10-git-send-email-michael.christie@oracle.com \
--to=michael.christie@oracle.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=cleech@redhat.com \
--cc=james.bottomley@hansenpartnership.com \
--cc=jitendra.bhivare@broadcom.com \
--cc=ketan.mukadam@broadcom.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mrangankar@marvell.com \
--cc=njavali@marvell.com \
--cc=subbu.seetharaman@broadcom.com \
--cc=varun@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).