From: Johannes Thumshirn <jthumshirn@suse.de>
To: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Cc: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, David.Carroll@microsemi.com,
Gana.Sridaran@microsemi.com, Scott.Benesh@microsemi.com
Subject: Re: [PATCH V3 16/24] aacraid: Add task management functionality
Date: Mon, 30 Jan 2017 12:19:47 +0100 [thread overview]
Message-ID: <20170130111947.GL3603@linux-x5ow.site> (raw)
In-Reply-To: <20170127192853.10082-17-RaghavaAditya.Renukunta@microsemi.com>
On Fri, Jan 27, 2017 at 11:28:45AM -0800, Raghava Aditya Renukunta wrote:
> Added support to send out task management commands.
>
> Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
> Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
>
> ---
[...]
> @@ -3365,7 +3462,151 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
>
> /**
> *
> - * aac_send_scb_fib
> + * aac_hba_callback
> + * @context: the context set in the fib - here it is scsi cmd
> + * @fibptr: pointer to the fib
> + *
> + * Handles the completion of a native HBA scsi command
> + *
> + */
> +void aac_hba_callback(void *context, struct fib *fibptr)
> +{
> + struct aac_dev *dev;
> + struct scsi_cmnd *scsicmd;
> +
> + scsicmd = (struct scsi_cmnd *) context;
> +
> + if (!aac_valid_context(scsicmd, fibptr))
> + return;
> +
> + WARN_ON(fibptr == NULL);
> + dev = fibptr->dev;
> +
> + if (!(fibptr->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF))
> + scsi_dma_unmap(scsicmd);
> +
> + if (fibptr->flags & FIB_CONTEXT_FLAG_FASTRESP) {
> + /* fast response */
> + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
> + } else {
> + struct aac_hba_resp *err =
> + &((struct aac_native_hba *)fibptr->hw_fib_va)->resp.err;
> +
> + // BUG_ON(err->iu_type != HBA_IU_TYPE_RESP);
Please zap that C++ comment and see if you can tidy up the remaining code a
bit (e.g a new function for the else block, switch statement iterating over
err->serivce_response, etc...)
> + if (err->service_response == HBA_RESP_SVCRES_TASK_COMPLETE) {
> + scsicmd->result = err->status;
> + /* set residual count */
> + scsi_set_resid(scsicmd,
> + le32_to_cpu(err->residual_count));
> +
> + switch (err->status) {
> + case SAM_STAT_GOOD:
> + scsicmd->result |= DID_OK << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + case SAM_STAT_CHECK_CONDITION:
> + {
> + int len;
> +
> + len = min_t(u8, err->sense_response_data_len,
> + SCSI_SENSE_BUFFERSIZE);
> + if (len)
> + memcpy(scsicmd->sense_buffer,
> + err->sense_response_buf, len);
> + scsicmd->result |= DID_OK << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + }
> + case SAM_STAT_BUSY:
> + scsicmd->result |= DID_BUS_BUSY << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + case SAM_STAT_TASK_ABORTED:
> + scsicmd->result |= DID_ABORT << 16 |
> + ABORT << 8;
> + break;
> + case SAM_STAT_RESERVATION_CONFLICT:
> + case SAM_STAT_TASK_SET_FULL:
> + default:
> + scsicmd->result |= DID_ERROR << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + }
> + } else if (err->service_response == HBA_RESP_SVCRES_FAILURE) {
> + switch (err->status) {
> + case HBA_RESP_STAT_HBAMODE_DISABLED:
> + {
> + u32 bus, cid;
> +
> + bus = aac_logical_to_phys(
> + scmd_channel(scsicmd));
> + cid = scmd_id(scsicmd);
> + if (dev->hba_map[bus][cid].devtype ==
> + AAC_DEVTYPE_NATIVE_RAW) {
> + dev->hba_map[bus][cid].devtype =
> + AAC_DEVTYPE_ARC_RAW;
> + dev->hba_map[bus][cid].rmw_nexus =
> + 0xffffffff;
> + }
> + scsicmd->result = DID_NO_CONNECT << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + }
> + case HBA_RESP_STAT_IO_ERROR:
> + case HBA_RESP_STAT_NO_PATH_TO_DEVICE:
> + scsicmd->result = DID_OK << 16 |
> + COMMAND_COMPLETE << 8 | SAM_STAT_BUSY;
> + break;
> + case HBA_RESP_STAT_IO_ABORTED:
> + scsicmd->result = DID_ABORT << 16 |
> + ABORT << 8;
> + break;
> + case HBA_RESP_STAT_INVALID_DEVICE:
> + scsicmd->result = DID_NO_CONNECT << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + case HBA_RESP_STAT_UNDERRUN:
> + /* UNDERRUN is OK */
> + scsicmd->result = DID_OK << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + case HBA_RESP_STAT_OVERRUN:
> + default:
> + scsicmd->result = DID_ERROR << 16 |
> + COMMAND_COMPLETE << 8;
> + break;
> + }
> + } else if (err->service_response ==
> + HBA_RESP_SVCRES_TMF_REJECTED) {
> + scsicmd->result =
> + DID_ERROR << 16 | MESSAGE_REJECT << 8;
> + } else if (err->service_response ==
> + HBA_RESP_SVCRES_TMF_LUN_INVALID) {
> + scsicmd->result =
> + DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
> + } else if ((err->service_response ==
> + HBA_RESP_SVCRES_TMF_COMPLETE) ||
> + (err->service_response ==
> + HBA_RESP_SVCRES_TMF_SUCCEEDED)) {
> + scsicmd->result =
> + DID_OK << 16 | COMMAND_COMPLETE << 8;
> + } else {
> + scsicmd->result =
> + DID_ERROR << 16 | COMMAND_COMPLETE << 8;
> + }
> + }
> +
> + aac_fib_complete(fibptr);
> +
> + if (fibptr->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF)
> + scsicmd->SCp.sent_command = 1;
> + else
> + scsicmd->scsi_done(scsicmd);
> +}
[...]
> @@ -3408,6 +3649,54 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
> return -1;
> }
>
> +/**
> + *
> + * aac_send_hba_fib
> + * @scsicmd: the scsi command block
> + *
> + * This routine will form a FIB and fill in the aac_hba_cmd_req from the
> + * scsicmd passed in.
> + */
> +static int aac_send_hba_fib(struct scsi_cmnd *scsicmd)
> +{
> + struct fib *cmd_fibcontext;
> + struct aac_dev *dev;
> + int status;
> +
> + dev = (struct aac_dev *)scsicmd->device->host->hostdata;
dev = shost_priv(scsicmd->device->host);
[...]
> @@ -3660,6 +3949,73 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int
> return 0;
> }
>
> +static long aac_build_sghba(struct scsi_cmnd *scsicmd,
> + struct aac_hba_cmd_req *hbacmd,
> + int sg_max,
> + u64 sg_address)
> +{
> + unsigned long byte_count = 0;
> + int nseg;
> +
> + nseg = scsi_dma_map(scsicmd);
> + if (nseg < 0)
> + return nseg;
if (nseg <= 0)
return nseg;
> + if (nseg) {
> + struct scatterlist *sg;
> + int i;
> + u32 cur_size;
> + struct aac_hba_sgl *sge;
> +
> + if (nseg > HBA_MAX_SG_EMBEDDED)
> + sge = &hbacmd->sge[2];
> + else
> + sge = &hbacmd->sge[0];
> +
> + scsi_for_each_sg(scsicmd, sg, nseg, i) {
> + int count = sg_dma_len(sg);
> + u64 addr = sg_dma_address(sg);
> +
> + WARN_ON(i >= sg_max);
> + sge->addr_hi = cpu_to_le32((u32)(addr>>32));
> + sge->addr_lo = cpu_to_le32((u32)(addr & 0xffffffff));
> + cur_size = cpu_to_le32(count);
> + sge->len = cur_size;
> + sge->flags = 0;
> + byte_count += count;
> + sge++;
> + }
> +
> + sge--;
> + /* hba wants the size to be exact */
> + if (byte_count > scsi_bufflen(scsicmd)) {
> + u32 temp = le32_to_cpu(sge->len) -
> + (byte_count - scsi_bufflen(scsicmd));
> + sge->len = cpu_to_le32(temp);
> + byte_count = scsi_bufflen(scsicmd);
> + }
> +
> + if (nseg <= HBA_MAX_SG_EMBEDDED) {
> + hbacmd->emb_data_desc_count = cpu_to_le32(nseg);
> + sge->flags = cpu_to_le32(0x40000000);
> + } else {
> + /* not embedded */
> + hbacmd->sge[0].flags = cpu_to_le32(0x80000000);
> + hbacmd->emb_data_desc_count = (u8)cpu_to_le32(1);
> + hbacmd->sge[0].addr_hi =
> + (u32)cpu_to_le32(sg_address >> 32);
> + hbacmd->sge[0].addr_lo =
> + cpu_to_le32((u32)(sg_address & 0xffffffff));
> + }
> +
> + /* Check for command underflow */
> + if (scsicmd->underflow && (byte_count < scsicmd->underflow)) {
> + pr_warn("aacraid: cmd len %08lX cmd underflow %08X\n",
> + byte_count, scsicmd->underflow);
> + }
> + }
> + return byte_count;
> +}
> +
> #ifdef AAC_DETAILED_STATUS_INFO
>
> struct aac_srb_status_info {
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
next prev parent reply other threads:[~2017-01-30 11:20 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 19:28 [PATCH V3 00/24] aacraid: Patchset for Smart Family Support Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 01/24] aacraid: Remove duplicate irq management code Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 02/24] aacraid: Added aacraid.h include guard Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 03/24] aacraid: added support for init_struct_8 Raghava Aditya Renukunta
2017-01-30 9:15 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 04/24] aacraid: Added sa firmware support Raghava Aditya Renukunta
2017-01-30 9:23 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 05/24] aacraid: Retrieve and update the device types Raghava Aditya Renukunta
2017-01-30 9:35 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 06/24] aacraid: Reworked scsi command submission path Raghava Aditya Renukunta
2017-01-30 9:38 ` Johannes Thumshirn
2017-01-30 20:17 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 07/24] aacraid: Process Error for response I/O Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 08/24] aacraid: Added support for response path Raghava Aditya Renukunta
2017-01-30 9:50 ` Johannes Thumshirn
2017-01-30 20:16 ` Raghava Aditya Renukunta
2017-01-31 8:02 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 09/24] aacraid: Added support for read medium error Raghava Aditya Renukunta
2017-01-30 9:55 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 10/24] aacraid: Reworked aac_command_thread Raghava Aditya Renukunta
2017-01-30 10:11 ` Johannes Thumshirn
2017-01-30 20:11 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 11/24] aacraid: Added support for periodic wellness sync Raghava Aditya Renukunta
2017-01-30 10:27 ` Johannes Thumshirn
2017-01-30 20:07 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 12/24] aacraid: Retrieve Queue Depth from Adapter FW Raghava Aditya Renukunta
2017-01-30 10:31 ` Johannes Thumshirn
2017-01-30 20:05 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 13/24] aacraid: Added support to set QD of attached drives Raghava Aditya Renukunta
2017-01-30 10:39 ` Johannes Thumshirn
2017-01-30 20:01 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 14/24] aacraid: Added support for hotplug Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 15/24] aacraid: Include HBA direct interface Raghava Aditya Renukunta
2017-01-30 11:02 ` Johannes Thumshirn
2017-01-30 20:00 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 16/24] aacraid: Add task management functionality Raghava Aditya Renukunta
2017-01-30 11:19 ` Johannes Thumshirn [this message]
2017-01-30 19:59 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 17/24] aacraid: Added support to abort cmd and reset lun Raghava Aditya Renukunta
2017-01-30 11:24 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 18/24] aacraid: VPD 83 type3 support Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 19/24] aacraid: Added new IWBR reset Raghava Aditya Renukunta
2017-01-30 11:39 ` Johannes Thumshirn
2017-01-30 19:56 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 20/24] aacraid: Added ioctl to trigger IOP/IWBR reset Raghava Aditya Renukunta
2017-01-30 11:41 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 21/24] aacraid: Retrieve HBA host information ioctl Raghava Aditya Renukunta
2017-01-30 11:43 ` Johannes Thumshirn
2017-01-30 19:53 ` Raghava Aditya Renukunta
2017-01-27 19:28 ` [PATCH V3 22/24] aacraid: Update copyrights Raghava Aditya Renukunta
2017-01-30 11:43 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 23/24] aacraid: Change Driver Version Prefix Raghava Aditya Renukunta
2017-01-30 11:44 ` Johannes Thumshirn
2017-01-27 19:28 ` [PATCH V3 24/24] aacraid: update version Raghava Aditya Renukunta
2017-01-30 11:44 ` Johannes Thumshirn
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=20170130111947.GL3603@linux-x5ow.site \
--to=jthumshirn@suse.de \
--cc=David.Carroll@microsemi.com \
--cc=Gana.Sridaran@microsemi.com \
--cc=RaghavaAditya.Renukunta@microsemi.com \
--cc=Scott.Benesh@microsemi.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.